Skip to content
Extraits de code Groupes Projets
Valider 49f98d2f rédigé par cerdic's avatar cerdic
Parcourir les fichiers

nettoyage de editer_auteurs qui fait simplement un appel au...

nettoyage de editer_auteurs qui fait simplement un appel au #FORMULAIRE_EDITER_LIENS avec les bons arguments.
Fonctionnelement, on perd la recherche par ressemblance, car on s'appuie maintenant sur {recherche} dans une boucle, 
mais c'est plutot une fonctionnalite generique de recherche qu'il faudrait implementer comme telle.
parent d040f921
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -16,7 +16,6 @@ ecrire/action/desinstaller_plugin.php -text ...@@ -16,7 +16,6 @@ ecrire/action/desinstaller_plugin.php -text
ecrire/action/documenter.php -text ecrire/action/documenter.php -text
ecrire/action/editer_article.php -text ecrire/action/editer_article.php -text
ecrire/action/editer_auteur.php -text ecrire/action/editer_auteur.php -text
ecrire/action/editer_auteurs.php -text
ecrire/action/editer_liens.php -text ecrire/action/editer_liens.php -text
ecrire/action/editer_message.php -text ecrire/action/editer_message.php -text
ecrire/action/editer_rubrique.php -text ecrire/action/editer_rubrique.php -text
...@@ -99,7 +98,6 @@ ecrire/exec/demande_mise_a_jour.php -text ...@@ -99,7 +98,6 @@ ecrire/exec/demande_mise_a_jour.php -text
ecrire/exec/documenter.php -text ecrire/exec/documenter.php -text
ecrire/exec/documents_colonne.php -text ecrire/exec/documents_colonne.php -text
ecrire/exec/documents_liste.php -text ecrire/exec/documents_liste.php -text
ecrire/exec/editer_auteurs.php -text
ecrire/exec/fond.php -text ecrire/exec/fond.php -text
ecrire/exec/fond_monobloc.php -text ecrire/exec/fond_monobloc.php -text
ecrire/exec/index.php -text ecrire/exec/index.php -text
......
<?php
/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
* Copyright (c) 2001-2010 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) return;
// http://doc.spip.org/@action_editer_auteurs_dist
function action_editer_auteurs_dist() {
$securiser_action = charger_fonction('securiser_action', 'inc');
$arg = $securiser_action();
$redirect = urldecode(_request('redirect'));
if ($script = _request('script'))
$redirect = parametre_url($redirect,'script',$script,'&');
if ($titre = _request('titre'))
$redirect = parametre_url($redirect,'titre',$titre,'&');
if (preg_match(",^\W*(\d+)\W(\w*)\W-(\d+)$,", $arg, $r)) {
supprimer_auteur_et_rediriger($r[2], $r[1], $r[3], parametre_url($redirect,'type',$r[2],'&'));
}
elseif (preg_match(",^\W*(\d+)\W(\w*)\W(\d+)$,", $arg, $r)) {
ajouter_auteur_et_rediriger($r[2], $r[1], $r[3], parametre_url($redirect,'type',$r[2],'&'));
}
elseif (preg_match(",^\W*(\d+)\W(\w*)$,", $arg, $r)) {
list(,$id, $type) = $r;
$idom = "auteur_$type" . "_$id" . '_new';
$nouv_auteur = intval(_request($idom));
if ($nouv_auteur) {
ajouter_auteur_et_rediriger($type, $id, $nouv_auteur, parametre_url($redirect,'type',$type,'&'));
} else if ($cherche = _request('cherche_auteur')) {
if ($p = strpos($redirect, '#')) {
$ancre = substr($redirect,$p);
$redirect = substr($redirect,0,$p);
} else $ancre ='';
$redirect = parametre_url($redirect,'type',$type,'&');
$res = rechercher_auteurs($cherche);
$n = count($res);
if ($n == 1)
# Bingo. Signaler le choix fait.
ajouter_auteur_et_rediriger($type, $id, $res[0], "$redirect&ids=" . $res[0] . "&cherche_auteur=" . rawurlencode($cherche) . $ancre);
# Trop vague. Le signaler.
elseif ($n > 16)
redirige_par_entete("$redirect&cherche_auteur=$cherche&ids=-1" . $ancre);
elseif (!$n)
# Recherche vide (mais faite). Le signaler
redirige_par_entete("$redirect&cherche_auteur=$cherche&ids=" . $ancre);
else
# renvoyer un formulaire de choix
redirige_par_entete("$redirect&cherche_auteur=$cherche&ids=" . join(',',$res) . $ancre);
} else {
include_spip('inc/actions');
ajax_retour("action_editer_auteur: $arg faux");exit;
}
} else spip_log("action_editer_auteur: $arg pas compris");
}
// http://doc.spip.org/@supprimer_auteur_et_rediriger
function supprimer_auteur_et_rediriger($type, $id, $id_auteur, $redirect)
{
$jointure = table_jointure('auteur', $type);
if (preg_match(',^[a-z]*$,',$type)){
sql_delete("spip_{$jointure}", "id_auteur=".sql_quote($id_auteur)." AND id_{$type}=".sql_quote($id));
// Notifications, gestion des revisions, reindexation...
pipeline('post_edition',
array(
'args' => array(
'operation' => 'supprimer_auteur',
'table' => table_objet_sql($type),
'id_objet' => $id
),
'data' => null
)
);
}
if ($redirect) redirige_par_entete($redirect);
}
// http://doc.spip.org/@ajouter_auteur_et_rediriger
function ajouter_auteur_et_rediriger($type, $id, $id_auteur, $redirect)
{
$jointure = table_jointure('auteur', $type);
if (preg_match(',^[a-z]*$,',$type)){
$res = sql_fetsel("id_$type", "spip_{$jointure}", "id_auteur=" . sql_quote($id_auteur) . " AND id_{$type}=" . $id);
if (!$res) {
sql_insertq("spip_{$jointure}",
array('id_auteur' => $id_auteur,
"id_$type" => $id));
}
// Notifications, gestion des revisions, reindexation...
pipeline('post_edition',
array(
'args' => array(
'operation' => 'ajouter_auteur',
'table' => table_objet_sql($type),
'id_objet' => $id
),
'data' => null
)
);
}
if ($redirect) redirige_par_entete($redirect);
}
// http://doc.spip.org/@rechercher_auteurs
function rechercher_auteurs($cherche_auteur)
{
include_spip('inc/ressembler');
include_spip('inc/charsets'); // pour tranlitteration
$result = sql_select("id_auteur, nom", "spip_auteurs");
$table_auteurs = array();
$table_ids = array();
while ($row = sql_fetch($result)) {
$table_auteurs[] = $row["nom"];
$table_ids[] = $row["id_auteur"];
}
return mots_ressemblants($cherche_auteur, $table_auteurs, $table_ids);
}
?>
<?php
/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
* Copyright (c) 2001-2010 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) return;
// http://doc.spip.org/@exec_editer_auteurs_dist
function exec_editer_auteurs_dist()
{
$type = _request('type');
if (!preg_match(',^[a-z]+$,',$type)) // securite et a defaut on assure le fonctionnement pour articles
$type = 'article';
$id = intval(_request("id_$type"));
if (! autoriser('modifier',$type,$id)) {
include_spip('inc/minipres');
echo minipres();
} else {
$script = _request('script');
$titre = ($titre=_request('titre'))?urldecode($titre):$titre;
$editer_auteurs = charger_fonction('editer_auteurs', 'inc');
include_spip('inc/actions');
ajax_retour($editer_auteurs($type, $id, 'ajax', _request('cherche_auteur'), _request('ids'),$titre,$script));
}
}
?>
...@@ -21,286 +21,8 @@ define('_SPIP_SELECT_MAX_AUTEURS', 30); // au-dessus: saisie + return ...@@ -21,286 +21,8 @@ define('_SPIP_SELECT_MAX_AUTEURS', 30); // au-dessus: saisie + return
// http://doc.spip.org/@inc_editer_auteurs_dist // http://doc.spip.org/@inc_editer_auteurs_dist
function inc_editer_auteurs_dist($type, $id, $flag, $cherche_auteur, $ids, $titre_boite = NULL, $script_edit_objet = NULL) { function inc_editer_auteurs_dist($type, $id, $flag, $cherche_auteur, $ids, $titre_boite = NULL, $script_edit_objet = NULL) {
$arg_ajax = "&id_{$type}=$id&type=$type";
if ($script_edit_objet===NULL) $script_edit_objet = $type.'s';
if ($titre_boite===NULL)
$titre_boite = _T('texte_auteurs'). aide("artauteurs");
else
$arg_ajax.= "&titre=".urlencode($titre_boite);
$aff_les_auteurs = afficher_auteurs_objet($type, $id, $flag, '', $script_edit_objet, $arg_ajax);
if ($flag) {
$futurs = ajouter_auteurs_objet($type, $id, '',$script_edit_objet, $arg_ajax);
} else $futurs = '';
return return
recuperer_fond('prive/editer/liens',array('table_source'=>'auteurs','objet'=>$type,'id_objet'=>$id)) recuperer_fond('prive/editer/liens',array('table_source'=>'auteurs','objet'=>$type,'id_objet'=>$id));
#.
#editer_auteurs_objet($type, $id, $flag, $cherche_auteur, $ids, $aff_les_auteurs, $futurs, $dummy,$titre_boite,$script_edit_objet, $arg_ajax)
;
} }
// http://doc.spip.org/@editer_auteurs_objet
function editer_auteurs_objet($type, $id, $flag, $cherche_auteur, $ids, $les_auteurs, $futurs, $statut, $titre_boite,$script_edit_objet, $arg_ajax)
{
global $spip_lang_left, $spip_lang_right;
$bouton_creer_auteur = $GLOBALS['connect_toutes_rubriques'];
$clic = _T('icone_creer_auteur');
//
// complement de action/editer_auteurs.php pour notifier la recherche d'auteur
//
if ($cherche_auteur) {
$reponse ="<div style='text-align: $spip_lang_left'>"
. debut_boite_info(true)
. rechercher_auteurs_objet($cherche_auteur, $ids, $type, $id,$script_edit_objet, $arg_ajax);
if ($type=='article' && $bouton_creer_auteur) { // pas generique pour le moment
$legende = generer_url_ecrire("auteur_infos", "new=oui&lier_id_article=$id");
if (isset($cherche_auteur))
$legende = parametre_url($legende, 'nom', $cherche_auteur);
$legende = parametre_url($legende, 'redirect',
generer_url_ecrire('articles', "id_article=$id", '&'));
$reponse .="<div style='width: 200px;'>"
. icone_horizontale($clic, $legende, "auteur-24.png", "new", false)
. "</div> ";
$bouton_creer_auteur = false;
}
$reponse .= fin_boite_info(true)
. '</div>';
} else $reponse ='';
$reponse .= $les_auteurs;
//
// Ajouter un auteur
//
$res = '';
if ($flag) {
if ($type=='article' && $bouton_creer_auteur) { // pas generique pour le moment
$legende = generer_url_ecrire("auteur_infos", "new=oui&lier_id_article=$id");
if (isset($cherche_auteur))
$legende = parametre_url($legende, 'nom', $cherche_auteur);
$legende = parametre_url($legende, 'redirect',
generer_url_ecrire('articles', "id_article=$id", '&'));
$clic = "<span class='verdana1'><b>$clic</b></span>";
$res = icone_horizontale($clic, $legende, "auteur-24.png", "new", false);
}
$res = "<div style='float:$spip_lang_right; width:280px;position:relative;display:inline;'>"
. $futurs
."</div>\n"
. $res;
}
$idom = "auteurs_$type" . "_$id";
$bouton = bouton_block_depliable($titre_boite,$flag ?($flag === 'ajax'):-1,$idom);
$res = debut_cadre_enfonce("auteur-24.png", true, "", $bouton)
. $reponse
. debut_block_depliable($flag === 'ajax',$idom)
. $res
. fin_block()
. fin_cadre_enfonce(true);
return ajax_action_greffe("editer_auteurs", $id, $res);
}
// Retourne les auteurs attaches a l'objet $id de type $type
// ou rien s'il y en a trop
// http://doc.spip.org/@determiner_auteurs_objet
function determiner_auteurs_objet($type, $id, $cond='', $limit=200)
{
if (!preg_match(',^[a-z]*$,',$type)) return array();
$jointure = 'spip_' . table_jointure('auteur', $type);
$cond = "objet='{$type}' AND id_objet=".sql_quote($id) . ($cond ? " AND $cond" : '');
if (sql_countsel($jointure, $cond) > $limit)
return array();
else return array_map('array_shift', sql_allfetsel("id_auteur", $jointure, $cond));
}
// http://doc.spip.org/@determiner_non_auteurs
function determiner_non_auteurs($type, $id, $andcond='')
{
return auteurs_autorises(determiner_auteurs_objet($type, $id, $andcond));
}
// http://doc.spip.org/@rechercher_auteurs_objet
function rechercher_auteurs_objet($cherche_auteur, $ids, $type, $id, $script_edit_objet, $arg_ajax)
{
if (!$ids) {
return "<b>"._T('texte_aucun_resultat_auteur', array('cherche_auteur' => $cherche_auteur)).".</b><br />";
}
elseif ($ids == -1) {
return "<b>"._T('texte_trop_resultats_auteurs', array('cherche_auteur' => $cherche_auteur))."</b><br />";
}
elseif (preg_match('/^\d+$/',$ids)) {
$nom = sql_getfetsel("nom", "spip_auteurs", "id_auteur=$ids");
return "<b>"._T('texte_ajout_auteur')."</b><br /><ul><li><span class='verdana1 spip_small'><b><span class='spip_medium'>".typo($nom)."</span></b></span></li></ul>";
}
else {
$ids = preg_replace('/[^0-9,]/','',$ids); // securite
$result = sql_select("*", "spip_auteurs", "id_auteur IN ($ids)", "", "nom");
$res = "<b>"
. _T('texte_plusieurs_articles', array('cherche_auteur' => $cherche_auteur))
. "</b><br />"
. "<ul class='verdana1'>";
while ($row = sql_fetch($result)) {
$id_auteur = $row['id_auteur'];
$nom_auteur = $row['nom'];
$email_auteur = $row['email'];
$bio_auteur = $row['bio'];
$res .= "<li><b>".typo($nom_auteur)."</b>";
if ($email_auteur) $res .= " ($email_auteur)";
$res .= " | "
. ajax_action_auteur('editer_auteurs', "$id,$type,$id_auteur",$script_edit_objet,"id_{$type}=$id", array(_T('lien_ajouter_auteur')),$arg_ajax);
if (trim($bio_auteur)) {
$res .= "<br />".couper(propre($bio_auteur), 100)."\n";
}
$res .= "</li>\n";
}
$res .= "</ul>";
return $res;
}
}
// http://doc.spip.org/@afficher_auteurs_objet
function afficher_auteurs_objet($type, $id, $edit, $cond, $script, $arg_ajax)
{
$from = table_jointure('auteur', $type);
if (!$from) return '' ; // securite
$from = "spip_{$from}";
$where = "objet='{$type}' AND id_objet=".sql_quote($id) . ($cond ? " AND $cond" : '');
$presenter_liste = charger_fonction('presenter_liste', 'inc');
$requete = array('SELECT' => "id_auteur", 'FROM' => $from, 'WHERE' => $where);
$tmp_var = "editer_auteurs-$id";
$url = generer_url_ecrire('editer_auteurs',$arg_ajax);
// charger ici meme si pas d'auteurs
// car inc_formater_auteur peut aussi redefinir
// determiner_non_auteurs qui sert plus loin
if (!$formater = charger_fonction("formater_auteur_$type", 'inc',true))
$formater = charger_fonction('formater_auteur', 'inc');
$retirer = array(_T('lien_retirer_auteur')."&nbsp;". http_img_pack(chemin_image('supprimer-8.png'), "X", " class='puce' style='vertical-align: bottom;'"));
$styles = array(array('arial11', 14), array('arial2'), array('arial11'), array('arial11'), array('arial11'), array('arial1'));
$tableau = array(); // ne sert pas
$f = function_exists($edit) ? $edit : 'ajouter_auteur_un';
return $presenter_liste($requete, $f, $tableau, array($formater, $retirer, $arg_ajax, $edit, $id, $type, $script), false, $styles, $tmp_var, '','', $url);
}
// http://doc.spip.org/@ajouter_auteur_un
function ajouter_auteur_un($row, $own) {
global $connect_statut, $connect_id_auteur;
list($formater, $retirer, $arg_ajax, $flag, $id, $type, $script_edit) = $own;
$id_auteur = $row['id_auteur'];
$vals = $formater($id_auteur);
$voir = ($flag AND ($connect_id_auteur != $id_auteur OR $connect_statut == '0minirezo'));
if ($voir) {
$vals[] = ajax_action_auteur('editer_auteurs', "$id,$type,-$id_auteur", $script_edit, "id_{$type}=$id", $retirer, $arg_ajax);
} else $vals[] = "";
return $vals;
}
// http://doc.spip.org/@ajouter_auteurs_objet
function ajouter_auteurs_objet($type, $id, $cond_les_auteurs,$script_edit, $arg_ajax)
{
if (!$determiner_non_auteurs = charger_fonction('determiner_non_auteurs_'.$type,'inc',true))
$determiner_non_auteurs = 'determiner_non_auteurs';
$cond = $determiner_non_auteurs($type, $id, $cond_les_auteurs);
$all = objet_auteur_select($cond);
if (!$all) return '';
$idom = "auteur_$type" . "_$id";
$new = $idom . '_new';
$menu = $idom . '_sel';
$js = "findObj_forcer('$menu').style.visibility='visible';";
$text = "<span class='verdana1'><label for='$new'><b>"
. _T('titre_cadre_ajouter_auteur')
. "</b></label></span>\n";
if (!is_numeric($all)) {
$sel = "$text<select name='$new' id='$new' size='1' style='width:150px;' class='fondl' onchange=\"$js\">$all</select>";
$clic = _T('bouton_ajouter');
} else if ((_SPIP_AJAX < 1) OR ($all >= _SPIP_SELECT_MAX_AUTEURS)) {
$sel = "$text <input type='text' name='cherche_auteur' id='$new' onclick=\"$js\" class='fondl ' value='' size='20' />";
$clic = _T('bouton_chercher');
} else {
$sel = selecteur_auteur_ajax($type, $id, $js, $text, $idom);
$clic = _T('bouton_ajouter');
}
return ajax_action_post('editer_auteurs', "$id,$type", $script_edit, "id_{$type}=$id", $sel, $clic, " class='fondo visible_au_chargement' id='$menu'",'', $arg_ajax);
}
// http://doc.spip.org/@objet_auteur_select
function objet_auteur_select($cond)
{
$count = sql_countsel('spip_auteurs', $cond);
if (!$count) return '';
if ($count > _SPIP_SELECT_MIN_AUTEURS) return $count;
$statut_old = '';
$statuts = $GLOBALS['liste_des_statuts'];
$res = sql_allfetsel('*', 'spip_auteurs', $cond, '', "statut, nom");
foreach ($res as $k => $row) {
$statut = array_search($row["statut"], $statuts);
$id_auteur = $row["id_auteur"];
$email = $row["email"];
if (!autoriser('voir', 'auteur'))
if ($p = strpos($email, '@'))
$email = substr($email, 0, $p).'@...';
if ($email)
$email = " ($email)";
if ($statut != $statut_old) {
$opt = "</optgroup>\n<optgroup class='option_separateur_statut_auteur' label='" . _T($statut) . "'>";
$statut_old = $statut;
} else $opt = '';
$res[$k]= $opt
. "\n<option class='option_auteur' value='$id_auteur'>"
. supprimer_tags(couper(typo($row["nom"] . $email), 40))
. "</option>";
}
return "<optgroup label=''><option value='0'>"
. _T('bouton_choisir')
. '</option>'
. join('', $res)
. "\n</optgroup>";
}
// http://doc.spip.org/@selecteur_auteur_ajax
function selecteur_auteur_ajax($type, $id, $js, $text, $idom='')
{
include_spip('inc/chercher_rubrique');
$idom2 = $idom . '_new';
$idom1 = $idom . '_div';
$url = generer_url_ecrire('selectionner_auteur',"id_article=$id&type=$type");
return $text . construire_selecteur($url, $js, $idom1, $idom2, ' type="hidden"');
}
?> ?>
...@@ -72,6 +72,7 @@ $GLOBALS[$GLOBALS['idx_lang']] = array( ...@@ -72,6 +72,7 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
'bouton_effacer_tout' => 'Effacer TOUT', 'bouton_effacer_tout' => 'Effacer TOUT',
'bouton_envoi_message_02' => 'ENVOYER UN MESSAGE', 'bouton_envoi_message_02' => 'ENVOYER UN MESSAGE',
'bouton_envoyer_message' => 'Message d&eacute;finitif : envoyer', 'bouton_envoyer_message' => 'Message d&eacute;finitif : envoyer',
'bouton_fermer' => 'Fermer',
'bouton_forum_petition' => 'FORUM &amp; P&Eacute;TITION', 'bouton_forum_petition' => 'FORUM &amp; P&Eacute;TITION',
'bouton_modifier' => 'Modifier', 'bouton_modifier' => 'Modifier',
'bouton_pense_bete' => 'PENSE-B&Ecirc;TE &Agrave; USAGE PERSONNEL', 'bouton_pense_bete' => 'PENSE-B&Ecirc;TE &Agrave; USAGE PERSONNEL',
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter