106 lines
5.8 KiB
PHP
106 lines
5.8 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* Script affichant un formulaire permettant de modifier / supprimer un flux
|
||
|
* dont l'id a été passé en paramètre
|
||
|
* Peut être appelé en ajax ou directement en php si JS désactivé
|
||
|
*
|
||
|
**/
|
||
|
$ajax_on=false;
|
||
|
if(!empty($_GET["ajax"]))
|
||
|
{
|
||
|
$ajax_on=true;
|
||
|
session_save_path(SESSIONS_REP);
|
||
|
ini_set("session.use_only_cookies",1);
|
||
|
session_start();
|
||
|
header('Content-Type: text/html; charset=utf-8');
|
||
|
require_once("../modele/FclFlux_flux.php");
|
||
|
}
|
||
|
if($_SESSION["statut"]!="administrateur")
|
||
|
$msg_form[]=ERREUR_IMPREVUE;
|
||
|
else
|
||
|
{
|
||
|
$id_flux=intval(trim($_GET["id_flux"]));
|
||
|
if(empty($Bd))
|
||
|
require("../modele/connexion-bd.php");
|
||
|
$flux=FclFlux_flux::recherche($id_flux,"id_flux","nom,url,source_id,description,langue,frequence_maj,memo,time_lecture,nb_clics");
|
||
|
if(!empty($flux))
|
||
|
{
|
||
|
$form_html[0]["nom"]="Informations actuelles sur ce flux.";
|
||
|
$stats_txt="";
|
||
|
$flux_stats=new FclFlux_flux();
|
||
|
$flux_stats->id_flux=$id_flux;
|
||
|
$stats=$flux_stats->get_liste_abonnes();
|
||
|
if(!empty($stats))
|
||
|
$stats_txt="<br><strong>Ce flux compte ".count($stats["actifs"])." abonnés actifs, ".count($stats["inactifs"])." abonnements désactivés et ".count($stats["en_pause"])." abonnés en pause. Ses articles ont reçu ".$flux["nb_clics"]." clics.</strong>";
|
||
|
unset($flux_stats);unset($stats);
|
||
|
$form_html[0]["champs"]="<form method='post' id='maj_flux' name='maj_flux' action='".PAGE_MAJ_FLUX."?id_flux=$id_flux' role='form'>
|
||
|
<a href='".PAGE_REPERTOIRE_FLUX_INFO."$id_flux' title='Voir le flux' class='btn btn-info btn-sm' target='_blank'>Voir le flux.</a>";
|
||
|
// désignation de la source ?
|
||
|
if(!empty($flux["source_id"]))
|
||
|
{
|
||
|
$source=FclFlux_source::recherche($flux["source_id"],"nom,id_source");
|
||
|
if(!empty($source["nom"]))
|
||
|
$form_html[0]["champs"].="<p>Site propriétaire du flux : <a href='".PAGE_MAJ_SOURCE."?id_source=".$source["id_source"]."' target='_blank' title='+ infos sur ce site'>".$source["nom"]."</a> (dernière importation : ".date("d/m/Y à h:m:s",$flux["time_lecture"]).").$stats_txt</p>";
|
||
|
}
|
||
|
$form_html[0]["champs"].="<div class='form-group'>
|
||
|
<label for='cherche_source'>Changer le site propriétaire ? alors saisissez votre recherche :</label>
|
||
|
<input class='form-control' type='text' maxlength='20' name='cherche_source' id='cherche_source'>
|
||
|
</div>
|
||
|
<div id='sup_sources'>";
|
||
|
if(!empty($source["id_source"]))
|
||
|
$form_html[0]["champs"].="<input type='hidden' value='".$source["id_source"]."' name='source_id'>";
|
||
|
$form_html[0]["champs"].="</div>
|
||
|
<div class='form-group'>
|
||
|
<label for='designation'>Titre.</label>
|
||
|
<input class='form-control' type='text' maxlength='".FLUX_MAX_NOM."' name='designation' id='nom' value=\"".htmlspecialchars($flux["nom"])."\" required>
|
||
|
<p class='help-block'><b>Obligatoire</b>.</p>
|
||
|
</div>
|
||
|
<div class='form-group'>
|
||
|
<label for='url'>Adresse.</label>
|
||
|
<input class='form-control' type='url' maxlength='".FLUX_MAX_URL."' name='url' id='url' value=\"".$flux["url"]."\" required>
|
||
|
<p class='help-block'><b>Obligatoire</b>. L'adresse complète du flux dont la lecture sera testée au moment de l'enregistrement.</p>
|
||
|
</div>
|
||
|
<div class='form-group'>
|
||
|
<label for='description'>Description.</label>
|
||
|
<input class='form-control' type='text' maxlength='".FLUX_MAX_DESCRIPTION."' name='description' id='description' value=\"".htmlspecialchars($flux["description"])."\">
|
||
|
<p class='help-block'><b>Facultatif</b>.</p>
|
||
|
</div>";
|
||
|
$langues=explode("|",FLUX_LANGUES);
|
||
|
$form_html[0]["champs"].="<div class='form-group'><label for='langue'>Langue principale du flux :".$flux["langue"]."</label>";
|
||
|
foreach ($langues as $langue)
|
||
|
{
|
||
|
if($langue==$flux["langue"])
|
||
|
$form_html[0]["champs"].="<label class='checkbox-inline'><input type='radio' name='langue' value='$langue' checked='checked'> ".$langue."</label>";
|
||
|
else
|
||
|
$form_html[0]["champs"].="<label class='checkbox-inline'><input type='radio' name='langue' value='$langue'> ".$langue."</label>";
|
||
|
}
|
||
|
$form_html[0]["champs"].="<p class='help-block'><b>Obligatoire</b>.</p></div>";
|
||
|
$frequences=explode("|",FLUX_FREQUENCES);
|
||
|
$form_html[0]["champs"].="<div class='form-group'><label for='frequence_maj'>Fréquence d'actualisation du flux.</label>";
|
||
|
foreach ($frequences as $frequence)
|
||
|
{
|
||
|
if($frequence==$flux["frequence_maj"])
|
||
|
$form_html[0]["champs"].="<label class='checkbox-inline'><input type='radio' name='frequence_maj' value='$frequence' checked='checked'> ".$frequence."</label>";
|
||
|
else
|
||
|
$form_html[0]["champs"].="<label class='checkbox-inline'><input type='radio' name='frequence_maj' value='$frequence'> ".$frequence."</label>";
|
||
|
}
|
||
|
$form_html[0]["champs"].="<p class='help-block'><b>Obligatoire</b>.</p></div>
|
||
|
<div class='form-group'>
|
||
|
<label for='memo'>Mémo.</label>
|
||
|
<input class='form-control' type='text' maxlength='".FLUX_MAX_MEMO."' name='memo' id='memo' value=\"".htmlspecialchars($flux["memo"])."\">
|
||
|
<p class='help-block'><b>Facultatif</b>. Mémo interne non publié.</p>
|
||
|
</div>
|
||
|
<div class='form-group'><label class='checkbox-inline' for='suppr_ok'><input type='checkbox' id='suppr_ok' name='suppr_ok' value='1'> Je souhaite supprimer ce flux si il n'a pas de dépendances.</label></div>
|
||
|
<div class='form-group'><label class='checkbox-inline text-danger' for='suppr_ok_tot'><input type='checkbox' id='suppr_ok_tot' name='suppr_ok_tot' value='1'> Je souhaite supprimer ce flux, <u>y compris si il a des dépendances (abonnements...)</u>.</label></div>
|
||
|
<input type='hidden' name='id_flux' id='id_flux' value='$id_flux'>
|
||
|
<button type='submit' class='btn btn-success btn-lg'>Enregistrer.</button>
|
||
|
<p><br><br><a href='".PAGE_MAJ_FLUX."' title='Saisir un nouveau flux' class='btn btn-info btn-sm'>+ Nouveau flux.</a></p>
|
||
|
</form>";
|
||
|
if($ajax_on)
|
||
|
echo get_html_form($form_html,false);
|
||
|
}
|
||
|
else
|
||
|
$msg_form[]=ERREUR_SQL_ENREG_ABSENT;
|
||
|
}
|
||
|
if((!empty($msg_form))&&($ajax_on))
|
||
|
echo get_html_alerte_msg($msg_form);
|