/** * * Vérifie la conformité du xml, élément par élément. * * @param array $res * @param string $mode * @return array **/ function valider_resultats($res, $mode) { $i = $j = 0; $table = ''; rsort($res); foreach ($res as $l) { $i++; $class = 'row_' . alterner($i, 'even', 'odd'); list($nb, $texte, $erreurs, $script, $appel, $temps) = $l; if ($texte < 0) { $texte = 0 - $texte; $color = ";color: red"; } else { $color = ''; } $err = !intval($nb) ? '' : $erreurs[0][0] . ' ' . _T('ligne') . ' ' . $erreurs[0][1] . ($nb == 1 ? '' : ' ...'); if ($err) { $j++; } $h = $mode ? $appel . '&var_mode=debug&var_mode_affiche=validation' : generer_url_ecrire('valider_xml', "var_url=" . urlencode($appel)); $table .= "<tr class='{$class}'>" . "<td style='text-align: right'>{$nb}</td>" . "<td style='text-align: right{$color}'>{$texte}</td>" . "<td style='text-align: right'>{$temps}</td>" . "<td style='text-align: left'>{$err}</td>" . "<td>{$script}</td>" . "<td><a href='{$h}'>{$appel}</a></td>"; } return array($j, "<table class='spip'>" . "<tr><th>" . _T('erreur_texte') . "</th><th>" . _T('taille_octets', array('taille' => ' ')) . "</th><th>" . _T('zbug_profile', array('time' => '')) . "</th><th>" . _T('message') . "</th><th>Page</th><th>args" . "</th></tr>" . $table . "</table>"); }
/** * http://code.spip.net/@traiter_tableau * * @param sring $bloc * @return string */ function traiter_tableau($bloc) { // id "unique" pour les id du tableau $tabid = substr(md5($bloc), 0, 4); // Decouper le tableau en lignes preg_match_all(',([|].*)[|]\\n,UmsS', $bloc, $regs, PREG_PATTERN_ORDER); $lignes = array(); $debut_table = $summary = ''; $l = 0; $numeric = true; // Traiter chaque ligne $reg_line1 = ',^(\\|(' . _RACCOURCI_TH_SPAN . '))+$,sS'; $reg_line_all = ',^(' . _RACCOURCI_TH_SPAN . ')$,sS'; $hc = $hl = array(); foreach ($regs[1] as $ligne) { $l++; // Gestion de la premiere ligne : if ($l == 1) { // - <caption> et summary dans la premiere ligne : // || caption | summary || (|summary est optionnel) if (preg_match(',^\\|\\|([^|]*)(\\|(.*))?$,sS', rtrim($ligne, '|'), $cap)) { $l = 0; if ($caption = trim($cap[1])) { $debut_table .= "<caption>" . $caption . "</caption>\n"; } $summary = ' summary="' . entites_html(trim($cap[3])) . '"'; } else { if (preg_match($reg_line1, $ligne, $thead)) { preg_match_all('/\\|([^|]*)/S', $ligne, $cols); $ligne = ''; $cols = $cols[1]; $colspan = 1; for ($c = count($cols) - 1; $c >= 0; $c--) { $attr = ''; if ($cols[$c] == '<') { $colspan++; } else { if ($colspan > 1) { $attr = " colspan='{$colspan}'"; $colspan = 1; } // inutile de garder le strong qui n'a servi que de marqueur $cols[$c] = str_replace(array('{', '}'), '', $cols[$c]); $ligne = "<th id='id{$tabid}_c{$c}'{$attr}>{$cols[$c]}</th>{$ligne}"; $hc[$c] = "id{$tabid}_c{$c}"; // pour mettre dans les headers des td } } $debut_table .= "<thead><tr class='row_first'>" . $ligne . "</tr></thead>\n"; $l = 0; } } } // Sinon ligne normale if ($l) { // Gerer les listes a puce dans les cellules // on declenche simplement sur \n- car il y a les // -* -# -? -! (qui produisent des - !) if (strpos($ligne, "\n-") !== false) { $ligne = traiter_listes($ligne); } // tout mettre dans un tableau 2d preg_match_all('/\\|([^|]*)/S', $ligne, $cols); // Pas de paragraphes dans les cellules foreach ($cols[1] as &$col) { if (strlen($col = trim($col))) { $col = preg_replace("/\n{2,}/S", "<br /> <br />", $col); if (_AUTOBR) { $col = str_replace("\n", _AUTOBR . "\n", $col); } } } // assembler le tableau $lignes[] = $cols[1]; } } // maintenant qu'on a toutes les cellules // on prepare une liste de rowspan par defaut, a partir // du nombre de colonnes dans la premiere ligne. // Reperer egalement les colonnes numeriques pour les cadrer a droite $rowspans = $numeric = array(); $n = count($lignes[0]); $k = count($lignes); // distinguer les colonnes numeriques a point ou a virgule, // pour les alignements eventuels sur "," ou "." $numeric_class = array('.' => 'point', ',' => 'virgule'); for ($i = 0; $i < $n; $i++) { $align = true; for ($j = 0; $j < $k; $j++) { $rowspans[$j][$i] = 1; if ($align and preg_match('/^[+-]?(?:\\s|\\d)*([.,]?)\\d*$/', trim($lignes[$j][$i]), $r)) { if ($r[1]) { $align = $r[1]; } } else { $align = ''; } } $numeric[$i] = $align ? " class='numeric " . $numeric_class[$align] . "'" : ''; } for ($j = 0; $j < $k; $j++) { if (preg_match($reg_line_all, $lignes[$j][0])) { $hl[$j] = "id{$tabid}_l{$j}"; // pour mettre dans les headers des td } else { unset($hl[0]); } } if (!isset($hl[0])) { $hl = array(); } // toute la colonne ou rien // et on parcourt le tableau a l'envers pour ramasser les // colspan et rowspan en passant $html = ''; for ($l = count($lignes) - 1; $l >= 0; $l--) { $cols = $lignes[$l]; $colspan = 1; $ligne = ''; for ($c = count($cols) - 1; $c >= 0; $c--) { $attr = $numeric[$c]; $cell = trim($cols[$c]); if ($cell == '<') { $colspan++; } elseif ($cell == '^') { $rowspans[$l - 1][$c] += $rowspans[$l][$c]; } else { if ($colspan > 1) { $attr .= " colspan='{$colspan}'"; $colspan = 1; } if (($x = $rowspans[$l][$c]) > 1) { $attr .= " rowspan='{$x}'"; } $b = ($c == 0 and isset($hl[$l])) ? 'th' : 'td'; $h = (isset($hc[$c]) ? $hc[$c] : '') . ' ' . (($b == 'td' and isset($hl[$l])) ? $hl[$l] : ''); if ($h = trim($h)) { $attr .= " headers='{$h}'"; } // inutile de garder le strong qui n'a servi que de marqueur if ($b == 'th') { $attr .= " id='" . $hl[$l] . "'"; $cols[$c] = str_replace(array('{', '}'), '', $cols[$c]); } $ligne = "\n<{$b}" . $attr . '>' . $cols[$c] . "</{$b}>" . $ligne; } } // ligne complete $class = alterner($l + 1, 'odd', 'even'); $html = "<tr class='row_{$class} {$class}'>{$ligne}</tr>\n{$html}"; } return "\n\n<table" . $GLOBALS['class_spip_plus'] . $summary . ">\n" . $debut_table . "<tbody>\n" . $html . "</tbody>\n" . "</table>\n\n"; }
function traiter_tableau($bloc) { // Decouper le tableau en lignes preg_match_all(',([|].*)[|]\\n,UmsS', $bloc, $regs, PREG_PATTERN_ORDER); $lignes = array(); $debut_table = $summary = ''; $l = 0; $numeric = true; // Traiter chaque ligne $reg_line1 = ',^(\\|(' . _RACCOURCI_TH_SPAN . '))+$,sS'; $reg_line_all = ',^' . _RACCOURCI_TH_SPAN . '$,sS'; foreach ($regs[1] as $ligne) { $l++; // Gestion de la premiere ligne : if ($l == 1) { // - <caption> et summary dans la premiere ligne : // || caption | summary || (|summary est optionnel) if (preg_match(',^\\|\\|([^|]*)(\\|(.*))?$,sS', rtrim($ligne, '|'), $cap)) { $l = 0; if ($caption = trim($cap[1])) { $debut_table .= "<caption>" . $caption . "</caption>\n"; } $summary = ' summary="' . entites_html(trim($cap[3])) . '"'; } else { if (preg_match($reg_line1, $ligne)) { preg_match_all('/\\|([^|]*)/S', $ligne, $cols); $ligne = ''; $cols = $cols[1]; $colspan = 1; for ($c = count($cols) - 1; $c >= 0; $c--) { $attr = ''; if ($cols[$c] == '<') { $colspan++; } else { if ($colspan > 1) { $attr = " colspan='{$colspan}'"; $colspan = 1; } // inutile de garder le strong qui n'a servi que de marqueur $cols[$c] = str_replace(array('{', '}'), '', $cols[$c]); $ligne = "<th scope='col'{$attr}>{$cols[$c]}</th>{$ligne}"; } } $debut_table .= "<thead><tr class='row_first'>" . $ligne . "</tr></thead>\n"; $l = 0; } } } // Sinon ligne normale if ($l) { // Gerer les listes a puce dans les cellules if (strpos($ligne, "\n-*") !== false or strpos($ligne, "\n-#") !== false) { $ligne = traiter_listes($ligne); } // Pas de paragraphes dans les cellules $ligne = preg_replace("/\n{2,}/", "<br /><br />\n", $ligne); // tout mettre dans un tableau 2d preg_match_all('/\\|([^|]*)/S', $ligne, $cols); $lignes[] = $cols[1]; } } // maintenant qu'on a toutes les cellules // on prepare une liste de rowspan par defaut, a partir // du nombre de colonnes dans la premiere ligne. // Reperer egalement les colonnes numeriques pour les cadrer a droite $rowspans = $numeric = array(); $n = count($lignes[0]); $k = count($lignes); for ($i = 0; $i < $n; $i++) { $align = true; for ($j = 0; $j < $k; $j++) { $rowspans[$j][$i] = 1; } for ($j = 0; $j < $k; $j++) { $cell = trim($lignes[$j][$i]); if (preg_match($reg_line_all, $cell)) { if (!preg_match('/^\\d+([.,]?)\\d*$/', $cell, $r)) { $align = ''; break; } else { if ($r[1]) { $align = $r[1]; } } } } $numeric[$i] = !$align ? '' : " style='text-align: " . 'right' . "'"; } // et on parcourt le tableau a l'envers pour ramasser les // colspan et rowspan en passant $html = ''; for ($l = count($lignes) - 1; $l >= 0; $l--) { $cols = $lignes[$l]; $colspan = 1; $ligne = ''; for ($c = count($cols) - 1; $c >= 0; $c--) { $attr = $numeric[$c]; $cell = trim($cols[$c]); if ($cell == '<') { $colspan++; } elseif ($cell == '^') { $rowspans[$l - 1][$c] += $rowspans[$l][$c]; } else { if ($colspan > 1) { $attr .= " colspan='{$colspan}'"; $colspan = 1; } if (($x = $rowspans[$l][$c]) > 1) { $attr .= " rowspan='{$x}'"; } $ligne = "\n<td" . $attr . '>' . $cols[$c] . '</td>' . $ligne; } } // ligne complete $class = alterner($l + 1, 'even', 'odd'); $html = "<tr class='row_{$class}'>{$ligne}</tr>\n{$html}"; } return "\n\n<table" . $GLOBALS['class_spip_plus'] . $summary . ">\n" . $debut_table . "<tbody>\n" . $html . "</tbody>\n" . "</table>\n\n"; }
function exec_admin_galettonuts() { // Seuls les super-admins sont authorisés réaliser des synchros, // et par conséquent de configurer le plugin if (!('0minirezo' === $GLOBALS['auteur_session']['statut'] && $GLOBALS['connect_toutes_rubriques'])) { echo minipres(_T('avis_non_acces_page')); exit; } $erreurs = array(); $icone_base = _DIR_PLUGIN_GALETTONUTS . 'img_pack/galettonuts-sql_status-'; $icone_src = 'config-168.png'; $icone_title = _T('galettonuts:icone_db_config'); include_spip('inc/galettonuts_fonctions'); // Lecture de la configuration if (!class_exists('L2_Spip_Plugin_Metas')) { include_spip('lib/L2/Spip/Plugin/Metas.class'); } $config = new L2_Spip_Plugin_Metas('galettonuts_config'); $contexte = $config->lire(); $activer_cron = array_key_exists('activer_cron', $contexte) ? $contexte['activer_cron'] : true; // {{{ Traitement des données reçues if (_request('_galettonuts_ok')) { $champs = array('adresse_db' => _request('adresse_db'), 'login_db' => _request('login_db'), 'pass_db' => _request('pass_db'), 'prefix_db' => _request('prefix_db'), 'choix_db' => _request('choix_db')); // Des champs sont-ils vides ? $champs = array_map('trim', $champs); if (false === (!in_array(null, $champs) || !in_array('', $champs))) { $erreurs[] = _T('galettonuts:texte_erreur_1'); } // Activer la synchronisation automatique ? if ('oui' == _request('activer_cron')) { $activer_cron = true; } else { $activer_cron = false; } if ($activer_cron) { $champs['heures'] = intval(_request('heures')); $champs['minutes'] = intval(_request('minutes')); $synchro = new L2_Spip_Plugin_Metas('galettonuts_synchro'); $frequence = 3600 * $champs['heures'] + 60 * $champs['minutes']; if ($frequence !== $synchro->lire('frequence')) { $synchro->ajouter(array('frequence' => $frequence), true); $fichier = '<?php define(\'_GALETTONUTS_DELAIS_CRON\', ' . $frequence . '); ?>'; ecrire_fichier(_DIR_TMP . 'galettonuts_cron.php', $fichier, true); unset($fichier); } } else { // On s'assure de bien supprimer le fichier de vérouillage // pour forcer la resynchronisation tenant compte de la nouvelle // configuration. if (file_exists(_DIR_TMP . 'galettonuts_cron.lock')) { unlink(_DIR_TMP . 'galettonuts_cron.lock'); } if (file_exists(_DIR_TMP . 'galettonuts_cron.php')) { unlink(_DIR_TMP . 'galettonuts_cron.php'); } } $contexte['activer_cron'] = $activer_cron; // Prise en compte dans le contexte $contexte = array_merge($contexte, $champs); unset($champs); // Test de connexion à la BDD Galette if (!count($erreurs)) { $link = galettonuts_galette_db($contexte['adresse_db'], $contexte['login_db'], $contexte['pass_db']); if (-1 === $link) { $erreurs[] = _T('galettonuts:avis_connexion_echec_1'); $icone_src = 'error-168.png'; $icone_title = _T('galettonuts:icone_db_erreur'); } else { if (-2 === galettonuts_galette_db($contexte['choix_db'], $link)) { $erreurs[] = _T('galettonuts:avis_connexion_echec_2'); $icone_src = 'error-168.png'; $icone_title = _T('galettonuts:icone_db_erreur'); } else { $icone_src = 'ok-168.png'; $icone_title = _T('galettonuts:icone_db_ok'); $contexte['db_ok'] = true; } } if (0 < $link) { mysql_close($link); } unset($link); } // Interraction avec Accès Restreint if (defined('_DIR_PLUGIN_ACCESRESTREINT')) { if ($config->existe('zones')) { galettonuts_dissocier_zones($config->lire('zones')); } $zones = _request('zones'); if (is_array($zones) && 0 < count($zones)) { $contexte['zones'] = $zones; } else { $config->supprimer(array('zones' => null)); unset($contexte['zones']); } unset($zones); } // Mémorisation de la configuration à la base de données Galette if (!count($erreurs)) { $config->ajouter($contexte, true); } // Lancer une synchronisation if (0 == count($erreurs)) { galettonuts_synchroniser(true); } } else { if (!empty($contexte['adresse_db']) && !empty($contexte['login_db']) && !empty($contexte['pass_db'])) { $link = galettonuts_galette_db($contexte['adresse_db'], $contexte['login_db'], $contexte['pass_db']); if (0 > $link) { $icone_src = 'error-168.png'; $icone_title = _T('galettonuts:icone_db_erreur'); $config->ajouter(array('db_ok' => false)); } else { $icone_src = 'ok-168.png'; $icone_title = _T('galettonuts:icone_db_ok'); $config->ajouter(array('db_ok' => true)); mysql_close($link); unset($link); } } } // }}} // {{{ Affichage // Haut de page $commencer_page = charger_fonction('commencer_page', 'inc'); echo $commencer_page(_T('galettonuts:titre_page_admin'), '', 'galettonuts'), '<br/><br/><br/>'; gros_titre(_T('galettonuts:titre_admin')); // Boîte d'informations debut_gauche(); debut_boite_info(); echo _T('galettonuts:texte_info_admin'); fin_boite_info(); // Message(s) d'erreur(s) debut_droite(); if ($c = count($erreurs)) { if (1 == $c) { $erreur_titre = _T('galettonuts:texte_erreur'); $erreur_texte = (string) $erreurs[0]; } else { $erreur_titre = _T('galettonuts:texte_erreurs'); $erreur_texte = '<ul>'; for ($i = 0; $c < $i; ++$i) { $erreur_texte .= '<li>' . $erreurs[$i] . '</li>'; } $erreur_texte .= '</ul>'; } echo '<div style="background-color:#fee;color:red;border:1px solid red;padding:.5em;margin-bottom:25px" class="verdana2"><strong>', $erreur_titre, '</strong> :<br />', $erreur_texte, '</div>'; } echo generer_url_post_ecrire('admin_galettonuts'); // Accès à la BDD debut_cadre_trait_couleur('base-24.gif', false, '', _T('galettonuts:info_bdd')); echo '<div style="float:right;width:175px" class="verdana2">', _T('galettonuts:texte_info_bdd'), '<div>', '<div style="position:absolute;bottom:35px;width:168px;height:168px">', '<img src="', $icone_base, $icone_src, '" width="168" height="168" alt="" title="', $icone_title, '" />', '</div>', '</div>', '</div>'; echo '<div style="width:298px">'; debut_cadre_couleur(); echo '<p><label for="adresse_db" style="font-weight:bold;cursor:pointer">', _T('galettonuts:entree_db_adresse'), '</label><br/>', '<input type="text" name="adresse_db" value="', $contexte['adresse_db'], '" id="adresse_db" class="fondl" style="width:278px" tabindex="504"/>', '</p>'; echo '<p><label for="login_db" style="font-weight:bold;cursor:pointer">', _T('galettonuts:entree_db_login'), '</label><br/>', '<input type="text" name="login_db" value="', $contexte['login_db'], '" id="login_db" class="fondl" style="width:278px" tabindex="508"/>', '</p>'; echo '<p><label for="pass_db" style="font-weight:bold;cursor:pointer">', _T('galettonuts:entree_db_mdp'), '</label><br/>', '<input type="password" name="pass_db" value="', $contexte['pass_db'], '" id="pass_db" class="fondl" style="width:278px" tabindex="512"/>', '</p>'; echo '<p><label for="prefix_db" style="font-weight:bold;cursor:pointer">', _T('galettonuts:entree_db_prefix'), '</label><br/>', '<input type="text" name="prefix_db" value="', $contexte['prefix_db'], '" id="prefix_db" class="fondl" style="width:278px" tabindex="516"/>', '</p>'; echo '<p><label for="choix_db" style="font-weight:bold;cursor:pointer">', _T('galettonuts:entree_db_choix'), '</label><br/>', '<input type="text" name="choix_db" value="', $contexte['choix_db'], '" id="choix_db" class="fondl" style="width:278px" tabindex="520"/>', '</p>'; fin_cadre_couleur(); echo '</div>'; echo '<div style="text-align:right;padding:0 2px;margin-top:.5em" id="buttons">', '<input type="submit" name="_galettonuts_ok" value="', _T('bouton_valider'), '" class="fondo" style="cursor:pointer" tabindex="560"/></div>'; fin_cadre_trait_couleur(); // Synchronisation automatique echo '<br />'; debut_cadre_relief('synchro-24.gif', false, '', _T('galettonuts:info_cron')); echo '<p class="verdana2">', _T('galettonuts:texte_info_cron'), '</p>'; echo '<p class="verdana2">', '<label', $activer_cron ? ' style="font-weight:bold"' : '', '>', '<input type="radio" name="activer_cron" value="oui" id="activer_cron_oui" tabindex="602" ', $activer_cron ? ' checked="checked" ' : '', 'onclick="changeVisible(this.checked, \'config-cron\', \'block\', \'none\');"', '/>', _T('galettonuts:entree_cron_utiliser'), '</label><br />', '<label', !$activer_cron ? ' style="font-weight:bold"' : '', '>', '<input type="radio" name="activer_cron" value="non" id="activer_cron_non" tabindex="604" ', !$activer_cron ? ' checked="checked" ' : '', 'onclick="changeVisible(this.checked, \'config-cron\', \'none\', \'block\');"', '/>', _T('galettonuts:entree_cron_utiliser_non'), '</label>', '</p>'; echo '<div id="config-cron"', !$activer_cron ? ' style="display:none"' : '', '><hr />'; echo '<p class="verdana2">', _T('galettonuts:frequence'), '</p>'; echo '<p class="verdana2" style="text-align:center">', '<input type="text" name="heures" value="', $contexte['heures'], '" id="cron_heures" size="2" maxlength="2" tabindex="606" class="fondl" style="text-align:right"/>', '<label for="cron_heures" style="font-weight:bold;cursor:pointer">', _T('galettonuts:heures'), '</label>', '<input type="text" name="minutes" value="', $contexte['minutes'], '" id="cron_minutes" size="2" maxlength="2" tabindex="606" class="fondl" style="text-align:right"/>', '<label for="cron_minutes" style="font-weight:bold;cursor:pointer">', _T('galettonuts:minutes'), '</label>', '</p>'; echo '</div>'; echo '<div style="text-align:right;padding:0 2px;margin-top:.5em" id="buttons">', '<input type="submit" name="_galettonuts_ok" value="', _T('bouton_valider'), '" class="fondo" style="cursor:pointer" tabindex="660"/></div>'; fin_cadre_relief(); // Liaison avec le plugin Accès restreint if (defined('_DIR_PLUGIN_ACCESRESTREINT')) { $zones = spip_query("SELECT `id_zone`, `titre`, `descriptif` FROM `spip_zones` WHERE 1;"); if (spip_num_rows($zones)) { global $couleur_foncee; $i = 0; $zone['num'] = _T('accesrestreint:colonne_id'); $zone['titre'] = _T('accesrestreint:titre'); $zone['descriptif'] = _T('accesrestreint:descriptif'); $tabindex = 700; $tab_zones = <<<HTML <table class="arial2" border="0" cellpadding="2" cellspacing="0" style="width:100%;border:1px solid #AAA;"> <thead> <tr style="background-color:{$couleur_foncee};color:#fff;font-weight=bold"> <th scope="col" style="text-align:left;padding-left:5px;padding-right:5px" width="40">{$zone['num']}</th> <th scope="col" style="text-align:left;border-left:1px inset #fff;padding-left:5px;padding-right:5px">{$zone['titre']}</th> <th scope="col" style="text-align:left;border-left:1px inset #fff;padding-left:5px;padding-right:5px">{$zone['descriptif']}</th> <th scope="col" style="text-align:center;border-left:1px inset #fff;padding-left:5px;padding-right:5px" width="16"> </th> </tr> </thead> <tbody> HTML; while ($zone = spip_fetch_array($zones)) { ++$tabindex; $bgcolor = alterner(++$i, '#FEFEFE', '#EEE'); if (array_key_exists('zones', $contexte)) { $checked = in_array($zone['id_zone'], $contexte['zones']) ? ' checked="checked"' : ''; } else { $checked = ''; } $tab_zones .= <<<HTML <tr style="background-color:{$bgcolor}"> <td style="text-align:left;padding-left:5px;padding-right:5px">{$zone['id_zone']}</td> <td style="text-align:left;padding-left:5px;padding-right:5px">{$zone['titre']}</td> <td style="text-align:left;padding-left:5px;padding-right:5px">{$zone['descriptif']}</td> <td style="text-align:center"> <input type="checkbox" name="zones[]" value="{$zone['id_zone']}" class="fondl" tabindex="{$tabindex}"{$checked} /> </td> </tr> HTML; } $tab_zones .= '</tbody></table>'; echo '<br />'; debut_cadre_relief(_DIR_PLUGIN_ACCESRESTREINT . 'img_pack/zones-acces-24.gif', false, '', _T('galettonuts:info_liaison_access_restreint')); echo '<p class="verdana2">', _T('galettonuts:texte_liaison_access_restreint_1'), '</p>'; echo '<p class="verdana2">', _T('galettonuts:texte_liaison_access_restreint_2'), '</p>'; echo $tab_zones; echo '<div style="text-align:right;padding:0 2px;margin-top:.5em" id="buttons">', '<input type="submit" name="_galettonuts_ok" value="', _T('bouton_valider'), '" class="fondo" style="cursor:pointer" tabindex="760"/></div>'; fin_cadre_relief(); } } echo '</form>'; // Fin de page echo fin_gauche() . fin_page(); // }}} }
function balise_SMILEYS_dist($p) { // Fonctions abandonnees par le plugin Porte Plume $js_compat = !defined('_DIR_PLUGIN_PORTE_PLUME')?"":"<script type=\"text/javascript\">/*<![CDATA[*/ // From SPIP 2.0 (spip_barre.js) if(typeof barre_inserer!='function') { function barre_inserer(text,champ) { var txtarea = champ; if(document.selection){ txtarea.focus(); var r = document.selection.createRange(); if (r == null) { txtarea.selectionStart = txtarea.value.length; txtarea.selectionEnd = txtarea.selectionStart; } else { var re = txtarea.createTextRange(); var rc = re.duplicate(); re.moveToBookmark(r.getBookmark()); rc.setEndPoint('EndToStart', re); txtarea.selectionStart = rc.text.length; txtarea.selectionEnd = rc.text.length + r.text.length; } } mozWrap(txtarea, '', text); }} // From http://www.massless.org/mozedit/ if(typeof mozWrap!='function') { function mozWrap(txtarea, open, close) { var selLength = txtarea.textLength; var selStart = txtarea.selectionStart; var selEnd = txtarea.selectionEnd; if (selEnd == 1 || selEnd == 2) selEnd = selLength; var selTop = txtarea.scrollTop; // Raccourcir la selection par double-clic si dernier caractere est espace if (selEnd - selStart > 0 && (txtarea.value).substring(selEnd-1,selEnd) == ' ') selEnd = selEnd-1; var s1 = (txtarea.value).substring(0,selStart); var s2 = (txtarea.value).substring(selStart, selEnd) var s3 = (txtarea.value).substring(selEnd, selLength); txtarea.value = s1 + open + s2 + close + s3; selDeb = selStart + open.length; selFin = selEnd + close.length; window.setSelectionRange(txtarea, selDeb, selFin); txtarea.scrollTop = selTop; txtarea.focus(); return; }} /*]]>*/</script>\n"; // le tableau des smileys est present dans les metas $smileys = cs_lire_data_outil('smileys');; // valeurs par defaut $nb_col = 8; $titre = _T('couteau:smileys_dispos'); $head = ''; $liens = false; // traitement des arguments : [(#SMILEYS{arg1, arg2, ...})] $n=1; $arg = interprete_argument_balise($n++,$p); while ($arg){ // un nombre est le nombre de colonne if (preg_match(",'([0-9]+)',", $arg, $reg)) $nb_col = intval($reg[1]); // on veut un titre elseif ($arg=="'titre'") $head = "<thead><tr class=\"row_first\"><td colspan=\"$nb_col\">$titre</td></tr></thead>"; // on veut un lien d'insertion sur chaque smiley elseif ($arg=="'liens'") { $liens = true; include_spip('outils/smileys'); $smileys = smileys_uniques($smileys); } $arg = interprete_argument_balise($n++,$p); } $max = count($smileys[0]); if (!$nb_col) $nb_col = $max; $html = "<table summary=\"$titre\" class=\"spip cs_smileys smileys\">$head"; $l = 1; for ($i=0; $i<$max; $i++) { if ($i % $nb_col == 0) { $class = 'row_'.alterner($l++, 'even', 'odd'); $html .= "<tr class=\"$class\">"; } $html .= $liens ?"<td><a href=\"javascript:barre_inserer('{$smileys[0][$i]}',document.getElementById('".(defined('_SPIP19300')?'texte':'textarea_1')."'))\">{$smileys[1][$i]}</a></td>" :"<td>{$smileys[1][$i]}<br />{$smileys[0][$i]}</td>"; if ($i % $nb_col == $nb_col - 1) $html .= "</tr>\n"; } // on finit la ligne qd meme... if ($i = $max % $nb_col) $html .= str_repeat('<td> </td>', $nb_col - $i) . '</tr>'; // accessibilite : alt et title avec le smiley en texte $html = $js_compat . echappe_retour($html, 'SMILE'); $html = str_replace("'", "\'", $html); $p->code = "'$html\n</table>\n'"; $p->interdire_scripts = false; $p->type = 'html'; return $p; }
function http_message_avec_participants($id_message, $statut, $forcer_dest, $cherche_auteur, $expediteur='') { global $connect_id_auteur ; if ($cherche_auteur) { echo "\n<div style='text-align: left' class='cadre-info'>" . http_auteurs_ressemblants($cherche_auteur , $id_message) . "\n</div>"; } $bouton = bouton_block_depliable(_T('info_nombre_partcipants'),true,"auteurs,ajouter_auteur"); echo debut_cadre_enfonce("redacteurs-24.gif", true, '', $bouton, 'participants'); // // Liste des participants // $result = sql_allfetsel("*", "spip_auteurs AS auteurs, spip_auteurs_messages AS lien", "lien.id_message=$id_message AND lien.id_auteur=auteurs.id_auteur"); $total_dest = count($result); if ($total_dest > 0) { $ifond = 0; $res = ''; $formater_auteur = charger_fonction('formater_auteur', 'inc'); $t = _T('lien_retrait_particpant'); foreach($result as $k => $row) { $id_auteur = $row["id_auteur"]; list($status, $mail, $nom, $site,) = $formater_auteur($id_auteur, $row); if ($id_auteur == $expediteur) { $nom = "<span class='arial0' style='margin-left: 10px'>" . _T('info_auteur_message') . "</span> $nom"; } $class = alterner (++$ifond,'row_even','row_odd'); $res .= "<tr class='$class'>\n<td class='nom'>$status $mail $nom $site$exp</td>" . "\n<td align='right' class='lien'>" . (($id_auteur == $connect_id_auteur) ? " " : ("[<a href='" . redirige_action_auteur("editer_message","$id_message/-$id_auteur", 'message', "id_message=$id_message") . "'>$t</a>]")) . "</td></tr>\n"; $result[$k] = $id_auteur; } echo debut_block_depliable(true,"auteurs"), "\n<table class='spip' width='100%'>", $res, "</table>\n", fin_block(); } if ($statut == 'redac' OR $forcer_dest) echo http_ajouter_participants($result, $id_message); else { echo debut_block_depliable(true,"ajouter_auteur"), "<br />\n<div style='text-align: right' class='verdana1 spip_small'><a href='" . generer_url_ecrire("message","id_message=$id_message&forcer_dest=oui") . "'>"._T('lien_ajouter_participant')."</a></div>", fin_block(); } echo fin_cadre_enfonce(true); return $total_dest; }
function valider_resultats($res, $mode) { $i = $j = $k = 0; $table = ''; rsort($res); foreach($res as $l) { $i++; $class = 'row_'.alterner($i, 'even', 'odd'); list($nb, $texte, $erreurs, $script, $appel, $temps) = $l; if ($texte < 0) { $texte = (0- $texte); $color = ";color: red"; } else {$color = '';} $err = (!intval($nb)) ? '' : ($erreurs[0][0] . ' ' . _T('ligne') . ' ' . $erreurs[0][1] .($nb==1? '': ' ...')); if ($err) {$j++; $k+= $nb;} $h = $mode ? ($appel . '&var_mode=debug&var_mode_affiche=validation') : generer_url_ecrire('valider_xml', "var_url=" . urlencode($appel)); $table .= "<tr class='$class'>" . "<td style='text-align: right'>$nb</td>" . "<td style='text-align: right$color'>$texte</td>" . "<td style='text-align: right'>$temps</td>" . "<td style='text-align: left'>$err</td>" . "<td><a href='$h' title='$appel'>$script</a></td>"; } return array($j, $k, "<table class='spip' width='95%'>" . "<tr><th>" . _T('erreur_texte') . "</th><th>" . _T('taille_octets', array('taille' => ' ')) . "</th><th>" . _T('zbug_profile', array('time' =>'')) . "</th><th>" . _T('public:message') . "</th><th>" . _T('ecrire:info_url') . "</th></tr>" . $table . "</table>"); }
function afficher_raccourcis($module = "public") { global $spip_lang; charger_langue($spip_lang, $module); $tableau = $GLOBALS['i18n_' . $module . '_' . $spip_lang]; ksort($tableau); $aff_nom_module= ""; if ($module != "public" AND $module != "local") $aff_nom_module = "$module:"; echo "<div class='arial2'>"._T('module_texte_explicatif')."</div>"; echo "<div> </div>"; foreach (preg_files(repertoire_lang().$module.'_[a-z_]+\.php[3]?$') as $f) if (preg_match(",^".$module."\_([a-z_]+)\.php[3]?$,", $f, $regs)) $langue_module[$regs[1]] = traduire_nom_langue($regs[1]); if (isset($langue_module) && ($langue_module)) { ksort($langue_module); echo "<div class='arial2'>"._T('module_texte_traduction', array('module' => $module)); echo " ".join(", ", $langue_module)."."; echo "</div><div> </div>"; } echo debut_cadre_relief('',true,'','','raccourcis'); echo "\n<table class='spip' style='border:0;'>"; echo "\n<tr class='titrem'><th class='verdana1'>"._T('module_raccourci')."</th>\n<th class='verdana2'>"._T('module_texte_affiche')."</th></tr>\n"; $i = 0; foreach ($tableau as $raccourci => $val) { $bgcolor = alterner(++$i, 'row_even','row_odd'); echo "\n<tr class='$bgcolor'><td class='verdana2'><b><:$aff_nom_module$raccourci:></b></td>\n<td class='arial2'>".$val."</td></tr>"; } echo "</table>",fin_cadre_relief(true); }
function saisie_langues_utiles($name, $selection) { include_spip('inc/lang_liste'); $langues = $GLOBALS['codes_langues']; $langues_installees = explode(',', $GLOBALS['meta']['langues_proposees']); $langues_trad = array_flip($langues_installees); $langues_bloquees = explode(',', $GLOBALS['meta']['langues_utilisees']); $res = ""; $i = 0; foreach ($langues_bloquees as $code_langue) { $nom_langue = $langues[$code_langue]; $res .= "<li class='choix " . alterner(++$i, 'odd', 'even') . (isset($langues_trad[$code_langue]) ? " traduite" : "") . "'>" . "<input type='hidden' name='{$name}[]' value='{$code_langue}'>" . "<input type='checkbox' name='{$name}[]' id='{$name}_{$code_langue}' value='{$code_langue}' checked='checked' disabled='disabled' />" . "<label for='{$name}_{$code_langue}'>" . $nom_langue . " <span class='code_langue'>[{$code_langue}]</span></label>" . "</li>"; } if ($res) { $res = "<ul id='langues_bloquees'>" . $res . "</ul><div class='nettoyeur'></div>"; } $res .= "<ul id='langues_proposees'>"; $i = 0; $langues_bloquees = array_flip($langues_bloquees); foreach ($langues as $code_langue => $nom_langue) { if (!isset($langues_bloquees[$code_langue])) { $checked = in_array($code_langue, $selection) ? ' checked="checked"' : ''; $res .= "<li class='choix " . alterner(++$i, 'odd', 'even') . (isset($langues_trad[$code_langue]) ? " traduite" : "") . "'>" . "<input type='checkbox' name='{$name}[]' id='{$name}_{$code_langue}' value='{$code_langue}'" . $checked . "/>" . "<label for='{$name}_{$code_langue}'" . ($checked ? " class='on'" : "") . ">" . $nom_langue . " <span class='code_langue'>[{$code_langue}]</span></label>" . "</li>"; } } $res .= "</ul><div class='nettoyeur'></div>"; return $res; }
function traiter_tableau($bloc) { // Decouper le tableau en lignes preg_match_all(',([|].*)[|]\n,UmsS', $bloc, $regs, PREG_PATTERN_ORDER); $lignes = array(); $debut_table = $summary = ''; $l = 0; $numeric = true; // Traiter chaque ligne $reg_line1 = ',^(\|(' . _RACCOURCI_TH_SPAN . '))+$,sS'; $reg_line_all = ',^' . _RACCOURCI_TH_SPAN . '$,sS'; $num_cols = 0; foreach ($regs[1] as $ligne) { $l ++; // Gestion de la premiere ligne : if (($l == 1) AND preg_match(_RACCOURCI_CAPTION, rtrim($ligne,'|'), $cap)) { // - <caption> et summary dans la premiere ligne : // || caption | summary || (|summary est optionnel) $l = 0; if ($caption = trim($cap[1])) $debut_table .= "<caption>".$caption."</caption>\n"; $summary = ' summary="'.entites_html(trim($cap[3])).'"'; } else { // - <th> sous la forme |{{titre}}|{{titre}}| if (preg_match($reg_line1, $ligne)) { preg_match_all('/\|([^|]*)/S', $ligne, $cols); $ligne='';$cols= $cols[1]; $colspan=1; $num_cols = count($cols); for($c=$num_cols-1; $c>=0; $c--) { $attr=''; if($cols[$c]=='<') { $colspan++; } else { if ($colspan>1) { $attr= " colspan='$colspan'"; $colspan=1; } // inutile de garder le strong qui n'a servi que de marqueur $cols[$c] = str_replace(array('{','}'), '', $cols[$c]); $ligne= "<th scope='col'$attr>$cols[$c]</th>$ligne"; } } $lignes[] = $ligne; } else { // Sinon ligne normale // Gerer les listes a puce dans les cellules if (strpos($ligne,"\n-*")!==false OR strpos($ligne,"\n-#")!==false) $ligne = traiter_listes($ligne); // Pas de paragraphes dans les cellules $ligne = preg_replace("/\n{2,}/", "<br /><br />\n", $ligne); // tout mettre dans un tableau 2d preg_match_all('/\|([^|]*)/S', $ligne, $cols); $lignes[]= $cols[1]; } } } // maintenant qu'on a toutes les cellules // on prepare une liste de rowspan par defaut, a partir // du nombre de colonnes dans la premiere ligne. // Reperer egalement les colonnes numeriques pour les cadrer a droite $rowspans = $numeric = array(); $n = $num_cols ? $num_cols : count($lignes[0]); $k = count($lignes); // distinguer les colonnes numeriques a point ou a virgule, // pour les alignements eventuels sur "," ou "." $numeric_class = array('.'=>'point',','=>'virgule'); for($i=0;$i<$n;$i++) { $align = true; for ($j=0;$j<$k;$j++) $rowspans[$j][$i] = 1; for ($j=0;$j<$k;$j++) { if (!is_array($lignes[$j])) continue; // cas du th $cell = trim($lignes[$j][$i]); if (preg_match($reg_line_all, $cell)) { if (!preg_match('/^[+-]?(?:\s|\d)*([.,]?)\d*$/', $cell, $r)) { $align = ''; break;} else if ($r[1]) $align = $r[1]; } } $numeric[$i] = !$align ? '' : (" class='numeric ".$numeric_class[$align]."'"); } // et on parcourt le tableau a l'envers pour ramasser les // colspan et rowspan en passant $html = ''; for($l=count($lignes)-1; $l>=0; $l--) { $cols= $lignes[$l]; if (!is_array($cols)) { $class = 'first'; $ligne = $cols; } else { $ligne=''; $colspan=1; $class = alterner($l+1, 'even', 'odd'); for($c=count($cols)-1; $c>=0; $c--) { $attr= $numeric[$c]; $cell = trim($cols[$c]); if($cell=='<') { $colspan++; } elseif($cell=='^') { $rowspans[$l-1][$c]+=$rowspans[$l][$c]; } else { if($colspan>1) { $attr .= " colspan='$colspan'"; $colspan=1; } if(($x=$rowspans[$l][$c])>1) { $attr.= " rowspan='$x'"; } $ligne= "\n<td".$attr.'>'.$cols[$c].'</td>'.$ligne; } } } $html = "<tr class='row_$class'>$ligne</tr>\n$html"; } if (_RACCOURCI_THEAD AND preg_match("@^(<tr class='row_first'.*?</tr>)(.*)$@s", $html, $m)) $html = "<thead>$m[1]</thead>\n<tbody>$m[2]</tbody>\n"; return "\n\n<table".$GLOBALS['class_spip_plus'].$summary.">\n" . $debut_table . $html . "</table>\n\n"; }
function admin_sauvegardes($dir_dump, $tri) { $liste_dump = preg_files(_DIR_DUMP,'\.xml(\.gz)?$',50,false); $selected = end($liste_dump); $n = strlen(_DIR_DUMP); $tl = $tt = $td = array(); $f = ""; $i = 0; foreach($liste_dump as $fichier){ $i++; $d = filemtime($fichier); $t = filesize($fichier); $s = ($fichier==$selected); $class = 'row_'.alterner($i, 'even', 'odd'); $fichier = substr($fichier, $n); $tl[]= liste_sauvegardes($i, $fichier, $class, $s, $d, $t); $td[] = $d; $tt[] = $t; } if ($tri == 'taille') array_multisort($tt, SORT_ASC, $tl); elseif ($tri == 'date') array_multisort($td, SORT_ASC, $tl); $fichier_defaut = $f ? basename($f) : str_replace(array("@stamp@","@nom_site@"),array("",""),_SPIP_DUMP); $self = self(); $class = 'row_'.alterner($i+1, 'even', 'odd'); $head = !$tl ? '' : ( "\n<tr>" . '<th></th><th><a href="' . parametre_url($self, 'tri', 'nom') . '#sauvegardes">' . _T('info_nom') . "</a></th>\n" . '<th><a href="' . parametre_url($self, 'tri', 'taille') . '#sauvegardes">' . _T('taille_octets', array('taille' => '')) . "</a></th>\n" . '<th><a href="' . parametre_url($self, 'tri', 'date') . '#sauvegardes">' . _T('public:date') . '</a></th></tr>'); $texte = _T('texte_compresse_ou_non')." "; $h = _T('texte_restaurer_sauvegarde', array('dossier' => '<i>'.$dir_dump.'</i>')); $res = "\n<p style='text-align: justify;'> " . $h . '</p>' . _T('entree_nom_fichier', array('texte_compresse' => $texte)) . "\n<br /><br /><table class='spip' id='sauvegardes'>" . $head . join('',$tl) . "\n<tr class='$class'><td><input type='radio' name='archive' id='archive' value='' /></td><td colspan='3'>" . "\n<span class='spip_x-small'><input type='text' name='archive_perso' id='archive_perso' value='$fichier_defaut' size='55' /></span></td></tr>" . '</table>'; $plie = _T('info_options_avancees'); // restauration partielle / fusion $opt = debut_cadre_enfonce('',true) . "\n<div>" . "<input name='insertion' id='insertion' type='checkbox' /> <label for='insertion'>". _T('sauvegarde_fusionner') . "</label><br />\n" . "<input name='statut' id='statut' type='checkbox' /> <label for='statut'>\n". _T('sauvegarde_fusionner_depublier') . "</label><br />\n" . "<label for='url_site'>" . _T('sauvegarde_url_origine') . "</label>" . " \n<input name='url_site' id='url_site' type='text' size='25' />" . '</div>' . fin_cadre_enfonce(true); $res .= block_parfois_visible('import_tables', $plie, $opt, '', false); return generer_form_ecrire('import_all', $res, '', _T('bouton_restaurer_base')); }