@@ -17,20 +17,20 @@ |
||
| 17 | 17 | // http://doc.spip.org/@exec_plonger_dist |
| 18 | 18 | function exec_plonger_dist() |
| 19 | 19 | { |
| 20 | - include_spip('inc/actions'); |
|
| 20 | + include_spip('inc/actions'); |
|
| 21 | 21 | |
| 22 | - $rac = _request('rac'); |
|
| 23 | - $id = intval(_request('id')); |
|
| 24 | - $exclus = intval(_request('exclus')); |
|
| 25 | - $col = intval(_request('col')); |
|
| 26 | - $do = _request('do'); |
|
| 27 | - if (preg_match('/^\w*$/', $do)) { |
|
| 28 | - if (!$do) $do = 'aff'; |
|
| 22 | + $rac = _request('rac'); |
|
| 23 | + $id = intval(_request('id')); |
|
| 24 | + $exclus = intval(_request('exclus')); |
|
| 25 | + $col = intval(_request('col')); |
|
| 26 | + $do = _request('do'); |
|
| 27 | + if (preg_match('/^\w*$/', $do)) { |
|
| 28 | + if (!$do) $do = 'aff'; |
|
| 29 | 29 | |
| 30 | - $plonger = charger_fonction('plonger', 'inc'); |
|
| 31 | - $r = $plonger($id, spip_htmlentities($rac), array(), $col, $exclus, $do); |
|
| 32 | - } else $r = ''; |
|
| 30 | + $plonger = charger_fonction('plonger', 'inc'); |
|
| 31 | + $r = $plonger($id, spip_htmlentities($rac), array(), $col, $exclus, $do); |
|
| 32 | + } else $r = ''; |
|
| 33 | 33 | |
| 34 | - ajax_retour($r); |
|
| 34 | + ajax_retour($r); |
|
| 35 | 35 | } |
| 36 | 36 | ?> |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | # afficher les sous-rubriques d'une rubrique (composant du mini-navigateur) |
| 16 | 18 | |
@@ -25,11 +27,15 @@ discard block |
||
| 25 | 27 | $col = intval(_request('col')); |
| 26 | 28 | $do = _request('do'); |
| 27 | 29 | if (preg_match('/^\w*$/', $do)) { |
| 28 | - if (!$do) $do = 'aff'; |
|
| 30 | + if (!$do) { |
|
| 31 | + $do = 'aff'; |
|
| 32 | + } |
|
| 29 | 33 | |
| 30 | 34 | $plonger = charger_fonction('plonger', 'inc'); |
| 31 | 35 | $r = $plonger($id, spip_htmlentities($rac), array(), $col, $exclus, $do); |
| 32 | - } else $r = ''; |
|
| 36 | + } else { |
|
| 37 | + $r = ''; |
|
| 38 | + } |
|
| 33 | 39 | |
| 34 | 40 | ajax_retour($r); |
| 35 | 41 | } |
@@ -15,30 +15,30 @@ |
||
| 15 | 15 | |
| 16 | 16 | // http://doc.spip.org/@exec_demande_mise_a_jour_dist |
| 17 | 17 | function exec_demande_mise_a_jour_dist() { |
| 18 | - // on fait la verif du path avant tout, |
|
| 19 | - // et l'installation des qu'on est dans la colonne principale |
|
| 20 | - // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 21 | - // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 22 | - include_spip('inc/plugin'); |
|
| 23 | - if (actualise_plugins_actifs()){ |
|
| 24 | - include_spip('inc/headers'); |
|
| 25 | - redirige_par_entete(self()); |
|
| 26 | - } |
|
| 18 | + // on fait la verif du path avant tout, |
|
| 19 | + // et l'installation des qu'on est dans la colonne principale |
|
| 20 | + // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 21 | + // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 22 | + include_spip('inc/plugin'); |
|
| 23 | + if (actualise_plugins_actifs()){ |
|
| 24 | + include_spip('inc/headers'); |
|
| 25 | + redirige_par_entete(self()); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - include_spip('inc/presentation'); |
|
| 29 | - include_spip('inc/filtres_boites'); |
|
| 30 | - $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 31 | - echo $commencer_page('','','','',true,false,false); |
|
| 28 | + include_spip('inc/presentation'); |
|
| 29 | + include_spip('inc/filtres_boites'); |
|
| 30 | + $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 31 | + echo $commencer_page('','','','',true,false,false); |
|
| 32 | 32 | |
| 33 | - echo debut_grand_cadre(true); |
|
| 34 | - echo boite_ouvrir(_T('info_message_technique'),'notice'); |
|
| 35 | - echo "<p>"._T('info_procedure_maj_version')."</p>", |
|
| 36 | - "<p>"._T('info_administrateur_site_01')."</p>"; |
|
| 37 | - echo bouton_action(_T('bouton_mettre_a_jour_base'),generer_url_ecrire("upgrade","reinstall=non")); |
|
| 38 | - echo boite_fermer(); |
|
| 39 | - // masquer les erreurs sql sur cette page car proviennent de la base pas a jour ! |
|
| 40 | - echo '<style type="text/css">#debug-nav {display: none;}</style>'; |
|
| 41 | - echo fin_grand_cadre(true); |
|
| 42 | - echo fin_page(); |
|
| 33 | + echo debut_grand_cadre(true); |
|
| 34 | + echo boite_ouvrir(_T('info_message_technique'),'notice'); |
|
| 35 | + echo "<p>"._T('info_procedure_maj_version')."</p>", |
|
| 36 | + "<p>"._T('info_administrateur_site_01')."</p>"; |
|
| 37 | + echo bouton_action(_T('bouton_mettre_a_jour_base'),generer_url_ecrire("upgrade","reinstall=non")); |
|
| 38 | + echo boite_fermer(); |
|
| 39 | + // masquer les erreurs sql sur cette page car proviennent de la base pas a jour ! |
|
| 40 | + echo '<style type="text/css">#debug-nav {display: none;}</style>'; |
|
| 41 | + echo fin_grand_cadre(true); |
|
| 42 | + echo fin_page(); |
|
| 43 | 43 | } |
| 44 | 44 | ?> |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
| 21 | 21 | // pour etre sur que les bons fichiers seront charges lors de l'install |
| 22 | 22 | include_spip('inc/plugin'); |
| 23 | - if (actualise_plugins_actifs()){ |
|
| 23 | + if (actualise_plugins_actifs()) { |
|
| 24 | 24 | include_spip('inc/headers'); |
| 25 | 25 | redirige_par_entete(self()); |
| 26 | 26 | } |
@@ -28,13 +28,13 @@ discard block |
||
| 28 | 28 | include_spip('inc/presentation'); |
| 29 | 29 | include_spip('inc/filtres_boites'); |
| 30 | 30 | $commencer_page = charger_fonction('commencer_page', 'inc'); |
| 31 | - echo $commencer_page('','','','',true,false,false); |
|
| 31 | + echo $commencer_page('', '', '', '', true, false, false); |
|
| 32 | 32 | |
| 33 | 33 | echo debut_grand_cadre(true); |
| 34 | - echo boite_ouvrir(_T('info_message_technique'),'notice'); |
|
| 34 | + echo boite_ouvrir(_T('info_message_technique'), 'notice'); |
|
| 35 | 35 | echo "<p>"._T('info_procedure_maj_version')."</p>", |
| 36 | 36 | "<p>"._T('info_administrateur_site_01')."</p>"; |
| 37 | - echo bouton_action(_T('bouton_mettre_a_jour_base'),generer_url_ecrire("upgrade","reinstall=non")); |
|
| 37 | + echo bouton_action(_T('bouton_mettre_a_jour_base'), generer_url_ecrire("upgrade", "reinstall=non")); |
|
| 38 | 38 | echo boite_fermer(); |
| 39 | 39 | // masquer les erreurs sql sur cette page car proviennent de la base pas a jour ! |
| 40 | 40 | echo '<style type="text/css">#debug-nav {display: none;}</style>'; |
@@ -10,7 +10,9 @@ |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | |
| 16 | 18 | // http://doc.spip.org/@exec_demande_mise_a_jour_dist |
@@ -19,18 +19,18 @@ |
||
| 19 | 19 | // http://doc.spip.org/@exec_selectionner_dist |
| 20 | 20 | function exec_selectionner_dist() |
| 21 | 21 | { |
| 22 | - $id = intval(_request('id')); |
|
| 23 | - $exclus = intval(_request('exclus')); |
|
| 24 | - $type = _request('type'); |
|
| 25 | - $rac = _request('racine'); |
|
| 26 | - $do = _request('do'); |
|
| 27 | - if (preg_match('/^\w*$/', $do)) { |
|
| 28 | - if (!$do) $do = 'aff'; |
|
| 22 | + $id = intval(_request('id')); |
|
| 23 | + $exclus = intval(_request('exclus')); |
|
| 24 | + $type = _request('type'); |
|
| 25 | + $rac = _request('racine'); |
|
| 26 | + $do = _request('do'); |
|
| 27 | + if (preg_match('/^\w*$/', $do)) { |
|
| 28 | + if (!$do) $do = 'aff'; |
|
| 29 | 29 | |
| 30 | - $selectionner = charger_fonction('selectionner', 'inc'); |
|
| 30 | + $selectionner = charger_fonction('selectionner', 'inc'); |
|
| 31 | 31 | |
| 32 | - $r = $selectionner($id, "choix_parent", $exclus, $rac, $type!='breve', $do); |
|
| 33 | - } else $r = ''; |
|
| 34 | - ajax_retour($r); |
|
| 32 | + $r = $selectionner($id, "choix_parent", $exclus, $rac, $type!='breve', $do); |
|
| 33 | + } else $r = ''; |
|
| 34 | + ajax_retour($r); |
|
| 35 | 35 | } |
| 36 | 36 | ?> |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | |
| 30 | 30 | $selectionner = charger_fonction('selectionner', 'inc'); |
| 31 | 31 | |
| 32 | - $r = $selectionner($id, "choix_parent", $exclus, $rac, $type!='breve', $do); |
|
| 32 | + $r = $selectionner($id, "choix_parent", $exclus, $rac, $type != 'breve', $do); |
|
| 33 | 33 | } else $r = ''; |
| 34 | 34 | ajax_retour($r); |
| 35 | 35 | } |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | include_spip('inc/actions'); |
| 16 | 18 | |
@@ -25,12 +27,16 @@ discard block |
||
| 25 | 27 | $rac = _request('racine'); |
| 26 | 28 | $do = _request('do'); |
| 27 | 29 | if (preg_match('/^\w*$/', $do)) { |
| 28 | - if (!$do) $do = 'aff'; |
|
| 30 | + if (!$do) { |
|
| 31 | + $do = 'aff'; |
|
| 32 | + } |
|
| 29 | 33 | |
| 30 | 34 | $selectionner = charger_fonction('selectionner', 'inc'); |
| 31 | 35 | |
| 32 | 36 | $r = $selectionner($id, "choix_parent", $exclus, $rac, $type!='breve', $do); |
| 33 | - } else $r = ''; |
|
| 37 | + } else { |
|
| 38 | + $r = ''; |
|
| 39 | + } |
|
| 34 | 40 | ajax_retour($r); |
| 35 | 41 | } |
| 36 | 42 | ?> |
@@ -22,135 +22,135 @@ discard block |
||
| 22 | 22 | // http://doc.spip.org/@exec_admin_plugin_dist |
| 23 | 23 | function exec_admin_plugin_dist($retour='') { |
| 24 | 24 | |
| 25 | - if (!autoriser('configurer', '_plugins')) { |
|
| 26 | - include_spip('inc/minipres'); |
|
| 27 | - echo minipres(); |
|
| 28 | - } else { |
|
| 29 | - // on fait la verif du path avant tout, |
|
| 30 | - // et l'installation des qu'on est dans la colonne principale |
|
| 31 | - // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 32 | - // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 33 | - $new = actualise_plugins_actifs(); |
|
| 34 | - if ($new AND _request('actualise')<2) { |
|
| 35 | - include_spip('inc/headers'); |
|
| 36 | - redirige_par_entete(parametre_url(self(),'actualise',_request('actualise')+1,'&')); |
|
| 37 | - } |
|
| 38 | - else { |
|
| 39 | - admin_plug_args(_request('voir'), _request('erreur'), _request('format')); |
|
| 40 | - } |
|
| 41 | - } |
|
| 25 | + if (!autoriser('configurer', '_plugins')) { |
|
| 26 | + include_spip('inc/minipres'); |
|
| 27 | + echo minipres(); |
|
| 28 | + } else { |
|
| 29 | + // on fait la verif du path avant tout, |
|
| 30 | + // et l'installation des qu'on est dans la colonne principale |
|
| 31 | + // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 32 | + // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 33 | + $new = actualise_plugins_actifs(); |
|
| 34 | + if ($new AND _request('actualise')<2) { |
|
| 35 | + include_spip('inc/headers'); |
|
| 36 | + redirige_par_entete(parametre_url(self(),'actualise',_request('actualise')+1,'&')); |
|
| 37 | + } |
|
| 38 | + else { |
|
| 39 | + admin_plug_args(_request('voir'), _request('erreur'), _request('format')); |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | function admin_plug_args($quoi, $erreur, $format) |
| 45 | 45 | { |
| 46 | - if (!$quoi) $quoi = 'actifs'; |
|
| 47 | - // empecher l'affichage des erreurs dans le bandeau, on le donne ensuite |
|
| 48 | - // format brut par plugin |
|
| 49 | - $GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false); |
|
| 50 | - // format resume mis en forme |
|
| 51 | - $erreur_activation = plugin_donne_erreurs(); |
|
| 52 | - $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 53 | - echo $commencer_page(_T('icone_admin_plugin'), "configuration", "plugin"); |
|
| 54 | - |
|
| 55 | - echo debut_gauche('plugin',true); |
|
| 56 | - echo recuperer_fond('prive/squelettes/navigation/configurer',array('exec'=>'admin_plugin')); |
|
| 57 | - |
|
| 58 | - echo pipeline('affiche_gauche', |
|
| 59 | - array( |
|
| 60 | - 'args'=>array('exec'=>'admin_plugin'), |
|
| 61 | - 'data'=>afficher_librairies() |
|
| 62 | - ) |
|
| 63 | - ); |
|
| 64 | - |
|
| 65 | - echo debut_droite('plugin', true); |
|
| 66 | - echo gros_titre(_T('icone_admin_plugin'),'',false); |
|
| 67 | - |
|
| 68 | - // Barre d'onglets de premier niveau |
|
| 69 | - echo barre_onglets("plugins", "plugins_actifs"); |
|
| 70 | - // Barre d'onglets de second niveau |
|
| 71 | - $onglet2 = $quoi=='actifs' ? 'plugins_actifs' : 'admin_plugin'; |
|
| 72 | - echo debut_onglet('onglets_simple second'); |
|
| 73 | - echo onglet(_T('plugins_tous_liste'), generer_url_ecrire("admin_plugin", "voir=tous"), 'admin_plugin', $onglet2); |
|
| 74 | - echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire("admin_plugin"), 'plugins_actifs', $onglet2); |
|
| 75 | - echo fin_onglet(); |
|
| 76 | - |
|
| 77 | - // message d'erreur au retour d'une operation |
|
| 78 | - if ($erreur) |
|
| 79 | - echo "<div class='error'>$erreur</div>"; |
|
| 80 | - if ($erreur_activation){ |
|
| 81 | - echo "<div class='error'>$erreur_activation</div>"; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - // la mise a jour de cette meta a ete faite par ecrire_plugin_actifs |
|
| 85 | - $actifs = unserialize($GLOBALS['meta']['plugin']); |
|
| 86 | - $lcpa = $actifs + unserialize($GLOBALS['meta']['plugin_attente']); |
|
| 87 | - |
|
| 88 | - // Les affichages se basent sur le repertoire, pas sur le nom |
|
| 89 | - $actifs = liste_chemin_plugin($actifs, ''); |
|
| 90 | - if (defined('_DIR_PLUGINS_SUPPL')) |
|
| 91 | - $lcpas = liste_chemin_plugin($lcpa,_DIR_PLUGINS_SUPPL); |
|
| 92 | - $lcpa = liste_chemin_plugin($lcpa); |
|
| 46 | + if (!$quoi) $quoi = 'actifs'; |
|
| 47 | + // empecher l'affichage des erreurs dans le bandeau, on le donne ensuite |
|
| 48 | + // format brut par plugin |
|
| 49 | + $GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false); |
|
| 50 | + // format resume mis en forme |
|
| 51 | + $erreur_activation = plugin_donne_erreurs(); |
|
| 52 | + $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 53 | + echo $commencer_page(_T('icone_admin_plugin'), "configuration", "plugin"); |
|
| 54 | + |
|
| 55 | + echo debut_gauche('plugin',true); |
|
| 56 | + echo recuperer_fond('prive/squelettes/navigation/configurer',array('exec'=>'admin_plugin')); |
|
| 57 | + |
|
| 58 | + echo pipeline('affiche_gauche', |
|
| 59 | + array( |
|
| 60 | + 'args'=>array('exec'=>'admin_plugin'), |
|
| 61 | + 'data'=>afficher_librairies() |
|
| 62 | + ) |
|
| 63 | + ); |
|
| 64 | + |
|
| 65 | + echo debut_droite('plugin', true); |
|
| 66 | + echo gros_titre(_T('icone_admin_plugin'),'',false); |
|
| 67 | + |
|
| 68 | + // Barre d'onglets de premier niveau |
|
| 69 | + echo barre_onglets("plugins", "plugins_actifs"); |
|
| 70 | + // Barre d'onglets de second niveau |
|
| 71 | + $onglet2 = $quoi=='actifs' ? 'plugins_actifs' : 'admin_plugin'; |
|
| 72 | + echo debut_onglet('onglets_simple second'); |
|
| 73 | + echo onglet(_T('plugins_tous_liste'), generer_url_ecrire("admin_plugin", "voir=tous"), 'admin_plugin', $onglet2); |
|
| 74 | + echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire("admin_plugin"), 'plugins_actifs', $onglet2); |
|
| 75 | + echo fin_onglet(); |
|
| 76 | + |
|
| 77 | + // message d'erreur au retour d'une operation |
|
| 78 | + if ($erreur) |
|
| 79 | + echo "<div class='error'>$erreur</div>"; |
|
| 80 | + if ($erreur_activation){ |
|
| 81 | + echo "<div class='error'>$erreur_activation</div>"; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + // la mise a jour de cette meta a ete faite par ecrire_plugin_actifs |
|
| 85 | + $actifs = unserialize($GLOBALS['meta']['plugin']); |
|
| 86 | + $lcpa = $actifs + unserialize($GLOBALS['meta']['plugin_attente']); |
|
| 87 | + |
|
| 88 | + // Les affichages se basent sur le repertoire, pas sur le nom |
|
| 89 | + $actifs = liste_chemin_plugin($actifs, ''); |
|
| 90 | + if (defined('_DIR_PLUGINS_SUPPL')) |
|
| 91 | + $lcpas = liste_chemin_plugin($lcpa,_DIR_PLUGINS_SUPPL); |
|
| 92 | + $lcpa = liste_chemin_plugin($lcpa); |
|
| 93 | 93 | |
| 94 | - // on installe les plugins maintenant, |
|
| 95 | - // cela permet aux scripts d'install de faire des affichages (moches...) |
|
| 96 | - plugin_installes_meta(); |
|
| 97 | - |
|
| 98 | - echo "<div class='liste-plugins formulaire_spip'>"; |
|
| 99 | - echo debut_cadre_trait_couleur('plugin-24.png',true,'',_T('plugins_liste'), 'plugins'); |
|
| 100 | - |
|
| 101 | - if ($quoi!=='actifs'){ |
|
| 102 | - $lpf = liste_plugin_files(); |
|
| 103 | - if ($lpf) |
|
| 104 | - echo "<p>"._T('texte_presente_plugin')."</p>"; |
|
| 105 | - else { |
|
| 106 | - if (!@is_dir(_DIR_PLUGINS)) |
|
| 107 | - echo "<p>"._T('plugin_info_automatique_ftp',array('rep'=>joli_repertoire(_DIR_PLUGINS))) |
|
| 108 | - . " — "._T('plugin_info_automatique_creer')."</p>"; |
|
| 109 | - } |
|
| 110 | - $lcpaffiche = $lpf; |
|
| 111 | - if (defined('_DIR_PLUGINS_SUPPL')) |
|
| 112 | - $lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL); |
|
| 113 | - } |
|
| 114 | - else { |
|
| 115 | - // la liste |
|
| 116 | - // $quoi=='actifs' |
|
| 117 | - $lcpaffiche = $lcpa; |
|
| 118 | - if (defined('_DIR_PLUGINS_SUPPL')) |
|
| 119 | - $lcpaffichesup = $lcpas; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - if ($quoi=='actifs' OR $lpf){ |
|
| 123 | - $nb = count($lcpa); |
|
| 124 | - if (defined('_DIR_PLUGINS_SUPPL')) |
|
| 125 | - $nb += count($lcpas); |
|
| 126 | - echo "<h3>".sinon(singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'), _T('plugins_actif_aucun'))."</h3>"; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - if (empty($format)) |
|
| 130 | - $format = 'liste'; |
|
| 131 | - elseif (!in_array($format,array('liste','repertoires'))) |
|
| 132 | - $format = 'repertoires'; |
|
| 133 | - |
|
| 134 | - $afficher = charger_fonction("afficher_$format",'plugins'); |
|
| 135 | - $corps = $afficher(self(),$lcpaffiche, $lcpa, $actifs); |
|
| 136 | - if (defined('_DIR_PLUGINS_SUPPL')) |
|
| 137 | - $corps .= $afficher(self(),$lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL); |
|
| 138 | - |
|
| 139 | - if ($corps) |
|
| 140 | - $corps .= "\n<div class='boutons' style='display:none;'>" |
|
| 141 | - . "<input type='submit' class='submit save' value='"._T('bouton_enregistrer') |
|
| 142 | - ."' />" |
|
| 143 | - . "</div>"; |
|
| 144 | - |
|
| 145 | - echo redirige_action_post('activer_plugins','activer','admin_plugin','', $corps); |
|
| 146 | - |
|
| 147 | - echo fin_cadre_trait_couleur(true); |
|
| 148 | - |
|
| 149 | - if ($quoi=='actifs') |
|
| 150 | - echo affiche_les_plugins_verrouilles($actifs); |
|
| 151 | - echo "</div>"; |
|
| 94 | + // on installe les plugins maintenant, |
|
| 95 | + // cela permet aux scripts d'install de faire des affichages (moches...) |
|
| 96 | + plugin_installes_meta(); |
|
| 97 | + |
|
| 98 | + echo "<div class='liste-plugins formulaire_spip'>"; |
|
| 99 | + echo debut_cadre_trait_couleur('plugin-24.png',true,'',_T('plugins_liste'), 'plugins'); |
|
| 100 | + |
|
| 101 | + if ($quoi!=='actifs'){ |
|
| 102 | + $lpf = liste_plugin_files(); |
|
| 103 | + if ($lpf) |
|
| 104 | + echo "<p>"._T('texte_presente_plugin')."</p>"; |
|
| 105 | + else { |
|
| 106 | + if (!@is_dir(_DIR_PLUGINS)) |
|
| 107 | + echo "<p>"._T('plugin_info_automatique_ftp',array('rep'=>joli_repertoire(_DIR_PLUGINS))) |
|
| 108 | + . " — "._T('plugin_info_automatique_creer')."</p>"; |
|
| 109 | + } |
|
| 110 | + $lcpaffiche = $lpf; |
|
| 111 | + if (defined('_DIR_PLUGINS_SUPPL')) |
|
| 112 | + $lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL); |
|
| 113 | + } |
|
| 114 | + else { |
|
| 115 | + // la liste |
|
| 116 | + // $quoi=='actifs' |
|
| 117 | + $lcpaffiche = $lcpa; |
|
| 118 | + if (defined('_DIR_PLUGINS_SUPPL')) |
|
| 119 | + $lcpaffichesup = $lcpas; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + if ($quoi=='actifs' OR $lpf){ |
|
| 123 | + $nb = count($lcpa); |
|
| 124 | + if (defined('_DIR_PLUGINS_SUPPL')) |
|
| 125 | + $nb += count($lcpas); |
|
| 126 | + echo "<h3>".sinon(singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'), _T('plugins_actif_aucun'))."</h3>"; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + if (empty($format)) |
|
| 130 | + $format = 'liste'; |
|
| 131 | + elseif (!in_array($format,array('liste','repertoires'))) |
|
| 132 | + $format = 'repertoires'; |
|
| 133 | + |
|
| 134 | + $afficher = charger_fonction("afficher_$format",'plugins'); |
|
| 135 | + $corps = $afficher(self(),$lcpaffiche, $lcpa, $actifs); |
|
| 136 | + if (defined('_DIR_PLUGINS_SUPPL')) |
|
| 137 | + $corps .= $afficher(self(),$lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL); |
|
| 138 | + |
|
| 139 | + if ($corps) |
|
| 140 | + $corps .= "\n<div class='boutons' style='display:none;'>" |
|
| 141 | + . "<input type='submit' class='submit save' value='"._T('bouton_enregistrer') |
|
| 142 | + ."' />" |
|
| 143 | + . "</div>"; |
|
| 144 | + |
|
| 145 | + echo redirige_action_post('activer_plugins','activer','admin_plugin','', $corps); |
|
| 146 | + |
|
| 147 | + echo fin_cadre_trait_couleur(true); |
|
| 148 | + |
|
| 149 | + if ($quoi=='actifs') |
|
| 150 | + echo affiche_les_plugins_verrouilles($actifs); |
|
| 151 | + echo "</div>"; |
|
| 152 | 152 | |
| 153 | - echo http_script(" |
|
| 153 | + echo http_script(" |
|
| 154 | 154 | jQuery(function(){ |
| 155 | 155 | jQuery('.plugins li.item a[rel=info]').click(function(){ |
| 156 | 156 | var li = jQuery(this).parents('li').eq(0); |
@@ -176,33 +176,33 @@ discard block |
||
| 176 | 176 | }); |
| 177 | 177 | "); |
| 178 | 178 | |
| 179 | - echo pipeline('affiche_milieu', |
|
| 180 | - array( |
|
| 181 | - 'args'=>array('exec'=>'admin_plugin'), |
|
| 182 | - 'data'=>'' |
|
| 183 | - ) |
|
| 184 | - ); |
|
| 179 | + echo pipeline('affiche_milieu', |
|
| 180 | + array( |
|
| 181 | + 'args'=>array('exec'=>'admin_plugin'), |
|
| 182 | + 'data'=>'' |
|
| 183 | + ) |
|
| 184 | + ); |
|
| 185 | 185 | |
| 186 | - echo fin_gauche(), fin_page(); |
|
| 186 | + echo fin_gauche(), fin_page(); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | function affiche_les_plugins_verrouilles($actifs) |
| 190 | 190 | { |
| 191 | - if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) return ''; |
|
| 192 | - |
|
| 193 | - $afficher = charger_fonction("afficher_liste",'plugins'); |
|
| 194 | - $liste = $afficher(self(), $liste, array(), $actifs, _DIR_PLUGINS_DIST); |
|
| 195 | - |
|
| 196 | - return |
|
| 197 | - "<div id='plugins_dist'>" |
|
| 198 | - . debut_cadre_trait_couleur('',true,'',_T('plugins_liste_dist'), 'liste_plugins_dist') |
|
| 199 | - . "<p>" |
|
| 200 | - . _T('plugin_info_plugins_dist_1', array('plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST))) |
|
| 201 | - . '<br />'. _T('plugin_info_plugins_dist_2') |
|
| 202 | - . "</p>" |
|
| 203 | - . $liste |
|
| 204 | - . fin_cadre_trait_couleur(true) |
|
| 205 | - . "</div>\n"; |
|
| 191 | + if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) return ''; |
|
| 192 | + |
|
| 193 | + $afficher = charger_fonction("afficher_liste",'plugins'); |
|
| 194 | + $liste = $afficher(self(), $liste, array(), $actifs, _DIR_PLUGINS_DIST); |
|
| 195 | + |
|
| 196 | + return |
|
| 197 | + "<div id='plugins_dist'>" |
|
| 198 | + . debut_cadre_trait_couleur('',true,'',_T('plugins_liste_dist'), 'liste_plugins_dist') |
|
| 199 | + . "<p>" |
|
| 200 | + . _T('plugin_info_plugins_dist_1', array('plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST))) |
|
| 201 | + . '<br />'. _T('plugin_info_plugins_dist_2') |
|
| 202 | + . "</p>" |
|
| 203 | + . $liste |
|
| 204 | + . fin_cadre_trait_couleur(true) |
|
| 205 | + . "</div>\n"; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -212,15 +212,15 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | function afficher_librairies(){ |
| 214 | 214 | |
| 215 | - if (!$libs = liste_librairies()) return ''; |
|
| 216 | - ksort($libs); |
|
| 217 | - $res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees')); |
|
| 218 | - $res .= '<dl>'; |
|
| 219 | - foreach ($libs as $lib => $rep) |
|
| 220 | - $res .= "<dt>$lib</dt><dd>".joli_repertoire($rep)."</dd>\n"; |
|
| 221 | - $res .= '</dl>'; |
|
| 222 | - $res .= fin_cadre_enfonce(true); |
|
| 223 | - return $res; |
|
| 215 | + if (!$libs = liste_librairies()) return ''; |
|
| 216 | + ksort($libs); |
|
| 217 | + $res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees')); |
|
| 218 | + $res .= '<dl>'; |
|
| 219 | + foreach ($libs as $lib => $rep) |
|
| 220 | + $res .= "<dt>$lib</dt><dd>".joli_repertoire($rep)."</dd>\n"; |
|
| 221 | + $res .= '</dl>'; |
|
| 222 | + $res .= fin_cadre_enfonce(true); |
|
| 223 | + return $res; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | |
@@ -232,17 +232,17 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | // http://doc.spip.org/@liste_librairies |
| 234 | 234 | function liste_librairies() { |
| 235 | - $libs = array(); |
|
| 236 | - foreach (array_reverse(creer_chemin()) as $d) { |
|
| 237 | - if (is_dir($dir = $d.'lib/') |
|
| 238 | - AND $t = @opendir($dir)) { |
|
| 239 | - while (($f = readdir($t)) !== false) { |
|
| 240 | - if ($f[0] != '.' |
|
| 241 | - AND is_dir("$dir/$f")) |
|
| 242 | - $libs[$f] = $dir; |
|
| 243 | - } |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - return $libs; |
|
| 235 | + $libs = array(); |
|
| 236 | + foreach (array_reverse(creer_chemin()) as $d) { |
|
| 237 | + if (is_dir($dir = $d.'lib/') |
|
| 238 | + AND $t = @opendir($dir)) { |
|
| 239 | + while (($f = readdir($t)) !== false) { |
|
| 240 | + if ($f[0] != '.' |
|
| 241 | + AND is_dir("$dir/$f")) |
|
| 242 | + $libs[$f] = $dir; |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + return $libs; |
|
| 247 | 247 | } |
| 248 | 248 | ?> |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | include_spip('inc/securiser_action'); |
| 21 | 21 | |
| 22 | 22 | // http://doc.spip.org/@exec_admin_plugin_dist |
| 23 | -function exec_admin_plugin_dist($retour='') { |
|
| 23 | +function exec_admin_plugin_dist($retour = '') { |
|
| 24 | 24 | |
| 25 | 25 | if (!autoriser('configurer', '_plugins')) { |
| 26 | 26 | include_spip('inc/minipres'); |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
| 32 | 32 | // pour etre sur que les bons fichiers seront charges lors de l'install |
| 33 | 33 | $new = actualise_plugins_actifs(); |
| 34 | - if ($new AND _request('actualise')<2) { |
|
| 34 | + if ($new AND _request('actualise') < 2) { |
|
| 35 | 35 | include_spip('inc/headers'); |
| 36 | - redirige_par_entete(parametre_url(self(),'actualise',_request('actualise')+1,'&')); |
|
| 36 | + redirige_par_entete(parametre_url(self(), 'actualise', _request('actualise') + 1, '&')); |
|
| 37 | 37 | } |
| 38 | 38 | else { |
| 39 | 39 | admin_plug_args(_request('voir'), _request('erreur'), _request('format')); |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | $commencer_page = charger_fonction('commencer_page', 'inc'); |
| 53 | 53 | echo $commencer_page(_T('icone_admin_plugin'), "configuration", "plugin"); |
| 54 | 54 | |
| 55 | - echo debut_gauche('plugin',true); |
|
| 56 | - echo recuperer_fond('prive/squelettes/navigation/configurer',array('exec'=>'admin_plugin')); |
|
| 55 | + echo debut_gauche('plugin', true); |
|
| 56 | + echo recuperer_fond('prive/squelettes/navigation/configurer', array('exec'=>'admin_plugin')); |
|
| 57 | 57 | |
| 58 | 58 | echo pipeline('affiche_gauche', |
| 59 | 59 | array( |
@@ -63,12 +63,12 @@ discard block |
||
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | 65 | echo debut_droite('plugin', true); |
| 66 | - echo gros_titre(_T('icone_admin_plugin'),'',false); |
|
| 66 | + echo gros_titre(_T('icone_admin_plugin'), '', false); |
|
| 67 | 67 | |
| 68 | 68 | // Barre d'onglets de premier niveau |
| 69 | 69 | echo barre_onglets("plugins", "plugins_actifs"); |
| 70 | 70 | // Barre d'onglets de second niveau |
| 71 | - $onglet2 = $quoi=='actifs' ? 'plugins_actifs' : 'admin_plugin'; |
|
| 71 | + $onglet2 = $quoi == 'actifs' ? 'plugins_actifs' : 'admin_plugin'; |
|
| 72 | 72 | echo debut_onglet('onglets_simple second'); |
| 73 | 73 | echo onglet(_T('plugins_tous_liste'), generer_url_ecrire("admin_plugin", "voir=tous"), 'admin_plugin', $onglet2); |
| 74 | 74 | echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire("admin_plugin"), 'plugins_actifs', $onglet2); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | // message d'erreur au retour d'une operation |
| 78 | 78 | if ($erreur) |
| 79 | 79 | echo "<div class='error'>$erreur</div>"; |
| 80 | - if ($erreur_activation){ |
|
| 80 | + if ($erreur_activation) { |
|
| 81 | 81 | echo "<div class='error'>$erreur_activation</div>"; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | // Les affichages se basent sur le repertoire, pas sur le nom |
| 89 | 89 | $actifs = liste_chemin_plugin($actifs, ''); |
| 90 | 90 | if (defined('_DIR_PLUGINS_SUPPL')) |
| 91 | - $lcpas = liste_chemin_plugin($lcpa,_DIR_PLUGINS_SUPPL); |
|
| 91 | + $lcpas = liste_chemin_plugin($lcpa, _DIR_PLUGINS_SUPPL); |
|
| 92 | 92 | $lcpa = liste_chemin_plugin($lcpa); |
| 93 | 93 | |
| 94 | 94 | // on installe les plugins maintenant, |
@@ -96,15 +96,15 @@ discard block |
||
| 96 | 96 | plugin_installes_meta(); |
| 97 | 97 | |
| 98 | 98 | echo "<div class='liste-plugins formulaire_spip'>"; |
| 99 | - echo debut_cadre_trait_couleur('plugin-24.png',true,'',_T('plugins_liste'), 'plugins'); |
|
| 99 | + echo debut_cadre_trait_couleur('plugin-24.png', true, '', _T('plugins_liste'), 'plugins'); |
|
| 100 | 100 | |
| 101 | - if ($quoi!=='actifs'){ |
|
| 101 | + if ($quoi !== 'actifs') { |
|
| 102 | 102 | $lpf = liste_plugin_files(); |
| 103 | 103 | if ($lpf) |
| 104 | 104 | echo "<p>"._T('texte_presente_plugin')."</p>"; |
| 105 | 105 | else { |
| 106 | 106 | if (!@is_dir(_DIR_PLUGINS)) |
| 107 | - echo "<p>"._T('plugin_info_automatique_ftp',array('rep'=>joli_repertoire(_DIR_PLUGINS))) |
|
| 107 | + echo "<p>"._T('plugin_info_automatique_ftp', array('rep'=>joli_repertoire(_DIR_PLUGINS))) |
|
| 108 | 108 | . " — "._T('plugin_info_automatique_creer')."</p>"; |
| 109 | 109 | } |
| 110 | 110 | $lcpaffiche = $lpf; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $lcpaffichesup = $lcpas; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if ($quoi=='actifs' OR $lpf){ |
|
| 122 | + if ($quoi == 'actifs' OR $lpf) { |
|
| 123 | 123 | $nb = count($lcpa); |
| 124 | 124 | if (defined('_DIR_PLUGINS_SUPPL')) |
| 125 | 125 | $nb += count($lcpas); |
@@ -128,13 +128,13 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | if (empty($format)) |
| 130 | 130 | $format = 'liste'; |
| 131 | - elseif (!in_array($format,array('liste','repertoires'))) |
|
| 131 | + elseif (!in_array($format, array('liste', 'repertoires'))) |
|
| 132 | 132 | $format = 'repertoires'; |
| 133 | 133 | |
| 134 | - $afficher = charger_fonction("afficher_$format",'plugins'); |
|
| 135 | - $corps = $afficher(self(),$lcpaffiche, $lcpa, $actifs); |
|
| 134 | + $afficher = charger_fonction("afficher_$format", 'plugins'); |
|
| 135 | + $corps = $afficher(self(), $lcpaffiche, $lcpa, $actifs); |
|
| 136 | 136 | if (defined('_DIR_PLUGINS_SUPPL')) |
| 137 | - $corps .= $afficher(self(),$lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL); |
|
| 137 | + $corps .= $afficher(self(), $lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL); |
|
| 138 | 138 | |
| 139 | 139 | if ($corps) |
| 140 | 140 | $corps .= "\n<div class='boutons' style='display:none;'>" |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | ."' />" |
| 143 | 143 | . "</div>"; |
| 144 | 144 | |
| 145 | - echo redirige_action_post('activer_plugins','activer','admin_plugin','', $corps); |
|
| 145 | + echo redirige_action_post('activer_plugins', 'activer', 'admin_plugin', '', $corps); |
|
| 146 | 146 | |
| 147 | 147 | echo fin_cadre_trait_couleur(true); |
| 148 | 148 | |
| 149 | - if ($quoi=='actifs') |
|
| 149 | + if ($quoi == 'actifs') |
|
| 150 | 150 | echo affiche_les_plugins_verrouilles($actifs); |
| 151 | 151 | echo "</div>"; |
| 152 | 152 | |
@@ -190,15 +190,15 @@ discard block |
||
| 190 | 190 | { |
| 191 | 191 | if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) return ''; |
| 192 | 192 | |
| 193 | - $afficher = charger_fonction("afficher_liste",'plugins'); |
|
| 193 | + $afficher = charger_fonction("afficher_liste", 'plugins'); |
|
| 194 | 194 | $liste = $afficher(self(), $liste, array(), $actifs, _DIR_PLUGINS_DIST); |
| 195 | 195 | |
| 196 | 196 | return |
| 197 | 197 | "<div id='plugins_dist'>" |
| 198 | - . debut_cadre_trait_couleur('',true,'',_T('plugins_liste_dist'), 'liste_plugins_dist') |
|
| 198 | + . debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist') |
|
| 199 | 199 | . "<p>" |
| 200 | 200 | . _T('plugin_info_plugins_dist_1', array('plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST))) |
| 201 | - . '<br />'. _T('plugin_info_plugins_dist_2') |
|
| 201 | + . '<br />'._T('plugin_info_plugins_dist_2') |
|
| 202 | 202 | . "</p>" |
| 203 | 203 | . $liste |
| 204 | 204 | . fin_cadre_trait_couleur(true) |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * |
| 211 | 211 | * @return <type> |
| 212 | 212 | */ |
| 213 | -function afficher_librairies(){ |
|
| 213 | +function afficher_librairies() { |
|
| 214 | 214 | |
| 215 | 215 | if (!$libs = liste_librairies()) return ''; |
| 216 | 216 | ksort($libs); |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | include_spip('inc/config'); |
| 16 | 18 | include_spip('inc/plugin'); |
@@ -34,8 +36,7 @@ discard block |
||
| 34 | 36 | if ($new AND _request('actualise')<2) { |
| 35 | 37 | include_spip('inc/headers'); |
| 36 | 38 | redirige_par_entete(parametre_url(self(),'actualise',_request('actualise')+1,'&')); |
| 37 | - } |
|
| 38 | - else { |
|
| 39 | + } else { |
|
| 39 | 40 | admin_plug_args(_request('voir'), _request('erreur'), _request('format')); |
| 40 | 41 | } |
| 41 | 42 | } |
@@ -43,7 +44,9 @@ discard block |
||
| 43 | 44 | |
| 44 | 45 | function admin_plug_args($quoi, $erreur, $format) |
| 45 | 46 | { |
| 46 | - if (!$quoi) $quoi = 'actifs'; |
|
| 47 | + if (!$quoi) { |
|
| 48 | + $quoi = 'actifs'; |
|
| 49 | + } |
|
| 47 | 50 | // empecher l'affichage des erreurs dans le bandeau, on le donne ensuite |
| 48 | 51 | // format brut par plugin |
| 49 | 52 | $GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false); |
@@ -75,8 +78,9 @@ discard block |
||
| 75 | 78 | echo fin_onglet(); |
| 76 | 79 | |
| 77 | 80 | // message d'erreur au retour d'une operation |
| 78 | - if ($erreur) |
|
| 79 | - echo "<div class='error'>$erreur</div>"; |
|
| 81 | + if ($erreur) { |
|
| 82 | + echo "<div class='error'>$erreur</div>"; |
|
| 83 | + } |
|
| 80 | 84 | if ($erreur_activation){ |
| 81 | 85 | echo "<div class='error'>$erreur_activation</div>"; |
| 82 | 86 | } |
@@ -87,8 +91,9 @@ discard block |
||
| 87 | 91 | |
| 88 | 92 | // Les affichages se basent sur le repertoire, pas sur le nom |
| 89 | 93 | $actifs = liste_chemin_plugin($actifs, ''); |
| 90 | - if (defined('_DIR_PLUGINS_SUPPL')) |
|
| 91 | - $lcpas = liste_chemin_plugin($lcpa,_DIR_PLUGINS_SUPPL); |
|
| 94 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 95 | + $lcpas = liste_chemin_plugin($lcpa,_DIR_PLUGINS_SUPPL); |
|
| 96 | + } |
|
| 92 | 97 | $lcpa = liste_chemin_plugin($lcpa); |
| 93 | 98 | |
| 94 | 99 | // on installe les plugins maintenant, |
@@ -100,54 +105,61 @@ discard block |
||
| 100 | 105 | |
| 101 | 106 | if ($quoi!=='actifs'){ |
| 102 | 107 | $lpf = liste_plugin_files(); |
| 103 | - if ($lpf) |
|
| 104 | - echo "<p>"._T('texte_presente_plugin')."</p>"; |
|
| 105 | - else { |
|
| 106 | - if (!@is_dir(_DIR_PLUGINS)) |
|
| 107 | - echo "<p>"._T('plugin_info_automatique_ftp',array('rep'=>joli_repertoire(_DIR_PLUGINS))) |
|
| 108 | + if ($lpf) { |
|
| 109 | + echo "<p>"._T('texte_presente_plugin')."</p>"; |
|
| 110 | + } else { |
|
| 111 | + if (!@is_dir(_DIR_PLUGINS)) { |
|
| 112 | + echo "<p>"._T('plugin_info_automatique_ftp',array('rep'=>joli_repertoire(_DIR_PLUGINS))) |
|
| 108 | 113 | . " — "._T('plugin_info_automatique_creer')."</p>"; |
| 114 | + } |
|
| 109 | 115 | } |
| 110 | 116 | $lcpaffiche = $lpf; |
| 111 | - if (defined('_DIR_PLUGINS_SUPPL')) |
|
| 112 | - $lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL); |
|
| 113 | - } |
|
| 114 | - else { |
|
| 117 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 118 | + $lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL); |
|
| 119 | + } |
|
| 120 | + } else { |
|
| 115 | 121 | // la liste |
| 116 | 122 | // $quoi=='actifs' |
| 117 | 123 | $lcpaffiche = $lcpa; |
| 118 | - if (defined('_DIR_PLUGINS_SUPPL')) |
|
| 119 | - $lcpaffichesup = $lcpas; |
|
| 124 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 125 | + $lcpaffichesup = $lcpas; |
|
| 126 | + } |
|
| 120 | 127 | } |
| 121 | 128 | |
| 122 | 129 | if ($quoi=='actifs' OR $lpf){ |
| 123 | 130 | $nb = count($lcpa); |
| 124 | - if (defined('_DIR_PLUGINS_SUPPL')) |
|
| 125 | - $nb += count($lcpas); |
|
| 131 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 132 | + $nb += count($lcpas); |
|
| 133 | + } |
|
| 126 | 134 | echo "<h3>".sinon(singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'), _T('plugins_actif_aucun'))."</h3>"; |
| 127 | 135 | } |
| 128 | 136 | |
| 129 | - if (empty($format)) |
|
| 130 | - $format = 'liste'; |
|
| 131 | - elseif (!in_array($format,array('liste','repertoires'))) |
|
| 132 | - $format = 'repertoires'; |
|
| 137 | + if (empty($format)) { |
|
| 138 | + $format = 'liste'; |
|
| 139 | + } elseif (!in_array($format,array('liste','repertoires'))) { |
|
| 140 | + $format = 'repertoires'; |
|
| 141 | + } |
|
| 133 | 142 | |
| 134 | 143 | $afficher = charger_fonction("afficher_$format",'plugins'); |
| 135 | 144 | $corps = $afficher(self(),$lcpaffiche, $lcpa, $actifs); |
| 136 | - if (defined('_DIR_PLUGINS_SUPPL')) |
|
| 137 | - $corps .= $afficher(self(),$lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL); |
|
| 145 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 146 | + $corps .= $afficher(self(),$lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL); |
|
| 147 | + } |
|
| 138 | 148 | |
| 139 | - if ($corps) |
|
| 140 | - $corps .= "\n<div class='boutons' style='display:none;'>" |
|
| 149 | + if ($corps) { |
|
| 150 | + $corps .= "\n<div class='boutons' style='display:none;'>" |
|
| 141 | 151 | . "<input type='submit' class='submit save' value='"._T('bouton_enregistrer') |
| 142 | 152 | ."' />" |
| 143 | 153 | . "</div>"; |
| 154 | + } |
|
| 144 | 155 | |
| 145 | 156 | echo redirige_action_post('activer_plugins','activer','admin_plugin','', $corps); |
| 146 | 157 | |
| 147 | 158 | echo fin_cadre_trait_couleur(true); |
| 148 | 159 | |
| 149 | - if ($quoi=='actifs') |
|
| 150 | - echo affiche_les_plugins_verrouilles($actifs); |
|
| 160 | + if ($quoi=='actifs') { |
|
| 161 | + echo affiche_les_plugins_verrouilles($actifs); |
|
| 162 | + } |
|
| 151 | 163 | echo "</div>"; |
| 152 | 164 | |
| 153 | 165 | echo http_script(" |
@@ -188,7 +200,9 @@ discard block |
||
| 188 | 200 | |
| 189 | 201 | function affiche_les_plugins_verrouilles($actifs) |
| 190 | 202 | { |
| 191 | - if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) return ''; |
|
| 203 | + if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) { |
|
| 204 | + return ''; |
|
| 205 | + } |
|
| 192 | 206 | |
| 193 | 207 | $afficher = charger_fonction("afficher_liste",'plugins'); |
| 194 | 208 | $liste = $afficher(self(), $liste, array(), $actifs, _DIR_PLUGINS_DIST); |
@@ -212,12 +226,15 @@ discard block |
||
| 212 | 226 | */ |
| 213 | 227 | function afficher_librairies(){ |
| 214 | 228 | |
| 215 | - if (!$libs = liste_librairies()) return ''; |
|
| 229 | + if (!$libs = liste_librairies()) { |
|
| 230 | + return ''; |
|
| 231 | + } |
|
| 216 | 232 | ksort($libs); |
| 217 | 233 | $res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees')); |
| 218 | 234 | $res .= '<dl>'; |
| 219 | - foreach ($libs as $lib => $rep) |
|
| 220 | - $res .= "<dt>$lib</dt><dd>".joli_repertoire($rep)."</dd>\n"; |
|
| 235 | + foreach ($libs as $lib => $rep) { |
|
| 236 | + $res .= "<dt>$lib</dt><dd>".joli_repertoire($rep)."</dd>\n"; |
|
| 237 | + } |
|
| 221 | 238 | $res .= '</dl>'; |
| 222 | 239 | $res .= fin_cadre_enfonce(true); |
| 223 | 240 | return $res; |
@@ -238,8 +255,9 @@ discard block |
||
| 238 | 255 | AND $t = @opendir($dir)) { |
| 239 | 256 | while (($f = readdir($t)) !== false) { |
| 240 | 257 | if ($f[0] != '.' |
| 241 | - AND is_dir("$dir/$f")) |
|
| 242 | - $libs[$f] = $dir; |
|
| 258 | + AND is_dir("$dir/$f")) { |
|
| 259 | + $libs[$f] = $dir; |
|
| 260 | + } |
|
| 243 | 261 | } |
| 244 | 262 | } |
| 245 | 263 | } |
@@ -36,30 +36,30 @@ |
||
| 36 | 36 | // http://doc.spip.org/@phraserTout |
| 37 | 37 | function phraserTout($phraseur, $data) |
| 38 | 38 | { |
| 39 | - xml_parsestring($this, $data); |
|
| 39 | + xml_parsestring($this, $data); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - var $depth = ""; |
|
| 43 | - var $res = ""; |
|
| 44 | - var $err = array(); |
|
| 45 | - var $contenu = array(); |
|
| 46 | - var $ouvrant = array(); |
|
| 47 | - var $reperes = array(); |
|
| 48 | - var $entete = ''; |
|
| 49 | - var $page = ''; |
|
| 50 | - var $dtc = NULL; |
|
| 51 | - var $sax = NULL; |
|
| 42 | + var $depth = ""; |
|
| 43 | + var $res = ""; |
|
| 44 | + var $err = array(); |
|
| 45 | + var $contenu = array(); |
|
| 46 | + var $ouvrant = array(); |
|
| 47 | + var $reperes = array(); |
|
| 48 | + var $entete = ''; |
|
| 49 | + var $page = ''; |
|
| 50 | + var $dtc = NULL; |
|
| 51 | + var $sax = NULL; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // http://doc.spip.org/@xml_indenter_dist |
| 55 | 55 | function xml_indenter_dist($page, $apply=false) |
| 56 | 56 | { |
| 57 | - $sax = charger_fonction('sax', 'xml'); |
|
| 58 | - $f = new IndenteurXML(); |
|
| 59 | - $sax($page, $apply, $f); |
|
| 60 | - if (!$f->err) return $f->entete . $f->res; |
|
| 61 | - spip_log("indentation impossible " . count($f->err) . " erreurs de validation"); |
|
| 62 | - return $f->entete . $f->page; |
|
| 57 | + $sax = charger_fonction('sax', 'xml'); |
|
| 58 | + $f = new IndenteurXML(); |
|
| 59 | + $sax($page, $apply, $f); |
|
| 60 | + if (!$f->err) return $f->entete . $f->res; |
|
| 61 | + spip_log("indentation impossible " . count($f->err) . " erreurs de validation"); |
|
| 62 | + return $f->entete . $f->page; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | ?> |
@@ -16,22 +16,22 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | // http://doc.spip.org/@debutElement |
| 18 | 18 | function debutElement($phraseur, $name, $attrs) |
| 19 | -{ xml_debutElement($this, $name, $attrs);} |
|
| 19 | +{ xml_debutElement($this, $name, $attrs); } |
|
| 20 | 20 | |
| 21 | 21 | // http://doc.spip.org/@finElement |
| 22 | 22 | function finElement($phraseur, $name) |
| 23 | -{ xml_finElement($this, $name);} |
|
| 23 | +{ xml_finElement($this, $name); } |
|
| 24 | 24 | |
| 25 | 25 | // http://doc.spip.org/@textElement |
| 26 | 26 | function textElement($phraseur, $data) |
| 27 | -{ xml_textElement($this, $data);} |
|
| 27 | +{ xml_textElement($this, $data); } |
|
| 28 | 28 | |
| 29 | 29 | function piElement($phraseur, $target, $data) |
| 30 | -{ xml_PiElement($this, $target, $data);} |
|
| 30 | +{ xml_PiElement($this, $target, $data); } |
|
| 31 | 31 | |
| 32 | 32 | // http://doc.spip.org/@defautElement |
| 33 | 33 | function defaultElement($phraseur, $data) |
| 34 | -{ xml_defaultElement($this, $data);} |
|
| 34 | +{ xml_defaultElement($this, $data); } |
|
| 35 | 35 | |
| 36 | 36 | // http://doc.spip.org/@phraserTout |
| 37 | 37 | function phraserTout($phraseur, $data) |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // http://doc.spip.org/@xml_indenter_dist |
| 55 | -function xml_indenter_dist($page, $apply=false) |
|
| 55 | +function xml_indenter_dist($page, $apply = false) |
|
| 56 | 56 | { |
| 57 | 57 | $sax = charger_fonction('sax', 'xml'); |
| 58 | 58 | $f = new IndenteurXML(); |
| 59 | 59 | $sax($page, $apply, $f); |
| 60 | - if (!$f->err) return $f->entete . $f->res; |
|
| 61 | - spip_log("indentation impossible " . count($f->err) . " erreurs de validation"); |
|
| 62 | - return $f->entete . $f->page; |
|
| 60 | + if (!$f->err) return $f->entete.$f->res; |
|
| 61 | + spip_log("indentation impossible ".count($f->err)." erreurs de validation"); |
|
| 62 | + return $f->entete.$f->page; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | ?> |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | class IndenteurXML { |
| 16 | 18 | |
@@ -57,7 +59,9 @@ discard block |
||
| 57 | 59 | $sax = charger_fonction('sax', 'xml'); |
| 58 | 60 | $f = new IndenteurXML(); |
| 59 | 61 | $sax($page, $apply, $f); |
| 60 | - if (!$f->err) return $f->entete . $f->res; |
|
| 62 | + if (!$f->err) { |
|
| 63 | + return $f->entete . $f->res; |
|
| 64 | + } |
|
| 61 | 65 | spip_log("indentation impossible " . count($f->err) . " erreurs de validation"); |
| 62 | 66 | return $f->entete . $f->page; |
| 63 | 67 | } |
@@ -21,251 +21,251 @@ discard block |
||
| 21 | 21 | // http://doc.spip.org/@validerElement |
| 22 | 22 | function validerElement($phraseur, $name, $attrs) |
| 23 | 23 | { |
| 24 | - if (!($p = isset($this->dtc->elements[$name]))) { |
|
| 25 | - if ($p = strpos($name, ':')) { |
|
| 26 | - $name = substr($name, $p+1); |
|
| 27 | - $p = isset($this->dtc->elements[$name]); |
|
| 28 | - } |
|
| 29 | - if (!$p) { |
|
| 30 | - coordonnees_erreur($this," <b>$name</b> : " |
|
| 31 | - . _T('zxml_inconnu_balise')); |
|
| 32 | - return; |
|
| 33 | - } |
|
| 34 | - } |
|
| 35 | - // controler les filles illegitimes, ca suffit |
|
| 36 | - $depth = $this->depth; |
|
| 37 | - $ouvrant = $this->ouvrant; |
|
| 24 | + if (!($p = isset($this->dtc->elements[$name]))) { |
|
| 25 | + if ($p = strpos($name, ':')) { |
|
| 26 | + $name = substr($name, $p+1); |
|
| 27 | + $p = isset($this->dtc->elements[$name]); |
|
| 28 | + } |
|
| 29 | + if (!$p) { |
|
| 30 | + coordonnees_erreur($this," <b>$name</b> : " |
|
| 31 | + . _T('zxml_inconnu_balise')); |
|
| 32 | + return; |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | + // controler les filles illegitimes, ca suffit |
|
| 36 | + $depth = $this->depth; |
|
| 37 | + $ouvrant = $this->ouvrant; |
|
| 38 | 38 | # spip_log("trouve $name apres " . $ouvrant[$depth]); |
| 39 | - if (isset($ouvrant[$depth])) { |
|
| 40 | - if (preg_match('/^\s*(\w+)/', $ouvrant[$depth], $r)) { |
|
| 41 | - $pere = $r[1]; |
|
| 39 | + if (isset($ouvrant[$depth])) { |
|
| 40 | + if (preg_match('/^\s*(\w+)/', $ouvrant[$depth], $r)) { |
|
| 41 | + $pere = $r[1]; |
|
| 42 | 42 | # spip_log("pere $pere"); |
| 43 | - if (isset($this->dtc->elements[$pere])) { |
|
| 44 | - $fils = $this->dtc->elements[$pere]; |
|
| 43 | + if (isset($this->dtc->elements[$pere])) { |
|
| 44 | + $fils = $this->dtc->elements[$pere]; |
|
| 45 | 45 | # spip_log("rejeton $name fils " . @join(',',$fils)); |
| 46 | - if (!($p = @in_array($name, $fils))) { |
|
| 47 | - if ($p = strpos($name, ':')) { |
|
| 48 | - $p = substr($name, $p+1); |
|
| 49 | - $p = @in_array($p, $fils); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - if (!$p) { |
|
| 53 | - $bons_peres = @join ('</b>, <b>', $this->dtc->peres[$name]); |
|
| 54 | - coordonnees_erreur($this, " <b>$name</b> " |
|
| 55 | - . _T('zxml_non_fils') |
|
| 56 | - . ' <b>' |
|
| 57 | - . $pere |
|
| 58 | - . '</b>' |
|
| 59 | - . (!$bons_peres ? '' |
|
| 60 | - : ('<p style="font-size: 80%"> '._T('zxml_mais_de').' <b>'. $bons_peres . '</b></p>'))); |
|
| 61 | - } else if ($this->dtc->regles[$pere][0]=='/') { |
|
| 62 | - $frat = substr($depth,2); |
|
| 63 | - if (!isset($this->fratrie[$frat])) { |
|
| 64 | - $this->fratrie[$frat] = ''; |
|
| 65 | - } |
|
| 66 | - $this->fratrie[$frat] .= "$name "; |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - // Init de la suite des balises a memoriser si regle difficile |
|
| 72 | - if ($this->dtc->regles[$name][0]=='/') |
|
| 73 | - $this->fratrie[$depth]=''; |
|
| 74 | - if (isset($this->dtc->attributs[$name])) { |
|
| 75 | - foreach ($this->dtc->attributs[$name] as $n => $v) |
|
| 76 | - { if (($v[1] == '#REQUIRED') AND (!isset($attrs[$n]))) |
|
| 77 | - coordonnees_erreur($this, " <b>$n</b>" |
|
| 78 | - . ' : ' |
|
| 79 | - . _T('zxml_obligatoire_attribut') |
|
| 80 | - . " <b>$name</b>"); |
|
| 81 | - } |
|
| 82 | - } |
|
| 46 | + if (!($p = @in_array($name, $fils))) { |
|
| 47 | + if ($p = strpos($name, ':')) { |
|
| 48 | + $p = substr($name, $p+1); |
|
| 49 | + $p = @in_array($p, $fils); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + if (!$p) { |
|
| 53 | + $bons_peres = @join ('</b>, <b>', $this->dtc->peres[$name]); |
|
| 54 | + coordonnees_erreur($this, " <b>$name</b> " |
|
| 55 | + . _T('zxml_non_fils') |
|
| 56 | + . ' <b>' |
|
| 57 | + . $pere |
|
| 58 | + . '</b>' |
|
| 59 | + . (!$bons_peres ? '' |
|
| 60 | + : ('<p style="font-size: 80%"> '._T('zxml_mais_de').' <b>'. $bons_peres . '</b></p>'))); |
|
| 61 | + } else if ($this->dtc->regles[$pere][0]=='/') { |
|
| 62 | + $frat = substr($depth,2); |
|
| 63 | + if (!isset($this->fratrie[$frat])) { |
|
| 64 | + $this->fratrie[$frat] = ''; |
|
| 65 | + } |
|
| 66 | + $this->fratrie[$frat] .= "$name "; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + // Init de la suite des balises a memoriser si regle difficile |
|
| 72 | + if ($this->dtc->regles[$name][0]=='/') |
|
| 73 | + $this->fratrie[$depth]=''; |
|
| 74 | + if (isset($this->dtc->attributs[$name])) { |
|
| 75 | + foreach ($this->dtc->attributs[$name] as $n => $v) |
|
| 76 | + { if (($v[1] == '#REQUIRED') AND (!isset($attrs[$n]))) |
|
| 77 | + coordonnees_erreur($this, " <b>$n</b>" |
|
| 78 | + . ' : ' |
|
| 79 | + . _T('zxml_obligatoire_attribut') |
|
| 80 | + . " <b>$name</b>"); |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // http://doc.spip.org/@validerAttribut |
| 86 | 86 | function validerAttribut($phraseur, $name, $val, $bal) |
| 87 | 87 | { |
| 88 | - // Si la balise est inconnue, eviter d'insister |
|
| 89 | - if (!isset($this->dtc->attributs[$bal])) |
|
| 90 | - return ; |
|
| 88 | + // Si la balise est inconnue, eviter d'insister |
|
| 89 | + if (!isset($this->dtc->attributs[$bal])) |
|
| 90 | + return ; |
|
| 91 | 91 | |
| 92 | - $a = $this->dtc->attributs[$bal]; |
|
| 93 | - if (!isset($a[$name])) { |
|
| 94 | - $bons = join(', ',array_keys($a)); |
|
| 95 | - if ($bons) |
|
| 96 | - $bons = " title=' " . |
|
| 97 | - _T('zxml_connus_attributs') . |
|
| 98 | - ' : ' . |
|
| 99 | - $bons . |
|
| 100 | - "'"; |
|
| 101 | - $bons .= " style='font-weight: bold'"; |
|
| 102 | - coordonnees_erreur($this, " <b>$name</b> " |
|
| 103 | - . _T('zxml_inconnu_attribut').' '._T('zxml_de') |
|
| 104 | - . " <a$bons>$bal</a> (" |
|
| 105 | - . _T('zxml_survoler') |
|
| 106 | - . ")"); |
|
| 107 | - } else{ |
|
| 108 | - $type = $a[$name][0]; |
|
| 109 | - if (!preg_match('/^\w+$/', $type)) |
|
| 110 | - $this->valider_motif($phraseur, $name, $val, $bal, $type); |
|
| 111 | - else if (method_exists($this, $f = 'validerAttribut_' . $type)) |
|
| 112 | - $this->$f($phraseur, $name, $val, $bal); |
|
| 92 | + $a = $this->dtc->attributs[$bal]; |
|
| 93 | + if (!isset($a[$name])) { |
|
| 94 | + $bons = join(', ',array_keys($a)); |
|
| 95 | + if ($bons) |
|
| 96 | + $bons = " title=' " . |
|
| 97 | + _T('zxml_connus_attributs') . |
|
| 98 | + ' : ' . |
|
| 99 | + $bons . |
|
| 100 | + "'"; |
|
| 101 | + $bons .= " style='font-weight: bold'"; |
|
| 102 | + coordonnees_erreur($this, " <b>$name</b> " |
|
| 103 | + . _T('zxml_inconnu_attribut').' '._T('zxml_de') |
|
| 104 | + . " <a$bons>$bal</a> (" |
|
| 105 | + . _T('zxml_survoler') |
|
| 106 | + . ")"); |
|
| 107 | + } else{ |
|
| 108 | + $type = $a[$name][0]; |
|
| 109 | + if (!preg_match('/^\w+$/', $type)) |
|
| 110 | + $this->valider_motif($phraseur, $name, $val, $bal, $type); |
|
| 111 | + else if (method_exists($this, $f = 'validerAttribut_' . $type)) |
|
| 112 | + $this->$f($phraseur, $name, $val, $bal); |
|
| 113 | 113 | # else spip_log("$type type d'attribut inconnu"); |
| 114 | - } |
|
| 114 | + } |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | function validerAttribut_NMTOKEN($phraseur, $name, $val, $bal) |
| 118 | 118 | { |
| 119 | - $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKEN); |
|
| 119 | + $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKEN); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | function validerAttribut_NMTOKENS($phraseur, $name, $val, $bal) |
| 123 | 123 | { |
| 124 | - $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKENS); |
|
| 124 | + $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKENS); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // http://doc.spip.org/@validerAttribut_ID |
| 128 | 128 | function validerAttribut_ID($phraseur, $name, $val, $bal) |
| 129 | 129 | { |
| 130 | - if (isset($this->ids[$val])) { |
|
| 131 | - list($l,$c) = $this->ids[$val]; |
|
| 132 | - coordonnees_erreur($this, " <p><b>$val</b> " |
|
| 133 | - . _T('zxml_valeur_attribut') |
|
| 134 | - . " <b>$name</b> " |
|
| 135 | - . _T('zxml_de') |
|
| 136 | - . " <b>$bal</b> " |
|
| 137 | - . _T('zxml_vu') |
|
| 138 | - . " (L$l,C$c)"); |
|
| 139 | - } else { |
|
| 140 | - $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_ID); |
|
| 141 | - $this->ids[$val] = array(xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)); |
|
| 142 | - } |
|
| 130 | + if (isset($this->ids[$val])) { |
|
| 131 | + list($l,$c) = $this->ids[$val]; |
|
| 132 | + coordonnees_erreur($this, " <p><b>$val</b> " |
|
| 133 | + . _T('zxml_valeur_attribut') |
|
| 134 | + . " <b>$name</b> " |
|
| 135 | + . _T('zxml_de') |
|
| 136 | + . " <b>$bal</b> " |
|
| 137 | + . _T('zxml_vu') |
|
| 138 | + . " (L$l,C$c)"); |
|
| 139 | + } else { |
|
| 140 | + $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_ID); |
|
| 141 | + $this->ids[$val] = array(xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)); |
|
| 142 | + } |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | // http://doc.spip.org/@validerAttribut_IDREF |
| 146 | 146 | function validerAttribut_IDREF($phraseur, $name, $val, $bal) |
| 147 | 147 | { |
| 148 | - $this->idrefs[] = array($val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)); |
|
| 148 | + $this->idrefs[] = array($val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // http://doc.spip.org/@validerAttribut_IDREFS |
| 152 | 152 | function validerAttribut_IDREFS($phraseur, $name, $val, $bal) |
| 153 | 153 | { |
| 154 | - $this->idrefss[] = array($val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)); |
|
| 154 | + $this->idrefss[] = array($val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | // http://doc.spip.org/@valider_motif |
| 158 | 158 | function valider_motif($phraseur, $name, $val, $bal, $motif) |
| 159 | 159 | { |
| 160 | - if (!preg_match($motif, $val)) { |
|
| 161 | - coordonnees_erreur($this, "<b>$val</b> " |
|
| 162 | - . _T('zxml_valeur_attribut') |
|
| 163 | - . " <b>$name</b> " |
|
| 164 | - . _T('zxml_de') |
|
| 165 | - . " <b>$bal</b> " |
|
| 166 | - . _T('zxml_non_conforme') |
|
| 167 | - . "</p><p>" |
|
| 168 | - . "<b>" . $motif . "</b>"); |
|
| 169 | - } |
|
| 160 | + if (!preg_match($motif, $val)) { |
|
| 161 | + coordonnees_erreur($this, "<b>$val</b> " |
|
| 162 | + . _T('zxml_valeur_attribut') |
|
| 163 | + . " <b>$name</b> " |
|
| 164 | + . _T('zxml_de') |
|
| 165 | + . " <b>$bal</b> " |
|
| 166 | + . _T('zxml_non_conforme') |
|
| 167 | + . "</p><p>" |
|
| 168 | + . "<b>" . $motif . "</b>"); |
|
| 169 | + } |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | // http://doc.spip.org/@valider_idref |
| 173 | 173 | function valider_idref($nom, $ligne, $col) |
| 174 | 174 | { |
| 175 | - if (!isset($this->ids[$nom])) |
|
| 176 | - $this->err[]= array(" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col); |
|
| 175 | + if (!isset($this->ids[$nom])) |
|
| 176 | + $this->err[]= array(" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | // http://doc.spip.org/@valider_passe2 |
| 180 | 180 | function valider_passe2() |
| 181 | 181 | { |
| 182 | - if (!$this->err) { |
|
| 183 | - foreach ($this->idrefs as $idref) { |
|
| 184 | - list($nom, $ligne, $col) = $idref; |
|
| 185 | - $this->valider_idref($nom, $ligne, $col); |
|
| 186 | - } |
|
| 187 | - foreach ($this->idrefss as $idref) { |
|
| 188 | - list($noms, $ligne, $col) = $idref; |
|
| 189 | - foreach(preg_split('/\s+/', $noms) as $nom) |
|
| 190 | - $this->valider_idref($nom, $ligne, $col); |
|
| 191 | - } |
|
| 192 | - } |
|
| 182 | + if (!$this->err) { |
|
| 183 | + foreach ($this->idrefs as $idref) { |
|
| 184 | + list($nom, $ligne, $col) = $idref; |
|
| 185 | + $this->valider_idref($nom, $ligne, $col); |
|
| 186 | + } |
|
| 187 | + foreach ($this->idrefss as $idref) { |
|
| 188 | + list($noms, $ligne, $col) = $idref; |
|
| 189 | + foreach(preg_split('/\s+/', $noms) as $nom) |
|
| 190 | + $this->valider_idref($nom, $ligne, $col); |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | // http://doc.spip.org/@debutElement |
| 196 | 196 | function debutElement($phraseur, $name, $attrs) |
| 197 | 197 | { |
| 198 | - if ($this->dtc->elements) |
|
| 199 | - $this->validerElement($phraseur, $name, $attrs); |
|
| 198 | + if ($this->dtc->elements) |
|
| 199 | + $this->validerElement($phraseur, $name, $attrs); |
|
| 200 | 200 | |
| 201 | - if ($f = $this->process['debut']) $f($this, $name, $attrs); |
|
| 202 | - $depth = $this->depth; |
|
| 203 | - $this->debuts[$depth] = strlen($this->res); |
|
| 204 | - foreach ($attrs as $k => $v) { |
|
| 205 | - $this->validerAttribut($phraseur, $k, $v, $name); |
|
| 206 | - } |
|
| 201 | + if ($f = $this->process['debut']) $f($this, $name, $attrs); |
|
| 202 | + $depth = $this->depth; |
|
| 203 | + $this->debuts[$depth] = strlen($this->res); |
|
| 204 | + foreach ($attrs as $k => $v) { |
|
| 205 | + $this->validerAttribut($phraseur, $k, $v, $name); |
|
| 206 | + } |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | // http://doc.spip.org/@finElement |
| 210 | 210 | function finElement($phraseur, $name) |
| 211 | 211 | { |
| 212 | - $depth = $this->depth; |
|
| 213 | - $contenu = $this->contenu; |
|
| 212 | + $depth = $this->depth; |
|
| 213 | + $contenu = $this->contenu; |
|
| 214 | 214 | |
| 215 | - $n = strlen($this->res); |
|
| 216 | - $c = strlen(trim($contenu[$depth])); |
|
| 217 | - $k = $this->debuts[$depth]; |
|
| 215 | + $n = strlen($this->res); |
|
| 216 | + $c = strlen(trim($contenu[$depth])); |
|
| 217 | + $k = $this->debuts[$depth]; |
|
| 218 | 218 | |
| 219 | - $regle = $this->dtc->regles[$name]; |
|
| 220 | - $vide = ($regle == 'EMPTY'); |
|
| 221 | - // controler que les balises devant etre vides le sont |
|
| 222 | - if ($vide) { |
|
| 223 | - if ($n <> ($k + $c)) |
|
| 224 | - coordonnees_erreur($this, " <p><b>$name</b> " |
|
| 225 | - . _T('zxml_nonvide_balise')); |
|
| 226 | - // pour les regles PCDATA ou iteration de disjonction, tout est fait |
|
| 227 | - } elseif ($regle AND ($regle != '*')) { |
|
| 228 | - if ($regle == '+') { |
|
| 229 | - // iteration de disjonction non vide: 1 balise au - |
|
| 230 | - if ($n == $k) { |
|
| 231 | - coordonnees_erreur($this, "<p>\n<b>$name</b> " |
|
| 232 | - . _T('zxml_vide_balise')); |
|
| 233 | - } |
|
| 234 | - } else { |
|
| 235 | - $f = $this->fratrie[substr($depth,2)]; |
|
| 236 | - if (!preg_match($regle, $f)) { |
|
| 237 | - coordonnees_erreur($this, |
|
| 238 | - " <p>\n<b>$name</b> " |
|
| 239 | - . _T('zxml_succession_fils_incorrecte') |
|
| 240 | - . ' : <b>' |
|
| 241 | - . $f |
|
| 242 | - . '</b>'); |
|
| 243 | - } |
|
| 244 | - } |
|
| 219 | + $regle = $this->dtc->regles[$name]; |
|
| 220 | + $vide = ($regle == 'EMPTY'); |
|
| 221 | + // controler que les balises devant etre vides le sont |
|
| 222 | + if ($vide) { |
|
| 223 | + if ($n <> ($k + $c)) |
|
| 224 | + coordonnees_erreur($this, " <p><b>$name</b> " |
|
| 225 | + . _T('zxml_nonvide_balise')); |
|
| 226 | + // pour les regles PCDATA ou iteration de disjonction, tout est fait |
|
| 227 | + } elseif ($regle AND ($regle != '*')) { |
|
| 228 | + if ($regle == '+') { |
|
| 229 | + // iteration de disjonction non vide: 1 balise au - |
|
| 230 | + if ($n == $k) { |
|
| 231 | + coordonnees_erreur($this, "<p>\n<b>$name</b> " |
|
| 232 | + . _T('zxml_vide_balise')); |
|
| 233 | + } |
|
| 234 | + } else { |
|
| 235 | + $f = $this->fratrie[substr($depth,2)]; |
|
| 236 | + if (!preg_match($regle, $f)) { |
|
| 237 | + coordonnees_erreur($this, |
|
| 238 | + " <p>\n<b>$name</b> " |
|
| 239 | + . _T('zxml_succession_fils_incorrecte') |
|
| 240 | + . ' : <b>' |
|
| 241 | + . $f |
|
| 242 | + . '</b>'); |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - } |
|
| 247 | - if ($f = $this->process['fin']) $f($this, $name, $vide); |
|
| 246 | + } |
|
| 247 | + if ($f = $this->process['fin']) $f($this, $name, $vide); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | // http://doc.spip.org/@textElement |
| 251 | 251 | function textElement($phraseur, $data) |
| 252 | 252 | { |
| 253 | - if (trim($data)) { |
|
| 254 | - $d = $this->depth; |
|
| 255 | - $d = $this->ouvrant[$d]; |
|
| 256 | - preg_match('/^\s*(\S+)/', $d, $m); |
|
| 257 | - if ($this->dtc->pcdata[$m[1]]) { |
|
| 258 | - coordonnees_erreur($this, " <p><b>". $m[1] . "</b> " |
|
| 259 | - . _T('zxml_nonvide_balise') // message a affiner |
|
| 260 | - ); |
|
| 261 | - } |
|
| 262 | - } |
|
| 263 | - if ($f = $this->process['text']) $f($this, $data); |
|
| 253 | + if (trim($data)) { |
|
| 254 | + $d = $this->depth; |
|
| 255 | + $d = $this->ouvrant[$d]; |
|
| 256 | + preg_match('/^\s*(\S+)/', $d, $m); |
|
| 257 | + if ($this->dtc->pcdata[$m[1]]) { |
|
| 258 | + coordonnees_erreur($this, " <p><b>". $m[1] . "</b> " |
|
| 259 | + . _T('zxml_nonvide_balise') // message a affiner |
|
| 260 | + ); |
|
| 261 | + } |
|
| 262 | + } |
|
| 263 | + if ($f = $this->process['text']) $f($this, $data); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | function piElement($phraseur, $target, $data) |
| 267 | 267 | { |
| 268 | - if ($f = $this->process['pi']) $f($this, $target, $data); |
|
| 268 | + if ($f = $this->process['pi']) $f($this, $target, $data); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | // Denonciation des entitees XML inconnues |
@@ -278,61 +278,61 @@ discard block |
||
| 278 | 278 | // http://doc.spip.org/@defautElement |
| 279 | 279 | function defaultElement($phraseur, $data) |
| 280 | 280 | { |
| 281 | - if (!preg_match('/^<!--/', $data) |
|
| 282 | - AND (preg_match_all('/&([^;]*)?/', $data, $r, PREG_SET_ORDER))) |
|
| 283 | - foreach ($r as $m) { |
|
| 284 | - list($t,$e) = $m; |
|
| 285 | - if (!isset($this->dtc->entites[$e])) |
|
| 286 | - coordonnees_erreur($this, " <b>$e</b> " |
|
| 287 | - . _T('zxml_inconnu_entite') |
|
| 288 | - . ' ' |
|
| 289 | - ); |
|
| 290 | - } |
|
| 291 | - if (isset($this->process['default']) AND ($f = $this->process['default'])) { |
|
| 292 | - $f($this, $data); |
|
| 293 | - } |
|
| 281 | + if (!preg_match('/^<!--/', $data) |
|
| 282 | + AND (preg_match_all('/&([^;]*)?/', $data, $r, PREG_SET_ORDER))) |
|
| 283 | + foreach ($r as $m) { |
|
| 284 | + list($t,$e) = $m; |
|
| 285 | + if (!isset($this->dtc->entites[$e])) |
|
| 286 | + coordonnees_erreur($this, " <b>$e</b> " |
|
| 287 | + . _T('zxml_inconnu_entite') |
|
| 288 | + . ' ' |
|
| 289 | + ); |
|
| 290 | + } |
|
| 291 | + if (isset($this->process['default']) AND ($f = $this->process['default'])) { |
|
| 292 | + $f($this, $data); |
|
| 293 | + } |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // http://doc.spip.org/@phraserTout |
| 297 | 297 | function phraserTout($phraseur, $data) |
| 298 | 298 | { |
| 299 | - xml_parsestring($this, $data); |
|
| 299 | + xml_parsestring($this, $data); |
|
| 300 | 300 | |
| 301 | - if (!$this->dtc OR preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) { |
|
| 302 | - $this->err[]= array('DOCTYPE ?', 0, 0); |
|
| 303 | - } else { |
|
| 304 | - $this->valider_passe2($this); |
|
| 305 | - } |
|
| 301 | + if (!$this->dtc OR preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) { |
|
| 302 | + $this->err[]= array('DOCTYPE ?', 0, 0); |
|
| 303 | + } else { |
|
| 304 | + $this->valider_passe2($this); |
|
| 305 | + } |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | // Init |
| 309 | 309 | function ValidateurXML($process=array()) { |
| 310 | - if (is_array($process)) $this->process = $process; |
|
| 310 | + if (is_array($process)) $this->process = $process; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - var $ids = array(); |
|
| 314 | - var $idrefs = array(); |
|
| 315 | - var $idrefss = array(); |
|
| 316 | - var $debuts = array(); |
|
| 317 | - var $fratrie = array(); |
|
| 313 | + var $ids = array(); |
|
| 314 | + var $idrefs = array(); |
|
| 315 | + var $idrefss = array(); |
|
| 316 | + var $debuts = array(); |
|
| 317 | + var $fratrie = array(); |
|
| 318 | 318 | |
| 319 | - var $dtc = NULL; |
|
| 320 | - var $sax = NULL; |
|
| 321 | - var $depth = ""; |
|
| 322 | - var $entete = ''; |
|
| 323 | - var $page = ''; |
|
| 324 | - var $res = ""; |
|
| 325 | - var $err = array(); |
|
| 326 | - var $contenu = array(); |
|
| 327 | - var $ouvrant = array(); |
|
| 328 | - var $reperes = array(); |
|
| 329 | - var $process = array( |
|
| 330 | - 'debut' => 'xml_debutElement', |
|
| 331 | - 'fin' => 'xml_finElement', |
|
| 332 | - 'text' => 'xml_textElement', |
|
| 333 | - 'pi' => 'xml_piElement', |
|
| 334 | - 'default' => 'xml_defaultElement' |
|
| 335 | - ); |
|
| 319 | + var $dtc = NULL; |
|
| 320 | + var $sax = NULL; |
|
| 321 | + var $depth = ""; |
|
| 322 | + var $entete = ''; |
|
| 323 | + var $page = ''; |
|
| 324 | + var $res = ""; |
|
| 325 | + var $err = array(); |
|
| 326 | + var $contenu = array(); |
|
| 327 | + var $ouvrant = array(); |
|
| 328 | + var $reperes = array(); |
|
| 329 | + var $process = array( |
|
| 330 | + 'debut' => 'xml_debutElement', |
|
| 331 | + 'fin' => 'xml_finElement', |
|
| 332 | + 'text' => 'xml_textElement', |
|
| 333 | + 'pi' => 'xml_piElement', |
|
| 334 | + 'default' => 'xml_defaultElement' |
|
| 335 | + ); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | // Retourne une structure ValidateurXML, dont le champ "err" est un tableau |
@@ -341,8 +341,8 @@ discard block |
||
| 341 | 341 | // http://doc.spip.org/@xml_valider_dist |
| 342 | 342 | function xml_valider_dist($page, $apply=false, $process=false, $doctype='', $charset=null) |
| 343 | 343 | { |
| 344 | - $f = new ValidateurXML($process); |
|
| 345 | - $sax = charger_fonction('sax', 'xml'); |
|
| 346 | - return $sax($page, $apply, $f, $doctype, $charset); |
|
| 344 | + $f = new ValidateurXML($process); |
|
| 345 | + $sax = charger_fonction('sax', 'xml'); |
|
| 346 | + return $sax($page, $apply, $f, $doctype, $charset); |
|
| 347 | 347 | } |
| 348 | 348 | ?> |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | if (!($p = isset($this->dtc->elements[$name]))) { |
| 25 | 25 | if ($p = strpos($name, ':')) { |
| 26 | - $name = substr($name, $p+1); |
|
| 26 | + $name = substr($name, $p + 1); |
|
| 27 | 27 | $p = isset($this->dtc->elements[$name]); |
| 28 | 28 | } |
| 29 | 29 | if (!$p) { |
| 30 | - coordonnees_erreur($this," <b>$name</b> : " |
|
| 30 | + coordonnees_erreur($this, " <b>$name</b> : " |
|
| 31 | 31 | . _T('zxml_inconnu_balise')); |
| 32 | 32 | return; |
| 33 | 33 | } |
@@ -45,21 +45,21 @@ discard block |
||
| 45 | 45 | # spip_log("rejeton $name fils " . @join(',',$fils)); |
| 46 | 46 | if (!($p = @in_array($name, $fils))) { |
| 47 | 47 | if ($p = strpos($name, ':')) { |
| 48 | - $p = substr($name, $p+1); |
|
| 48 | + $p = substr($name, $p + 1); |
|
| 49 | 49 | $p = @in_array($p, $fils); |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | if (!$p) { |
| 53 | - $bons_peres = @join ('</b>, <b>', $this->dtc->peres[$name]); |
|
| 53 | + $bons_peres = @join('</b>, <b>', $this->dtc->peres[$name]); |
|
| 54 | 54 | coordonnees_erreur($this, " <b>$name</b> " |
| 55 | 55 | . _T('zxml_non_fils') |
| 56 | 56 | . ' <b>' |
| 57 | 57 | . $pere |
| 58 | 58 | . '</b>' |
| 59 | 59 | . (!$bons_peres ? '' |
| 60 | - : ('<p style="font-size: 80%"> '._T('zxml_mais_de').' <b>'. $bons_peres . '</b></p>'))); |
|
| 61 | - } else if ($this->dtc->regles[$pere][0]=='/') { |
|
| 62 | - $frat = substr($depth,2); |
|
| 60 | + : ('<p style="font-size: 80%"> '._T('zxml_mais_de').' <b>'.$bons_peres.'</b></p>'))); |
|
| 61 | + } else if ($this->dtc->regles[$pere][0] == '/') { |
|
| 62 | + $frat = substr($depth, 2); |
|
| 63 | 63 | if (!isset($this->fratrie[$frat])) { |
| 64 | 64 | $this->fratrie[$frat] = ''; |
| 65 | 65 | } |
@@ -69,8 +69,8 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | // Init de la suite des balises a memoriser si regle difficile |
| 72 | - if ($this->dtc->regles[$name][0]=='/') |
|
| 73 | - $this->fratrie[$depth]=''; |
|
| 72 | + if ($this->dtc->regles[$name][0] == '/') |
|
| 73 | + $this->fratrie[$depth] = ''; |
|
| 74 | 74 | if (isset($this->dtc->attributs[$name])) { |
| 75 | 75 | foreach ($this->dtc->attributs[$name] as $n => $v) |
| 76 | 76 | { if (($v[1] == '#REQUIRED') AND (!isset($attrs[$n]))) |
@@ -87,16 +87,16 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | // Si la balise est inconnue, eviter d'insister |
| 89 | 89 | if (!isset($this->dtc->attributs[$bal])) |
| 90 | - return ; |
|
| 90 | + return; |
|
| 91 | 91 | |
| 92 | 92 | $a = $this->dtc->attributs[$bal]; |
| 93 | 93 | if (!isset($a[$name])) { |
| 94 | - $bons = join(', ',array_keys($a)); |
|
| 94 | + $bons = join(', ', array_keys($a)); |
|
| 95 | 95 | if ($bons) |
| 96 | - $bons = " title=' " . |
|
| 97 | - _T('zxml_connus_attributs') . |
|
| 98 | - ' : ' . |
|
| 99 | - $bons . |
|
| 96 | + $bons = " title=' ". |
|
| 97 | + _T('zxml_connus_attributs'). |
|
| 98 | + ' : '. |
|
| 99 | + $bons. |
|
| 100 | 100 | "'"; |
| 101 | 101 | $bons .= " style='font-weight: bold'"; |
| 102 | 102 | coordonnees_erreur($this, " <b>$name</b> " |
@@ -104,11 +104,11 @@ discard block |
||
| 104 | 104 | . " <a$bons>$bal</a> (" |
| 105 | 105 | . _T('zxml_survoler') |
| 106 | 106 | . ")"); |
| 107 | - } else{ |
|
| 108 | - $type = $a[$name][0]; |
|
| 107 | + } else { |
|
| 108 | + $type = $a[$name][0]; |
|
| 109 | 109 | if (!preg_match('/^\w+$/', $type)) |
| 110 | 110 | $this->valider_motif($phraseur, $name, $val, $bal, $type); |
| 111 | - else if (method_exists($this, $f = 'validerAttribut_' . $type)) |
|
| 111 | + else if (method_exists($this, $f = 'validerAttribut_'.$type)) |
|
| 112 | 112 | $this->$f($phraseur, $name, $val, $bal); |
| 113 | 113 | # else spip_log("$type type d'attribut inconnu"); |
| 114 | 114 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | function validerAttribut_ID($phraseur, $name, $val, $bal) |
| 129 | 129 | { |
| 130 | 130 | if (isset($this->ids[$val])) { |
| 131 | - list($l,$c) = $this->ids[$val]; |
|
| 131 | + list($l, $c) = $this->ids[$val]; |
|
| 132 | 132 | coordonnees_erreur($this, " <p><b>$val</b> " |
| 133 | 133 | . _T('zxml_valeur_attribut') |
| 134 | 134 | . " <b>$name</b> " |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | . " <b>$bal</b> " |
| 166 | 166 | . _T('zxml_non_conforme') |
| 167 | 167 | . "</p><p>" |
| 168 | - . "<b>" . $motif . "</b>"); |
|
| 168 | + . "<b>".$motif."</b>"); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | function valider_idref($nom, $ligne, $col) |
| 174 | 174 | { |
| 175 | 175 | if (!isset($this->ids[$nom])) |
| 176 | - $this->err[]= array(" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col); |
|
| 176 | + $this->err[] = array(" <p><b>$nom</b> "._T('zxml_inconnu_id'), $ligne, $col); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | // http://doc.spip.org/@valider_passe2 |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | foreach ($this->idrefss as $idref) { |
| 188 | 188 | list($noms, $ligne, $col) = $idref; |
| 189 | - foreach(preg_split('/\s+/', $noms) as $nom) |
|
| 189 | + foreach (preg_split('/\s+/', $noms) as $nom) |
|
| 190 | 190 | $this->valider_idref($nom, $ligne, $col); |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | if ($f = $this->process['debut']) $f($this, $name, $attrs); |
| 202 | 202 | $depth = $this->depth; |
| 203 | - $this->debuts[$depth] = strlen($this->res); |
|
| 203 | + $this->debuts[$depth] = strlen($this->res); |
|
| 204 | 204 | foreach ($attrs as $k => $v) { |
| 205 | 205 | $this->validerAttribut($phraseur, $k, $v, $name); |
| 206 | 206 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $k = $this->debuts[$depth]; |
| 218 | 218 | |
| 219 | 219 | $regle = $this->dtc->regles[$name]; |
| 220 | - $vide = ($regle == 'EMPTY'); |
|
| 220 | + $vide = ($regle == 'EMPTY'); |
|
| 221 | 221 | // controler que les balises devant etre vides le sont |
| 222 | 222 | if ($vide) { |
| 223 | 223 | if ($n <> ($k + $c)) |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | . _T('zxml_vide_balise')); |
| 233 | 233 | } |
| 234 | 234 | } else { |
| 235 | - $f = $this->fratrie[substr($depth,2)]; |
|
| 235 | + $f = $this->fratrie[substr($depth, 2)]; |
|
| 236 | 236 | if (!preg_match($regle, $f)) { |
| 237 | 237 | coordonnees_erreur($this, |
| 238 | 238 | " <p>\n<b>$name</b> " |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | $d = $this->ouvrant[$d]; |
| 256 | 256 | preg_match('/^\s*(\S+)/', $d, $m); |
| 257 | 257 | if ($this->dtc->pcdata[$m[1]]) { |
| 258 | - coordonnees_erreur($this, " <p><b>". $m[1] . "</b> " |
|
| 258 | + coordonnees_erreur($this, " <p><b>".$m[1]."</b> " |
|
| 259 | 259 | . _T('zxml_nonvide_balise') // message a affiner |
| 260 | 260 | ); |
| 261 | 261 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | if (!preg_match('/^<!--/', $data) |
| 282 | 282 | AND (preg_match_all('/&([^;]*)?/', $data, $r, PREG_SET_ORDER))) |
| 283 | 283 | foreach ($r as $m) { |
| 284 | - list($t,$e) = $m; |
|
| 284 | + list($t, $e) = $m; |
|
| 285 | 285 | if (!isset($this->dtc->entites[$e])) |
| 286 | 286 | coordonnees_erreur($this, " <b>$e</b> " |
| 287 | 287 | . _T('zxml_inconnu_entite') |
@@ -298,15 +298,15 @@ discard block |
||
| 298 | 298 | { |
| 299 | 299 | xml_parsestring($this, $data); |
| 300 | 300 | |
| 301 | - if (!$this->dtc OR preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) { |
|
| 302 | - $this->err[]= array('DOCTYPE ?', 0, 0); |
|
| 301 | + if (!$this->dtc OR preg_match(',^'._MESSAGE_DOCTYPE.',', $data)) { |
|
| 302 | + $this->err[] = array('DOCTYPE ?', 0, 0); |
|
| 303 | 303 | } else { |
| 304 | 304 | $this->valider_passe2($this); |
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | // Init |
| 309 | -function ValidateurXML($process=array()) { |
|
| 309 | +function ValidateurXML($process = array()) { |
|
| 310 | 310 | if (is_array($process)) $this->process = $process; |
| 311 | 311 | } |
| 312 | 312 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | var $contenu = array(); |
| 327 | 327 | var $ouvrant = array(); |
| 328 | 328 | var $reperes = array(); |
| 329 | - var $process = array( |
|
| 329 | + var $process = array( |
|
| 330 | 330 | 'debut' => 'xml_debutElement', |
| 331 | 331 | 'fin' => 'xml_finElement', |
| 332 | 332 | 'text' => 'xml_textElement', |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | // ayant comme entrees des sous-tableaux [message, ligne, colonne] |
| 340 | 340 | |
| 341 | 341 | // http://doc.spip.org/@xml_valider_dist |
| 342 | -function xml_valider_dist($page, $apply=false, $process=false, $doctype='', $charset=null) |
|
| 342 | +function xml_valider_dist($page, $apply = false, $process = false, $doctype = '', $charset = null) |
|
| 343 | 343 | { |
| 344 | 344 | $f = new ValidateurXML($process); |
| 345 | 345 | $sax = charger_fonction('sax', 'xml'); |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | // Validateur XML en deux passes, fonde sur SAX pour la premiere |
| 16 | 18 | // Faudrait faire deux classes car pour la premiere passe |
@@ -69,16 +71,18 @@ discard block |
||
| 69 | 71 | } |
| 70 | 72 | } |
| 71 | 73 | // Init de la suite des balises a memoriser si regle difficile |
| 72 | - if ($this->dtc->regles[$name][0]=='/') |
|
| 73 | - $this->fratrie[$depth]=''; |
|
| 74 | + if ($this->dtc->regles[$name][0]=='/') { |
|
| 75 | + $this->fratrie[$depth]=''; |
|
| 76 | + } |
|
| 74 | 77 | if (isset($this->dtc->attributs[$name])) { |
| 75 | 78 | foreach ($this->dtc->attributs[$name] as $n => $v) |
| 76 | - { if (($v[1] == '#REQUIRED') AND (!isset($attrs[$n]))) |
|
| 77 | - coordonnees_erreur($this, " <b>$n</b>" |
|
| 79 | + { if (($v[1] == '#REQUIRED') AND (!isset($attrs[$n]))) { |
|
| 80 | + coordonnees_erreur($this, " <b>$n</b>" |
|
| 78 | 81 | . ' : ' |
| 79 | 82 | . _T('zxml_obligatoire_attribut') |
| 80 | 83 | . " <b>$name</b>"); |
| 81 | 84 | } |
| 85 | + } |
|
| 82 | 86 | } |
| 83 | 87 | } |
| 84 | 88 | |
@@ -86,18 +90,20 @@ discard block |
||
| 86 | 90 | function validerAttribut($phraseur, $name, $val, $bal) |
| 87 | 91 | { |
| 88 | 92 | // Si la balise est inconnue, eviter d'insister |
| 89 | - if (!isset($this->dtc->attributs[$bal])) |
|
| 90 | - return ; |
|
| 93 | + if (!isset($this->dtc->attributs[$bal])) { |
|
| 94 | + return ; |
|
| 95 | + } |
|
| 91 | 96 | |
| 92 | 97 | $a = $this->dtc->attributs[$bal]; |
| 93 | 98 | if (!isset($a[$name])) { |
| 94 | 99 | $bons = join(', ',array_keys($a)); |
| 95 | - if ($bons) |
|
| 96 | - $bons = " title=' " . |
|
| 100 | + if ($bons) { |
|
| 101 | + $bons = " title=' " . |
|
| 97 | 102 | _T('zxml_connus_attributs') . |
| 98 | 103 | ' : ' . |
| 99 | 104 | $bons . |
| 100 | 105 | "'"; |
| 106 | + } |
|
| 101 | 107 | $bons .= " style='font-weight: bold'"; |
| 102 | 108 | coordonnees_erreur($this, " <b>$name</b> " |
| 103 | 109 | . _T('zxml_inconnu_attribut').' '._T('zxml_de') |
@@ -106,11 +112,12 @@ discard block |
||
| 106 | 112 | . ")"); |
| 107 | 113 | } else{ |
| 108 | 114 | $type = $a[$name][0]; |
| 109 | - if (!preg_match('/^\w+$/', $type)) |
|
| 110 | - $this->valider_motif($phraseur, $name, $val, $bal, $type); |
|
| 111 | - else if (method_exists($this, $f = 'validerAttribut_' . $type)) |
|
| 112 | - $this->$f($phraseur, $name, $val, $bal); |
|
| 113 | -# else spip_log("$type type d'attribut inconnu"); |
|
| 115 | + if (!preg_match('/^\w+$/', $type)) { |
|
| 116 | + $this->valider_motif($phraseur, $name, $val, $bal, $type); |
|
| 117 | + } else if (method_exists($this, $f = 'validerAttribut_' . $type)) { |
|
| 118 | + $this->$f($phraseur, $name, $val, $bal); |
|
| 119 | + } |
|
| 120 | + # else spip_log("$type type d'attribut inconnu"); |
|
| 114 | 121 | } |
| 115 | 122 | } |
| 116 | 123 | |
@@ -172,9 +179,10 @@ discard block |
||
| 172 | 179 | // http://doc.spip.org/@valider_idref |
| 173 | 180 | function valider_idref($nom, $ligne, $col) |
| 174 | 181 | { |
| 175 | - if (!isset($this->ids[$nom])) |
|
| 176 | - $this->err[]= array(" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col); |
|
| 177 | -} |
|
| 182 | + if (!isset($this->ids[$nom])) { |
|
| 183 | + $this->err[]= array(" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col); |
|
| 184 | + } |
|
| 185 | + } |
|
| 178 | 186 | |
| 179 | 187 | // http://doc.spip.org/@valider_passe2 |
| 180 | 188 | function valider_passe2() |
@@ -186,8 +194,9 @@ discard block |
||
| 186 | 194 | } |
| 187 | 195 | foreach ($this->idrefss as $idref) { |
| 188 | 196 | list($noms, $ligne, $col) = $idref; |
| 189 | - foreach(preg_split('/\s+/', $noms) as $nom) |
|
| 190 | - $this->valider_idref($nom, $ligne, $col); |
|
| 197 | + foreach(preg_split('/\s+/', $noms) as $nom) { |
|
| 198 | + $this->valider_idref($nom, $ligne, $col); |
|
| 199 | + } |
|
| 191 | 200 | } |
| 192 | 201 | } |
| 193 | 202 | } |
@@ -195,10 +204,13 @@ discard block |
||
| 195 | 204 | // http://doc.spip.org/@debutElement |
| 196 | 205 | function debutElement($phraseur, $name, $attrs) |
| 197 | 206 | { |
| 198 | - if ($this->dtc->elements) |
|
| 199 | - $this->validerElement($phraseur, $name, $attrs); |
|
| 207 | + if ($this->dtc->elements) { |
|
| 208 | + $this->validerElement($phraseur, $name, $attrs); |
|
| 209 | + } |
|
| 200 | 210 | |
| 201 | - if ($f = $this->process['debut']) $f($this, $name, $attrs); |
|
| 211 | + if ($f = $this->process['debut']) { |
|
| 212 | + $f($this, $name, $attrs); |
|
| 213 | + } |
|
| 202 | 214 | $depth = $this->depth; |
| 203 | 215 | $this->debuts[$depth] = strlen($this->res); |
| 204 | 216 | foreach ($attrs as $k => $v) { |
@@ -220,9 +232,10 @@ discard block |
||
| 220 | 232 | $vide = ($regle == 'EMPTY'); |
| 221 | 233 | // controler que les balises devant etre vides le sont |
| 222 | 234 | if ($vide) { |
| 223 | - if ($n <> ($k + $c)) |
|
| 224 | - coordonnees_erreur($this, " <p><b>$name</b> " |
|
| 235 | + if ($n <> ($k + $c)) { |
|
| 236 | + coordonnees_erreur($this, " <p><b>$name</b> " |
|
| 225 | 237 | . _T('zxml_nonvide_balise')); |
| 238 | + } |
|
| 226 | 239 | // pour les regles PCDATA ou iteration de disjonction, tout est fait |
| 227 | 240 | } elseif ($regle AND ($regle != '*')) { |
| 228 | 241 | if ($regle == '+') { |
@@ -244,8 +257,10 @@ discard block |
||
| 244 | 257 | } |
| 245 | 258 | |
| 246 | 259 | } |
| 247 | - if ($f = $this->process['fin']) $f($this, $name, $vide); |
|
| 248 | -} |
|
| 260 | + if ($f = $this->process['fin']) { |
|
| 261 | + $f($this, $name, $vide); |
|
| 262 | + } |
|
| 263 | + } |
|
| 249 | 264 | |
| 250 | 265 | // http://doc.spip.org/@textElement |
| 251 | 266 | function textElement($phraseur, $data) |
@@ -260,13 +275,17 @@ discard block |
||
| 260 | 275 | ); |
| 261 | 276 | } |
| 262 | 277 | } |
| 263 | - if ($f = $this->process['text']) $f($this, $data); |
|
| 264 | -} |
|
| 278 | + if ($f = $this->process['text']) { |
|
| 279 | + $f($this, $data); |
|
| 280 | + } |
|
| 281 | + } |
|
| 265 | 282 | |
| 266 | 283 | function piElement($phraseur, $target, $data) |
| 267 | 284 | { |
| 268 | - if ($f = $this->process['pi']) $f($this, $target, $data); |
|
| 269 | -} |
|
| 285 | + if ($f = $this->process['pi']) { |
|
| 286 | + $f($this, $target, $data); |
|
| 287 | + } |
|
| 288 | + } |
|
| 270 | 289 | |
| 271 | 290 | // Denonciation des entitees XML inconnues |
| 272 | 291 | // Pour contourner le bug de conception de SAX qui ne signale pas si elles |
@@ -279,14 +298,16 @@ discard block |
||
| 279 | 298 | function defaultElement($phraseur, $data) |
| 280 | 299 | { |
| 281 | 300 | if (!preg_match('/^<!--/', $data) |
| 282 | - AND (preg_match_all('/&([^;]*)?/', $data, $r, PREG_SET_ORDER))) |
|
| 283 | - foreach ($r as $m) { |
|
| 301 | + AND (preg_match_all('/&([^;]*)?/', $data, $r, PREG_SET_ORDER))) { |
|
| 302 | + foreach ($r as $m) { |
|
| 284 | 303 | list($t,$e) = $m; |
| 285 | - if (!isset($this->dtc->entites[$e])) |
|
| 286 | - coordonnees_erreur($this, " <b>$e</b> " |
|
| 304 | + } |
|
| 305 | + if (!isset($this->dtc->entites[$e])) { |
|
| 306 | + coordonnees_erreur($this, " <b>$e</b> " |
|
| 287 | 307 | . _T('zxml_inconnu_entite') |
| 288 | 308 | . ' ' |
| 289 | 309 | ); |
| 310 | + } |
|
| 290 | 311 | } |
| 291 | 312 | if (isset($this->process['default']) AND ($f = $this->process['default'])) { |
| 292 | 313 | $f($this, $data); |
@@ -307,8 +328,10 @@ discard block |
||
| 307 | 328 | |
| 308 | 329 | // Init |
| 309 | 330 | function ValidateurXML($process=array()) { |
| 310 | - if (is_array($process)) $this->process = $process; |
|
| 311 | -} |
|
| 331 | + if (is_array($process)) { |
|
| 332 | + $this->process = $process; |
|
| 333 | + } |
|
| 334 | + } |
|
| 312 | 335 | |
| 313 | 336 | var $ids = array(); |
| 314 | 337 | var $idrefs = array(); |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 14 | 14 | |
| 15 | 15 | define('_REGEXP_DOCTYPE', |
| 16 | - '/^((?:<\001?[?][^>]*>\s*)*(?:<!--.*?-->\s*)*)*<!DOCTYPE\s+(\w+)\s+(\w+)\s*([^>]*)>\s*/s'); |
|
| 16 | + '/^((?:<\001?[?][^>]*>\s*)*(?:<!--.*?-->\s*)*)*<!DOCTYPE\s+(\w+)\s+(\w+)\s*([^>]*)>\s*/s'); |
|
| 17 | 17 | |
| 18 | 18 | define('_REGEXP_XML', '/^(\s*(?:<[?][^x>][^>]*>\s*)?(?:<[?]xml[^>]*>)?\s*(?:<!--.*?-->\s*)*)<(\w+)/s'); |
| 19 | 19 | |
@@ -31,14 +31,14 @@ discard block |
||
| 31 | 31 | define('_REGEXP_ENTITY_DEF', '/^%(' . _SUB_REGEXP_SYMBOL . '+);/'); |
| 32 | 32 | define('_REGEXP_TYPE_XML', 'PUBLIC|SYSTEM|INCLUDE|IGNORE|CDATA'); |
| 33 | 33 | define('_REGEXP_ENTITY_DECL', '/^<!ENTITY\s+(%?)\s*(' . |
| 34 | - _SUB_REGEXP_SYMBOL . |
|
| 35 | - '+;?)\s+(' . |
|
| 36 | - _REGEXP_TYPE_XML . |
|
| 37 | - ')?\s*(' . |
|
| 38 | - "('([^']*)')" . |
|
| 39 | - '|("([^"]*)")' . |
|
| 34 | + _SUB_REGEXP_SYMBOL . |
|
| 35 | + '+;?)\s+(' . |
|
| 36 | + _REGEXP_TYPE_XML . |
|
| 37 | + ')?\s*(' . |
|
| 38 | + "('([^']*)')" . |
|
| 39 | + '|("([^"]*)")' . |
|
| 40 | 40 | '|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' . |
| 41 | - ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s'); |
|
| 41 | + ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s'); |
|
| 42 | 42 | |
| 43 | 43 | define('_REGEXP_INCLUDE_USE', '/^<!\[\s*%\s*([^;]*);\s*\[\s*(.*)$/s'); |
| 44 | 44 | |
@@ -47,12 +47,12 @@ discard block |
||
| 47 | 47 | // Document Type Compilation |
| 48 | 48 | |
| 49 | 49 | class DTC { |
| 50 | - var $macros = array(); |
|
| 51 | - var $elements = array(); |
|
| 52 | - var $peres = array(); |
|
| 53 | - var $attributs = array(); |
|
| 54 | - var $entites = array(); |
|
| 55 | - var $regles = array(); |
|
| 56 | - var $pcdata = array(); |
|
| 50 | + var $macros = array(); |
|
| 51 | + var $elements = array(); |
|
| 52 | + var $peres = array(); |
|
| 53 | + var $attributs = array(); |
|
| 54 | + var $entites = array(); |
|
| 55 | + var $regles = array(); |
|
| 56 | + var $pcdata = array(); |
|
| 57 | 57 | } |
| 58 | 58 | ?> |
@@ -21,23 +21,23 @@ |
||
| 21 | 21 | |
| 22 | 22 | define('_SUB_REGEXP_SYMBOL', '[\w_:.-]'); |
| 23 | 23 | |
| 24 | -define('_REGEXP_NMTOKEN', '/^' . _SUB_REGEXP_SYMBOL . '+$/'); |
|
| 24 | +define('_REGEXP_NMTOKEN', '/^'._SUB_REGEXP_SYMBOL.'+$/'); |
|
| 25 | 25 | |
| 26 | -define('_REGEXP_NMTOKENS', '/^(' . _SUB_REGEXP_SYMBOL . '+\s*)*$/'); |
|
| 26 | +define('_REGEXP_NMTOKENS', '/^('._SUB_REGEXP_SYMBOL.'+\s*)*$/'); |
|
| 27 | 27 | |
| 28 | -define('_REGEXP_ID', '/^[A-Za-z_:]' . _SUB_REGEXP_SYMBOL . '*$/'); |
|
| 28 | +define('_REGEXP_ID', '/^[A-Za-z_:]'._SUB_REGEXP_SYMBOL.'*$/'); |
|
| 29 | 29 | |
| 30 | -define('_REGEXP_ENTITY_USE', '/%(' . _SUB_REGEXP_SYMBOL . '+);/'); |
|
| 31 | -define('_REGEXP_ENTITY_DEF', '/^%(' . _SUB_REGEXP_SYMBOL . '+);/'); |
|
| 30 | +define('_REGEXP_ENTITY_USE', '/%('._SUB_REGEXP_SYMBOL.'+);/'); |
|
| 31 | +define('_REGEXP_ENTITY_DEF', '/^%('._SUB_REGEXP_SYMBOL.'+);/'); |
|
| 32 | 32 | define('_REGEXP_TYPE_XML', 'PUBLIC|SYSTEM|INCLUDE|IGNORE|CDATA'); |
| 33 | -define('_REGEXP_ENTITY_DECL', '/^<!ENTITY\s+(%?)\s*(' . |
|
| 34 | - _SUB_REGEXP_SYMBOL . |
|
| 35 | - '+;?)\s+(' . |
|
| 36 | - _REGEXP_TYPE_XML . |
|
| 37 | - ')?\s*(' . |
|
| 38 | - "('([^']*)')" . |
|
| 39 | - '|("([^"]*)")' . |
|
| 40 | - '|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' . |
|
| 33 | +define('_REGEXP_ENTITY_DECL', '/^<!ENTITY\s+(%?)\s*('. |
|
| 34 | + _SUB_REGEXP_SYMBOL. |
|
| 35 | + '+;?)\s+('. |
|
| 36 | + _REGEXP_TYPE_XML. |
|
| 37 | + ')?\s*('. |
|
| 38 | + "('([^']*)')". |
|
| 39 | + '|("([^"]*)")'. |
|
| 40 | + '|\s*(%'._SUB_REGEXP_SYMBOL.'+;)\s*'. |
|
| 41 | 41 | ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s'); |
| 42 | 42 | |
| 43 | 43 | define('_REGEXP_INCLUDE_USE', '/^<!\[\s*%\s*([^;]*);\s*\[\s*(.*)$/s'); |
@@ -10,7 +10,9 @@ |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | define('_REGEXP_DOCTYPE', |
| 16 | 18 | '/^((?:<\001?[?][^>]*>\s*)*(?:<!--.*?-->\s*)*)*<!DOCTYPE\s+(\w+)\s+(\w+)\s*([^>]*)>\s*/s'); |
@@ -62,120 +62,120 @@ |
||
| 62 | 62 | * |
| 63 | 63 | **/ |
| 64 | 64 | function base_trouver_table_dist($nom, $serveur='', $table_spip = true){ |
| 65 | - static $nom_cache_desc_sql=array(); |
|
| 66 | - global $tables_principales, $tables_auxiliaires, $table_des_tables; |
|
| 67 | - |
|
| 68 | - if (!spip_connect($serveur) |
|
| 69 | - OR !preg_match('/^[a-zA-Z0-9._-]*/',$nom)) |
|
| 70 | - return null; |
|
| 71 | - |
|
| 72 | - $connexion = &$GLOBALS['connexions'][$serveur ? strtolower($serveur) : 0]; |
|
| 73 | - $objets_sql = lister_tables_objets_sql("::md5"); |
|
| 74 | - |
|
| 75 | - // le nom du cache depend du serveur mais aussi du nom de la db et du prefixe |
|
| 76 | - // ce qui permet une auto invalidation en cas de modif manuelle du fichier |
|
| 77 | - // de connexion, et tout risque d'ambiguite |
|
| 78 | - if (!isset($nom_cache_desc_sql[$serveur][$objets_sql])){ |
|
| 79 | - $nom_cache_desc_sql[$serveur][$objets_sql] = |
|
| 80 | - _DIR_CACHE . 'sql_desc_' |
|
| 81 | - . ($serveur ? "{$serveur}_":"") |
|
| 82 | - . substr(md5($connexion['db'].":".$connexion['prefixe'].":$objets_sql"),0,8) |
|
| 83 | - .'.txt'; |
|
| 84 | - // nouveau nom de cache = nouvelle version en memoire |
|
| 85 | - unset($connexion['tables']); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - // un appel avec $nom vide est une demande explicite de vidange du cache des descriptions |
|
| 89 | - if (!$nom){ |
|
| 90 | - spip_unlink($nom_cache_desc_sql[$serveur][$objets_sql]); |
|
| 91 | - $connexion['tables'] = array(); |
|
| 92 | - return null; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - $nom_sql = $nom; |
|
| 96 | - if (preg_match('/\.(.*)$/', $nom, $s)) |
|
| 97 | - $nom_sql = $s[1]; |
|
| 98 | - else |
|
| 99 | - $nom_sql = $nom; |
|
| 100 | - |
|
| 101 | - $fdesc = $desc = ''; |
|
| 102 | - $connexion = &$GLOBALS['connexions'][$serveur ? $serveur : 0]; |
|
| 103 | - |
|
| 104 | - // base sous SPIP: gerer les abreviations explicites des noms de table |
|
| 105 | - if ($connexion['spip_connect_version']) { |
|
| 106 | - if ($table_spip AND isset($table_des_tables[$nom])) { |
|
| 107 | - $nom = $table_des_tables[$nom]; |
|
| 108 | - $nom_sql = 'spip_' . $nom; |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - // si c'est la premiere table qu'on cherche |
|
| 113 | - // et si on est pas explicitement en recalcul |
|
| 114 | - // on essaye de recharger le cache des decriptions de ce serveur |
|
| 115 | - // dans le fichier cache |
|
| 116 | - if (!isset($connexion['tables'][$nom_sql]) |
|
| 117 | - AND defined('_VAR_MODE') AND _VAR_MODE!=='recalcul' |
|
| 118 | - AND (!isset($connexion['tables']) OR !$connexion['tables'])) { |
|
| 119 | - if (lire_fichier($nom_cache_desc_sql[$serveur][$objets_sql],$desc_cache) |
|
| 120 | - AND $desc_cache=unserialize($desc_cache)) |
|
| 121 | - $connexion['tables'] = $desc_cache; |
|
| 122 | - } |
|
| 123 | - if ($table_spip AND !isset($connexion['tables'][$nom_sql])) { |
|
| 124 | - |
|
| 125 | - if (isset($tables_principales[$nom_sql])) |
|
| 126 | - $fdesc = $tables_principales[$nom_sql]; |
|
| 127 | - // meme si pas d'abreviation declaree, trouver la table spip_$nom |
|
| 128 | - // si c'est une table principale, |
|
| 129 | - // puisqu'on le fait aussi pour les tables auxiliaires |
|
| 130 | - elseif ($nom_sql==$nom AND isset($tables_principales['spip_' .$nom])){ |
|
| 131 | - $nom_sql = 'spip_' . $nom; |
|
| 132 | - $fdesc = &$tables_principales[$nom_sql]; |
|
| 133 | - } |
|
| 134 | - elseif (isset($tables_auxiliaires[$n=$nom]) |
|
| 135 | - OR isset($tables_auxiliaires[$n='spip_'.$nom])) { |
|
| 136 | - $nom_sql = $n; |
|
| 137 | - $fdesc = &$tables_auxiliaires[$n]; |
|
| 138 | - } # table locale a cote de SPIP, comme non SPIP: |
|
| 139 | - } |
|
| 140 | - if (!isset($connexion['tables'][$nom_sql])) { |
|
| 141 | - |
|
| 142 | - // La *vraie* base a la priorite |
|
| 143 | - $desc = sql_showtable($nom_sql, $table_spip, $serveur); |
|
| 144 | - if (!$desc OR !$desc['field']) { |
|
| 145 | - if (!$fdesc) { |
|
| 146 | - spip_log("trouver_table: table inconnue '$serveur' '$nom'",_LOG_INFO_IMPORTANTE); |
|
| 147 | - return null; |
|
| 148 | - } |
|
| 149 | - // on ne sait pas lire la structure de la table : |
|
| 150 | - // on retombe sur la description donnee dans les fichiers spip |
|
| 151 | - $desc = $fdesc; |
|
| 152 | - } |
|
| 153 | - else { |
|
| 154 | - $desc['exist'] = true; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - $desc['table'] = $desc['table_sql'] = $nom_sql; |
|
| 158 | - $desc['connexion']= $serveur; |
|
| 159 | - |
|
| 160 | - // charger les infos declarees pour cette table |
|
| 161 | - // en lui passant les infos connues |
|
| 162 | - // $desc est prioritaire pour la description de la table |
|
| 163 | - $desc = array_merge(lister_tables_objets_sql($nom_sql,$desc),$desc); |
|
| 164 | - |
|
| 165 | - // si tables_objets_sql est bien fini d'init, on peut cacher |
|
| 166 | - $connexion['tables'][$nom_sql] = $desc; |
|
| 167 | - $res = &$connexion['tables'][$nom_sql]; |
|
| 168 | - // une nouvelle table a ete decrite |
|
| 169 | - // mettons donc a jour le cache des descriptions de ce serveur |
|
| 170 | - if (is_writeable(_DIR_CACHE)) |
|
| 171 | - ecrire_fichier($nom_cache_desc_sql[$serveur][$objets_sql],serialize($connexion['tables']),true); |
|
| 172 | - } |
|
| 173 | - else |
|
| 174 | - $res = &$connexion['tables'][$nom_sql]; |
|
| 175 | - |
|
| 176 | - // toujours retourner $nom dans id_table |
|
| 177 | - $res['id_table']=$nom; |
|
| 178 | - |
|
| 179 | - return $res; |
|
| 65 | + static $nom_cache_desc_sql=array(); |
|
| 66 | + global $tables_principales, $tables_auxiliaires, $table_des_tables; |
|
| 67 | + |
|
| 68 | + if (!spip_connect($serveur) |
|
| 69 | + OR !preg_match('/^[a-zA-Z0-9._-]*/',$nom)) |
|
| 70 | + return null; |
|
| 71 | + |
|
| 72 | + $connexion = &$GLOBALS['connexions'][$serveur ? strtolower($serveur) : 0]; |
|
| 73 | + $objets_sql = lister_tables_objets_sql("::md5"); |
|
| 74 | + |
|
| 75 | + // le nom du cache depend du serveur mais aussi du nom de la db et du prefixe |
|
| 76 | + // ce qui permet une auto invalidation en cas de modif manuelle du fichier |
|
| 77 | + // de connexion, et tout risque d'ambiguite |
|
| 78 | + if (!isset($nom_cache_desc_sql[$serveur][$objets_sql])){ |
|
| 79 | + $nom_cache_desc_sql[$serveur][$objets_sql] = |
|
| 80 | + _DIR_CACHE . 'sql_desc_' |
|
| 81 | + . ($serveur ? "{$serveur}_":"") |
|
| 82 | + . substr(md5($connexion['db'].":".$connexion['prefixe'].":$objets_sql"),0,8) |
|
| 83 | + .'.txt'; |
|
| 84 | + // nouveau nom de cache = nouvelle version en memoire |
|
| 85 | + unset($connexion['tables']); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + // un appel avec $nom vide est une demande explicite de vidange du cache des descriptions |
|
| 89 | + if (!$nom){ |
|
| 90 | + spip_unlink($nom_cache_desc_sql[$serveur][$objets_sql]); |
|
| 91 | + $connexion['tables'] = array(); |
|
| 92 | + return null; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + $nom_sql = $nom; |
|
| 96 | + if (preg_match('/\.(.*)$/', $nom, $s)) |
|
| 97 | + $nom_sql = $s[1]; |
|
| 98 | + else |
|
| 99 | + $nom_sql = $nom; |
|
| 100 | + |
|
| 101 | + $fdesc = $desc = ''; |
|
| 102 | + $connexion = &$GLOBALS['connexions'][$serveur ? $serveur : 0]; |
|
| 103 | + |
|
| 104 | + // base sous SPIP: gerer les abreviations explicites des noms de table |
|
| 105 | + if ($connexion['spip_connect_version']) { |
|
| 106 | + if ($table_spip AND isset($table_des_tables[$nom])) { |
|
| 107 | + $nom = $table_des_tables[$nom]; |
|
| 108 | + $nom_sql = 'spip_' . $nom; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + // si c'est la premiere table qu'on cherche |
|
| 113 | + // et si on est pas explicitement en recalcul |
|
| 114 | + // on essaye de recharger le cache des decriptions de ce serveur |
|
| 115 | + // dans le fichier cache |
|
| 116 | + if (!isset($connexion['tables'][$nom_sql]) |
|
| 117 | + AND defined('_VAR_MODE') AND _VAR_MODE!=='recalcul' |
|
| 118 | + AND (!isset($connexion['tables']) OR !$connexion['tables'])) { |
|
| 119 | + if (lire_fichier($nom_cache_desc_sql[$serveur][$objets_sql],$desc_cache) |
|
| 120 | + AND $desc_cache=unserialize($desc_cache)) |
|
| 121 | + $connexion['tables'] = $desc_cache; |
|
| 122 | + } |
|
| 123 | + if ($table_spip AND !isset($connexion['tables'][$nom_sql])) { |
|
| 124 | + |
|
| 125 | + if (isset($tables_principales[$nom_sql])) |
|
| 126 | + $fdesc = $tables_principales[$nom_sql]; |
|
| 127 | + // meme si pas d'abreviation declaree, trouver la table spip_$nom |
|
| 128 | + // si c'est une table principale, |
|
| 129 | + // puisqu'on le fait aussi pour les tables auxiliaires |
|
| 130 | + elseif ($nom_sql==$nom AND isset($tables_principales['spip_' .$nom])){ |
|
| 131 | + $nom_sql = 'spip_' . $nom; |
|
| 132 | + $fdesc = &$tables_principales[$nom_sql]; |
|
| 133 | + } |
|
| 134 | + elseif (isset($tables_auxiliaires[$n=$nom]) |
|
| 135 | + OR isset($tables_auxiliaires[$n='spip_'.$nom])) { |
|
| 136 | + $nom_sql = $n; |
|
| 137 | + $fdesc = &$tables_auxiliaires[$n]; |
|
| 138 | + } # table locale a cote de SPIP, comme non SPIP: |
|
| 139 | + } |
|
| 140 | + if (!isset($connexion['tables'][$nom_sql])) { |
|
| 141 | + |
|
| 142 | + // La *vraie* base a la priorite |
|
| 143 | + $desc = sql_showtable($nom_sql, $table_spip, $serveur); |
|
| 144 | + if (!$desc OR !$desc['field']) { |
|
| 145 | + if (!$fdesc) { |
|
| 146 | + spip_log("trouver_table: table inconnue '$serveur' '$nom'",_LOG_INFO_IMPORTANTE); |
|
| 147 | + return null; |
|
| 148 | + } |
|
| 149 | + // on ne sait pas lire la structure de la table : |
|
| 150 | + // on retombe sur la description donnee dans les fichiers spip |
|
| 151 | + $desc = $fdesc; |
|
| 152 | + } |
|
| 153 | + else { |
|
| 154 | + $desc['exist'] = true; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + $desc['table'] = $desc['table_sql'] = $nom_sql; |
|
| 158 | + $desc['connexion']= $serveur; |
|
| 159 | + |
|
| 160 | + // charger les infos declarees pour cette table |
|
| 161 | + // en lui passant les infos connues |
|
| 162 | + // $desc est prioritaire pour la description de la table |
|
| 163 | + $desc = array_merge(lister_tables_objets_sql($nom_sql,$desc),$desc); |
|
| 164 | + |
|
| 165 | + // si tables_objets_sql est bien fini d'init, on peut cacher |
|
| 166 | + $connexion['tables'][$nom_sql] = $desc; |
|
| 167 | + $res = &$connexion['tables'][$nom_sql]; |
|
| 168 | + // une nouvelle table a ete decrite |
|
| 169 | + // mettons donc a jour le cache des descriptions de ce serveur |
|
| 170 | + if (is_writeable(_DIR_CACHE)) |
|
| 171 | + ecrire_fichier($nom_cache_desc_sql[$serveur][$objets_sql],serialize($connexion['tables']),true); |
|
| 172 | + } |
|
| 173 | + else |
|
| 174 | + $res = &$connexion['tables'][$nom_sql]; |
|
| 175 | + |
|
| 176 | + // toujours retourner $nom dans id_table |
|
| 177 | + $res['id_table']=$nom; |
|
| 178 | + |
|
| 179 | + return $res; |
|
| 180 | 180 | } |
| 181 | 181 | ?> |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * |
| 63 | 63 | **/ |
| 64 | -function base_trouver_table_dist($nom, $serveur='', $table_spip = true){ |
|
| 65 | - static $nom_cache_desc_sql=array(); |
|
| 64 | +function base_trouver_table_dist($nom, $serveur = '', $table_spip = true) { |
|
| 65 | + static $nom_cache_desc_sql = array(); |
|
| 66 | 66 | global $tables_principales, $tables_auxiliaires, $table_des_tables; |
| 67 | 67 | |
| 68 | 68 | if (!spip_connect($serveur) |
| 69 | - OR !preg_match('/^[a-zA-Z0-9._-]*/',$nom)) |
|
| 69 | + OR !preg_match('/^[a-zA-Z0-9._-]*/', $nom)) |
|
| 70 | 70 | return null; |
| 71 | 71 | |
| 72 | 72 | $connexion = &$GLOBALS['connexions'][$serveur ? strtolower($serveur) : 0]; |
@@ -75,18 +75,18 @@ discard block |
||
| 75 | 75 | // le nom du cache depend du serveur mais aussi du nom de la db et du prefixe |
| 76 | 76 | // ce qui permet une auto invalidation en cas de modif manuelle du fichier |
| 77 | 77 | // de connexion, et tout risque d'ambiguite |
| 78 | - if (!isset($nom_cache_desc_sql[$serveur][$objets_sql])){ |
|
| 78 | + if (!isset($nom_cache_desc_sql[$serveur][$objets_sql])) { |
|
| 79 | 79 | $nom_cache_desc_sql[$serveur][$objets_sql] = |
| 80 | - _DIR_CACHE . 'sql_desc_' |
|
| 81 | - . ($serveur ? "{$serveur}_":"") |
|
| 82 | - . substr(md5($connexion['db'].":".$connexion['prefixe'].":$objets_sql"),0,8) |
|
| 80 | + _DIR_CACHE.'sql_desc_' |
|
| 81 | + . ($serveur ? "{$serveur}_" : "") |
|
| 82 | + . substr(md5($connexion['db'].":".$connexion['prefixe'].":$objets_sql"), 0, 8) |
|
| 83 | 83 | .'.txt'; |
| 84 | 84 | // nouveau nom de cache = nouvelle version en memoire |
| 85 | 85 | unset($connexion['tables']); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // un appel avec $nom vide est une demande explicite de vidange du cache des descriptions |
| 89 | - if (!$nom){ |
|
| 89 | + if (!$nom) { |
|
| 90 | 90 | spip_unlink($nom_cache_desc_sql[$serveur][$objets_sql]); |
| 91 | 91 | $connexion['tables'] = array(); |
| 92 | 92 | return null; |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | if ($connexion['spip_connect_version']) { |
| 106 | 106 | if ($table_spip AND isset($table_des_tables[$nom])) { |
| 107 | 107 | $nom = $table_des_tables[$nom]; |
| 108 | - $nom_sql = 'spip_' . $nom; |
|
| 108 | + $nom_sql = 'spip_'.$nom; |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
@@ -114,10 +114,10 @@ discard block |
||
| 114 | 114 | // on essaye de recharger le cache des decriptions de ce serveur |
| 115 | 115 | // dans le fichier cache |
| 116 | 116 | if (!isset($connexion['tables'][$nom_sql]) |
| 117 | - AND defined('_VAR_MODE') AND _VAR_MODE!=='recalcul' |
|
| 117 | + AND defined('_VAR_MODE') AND _VAR_MODE !== 'recalcul' |
|
| 118 | 118 | AND (!isset($connexion['tables']) OR !$connexion['tables'])) { |
| 119 | - if (lire_fichier($nom_cache_desc_sql[$serveur][$objets_sql],$desc_cache) |
|
| 120 | - AND $desc_cache=unserialize($desc_cache)) |
|
| 119 | + if (lire_fichier($nom_cache_desc_sql[$serveur][$objets_sql], $desc_cache) |
|
| 120 | + AND $desc_cache = unserialize($desc_cache)) |
|
| 121 | 121 | $connexion['tables'] = $desc_cache; |
| 122 | 122 | } |
| 123 | 123 | if ($table_spip AND !isset($connexion['tables'][$nom_sql])) { |
@@ -127,12 +127,12 @@ discard block |
||
| 127 | 127 | // meme si pas d'abreviation declaree, trouver la table spip_$nom |
| 128 | 128 | // si c'est une table principale, |
| 129 | 129 | // puisqu'on le fait aussi pour les tables auxiliaires |
| 130 | - elseif ($nom_sql==$nom AND isset($tables_principales['spip_' .$nom])){ |
|
| 131 | - $nom_sql = 'spip_' . $nom; |
|
| 130 | + elseif ($nom_sql == $nom AND isset($tables_principales['spip_'.$nom])) { |
|
| 131 | + $nom_sql = 'spip_'.$nom; |
|
| 132 | 132 | $fdesc = &$tables_principales[$nom_sql]; |
| 133 | 133 | } |
| 134 | - elseif (isset($tables_auxiliaires[$n=$nom]) |
|
| 135 | - OR isset($tables_auxiliaires[$n='spip_'.$nom])) { |
|
| 134 | + elseif (isset($tables_auxiliaires[$n = $nom]) |
|
| 135 | + OR isset($tables_auxiliaires[$n = 'spip_'.$nom])) { |
|
| 136 | 136 | $nom_sql = $n; |
| 137 | 137 | $fdesc = &$tables_auxiliaires[$n]; |
| 138 | 138 | } # table locale a cote de SPIP, comme non SPIP: |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $desc = sql_showtable($nom_sql, $table_spip, $serveur); |
| 144 | 144 | if (!$desc OR !$desc['field']) { |
| 145 | 145 | if (!$fdesc) { |
| 146 | - spip_log("trouver_table: table inconnue '$serveur' '$nom'",_LOG_INFO_IMPORTANTE); |
|
| 146 | + spip_log("trouver_table: table inconnue '$serveur' '$nom'", _LOG_INFO_IMPORTANTE); |
|
| 147 | 147 | return null; |
| 148 | 148 | } |
| 149 | 149 | // on ne sait pas lire la structure de la table : |
@@ -155,12 +155,12 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | $desc['table'] = $desc['table_sql'] = $nom_sql; |
| 158 | - $desc['connexion']= $serveur; |
|
| 158 | + $desc['connexion'] = $serveur; |
|
| 159 | 159 | |
| 160 | 160 | // charger les infos declarees pour cette table |
| 161 | 161 | // en lui passant les infos connues |
| 162 | 162 | // $desc est prioritaire pour la description de la table |
| 163 | - $desc = array_merge(lister_tables_objets_sql($nom_sql,$desc),$desc); |
|
| 163 | + $desc = array_merge(lister_tables_objets_sql($nom_sql, $desc), $desc); |
|
| 164 | 164 | |
| 165 | 165 | // si tables_objets_sql est bien fini d'init, on peut cacher |
| 166 | 166 | $connexion['tables'][$nom_sql] = $desc; |
@@ -168,13 +168,13 @@ discard block |
||
| 168 | 168 | // une nouvelle table a ete decrite |
| 169 | 169 | // mettons donc a jour le cache des descriptions de ce serveur |
| 170 | 170 | if (is_writeable(_DIR_CACHE)) |
| 171 | - ecrire_fichier($nom_cache_desc_sql[$serveur][$objets_sql],serialize($connexion['tables']),true); |
|
| 171 | + ecrire_fichier($nom_cache_desc_sql[$serveur][$objets_sql], serialize($connexion['tables']), true); |
|
| 172 | 172 | } |
| 173 | 173 | else |
| 174 | 174 | $res = &$connexion['tables'][$nom_sql]; |
| 175 | 175 | |
| 176 | 176 | // toujours retourner $nom dans id_table |
| 177 | - $res['id_table']=$nom; |
|
| 177 | + $res['id_table'] = $nom; |
|
| 178 | 178 | |
| 179 | 179 | return $res; |
| 180 | 180 | } |
@@ -15,7 +15,9 @@ discard block |
||
| 15 | 15 | * |
| 16 | 16 | * @package SPIP\SQL\Tables |
| 17 | 17 | **/ |
| 18 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 18 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 19 | + return; |
|
| 20 | +} |
|
| 19 | 21 | include_spip('base/objets'); |
| 20 | 22 | |
| 21 | 23 | /** |
@@ -66,8 +68,9 @@ discard block |
||
| 66 | 68 | global $tables_principales, $tables_auxiliaires, $table_des_tables; |
| 67 | 69 | |
| 68 | 70 | if (!spip_connect($serveur) |
| 69 | - OR !preg_match('/^[a-zA-Z0-9._-]*/',$nom)) |
|
| 70 | - return null; |
|
| 71 | + OR !preg_match('/^[a-zA-Z0-9._-]*/',$nom)) { |
|
| 72 | + return null; |
|
| 73 | + } |
|
| 71 | 74 | |
| 72 | 75 | $connexion = &$GLOBALS['connexions'][$serveur ? strtolower($serveur) : 0]; |
| 73 | 76 | $objets_sql = lister_tables_objets_sql("::md5"); |
@@ -93,10 +96,11 @@ discard block |
||
| 93 | 96 | } |
| 94 | 97 | |
| 95 | 98 | $nom_sql = $nom; |
| 96 | - if (preg_match('/\.(.*)$/', $nom, $s)) |
|
| 97 | - $nom_sql = $s[1]; |
|
| 98 | - else |
|
| 99 | - $nom_sql = $nom; |
|
| 99 | + if (preg_match('/\.(.*)$/', $nom, $s)) { |
|
| 100 | + $nom_sql = $s[1]; |
|
| 101 | + } else { |
|
| 102 | + $nom_sql = $nom; |
|
| 103 | + } |
|
| 100 | 104 | |
| 101 | 105 | $fdesc = $desc = ''; |
| 102 | 106 | $connexion = &$GLOBALS['connexions'][$serveur ? $serveur : 0]; |
@@ -117,21 +121,22 @@ discard block |
||
| 117 | 121 | AND defined('_VAR_MODE') AND _VAR_MODE!=='recalcul' |
| 118 | 122 | AND (!isset($connexion['tables']) OR !$connexion['tables'])) { |
| 119 | 123 | if (lire_fichier($nom_cache_desc_sql[$serveur][$objets_sql],$desc_cache) |
| 120 | - AND $desc_cache=unserialize($desc_cache)) |
|
| 121 | - $connexion['tables'] = $desc_cache; |
|
| 124 | + AND $desc_cache=unserialize($desc_cache)) { |
|
| 125 | + $connexion['tables'] = $desc_cache; |
|
| 126 | + } |
|
| 122 | 127 | } |
| 123 | 128 | if ($table_spip AND !isset($connexion['tables'][$nom_sql])) { |
| 124 | 129 | |
| 125 | - if (isset($tables_principales[$nom_sql])) |
|
| 126 | - $fdesc = $tables_principales[$nom_sql]; |
|
| 130 | + if (isset($tables_principales[$nom_sql])) { |
|
| 131 | + $fdesc = $tables_principales[$nom_sql]; |
|
| 132 | + } |
|
| 127 | 133 | // meme si pas d'abreviation declaree, trouver la table spip_$nom |
| 128 | 134 | // si c'est une table principale, |
| 129 | 135 | // puisqu'on le fait aussi pour les tables auxiliaires |
| 130 | 136 | elseif ($nom_sql==$nom AND isset($tables_principales['spip_' .$nom])){ |
| 131 | 137 | $nom_sql = 'spip_' . $nom; |
| 132 | 138 | $fdesc = &$tables_principales[$nom_sql]; |
| 133 | - } |
|
| 134 | - elseif (isset($tables_auxiliaires[$n=$nom]) |
|
| 139 | + } elseif (isset($tables_auxiliaires[$n=$nom]) |
|
| 135 | 140 | OR isset($tables_auxiliaires[$n='spip_'.$nom])) { |
| 136 | 141 | $nom_sql = $n; |
| 137 | 142 | $fdesc = &$tables_auxiliaires[$n]; |
@@ -149,8 +154,7 @@ discard block |
||
| 149 | 154 | // on ne sait pas lire la structure de la table : |
| 150 | 155 | // on retombe sur la description donnee dans les fichiers spip |
| 151 | 156 | $desc = $fdesc; |
| 152 | - } |
|
| 153 | - else { |
|
| 157 | + } else { |
|
| 154 | 158 | $desc['exist'] = true; |
| 155 | 159 | } |
| 156 | 160 | |
@@ -167,11 +171,12 @@ discard block |
||
| 167 | 171 | $res = &$connexion['tables'][$nom_sql]; |
| 168 | 172 | // une nouvelle table a ete decrite |
| 169 | 173 | // mettons donc a jour le cache des descriptions de ce serveur |
| 170 | - if (is_writeable(_DIR_CACHE)) |
|
| 171 | - ecrire_fichier($nom_cache_desc_sql[$serveur][$objets_sql],serialize($connexion['tables']),true); |
|
| 174 | + if (is_writeable(_DIR_CACHE)) { |
|
| 175 | + ecrire_fichier($nom_cache_desc_sql[$serveur][$objets_sql],serialize($connexion['tables']),true); |
|
| 176 | + } |
|
| 177 | + } else { |
|
| 178 | + $res = &$connexion['tables'][$nom_sql]; |
|
| 172 | 179 | } |
| 173 | - else |
|
| 174 | - $res = &$connexion['tables'][$nom_sql]; |
|
| 175 | 180 | |
| 176 | 181 | // toujours retourner $nom dans id_table |
| 177 | 182 | $res['id_table']=$nom; |
@@ -26,17 +26,17 @@ discard block |
||
| 26 | 26 | * @return bool |
| 27 | 27 | */ |
| 28 | 28 | function base_determine_autoinc($table,$desc=array()){ |
| 29 | - if ($t=lister_tables_principales() AND isset($t[$table])) |
|
| 30 | - $autoinc = true; |
|
| 31 | - elseif ($t=lister_tables_auxiliaires() AND isset($t[$table])) |
|
| 32 | - $autoinc = false; |
|
| 33 | - else { |
|
| 34 | - // essayer de faire au mieux ! |
|
| 35 | - $autoinc = (isset($desc['key']['PRIMARY KEY']) |
|
| 36 | - AND strpos($desc['key']['PRIMARY KEY'],',')===false |
|
| 37 | - AND strpos($desc['field'][$desc['key']['PRIMARY KEY']],'default')===false); |
|
| 38 | - } |
|
| 39 | - return $autoinc; |
|
| 29 | + if ($t=lister_tables_principales() AND isset($t[$table])) |
|
| 30 | + $autoinc = true; |
|
| 31 | + elseif ($t=lister_tables_auxiliaires() AND isset($t[$table])) |
|
| 32 | + $autoinc = false; |
|
| 33 | + else { |
|
| 34 | + // essayer de faire au mieux ! |
|
| 35 | + $autoinc = (isset($desc['key']['PRIMARY KEY']) |
|
| 36 | + AND strpos($desc['key']['PRIMARY KEY'],',')===false |
|
| 37 | + AND strpos($desc['field'][$desc['key']['PRIMARY KEY']],'default')===false); |
|
| 38 | + } |
|
| 39 | + return $autoinc; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -55,51 +55,51 @@ discard block |
||
| 55 | 55 | * @return void |
| 56 | 56 | */ |
| 57 | 57 | function creer_ou_upgrader_table($table,$desc,$autoinc,$upgrade=false,$serveur='') { |
| 58 | - #spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 59 | - $sql_desc = $upgrade ? sql_showtable($table,true,$serveur) : false; |
|
| 60 | - #if (!$sql_desc) $sql_desc = false; |
|
| 61 | - #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 62 | - if (!$sql_desc) { |
|
| 63 | - if ($autoinc==='auto') |
|
| 64 | - $autoinc = base_determine_autoinc($table,$desc); |
|
| 65 | - #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 66 | - sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 67 | - // verifier la bonne installation de la table (php-fpm es-tu la ?) |
|
| 68 | - $sql_desc = sql_showtable($table,true,$serveur); |
|
| 69 | - #if (!$sql_desc) $sql_desc = false; |
|
| 70 | - #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 71 | - if (!$sql_desc){ |
|
| 72 | - // on retente avec un sleep ? |
|
| 73 | - sleep(1); |
|
| 74 | - sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 75 | - $sql_desc = sql_showtable($table,true,$serveur); |
|
| 76 | - #if (!$sql_desc) $sql_desc = false; |
|
| 77 | - #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 78 | - if (!$sql_desc){ |
|
| 79 | - spip_log("Echec creation table $table","maj"._LOG_CRITIQUE); |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - else { |
|
| 84 | - #spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 85 | - // ajouter les champs manquants |
|
| 86 | - // on ne supprime jamais les champs, car c'est dangereux |
|
| 87 | - // c'est toujours a faire manuellement |
|
| 88 | - $last = ''; |
|
| 89 | - foreach($desc['field'] as $field=>$type){ |
|
| 90 | - if (!isset($sql_desc['field'][$field])) |
|
| 91 | - sql_alter("TABLE $table ADD $field $type".($last?" AFTER $last":""),$serveur); |
|
| 92 | - $last = $field; |
|
| 93 | - } |
|
| 94 | - foreach($desc['key'] as $key=>$type){ |
|
| 95 | - // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
|
| 96 | - // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
|
| 97 | - if (!isset($sql_desc['key'][$key]) AND !isset($sql_desc['key']["$key $type"])) |
|
| 98 | - sql_alter("TABLE $table ADD $key ($type)",$serveur); |
|
| 99 | - $last = $field; |
|
| 100 | - } |
|
| 58 | + #spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 59 | + $sql_desc = $upgrade ? sql_showtable($table,true,$serveur) : false; |
|
| 60 | + #if (!$sql_desc) $sql_desc = false; |
|
| 61 | + #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 62 | + if (!$sql_desc) { |
|
| 63 | + if ($autoinc==='auto') |
|
| 64 | + $autoinc = base_determine_autoinc($table,$desc); |
|
| 65 | + #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 66 | + sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 67 | + // verifier la bonne installation de la table (php-fpm es-tu la ?) |
|
| 68 | + $sql_desc = sql_showtable($table,true,$serveur); |
|
| 69 | + #if (!$sql_desc) $sql_desc = false; |
|
| 70 | + #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 71 | + if (!$sql_desc){ |
|
| 72 | + // on retente avec un sleep ? |
|
| 73 | + sleep(1); |
|
| 74 | + sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 75 | + $sql_desc = sql_showtable($table,true,$serveur); |
|
| 76 | + #if (!$sql_desc) $sql_desc = false; |
|
| 77 | + #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 78 | + if (!$sql_desc){ |
|
| 79 | + spip_log("Echec creation table $table","maj"._LOG_CRITIQUE); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + else { |
|
| 84 | + #spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 85 | + // ajouter les champs manquants |
|
| 86 | + // on ne supprime jamais les champs, car c'est dangereux |
|
| 87 | + // c'est toujours a faire manuellement |
|
| 88 | + $last = ''; |
|
| 89 | + foreach($desc['field'] as $field=>$type){ |
|
| 90 | + if (!isset($sql_desc['field'][$field])) |
|
| 91 | + sql_alter("TABLE $table ADD $field $type".($last?" AFTER $last":""),$serveur); |
|
| 92 | + $last = $field; |
|
| 93 | + } |
|
| 94 | + foreach($desc['key'] as $key=>$type){ |
|
| 95 | + // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
|
| 96 | + // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
|
| 97 | + if (!isset($sql_desc['key'][$key]) AND !isset($sql_desc['key']["$key $type"])) |
|
| 98 | + sql_alter("TABLE $table ADD $key ($type)",$serveur); |
|
| 99 | + $last = $field; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - } |
|
| 102 | + } |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -120,20 +120,20 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | function alterer_base($tables_inc, $tables_noinc, $up=false, $serveur='') |
| 122 | 122 | { |
| 123 | - if ($up === false) { |
|
| 124 | - $old = false; |
|
| 125 | - $up = array(); |
|
| 126 | - } else { |
|
| 127 | - $old = true; |
|
| 128 | - if (!is_array($up)) $up = array($up); |
|
| 129 | - } |
|
| 130 | - foreach($tables_inc as $k => $v) |
|
| 131 | - if (!$old OR in_array($k, $up)) |
|
| 132 | - creer_ou_upgrader_table($k,$v,true,$old,$serveur); |
|
| 123 | + if ($up === false) { |
|
| 124 | + $old = false; |
|
| 125 | + $up = array(); |
|
| 126 | + } else { |
|
| 127 | + $old = true; |
|
| 128 | + if (!is_array($up)) $up = array($up); |
|
| 129 | + } |
|
| 130 | + foreach($tables_inc as $k => $v) |
|
| 131 | + if (!$old OR in_array($k, $up)) |
|
| 132 | + creer_ou_upgrader_table($k,$v,true,$old,$serveur); |
|
| 133 | 133 | |
| 134 | - foreach($tables_noinc as $k => $v) |
|
| 135 | - if (!$old OR in_array($k, $up)) |
|
| 136 | - creer_ou_upgrader_table($k,$v,false,$old,$serveur); |
|
| 134 | + foreach($tables_noinc as $k => $v) |
|
| 135 | + if (!$old OR in_array($k, $up)) |
|
| 136 | + creer_ou_upgrader_table($k,$v,false,$old,$serveur); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -147,14 +147,14 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | function creer_base($serveur='') { |
| 149 | 149 | |
| 150 | - // Note: les mises a jour reexecutent ce code pour s'assurer |
|
| 151 | - // de la conformite de la base |
|
| 152 | - // pas de panique sur "already exists" et "duplicate entry" donc. |
|
| 150 | + // Note: les mises a jour reexecutent ce code pour s'assurer |
|
| 151 | + // de la conformite de la base |
|
| 152 | + // pas de panique sur "already exists" et "duplicate entry" donc. |
|
| 153 | 153 | |
| 154 | - alterer_base(lister_tables_principales(), |
|
| 155 | - lister_tables_auxiliaires(), |
|
| 156 | - false, |
|
| 157 | - $serveur); |
|
| 154 | + alterer_base(lister_tables_principales(), |
|
| 155 | + lister_tables_auxiliaires(), |
|
| 156 | + false, |
|
| 157 | + $serveur); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -167,10 +167,10 @@ discard block |
||
| 167 | 167 | * @return void |
| 168 | 168 | */ |
| 169 | 169 | function maj_tables($upgrade_tables=array(),$serveur=''){ |
| 170 | - alterer_base(lister_tables_principales(), |
|
| 171 | - lister_tables_auxiliaires(), |
|
| 172 | - $upgrade_tables, |
|
| 173 | - $serveur); |
|
| 170 | + alterer_base(lister_tables_principales(), |
|
| 171 | + lister_tables_auxiliaires(), |
|
| 172 | + $upgrade_tables, |
|
| 173 | + $serveur); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | ?> |
@@ -25,16 +25,16 @@ discard block |
||
| 25 | 25 | * @param array $desc |
| 26 | 26 | * @return bool |
| 27 | 27 | */ |
| 28 | -function base_determine_autoinc($table,$desc=array()){ |
|
| 29 | - if ($t=lister_tables_principales() AND isset($t[$table])) |
|
| 28 | +function base_determine_autoinc($table, $desc = array()) { |
|
| 29 | + if ($t = lister_tables_principales() AND isset($t[$table])) |
|
| 30 | 30 | $autoinc = true; |
| 31 | - elseif ($t=lister_tables_auxiliaires() AND isset($t[$table])) |
|
| 31 | + elseif ($t = lister_tables_auxiliaires() AND isset($t[$table])) |
|
| 32 | 32 | $autoinc = false; |
| 33 | 33 | else { |
| 34 | 34 | // essayer de faire au mieux ! |
| 35 | 35 | $autoinc = (isset($desc['key']['PRIMARY KEY']) |
| 36 | - AND strpos($desc['key']['PRIMARY KEY'],',')===false |
|
| 37 | - AND strpos($desc['field'][$desc['key']['PRIMARY KEY']],'default')===false); |
|
| 36 | + AND strpos($desc['key']['PRIMARY KEY'], ',') === false |
|
| 37 | + AND strpos($desc['field'][$desc['key']['PRIMARY KEY']], 'default') === false); |
|
| 38 | 38 | } |
| 39 | 39 | return $autoinc; |
| 40 | 40 | } |
@@ -54,29 +54,29 @@ discard block |
||
| 54 | 54 | * @param string $serveur |
| 55 | 55 | * @return void |
| 56 | 56 | */ |
| 57 | -function creer_ou_upgrader_table($table,$desc,$autoinc,$upgrade=false,$serveur='') { |
|
| 57 | +function creer_ou_upgrader_table($table, $desc, $autoinc, $upgrade = false, $serveur = '') { |
|
| 58 | 58 | #spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE); |
| 59 | - $sql_desc = $upgrade ? sql_showtable($table,true,$serveur) : false; |
|
| 59 | + $sql_desc = $upgrade ? sql_showtable($table, true, $serveur) : false; |
|
| 60 | 60 | #if (!$sql_desc) $sql_desc = false; |
| 61 | 61 | #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
| 62 | 62 | if (!$sql_desc) { |
| 63 | - if ($autoinc==='auto') |
|
| 64 | - $autoinc = base_determine_autoinc($table,$desc); |
|
| 63 | + if ($autoinc === 'auto') |
|
| 64 | + $autoinc = base_determine_autoinc($table, $desc); |
|
| 65 | 65 | #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
| 66 | 66 | sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
| 67 | 67 | // verifier la bonne installation de la table (php-fpm es-tu la ?) |
| 68 | - $sql_desc = sql_showtable($table,true,$serveur); |
|
| 68 | + $sql_desc = sql_showtable($table, true, $serveur); |
|
| 69 | 69 | #if (!$sql_desc) $sql_desc = false; |
| 70 | 70 | #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
| 71 | - if (!$sql_desc){ |
|
| 71 | + if (!$sql_desc) { |
|
| 72 | 72 | // on retente avec un sleep ? |
| 73 | 73 | sleep(1); |
| 74 | 74 | sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
| 75 | - $sql_desc = sql_showtable($table,true,$serveur); |
|
| 75 | + $sql_desc = sql_showtable($table, true, $serveur); |
|
| 76 | 76 | #if (!$sql_desc) $sql_desc = false; |
| 77 | 77 | #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
| 78 | - if (!$sql_desc){ |
|
| 79 | - spip_log("Echec creation table $table","maj"._LOG_CRITIQUE); |
|
| 78 | + if (!$sql_desc) { |
|
| 79 | + spip_log("Echec creation table $table", "maj"._LOG_CRITIQUE); |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -86,16 +86,16 @@ discard block |
||
| 86 | 86 | // on ne supprime jamais les champs, car c'est dangereux |
| 87 | 87 | // c'est toujours a faire manuellement |
| 88 | 88 | $last = ''; |
| 89 | - foreach($desc['field'] as $field=>$type){ |
|
| 89 | + foreach ($desc['field'] as $field=>$type) { |
|
| 90 | 90 | if (!isset($sql_desc['field'][$field])) |
| 91 | - sql_alter("TABLE $table ADD $field $type".($last?" AFTER $last":""),$serveur); |
|
| 91 | + sql_alter("TABLE $table ADD $field $type".($last ? " AFTER $last" : ""), $serveur); |
|
| 92 | 92 | $last = $field; |
| 93 | 93 | } |
| 94 | - foreach($desc['key'] as $key=>$type){ |
|
| 94 | + foreach ($desc['key'] as $key=>$type) { |
|
| 95 | 95 | // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
| 96 | 96 | // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
| 97 | 97 | if (!isset($sql_desc['key'][$key]) AND !isset($sql_desc['key']["$key $type"])) |
| 98 | - sql_alter("TABLE $table ADD $key ($type)",$serveur); |
|
| 98 | + sql_alter("TABLE $table ADD $key ($type)", $serveur); |
|
| 99 | 99 | $last = $field; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * serveur sql |
| 119 | 119 | * @return void |
| 120 | 120 | */ |
| 121 | -function alterer_base($tables_inc, $tables_noinc, $up=false, $serveur='') |
|
| 121 | +function alterer_base($tables_inc, $tables_noinc, $up = false, $serveur = '') |
|
| 122 | 122 | { |
| 123 | 123 | if ($up === false) { |
| 124 | 124 | $old = false; |
@@ -127,13 +127,13 @@ discard block |
||
| 127 | 127 | $old = true; |
| 128 | 128 | if (!is_array($up)) $up = array($up); |
| 129 | 129 | } |
| 130 | - foreach($tables_inc as $k => $v) |
|
| 130 | + foreach ($tables_inc as $k => $v) |
|
| 131 | 131 | if (!$old OR in_array($k, $up)) |
| 132 | - creer_ou_upgrader_table($k,$v,true,$old,$serveur); |
|
| 132 | + creer_ou_upgrader_table($k, $v, true, $old, $serveur); |
|
| 133 | 133 | |
| 134 | - foreach($tables_noinc as $k => $v) |
|
| 134 | + foreach ($tables_noinc as $k => $v) |
|
| 135 | 135 | if (!$old OR in_array($k, $up)) |
| 136 | - creer_ou_upgrader_table($k,$v,false,$old,$serveur); |
|
| 136 | + creer_ou_upgrader_table($k, $v, false, $old, $serveur); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param string $serveur |
| 146 | 146 | * @return void |
| 147 | 147 | */ |
| 148 | -function creer_base($serveur='') { |
|
| 148 | +function creer_base($serveur = '') { |
|
| 149 | 149 | |
| 150 | 150 | // Note: les mises a jour reexecutent ce code pour s'assurer |
| 151 | 151 | // de la conformite de la base |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @param string $serveur |
| 167 | 167 | * @return void |
| 168 | 168 | */ |
| 169 | -function maj_tables($upgrade_tables=array(),$serveur=''){ |
|
| 169 | +function maj_tables($upgrade_tables = array(), $serveur = '') { |
|
| 170 | 170 | alterer_base(lister_tables_principales(), |
| 171 | 171 | lister_tables_auxiliaires(), |
| 172 | 172 | $upgrade_tables, |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | include_spip('inc/acces'); |
| 16 | 18 | include_spip('base/objets'); |
@@ -26,11 +28,11 @@ discard block |
||
| 26 | 28 | * @return bool |
| 27 | 29 | */ |
| 28 | 30 | function base_determine_autoinc($table,$desc=array()){ |
| 29 | - if ($t=lister_tables_principales() AND isset($t[$table])) |
|
| 30 | - $autoinc = true; |
|
| 31 | - elseif ($t=lister_tables_auxiliaires() AND isset($t[$table])) |
|
| 32 | - $autoinc = false; |
|
| 33 | - else { |
|
| 31 | + if ($t=lister_tables_principales() AND isset($t[$table])) { |
|
| 32 | + $autoinc = true; |
|
| 33 | + } elseif ($t=lister_tables_auxiliaires() AND isset($t[$table])) { |
|
| 34 | + $autoinc = false; |
|
| 35 | + } else { |
|
| 34 | 36 | // essayer de faire au mieux ! |
| 35 | 37 | $autoinc = (isset($desc['key']['PRIMARY KEY']) |
| 36 | 38 | AND strpos($desc['key']['PRIMARY KEY'],',')===false |
@@ -60,8 +62,9 @@ discard block |
||
| 60 | 62 | #if (!$sql_desc) $sql_desc = false; |
| 61 | 63 | #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
| 62 | 64 | if (!$sql_desc) { |
| 63 | - if ($autoinc==='auto') |
|
| 64 | - $autoinc = base_determine_autoinc($table,$desc); |
|
| 65 | + if ($autoinc==='auto') { |
|
| 66 | + $autoinc = base_determine_autoinc($table,$desc); |
|
| 67 | + } |
|
| 65 | 68 | #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
| 66 | 69 | sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
| 67 | 70 | // verifier la bonne installation de la table (php-fpm es-tu la ?) |
@@ -79,23 +82,24 @@ discard block |
||
| 79 | 82 | spip_log("Echec creation table $table","maj"._LOG_CRITIQUE); |
| 80 | 83 | } |
| 81 | 84 | } |
| 82 | - } |
|
| 83 | - else { |
|
| 85 | + } else { |
|
| 84 | 86 | #spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE); |
| 85 | 87 | // ajouter les champs manquants |
| 86 | 88 | // on ne supprime jamais les champs, car c'est dangereux |
| 87 | 89 | // c'est toujours a faire manuellement |
| 88 | 90 | $last = ''; |
| 89 | 91 | foreach($desc['field'] as $field=>$type){ |
| 90 | - if (!isset($sql_desc['field'][$field])) |
|
| 91 | - sql_alter("TABLE $table ADD $field $type".($last?" AFTER $last":""),$serveur); |
|
| 92 | + if (!isset($sql_desc['field'][$field])) { |
|
| 93 | + sql_alter("TABLE $table ADD $field $type".($last?" AFTER $last":""),$serveur); |
|
| 94 | + } |
|
| 92 | 95 | $last = $field; |
| 93 | 96 | } |
| 94 | 97 | foreach($desc['key'] as $key=>$type){ |
| 95 | 98 | // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
| 96 | 99 | // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
| 97 | - if (!isset($sql_desc['key'][$key]) AND !isset($sql_desc['key']["$key $type"])) |
|
| 98 | - sql_alter("TABLE $table ADD $key ($type)",$serveur); |
|
| 100 | + if (!isset($sql_desc['key'][$key]) AND !isset($sql_desc['key']["$key $type"])) { |
|
| 101 | + sql_alter("TABLE $table ADD $key ($type)",$serveur); |
|
| 102 | + } |
|
| 99 | 103 | $last = $field; |
| 100 | 104 | } |
| 101 | 105 | |
@@ -125,16 +129,20 @@ discard block |
||
| 125 | 129 | $up = array(); |
| 126 | 130 | } else { |
| 127 | 131 | $old = true; |
| 128 | - if (!is_array($up)) $up = array($up); |
|
| 132 | + if (!is_array($up)) { |
|
| 133 | + $up = array($up); |
|
| 134 | + } |
|
| 129 | 135 | } |
| 130 | - foreach($tables_inc as $k => $v) |
|
| 131 | - if (!$old OR in_array($k, $up)) |
|
| 136 | + foreach($tables_inc as $k => $v) { |
|
| 137 | + if (!$old OR in_array($k, $up)) |
|
| 132 | 138 | creer_ou_upgrader_table($k,$v,true,$old,$serveur); |
| 139 | + } |
|
| 133 | 140 | |
| 134 | - foreach($tables_noinc as $k => $v) |
|
| 135 | - if (!$old OR in_array($k, $up)) |
|
| 141 | + foreach($tables_noinc as $k => $v) { |
|
| 142 | + if (!$old OR in_array($k, $up)) |
|
| 136 | 143 | creer_ou_upgrader_table($k,$v,false,$old,$serveur); |
| 137 | -} |
|
| 144 | + } |
|
| 145 | + } |
|
| 138 | 146 | |
| 139 | 147 | /** |
| 140 | 148 | * Creer une base de donnee |