function BOUCLE_articleshtml_ce97d1249b67fffb20134bd49b8a9e29(&$Cache, &$Pile, &$doublons, &$Numrows, $SP)
{
    static $command = array();
    static $connect;
    $command['connect'] = $connect = '';
    if (!isset($command['table'])) {
        $command['table'] = 'articles';
        $command['id'] = '_articles';
        $command['from'] = array('articles' => 'spip_articles', 'L1' => 'spip_auteurs_liens');
        $command['type'] = array();
        $command['groupby'] = array("articles.id_article");
        $command['select'] = array("articles.titre", "articles.id_article", "articles.lang", "articles.texte", "articles.descriptif", "articles.chapo", "articles.date");
        $command['orderby'] = array('articles.titre');
        $command['join'] = array('L1' => array('articles', 'id_objet', 'id_article', 'L1.objet=' . sql_quote('article')));
        $command['limit'] = '';
        $command['having'] = array();
    }
    $command['where'] = array(quete_condition_statut('articles.statut', 'publie,prop,prepa/auteur', 'publie', ''), array('=', 'L1.id_auteur', sql_quote($Pile[$SP]['id_auteur'], '', 'bigint(21) NOT NULL DEFAULT \'0\'')));
    if (defined("_BOUCLE_PROFILER")) {
        $timer = time() + microtime();
    }
    $t0 = "";
    // REQUETE
    $iter = IterFactory::create("SQL", $command, array('squelettes/auteur.html', 'html_ce97d1249b67fffb20134bd49b8a9e29', '_articles', 39, $GLOBALS['spip_lang']));
    if (!$iter->err()) {
        lang_select($GLOBALS['spip_lang']);
        $SP++;
        // RESULTATS
        while ($Pile[$SP] = $iter->fetch()) {
            lang_select_public($Pile[$SP]['lang'], '', $Pile[$SP]['titre']);
            $t1 = '
			<h3><a href="' . spip_htmlspecialchars(sinon($GLOBALS['meta']['adresse_site'], '.')) . '/spip.php?action=converser&amp;redirect=' . spip_htmlspecialchars(sinon($GLOBALS['meta']['adresse_site'], '.')) . '%2F' . vider_url(urlencode_1738(generer_url_entite($Pile[$SP]['id_article'], 'article', '', '', true))) . '&amp;var_lang=' . spip_htmlentities($Pile[$SP]['lang'] ? $Pile[$SP]['lang'] : $GLOBALS['spip_lang']) . '" hreflang="' . spip_htmlentities($Pile[$SP]['lang'] ? $Pile[$SP]['lang'] : $GLOBALS['spip_lang']) . '" ' . (($t1 = strval(interdire_scripts(entites_html(textebrut(filtre_introduction_dist($Pile[$SP]['descriptif'], strlen($Pile[$SP]['descriptif']) ? '' : $Pile[$SP]['chapo'] . "\n\n" . $Pile[$SP]['texte'], 500, $connect, null)))))) !== '' ? 'title="' . $t1 . '"' : '') . '>' . interdire_scripts(supprimer_numero(typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0]))) . '</a></h3>
			<div class="detail">
				' . interdire_scripts(nom_jour(normaliser_date($Pile[$SP]['date']))) . ' ' . interdire_scripts(affdate(normaliser_date($Pile[$SP]['date']))) . '
			</div>
		';
            $t0 .= (strlen($t1) && strlen($t0) ? '<br />' : '') . $t1;
            lang_select();
        }
        lang_select();
        $iter->free();
    }
    if (defined("_BOUCLE_PROFILER") and 1000 * ($timer = time() + microtime() - $timer) > _BOUCLE_PROFILER) {
        spip_log(intval(1000 * $timer) . "ms BOUCLE_articles @ squelettes/auteur.html", "profiler" . _LOG_AVERTISSEMENT);
    }
    return $t0;
}
function BOUCLE_art_agendahtml_78503d8cb0bd66f2d97f4b9c0f7d329a(&$Cache, &$Pile, &$doublons, &$Numrows, $SP)
{
    static $command = array();
    static $connect;
    $command['connect'] = $connect = '';
    if (!isset($command['table'])) {
        $command['table'] = 'articles';
        $command['id'] = '_art_agenda';
        $command['from'] = array('articles' => 'spip_articles', 'L1' => 'spip_mots_liens', 'L2' => 'spip_mots');
        $command['type'] = array();
        $command['groupby'] = array("articles.id_article");
        $command['select'] = array("articles.date_redac", "articles.id_article", "articles.texte", "articles.descriptif", "articles.chapo", "articles.titre", "articles.lang");
        $command['orderby'] = array('articles.date_redac');
        $command['join'] = array('L1' => array('articles', 'id_objet', 'id_article', 'L1.objet=' . sql_quote('article')), 'L2' => array('L1', 'id_mot'));
        $command['limit'] = '0,5';
        $command['having'] = array();
    }
    $command['where'] = array(quete_condition_statut('articles.statut', 'publie,prop,prepa/auteur', 'publie', ''), array('=', 'L2.titre', "'Agenda'"), array('<', 'TIMESTAMPDIFF(HOUR,articles.date_redac,NOW())/24', "1"), array('=', 'articles.lang', sql_quote($GLOBALS['spip_lang'], '', 'varchar(10) NOT NULL DEFAULT \'\'')));
    if (defined("_BOUCLE_PROFILER")) {
        $timer = time() + microtime();
    }
    $t0 = "";
    // REQUETE
    $iter = IterFactory::create("SQL", $command, array('squelettes/inc/inc-menu-agenda.html', 'html_78503d8cb0bd66f2d97f4b9c0f7d329a', '_art_agenda', 4, $GLOBALS['spip_lang']));
    if (!$iter->err()) {
        lang_select($GLOBALS['spip_lang']);
        $SP++;
        // RESULTATS
        while ($Pile[$SP] = $iter->fetch()) {
            lang_select_public($Pile[$SP]['lang'], '', $Pile[$SP]['titre']);
            $t0 .= '
				<li>' . (($t1 = strval(affdate(normaliser_date($Pile[$SP]['date_redac'])))) !== '' ? '<span>' . $t1 . (' ' . (($t2 = strval(heures(normaliser_date($Pile[$SP]['date_redac'])) != '0' ? (($t3 = strval(heures(normaliser_date($Pile[$SP]['date_redac'])))) !== '' ? $t3 . ':' : '') . minutes(normaliser_date($Pile[$SP]['date_redac'])) : '')) !== '' ? '- ' . $t2 : '') . '</span>') : '') . '
					<a class="lien' . interdire_scripts(@$Pile[0]['exposer']) . ' article" href="' . vider_url(urlencode_1738(generer_url_entite($Pile[$SP]['id_article'], 'article', '', '', true))) . '" ' . (($t1 = strval(interdire_scripts(entites_html(textebrut(filtre_introduction_dist($Pile[$SP]['descriptif'], strlen($Pile[$SP]['descriptif']) ? '' : $Pile[$SP]['chapo'] . "\n\n" . $Pile[$SP]['texte'], 500, $connect, null)))))) !== '' ? 'title="' . $t1 . '"' : '') . '>' . interdire_scripts(supprimer_numero(typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0]))) . '</a>

				</li>
		';
            lang_select();
        }
        lang_select();
        $iter->free();
    }
    if (defined("_BOUCLE_PROFILER") and 1000 * ($timer = time() + microtime() - $timer) > _BOUCLE_PROFILER) {
        spip_log(intval(1000 * $timer) . "ms BOUCLE_art_agenda @ squelettes/inc/inc-menu-agenda.html", "profiler" . _LOG_AVERTISSEMENT);
    }
    return $t0;
}
function BOUCLE_breves_rubriqueshtml_11157eacea3e766769d2031f1e2eed04(&$Cache, &$Pile, &$doublons, &$Numrows, $SP)
{
    static $command = array();
    static $connect;
    $command['connect'] = $connect = '';
    if (!isset($command['table'])) {
        $command['table'] = 'breves';
        $command['id'] = '_breves_rubriques';
        $command['from'] = array('breves' => 'spip_breves');
        $command['type'] = array();
        $command['groupby'] = array();
        $command['select'] = array("breves.date_heure", "breves.date_heure AS date", "breves.id_breve", "breves.texte", "breves.titre", "breves.lang");
        $command['orderby'] = array('breves.date_heure DESC');
        $command['join'] = array();
        $command['limit'] = '0,10';
        $command['having'] = array();
    }
    $command['where'] = array(quete_condition_statut('breves.statut', 'publie,prop', 'publie', ''), array('=', 'breves.id_rubrique', sql_quote(@$Pile[0]['id_rubrique'], '', 'bigint(21) NOT NULL DEFAULT \'0\'')), array('=', 'breves.lang', sql_quote($GLOBALS['spip_lang'], '', 'varchar(10) NOT NULL DEFAULT \'\'')));
    if (defined("_BOUCLE_PROFILER")) {
        $timer = time() + microtime();
    }
    $t0 = "";
    // REQUETE
    $iter = IterFactory::create("SQL", $command, array('squelettes/inc/inc-breves.html', 'html_11157eacea3e766769d2031f1e2eed04', '_breves_rubriques', 2, $GLOBALS['spip_lang']));
    if (!$iter->err()) {
        lang_select($GLOBALS['spip_lang']);
        $SP++;
        // RESULTATS
        while ($Pile[$SP] = $iter->fetch()) {
            lang_select_public($Pile[$SP]['lang'], '', $Pile[$SP]['titre']);
            $t0 .= '
          	<li>' . (($t1 = strval(interdire_scripts(affdate(normaliser_date($Pile[$SP]['date']))))) !== '' ? '<span>' . $t1 . '</span>' : '') . '
              <a href="' . vider_url(urlencode_1738(generer_url_entite($Pile[$SP]['id_breve'], 'breve', '', '', true))) . '" ' . (($t1 = strval(interdire_scripts(entites_html(textebrut(filtre_introduction_dist('', $Pile[$SP]['texte'], 300, $connect, null)))))) !== '' ? 'title="' . $t1 . '"' : '') . '>' . interdire_scripts(supprimer_numero(typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0]))) . '</a>
          	</li>
            ';
            lang_select();
        }
        lang_select();
        $iter->free();
    }
    if (defined("_BOUCLE_PROFILER") and 1000 * ($timer = time() + microtime() - $timer) > _BOUCLE_PROFILER) {
        spip_log(intval(1000 * $timer) . "ms BOUCLE_breves_rubriques @ squelettes/inc/inc-breves.html", "profiler" . _LOG_AVERTISSEMENT);
    }
    return $t0;
}
function BOUCLE_art_syndichtml_bb1fa8f06f75cd5c61b4de0a063c1a54(&$Cache, &$Pile, &$doublons, &$Numrows, $SP)
{
    static $command = array();
    static $connect;
    $command['connect'] = $connect = '';
    if (!isset($command['table'])) {
        $command['table'] = 'syndic_articles';
        $command['id'] = '_art_syndic';
        $command['from'] = array('syndic_articles' => 'spip_syndic_articles', 'L1' => 'spip_syndic');
        $command['type'] = array();
        $command['groupby'] = array();
        $command['select'] = array("syndic_articles.date", "syndic_articles.titre", "syndic_articles.url", "L1.url_site", "L1.nom_site", "syndic_articles.descriptif");
        $command['orderby'] = array('syndic_articles.date DESC');
        $command['join'] = array('L1' => array('syndic_articles', 'id_syndic'));
        $command['limit'] = '0,5';
        $command['having'] = array();
    }
    $command['where'] = array(quete_condition_statut('L1.statut', 'publie,prop', 'publie', ''), quete_condition_statut('syndic_articles.statut', 'publie,prop', 'publie', ''), array('=', 'L1.id_rubrique', sql_quote(@$Pile[0]['id_rubrique'], '', 'bigint(21) NOT NULL DEFAULT \'0\'')));
    if (defined("_BOUCLE_PROFILER")) {
        $timer = time() + microtime();
    }
    $t0 = "";
    // REQUETE
    $iter = IterFactory::create("SQL", $command, array('squelettes/inc/inc-syndic.html', 'html_bb1fa8f06f75cd5c61b4de0a063c1a54', '_art_syndic', 6, $GLOBALS['spip_lang']));
    if (!$iter->err()) {
        $l1 = _T('public|spip|ecrire:form_prop_nom_site');
        $SP++;
        // RESULTATS
        while ($Pile[$SP] = $iter->fetch()) {
            $t0 .= '
            <li>' . (($t1 = strval(interdire_scripts(affdate(normaliser_date($Pile[$SP]['date']))))) !== '' ? '<span>' . $t1 . '</span>' : '') . '
                ' . (($t1 = strval(interdire_scripts(supprimer_numero($Pile[$SP]['titre'])))) !== '' ? '<a href="' . vider_url($Pile[$SP]['url']) . '" ' . (($t2 = strval(interdire_scripts(attribut_html(supprimer_tags(typo(supprimer_numero(calculer_url($Pile[$SP]['url_site'], $Pile[$SP]['nom_site'], 'titre', $connect, false)), "TYPO", $connect, $Pile[0])))))) !== '' ? 'title="' . $l1 . ' : ' . $t2 . '"' : '') . ' class="spip_out">' . $t1 . '</a>' : '') . '
                ' . (($t1 = strval(interdire_scripts(typo(supprimer_numero(calculer_url($Pile[$SP]['url_site'], $Pile[$SP]['nom_site'], 'titre', $connect, false)), "TYPO", $connect, $Pile[0])))) !== '' ? '<span style="text-align: right;"><a href="' . calculer_url($Pile[$SP]['url_site'], '', 'url', $connect) . '" ' . (($t2 = strval(interdire_scripts(attribut_html(supprimer_tags(safehtml($Pile[$SP]['descriptif'])))))) !== '' ? 'title="' . $t2 . '"' : '') . ' class="spip_out" style="text-align: right; color: maroon; margin-top:-.5em">' . $t1 . '</a></span>' : '') . '
            </li>
            ';
        }
        $iter->free();
    }
    if (defined("_BOUCLE_PROFILER") and 1000 * ($timer = time() + microtime() - $timer) > _BOUCLE_PROFILER) {
        spip_log(intval(1000 * $timer) . "ms BOUCLE_art_syndic @ squelettes/inc/inc-syndic.html", "profiler" . _LOG_AVERTISSEMENT);
    }
    return $t0;
}
Exemplo n.º 5
0
function exec_spiplistes_liste_gerer () {

	include_spip('inc/autoriser');
	include_spip('inc/mots');
	include_spip('inc/lang');
	include_spip('inc/editer_auteurs');
	include_spip('base/spiplistes_tables');
	include_spip('inc/spiplistes_api');
	include_spip('inc/spiplistes_api_presentation');
	include_spip('inc/spiplistes_dater_envoi');
	include_spip('inc/spiplistes_naviguer_paniers');
	include_spip('inc/spiplistes_listes_selectionner_auteur');
	
	global $meta
		, $connect_statut
		, $connect_toutes_rubriques
		, $connect_id_auteur
		, $spip_lang_left
		, $spip_lang_right
		, $couleur_claire
		;

	// initialise les variables postees par le formulaire
	foreach(array(
		'new'	// nouvelle liste si 'oui'
		, 'id_liste'// si modif dans l'editeur
		, 'btn_liste_edit', 'titre', 'texte', 'pied_page' // renvoyes par l'editeur
		, 'btn_modifier_diffusion', 'changer_lang', 'statut' // local
		, 'btn_modifier_replyto', 'email_envoi' // local
		, 'btn_modifier_courrier_auto', 'message_auto' // local
			, 'auto_chrono', 'auto_weekly', 'auto_mois'
			, 'titre_message', 'patron', 'periode', 'envoyer_maintenant'
			, 'jour', 'mois', 'annee', 'heure', 'minute'
		, 'btn_patron_pied', 'btn_grand_patron' // boites gauches
		, 'btn_valider_forcer_abos', 'forcer_abo', 'forcer_format_abo', 'forcer_format_reception'
		, 'btn_supprimer_liste' //local
		) as $key) {
		$$key = _request($key);
	}
	foreach(array('id_liste', 'periode') as $key) {
		$$key = intval($$key);
	}
	foreach(array('titre', 'texte', 'pied_page') as $key) {
		$$key = trim(corriger_caracteres($$key));
	}
	$lang = $changer_lang;

	$cherche_auteur = _request('cherche_auteur');
	$debut = _request('debut');

	$envoyer_maintenant = ($envoyer_maintenant == 'oui');
	
	$boite_pour_confirmer_envoi_maintenant = 
		$grosse_boite_moderateurs = 
		$message_erreur =
		$page_result = "";

	if(!$id_liste)
	{
	//////////////////////////////////////////////////////
	// Creer une liste
	////
		// admin lambda peut creer une liste
		$flag_editable = ($connect_statut == "0minirezo");
		
		if ($btn_liste_edit && ($new=='oui')) {
			
			if ($titre == '') {
				$titre = _T('spiplistes:liste_sans_titre');
			}
			
			$pied_page = _SPIPLISTES_PATRON_PIED_DEFAUT;
			
			if($id_liste = spiplistes_listes_liste_creer(_SPIPLISTES_LIST_PRIVATE, $GLOBALS['spip_lang']
				, $titre, $texte, $pied_page)) {
					spiplistes_log("id_liste #$id_liste added by id_auteur #$connect_id_auteur");
			}
		} 	
	}
	else if($id_liste > 0)
	{
	//////////////////////////////////////////////////////
	// Modifier une liste
	////
		// les admins toutes rubriques et le moderateur seuls peuvent modifier la liste
		$flag_editable = autoriser('moderer', 'liste', $id_liste);

		if($flag_editable)
		{
		
			// Recupere les donnees de la liste courante pour optimiser l'update
			$sql_select = "statut,titre,date,lang";
			$sql_result = sql_select($sql_select, "spip_listes", "id_liste=".sql_quote($id_liste), "", "", "1");
			if($row = sql_fetch($sql_result)) {
				foreach(explode(",", $sql_select) as $key) {
					$current_liste[$key] = $row[$key];
				}
			}
			
			///////////////////////////////////
			// Les modifications (sql_upadteq)
			// A noter, ne pas preparer les valeurs par sql_quote()
			//  sql_upadteq() s'en occupe
			
			$sql_champs = array();

			// Retour de l'editeur ?
			if($btn_liste_edit) {
				$titre = corriger_caracteres($titre);
				$texte = corriger_caracteres($texte);
				if(empty($titre)) {
					$titre = filtrer_entites(_T('spiplistes:Nouvelle_liste_de_diffusion'));
				}
				$sql_champs['titre'] = $titre;
				$sql_champs['texte'] = $texte;
			}
			
			// Modifier le grand patron ?
			// a partir de 2.0049, le patron de pied est construit par la meleuse
			// afin de permettre _texte et multilingue
			if($btn_grand_patron && $patron) {
				$sql_champs['patron'] = $patron;
			}
			
			// Modifier patron de pied ?
			if($btn_patron_pied && $patron) {
				$sql_champs['pied_page'] = $patron;
			}
			
			// Modifier diffusion ?
			if($btn_modifier_diffusion)
			{
				$current_statut = ($statut)
					? $statut
					: $current_liste['statut']
					;
					
				spiplistes_debug_log ('Modification diffusion statut: '.$current_statut);
				
				// Modifier le statut ?
				if(in_array($statut, explode(";", _SPIPLISTES_LISTES_STATUTS_TOUS)) 
					&& ($statut != $current_liste['statut'])
				) {
					spiplistes_debug_log ('Modification statut: '.$statut);
					$sql_champs['statut'] = $statut;
					// si la liste passe en privee, retire les invites
					if($statut == _SPIPLISTES_LIST_PRIVATE) {
						$auteur_statut = '6forum';
						spiplistes_abonnements_auteurs_supprimer($auteur_statut);
						spiplistes_log("AUTEURS ($auteur_statut) REMOVED FROM LISTE #$id_liste ($statut) BY ID_AUTEUR #$connect_id_auteur");
					}
				}
				// Modifier la langue ?
				if(!empty($lang) && ($lang!=$current_liste['lang'])) {
					$sql_champs['lang'] = $lang;
				}
			}
			
			// Modifier l'adresse email de reponse ?
			if($btn_modifier_replyto && email_valide($email_envoi) && ($email_envoi!=$current_liste['email_envoi'])) {
				$sql_champs['email_envoi'] = $email_envoi;
			}

			////////////////////////////////////
			// Modifier message_auto ?
			// bloc "courriers automatiques"
			if($btn_modifier_courrier_auto)
			{
				$current_statut = ($statut)
					? $statut
					: $current_liste['statut']
					;
					
				spiplistes_debug_log ('Modification periodicite statut: '.$current_statut);
				
				$envoyer_quand = spiplistes_formate_date_form($annee, $mois, $jour, $heure, $minute);
			
				if(time() > strtotime($envoyer_quand)) {
				// envoi dans le passe est considere comme envoyer maintenant
					$envoyer_maintenant = true;
					$date_depuis = $envoyer_quand;
					$envoyer_quand = false;
				}
				// spiplistes_debug_log("nb vrais abos : ".spiplistes_listes_vrais_abos_compter($id_liste));
				if($envoyer_maintenant && ($message_auto != 'non')) {
					if(!spiplistes_listes_vrais_abos_compter($id_liste)) {
						$boite_pour_confirmer_envoi_maintenant .= 
							spiplistes_boite_alerte(_T('spiplistes:boite_alerte_manque_vrais_abos'), true);
					}
					else {
						$boite_pour_confirmer_envoi_maintenant = ""
							. debut_cadre_couleur('', true)
							// formulaire de confirmation envoi
							. spiplistes_form_debut(generer_url_ecrire(_SPIPLISTES_EXEC_LISTES_LISTE), true)
							. "<p style='text-align:center;font-weight:bold;' class='verdana2'>"
							. _T('spiplistes:boite_confirmez_envoi_liste') . "</p>"
							. "<input type='hidden' name='id_liste' value='$id_liste' />\n"
							. spiplistes_form_bouton_valider('btn_confirmer_envoi_maintenant')
							. spiplistes_form_fin(true)
							. fin_cadre_couleur(true)
							;
					}
					$date_prevue = normaliser_date(time());
				}

				if($message_auto == 'oui') {
				
					$sql_champs['message_auto'] = 'oui';
					$sql_champs['titre_message'] = $titre_message;
					$sql_champs['date'] = (!$envoyer_maintenant) ? $envoyer_quand : '';
					
					switch($auto_chrono) {
						case 'auto_jour':
							$sql_champs['statut'] =
								($current_statut == _SPIPLISTES_LIST_PRIVATE)
								? _SPIPLISTES_LIST_PRIV_DAILY
								: _SPIPLISTES_LIST_PUB_DAILY
								;
							// force au minimum 1 jour
							$sql_champs['periode'] = (($periode > 0) ? $periode : 1);
							break;
						case 'auto_hebdo':
							if($auto_weekly == 'oui') {
								// debut de semaine ?
								$sql_champs['statut'] =
									($current_statut == _SPIPLISTES_LIST_PRIVATE)
									? _SPIPLISTES_LIST_PRIV_WEEKLY
									: _SPIPLISTES_LIST_PUB_WEEKLY
									;
								// corrige la date pour le lundi de la semaine
								$time = strtotime($envoyer_quand);
								$time = mktime(0,0,0,date("m", $time),date("d", $time)-date("w", $time)+1,date("Y", $time));
    							$envoyer_quand = date("Y-m-d H:i:s", $time);
	 							$sql_champs['date'] = $envoyer_quand;
							} else {
								$sql_champs['statut'] =
									($current_statut == _SPIPLISTES_LIST_PRIVATE)
									? _SPIPLISTES_LIST_PRIV_HEBDO
									: _SPIPLISTES_LIST_PUB_HEBDO
									;
							}
							$sql_champs['periode'] = 0;
							break;
						case 'auto_mensuel':
							if($auto_mois == 'oui') {
								// debut du mois ?
								$sql_champs['statut'] =
									($current_statut == _SPIPLISTES_LIST_PRIVATE)
									? _SPIPLISTES_LIST_PRIV_MONTHLY
									: _SPIPLISTES_LIST_PUB_MONTHLY
									;
								// corrige la date, 1' du mois
								$envoyer_quand = substr($envoyer_quand, 0, 8)."01 00:00:00";
								$sql_champs['date'] = $envoyer_quand;
							} else {
								$sql_champs['statut'] =
									($current_statut == _SPIPLISTES_LIST_PRIVATE)
									? _SPIPLISTES_LIST_PRIV_MENSUEL
									: _SPIPLISTES_LIST_PUB_MENSUEL
									;
							}
							$sql_champs['periode'] = 0;
							break;
						case 'auto_an':
							$sql_champs['statut'] =
								($current_statut == _SPIPLISTES_LIST_PRIVATE)
								? _SPIPLISTES_LIST_PRIV_YEARLY
								: _SPIPLISTES_LIST_PUB_YEARLY
								;
							$sql_champs['periode'] = 0;
							break;
					}
				}
				else if($message_auto == 'non') {
					$sql_champs['message_auto'] = 'non';
					$sql_champs['date'] = '';
					$sql_champs['periode'] = 0;
				}
			} // end if($btn_modifier_courrier_auto)
			
			// Enregistre les modifs pour cette liste
			if(count($sql_champs))
			{
				sql_updateq('spip_listes', $sql_champs, 'id_liste='.sql_quote($id_liste).' LIMIT 1');
			}
			
			// Forcer les abonnements
			if($btn_valider_forcer_abos && $forcer_abo && in_array($forcer_abo, array('tous', 'auteurs', '6forum', 'aucun'))) {
				
				$forcer_format_reception = 
					(($forcer_format_abo == 'oui') && in_array($forcer_format_reception, spiplistes_formats_autorises()))
					? $forcer_format_reception
					: false
					;
				include_spip('inc/spiplistes_listes_forcer_abonnement');
				
				if(spiplistes_listes_forcer_abonnement ($id_liste, $forcer_abo, $forcer_format_reception) ===  false) {
					$message_erreur .= spiplistes_boite_alerte(_T('spiplistes:Forcer_abonnement_erreur'), true);
				}
			}
			
		} // end if($flag_editable)
	}

	//////////////////////////////////////////////////////
	// Recharge les donnees la liste

	$sql_select_array = array('id_liste', 'titre', 'texte'
			, 'titre_message', 'pied_page', 'date', 'statut', 'maj'
			, 'email_envoi', 'message_auto', 'periode', 'patron', 'lang');

	if($row = spiplistes_listes_liste_fetsel($id_liste, $sql_select_array)) {
		foreach($sql_select_array as $key) {
			// initialise les variables du resultat SQL
			$$key = $row[$key];
		}
	}

	// les supers-admins et le moderateur seuls peuvent modifier la liste
	$flag_editable = autoriser('moderer', 'liste', $id_liste);

	if (empty($titre_message))
	{
		$titre_message = $titre;
		if (spiplistes_pref_lire_defaut('opt_completer_titre_nom_site', 'oui') == 'oui')
		{
			$titre_message .= _T('spiplistes:_de_')
				. spiplistes_nom_site_texte($lang);
		}
	}
	
	$nb_abonnes = spiplistes_listes_nb_abonnes_compter($id_liste);

	// preparation des boutons 
	if($flag_editable) {
		// Propose de modifier la liste 
		$gros_bouton_modifier = 
			icone (
				_T('spiplistes:Modifier_cette_liste') // legende bouton
				, generer_url_ecrire(_SPIPLISTES_EXEC_LISTE_EDIT,'id_liste='.$id_liste) // lien
				, _DIR_PLUGIN_SPIPLISTES_IMG_PACK."reply-to-all-24.gif" // image du fond
				, "edit.gif" // image de la fonction. Ici, le crayon
				, '' // alignement
				, false // pas echo, demande retour
				)
			;
		// Propose de supprimer la liste 
		$gros_bouton_supprimer = 
			icone (
					_T('spiplistes:Supprimer_cette_liste')
					, generer_url_ecrire(_SPIPLISTES_EXEC_LISTE_GERER, "btn_supprimer_liste=$id_liste&id_liste=$id_liste")
					, _DIR_PLUGIN_SPIPLISTES_IMG_PACK.'poubelle_msg.gif'
					, ""
					, "right"
					, false
					)
			;
			
		// la grosse boite des abonnes
		$tri = _request('tri') ? _request('tri') : 'nom';
		//
		// CP-20101017: Si trop d'elligibles, ca gele.
		// @todo: revoir la boite/liste des abonnes/elligibles
		// En attendant ...
		//if(spiplistes_auteurs_elligibles_compter() < 1000)
		//{
			$boite_liste_abonnes = spiplistes_listes_boite_abonnements(
				$id_liste, $statut, $tri, $debut, _SPIPLISTES_EXEC_LISTE_GERER
			);
		//}
		//else
		//{
		//	$boite_liste_abonnes = _T('spiplistes:code_en_travaux');
		//}
		
		
		// @see http://www.spip-contrib.net/SPIP-Listes#comment444314
		
		
		
		$titre_boite = _T('spiplistes:abos_cette_liste');
		$legend = '<small id="legend-abos1">'
			. spiplistes_nb_abonnes_liste_str_get($id_liste)
			. '</small>'.PHP_EOL
			;
		$grosse_boite_abonnements = ''
			. '<!-- boite abonnes/elligibles -->'.PHP_EOL
			. debut_cadre_enfonce('auteur-24.gif', true, '', $titre_boite)
			. spiplistes_bouton_block_depliable($legend
				, false, md5('abonnes_liste'))
			. (spiplistes_spip_est_inferieur_193() ? $legend : '')
			. spiplistes_debut_block_invisible(md5('abonnes_liste'))
			. debut_cadre_relief('', true)
			. $boite_liste_abonnes
			. fin_cadre_relief(true)
			. fin_block()
			. fin_cadre_enfonce(true)
			. '<!-- fin boite abonnes/elligibles -->'.PHP_EOL
			;

		// la grosse boite des moderateurs
		$boite_liste_moderateurs = spiplistes_listes_boite_moderateurs(
			$id_liste, _SPIPLISTES_EXEC_LISTE_GERER, 'mods-conteneur'
			);
		$titre_boite = _T('spiplistes:mods_cette_liste');
		$nb = spiplistes_mod_listes_compter($id_liste);
		$legend = '<small>'
			. spiplistes_nb_moderateurs_liste_str_get($nb)
			. '</small>'.PHP_EOL
			;
		$grosse_boite_moderateurs = ''
			. '<!-- boite moderateurs -->'.PHP_EOL
			. debut_cadre_enfonce('redacteurs-24.gif', true, '', $titre_boite)
			. spiplistes_bouton_block_depliable($legend
				, false, md5('mods_liste'))
			. (spiplistes_spip_est_inferieur_193() ? $legend : '')
			. spiplistes_debut_block_invisible(md5('mods_liste'))
			. debut_cadre_relief('', true)
			. '<div id="mods-conteneur">'.PHP_EOL
			. $boite_liste_moderateurs
			. '</div>'.PHP_EOL
			. fin_cadre_relief(true)
			. fin_block()
			. fin_cadre_enfonce(true)
			. '<!-- fin boite moderateurs -->'.PHP_EOL
			;

	}
	else {
		$gros_bouton_modifier = $gros_bouton_supprimer = $grosse_boite_abonnements = '';
	}

////////////////////////////////////
// PAGE CONTENU
////////////////////////////////////

	$titre_page = _T('spiplistes:gestion_dune_liste');
	// Permet entre autres d'ajouter les classes a la page : <body class='$rubrique $sous_rubrique'>
	$rubrique = _SPIPLISTES_PREFIX;
	$sous_rubrique = 'liste_gerer';

	$commencer_page = charger_fonction('commencer_page', 'inc');
	echo($commencer_page(_T('spiplistes:spiplistes') . ' - ' . $titre_page, $rubrique, $sous_rubrique));

	// la gestion des listes de courriers est reservee aux admins 
	if($connect_statut != '0minirezo') {
		die (spiplistes_terminer_page_non_autorisee() . fin_page());
	}

	$page_result .= ''
		. '<br /><br /><br />' . PHP_EOL
		. spiplistes_gros_titre($titre_page, '', true)
		. barre_onglets($rubrique, $sous_rubrique)
		. debut_gauche($rubrique, true)
		. spiplistes_boite_info_id(_T('spiplistes:liste_numero'), $id_liste, true)
		. spiplistes_naviguer_paniers_listes(_T('spiplistes:aller_aux_listes_'), true)
		. spiplistes_boite_patron($flag_editable, $id_liste, _SPIPLISTES_EXEC_LISTE_GERER, 'btn_grand_patron'
			, _SPIPLISTES_PATRONS_DIR, _T('spiplistes:Patron_grand_')
			, ($patron ? $patron : '')
			, $patron)
		. spiplistes_boite_patron($flag_editable, $id_liste, _SPIPLISTES_EXEC_LISTE_GERER, 'btn_patron_pied'
			, _SPIPLISTES_PATRONS_PIED_DIR, _T('spiplistes:Patron_de_pied_')
			, ((($ii = strlen($pied_page)) > _SPIPLISTES_PATRON_FILENAMEMAX) 
				? _T('taille_octets',array('taille'=>$ii)) . _T('spiplistes:conseil_regenerer_pied')
				: $pied_page)
			, $pied_page)
		. pipeline('affiche_gauche', array('args'=>array('exec'=>$sous_rubrique),'data'=>''))
		//. creer_colonne_droite($rubrique, true)  // spiplistes_boite_raccourcis() s'en occupe
		. spiplistes_boite_raccourcis(true)
		. spiplistes_boite_autocron()
		. pipeline('affiche_droite', array('args'=>array('exec'=>$sous_rubrique),'data'=>''))
		. debut_droite($rubrique, true)
		. $message_erreur
		;

	changer_typo('','liste'.$id_liste);

	// message alerte et demande de confirmation si supprimer liste
	if(($btn_supprimer_liste > 0) && ($btn_supprimer_liste == $id_liste)) {
		$page_result .= ''
			. spiplistes_boite_alerte (_T('spiplistes:Attention_suppression_liste').'<br />'._T('spiplistes:Confirmez_requete'), true)
			. '<form name="form_suppr_liste" id="form_suppr_liste" method="post"
				action="'.generer_url_ecrire(_SPIPLISTES_EXEC_LISTES_LISTE, '').'">' . PHP_EOL
			. "<div class='verdana2' style='text-align:right;'>\n"
			. "<input type='hidden' name='id_liste' value='$id_liste' />\n"
   		. "<label>"._T('spiplistes:Confirmer_la_suppression_de_la_liste')."# $id_liste : \n"
   		. "<input class='fondo' type='submit' name='btn_supprimer_liste_confirme' value='"._T('bouton_valider')."' /></label>\n"
			. "</div>\n"
			. "</form>\n"
			. "<br />\n"
		;
	}

	$page_result .= ""
		. debut_cadre_relief("", true)
		. "\n<table cellpadding='0' cellspacing='0' border='0' width='100%'>\n"
		. "<tr><td valign='top'>\n"
		. spiplistes_gros_titre(spiplistes_bullet_titre_liste('puce', $statut, '', true)." "
			. spiplistes_calculer_balise_titre(extraire_multi($titre))
			, '', true)
		. "</td>"
		. "<td rowspan='2'>"
		// le gros bouton modifier si besoin
		. $gros_bouton_modifier
		. "</td></tr>\n"
		. "<tr><td width='100%'>\n"
		. "<div align='$spip_lang_left' style='padding: 5px; border: 1px dashed #aaa; ' class='verdana1 spip_small'>\n"
		. propre($texte."~")
		. "</div>\n"
		. "</td>\n"
		. "</tr></table>\n"
		;

	
	//////////////////////////////////////////////////////
	// Modifier le statut de la liste
	//$email_defaut = entites_html($meta['email_webmaster']);
	$email_defaut = ($m = email_valide($GLOBALS['meta']['email_defaut']))
		? $m
		: $GLOBALS['meta']['email_webmaster']
		;
	$email_envoi = ($m = email_valide($email_envoi))
		? $email_envoi
		: $email_defaut
		;

	$page_result .= ""
		//. debut_cadre_relief("racine-site-24.gif", true)
		. debut_cadre_relief("racine-site-24.gif", true, '', _T('spiplistes:Diffusion').spiplistes_plugin_aide(_SPIPLISTES_EXEC_AIDE, "diffusion"))
		//
		////////////////////////////
		// Formulaire diffusion
		.	(
			($flag_editable)
			? ''
				. spiplistes_form_debut(generer_url_ecrire(_SPIPLISTES_EXEC_LISTE_GERER,'id_liste='.$id_liste), true)
				. '<input type="hidden" name="exec" value="listes" />' . PHP_EOL
				. '<input type="hidden" name="id_liste" value="'.$id_liste.'" />' . PHP_EOL
			: ''
			)
		. '<span class="verdana2">'
			. _T('spiplistes:cette_liste_est_'
			 	, array('s' => spiplistes_bullet_titre_liste ('puce', $statut, 'img_statut', true)))
		. '</span>' . PHP_EOL
		;

		$sel_private = ' value="' . _SPIPLISTES_LIST_PRIVATE . '" ' 
			. 	(
					in_array ($statut, array(
									_SPIPLISTES_LIST_PRIVATE
									, _SPIPLISTES_LIST_PRIV_DAILY
									, _SPIPLISTES_LIST_PRIV_HEBDO
									, _SPIPLISTES_LIST_PRIV_WEEKLY
									, _SPIPLISTES_LIST_PRIV_MENSUEL
									, _SPIPLISTES_LIST_PRIV_MONTHLY
									, _SPIPLISTES_LIST_PRIV_YEARLY
									)
						 )
					? ' selected="selected"' 
					: ''
				)
				;
		$sel_publique = ' value="' . _SPIPLISTES_LIST_PUBLIC . '" ' 
			. 	(
					in_array ($statut, array(
									_SPIPLISTES_LIST_PUBLIC
									, _SPIPLISTES_LIST_PUB_DAILY
									, _SPIPLISTES_LIST_PUB_HEBDO
									, _SPIPLISTES_LIST_PUB_WEEKLY
									, _SPIPLISTES_LIST_PUB_MENSUEL
									, _SPIPLISTES_LIST_PUB_MONTHLY
									, _SPIPLISTES_LIST_PUB_YEARLY
									)
						 )
					? ' selected="selected"' 
					: ''
				)
				;
	$page_result .= PHP_EOL
		.	(
			($flag_editable)
			? ''
				. '<select class="verdana2 fondl" name="statut" size="1" id="change_statut">' . PHP_EOL
				. '<option' . $sel_private . ' style="background-color:#fff">'
					. _T('spiplistes:statut_interne')
					. '</option>' . PHP_EOL
				. '<option' . $sel_publique . ' style="background-color:#B4E8C5">'
					. _T('spiplistes:statut_publique')
					. '</option>' . PHP_EOL
				. '<option' . mySel(_SPIPLISTES_TRASH_LIST, $statut)
					. ' style="background:url(' . _DIR_IMG_PACK.'rayures-sup.gif)">'
					. _T('texte_statut_poubelle').'</option>' . PHP_EOL
				. '</select>' . PHP_EOL
			: '<span class="verdana2" style="font-weight:bold;">'
				. spiplistes_items_get_item('alt', $statut)
				. '</span>'. PHP_EOL
			)
		. '<div style="margin:10px 0px;">' . PHP_EOL
		.	(
			($flag_editable && strpos($GLOBALS['meta']['langues_multilingue'], ','))
			? ''
				. '<label class="verdana2" for="changer_lang">'
					. _T('info_multi_herit').' : </label>' . PHP_EOL
				. '<select name="changer_lang" class="fondl" id="changer_lang">' . PHP_EOL
				. liste_options_langues('changer_lang', $lang , _T('spiplistes:langue_'), '', '')
				. '</select>' . PHP_EOL
			: ''
				//. "<span class='verdana2'>". _T('info_multi_herit')." : "
				//. "<span class='verdana2' style='font-weight:bold;'>".traduire_nom_langue($lang)."</span>\n"
			)
		. '</div>' . PHP_EOL
		.	(
				($flag_editable)
				? spiplistes_form_bouton_valider('btn_modifier_diffusion')
					. spiplistes_form_fin(true)
				: ''
			)
		. fin_cadre_relief(true)
		;

		////////////////////////////
		// Formulaire adresse email pour le reply-to
	$page_result .= ''
		. debut_cadre_relief(_DIR_PLUGIN_SPIPLISTES_IMG_PACK."reply_to-24.png"
							, true
							, ''
							, _T('spiplistes:adresse_de_reponse').spiplistes_plugin_aide(_SPIPLISTES_EXEC_AIDE
								, "replyto")
							)
		. spiplistes_form_debut(generer_url_ecrire(_SPIPLISTES_EXEC_LISTE_GERER,"id_liste=$id_liste"), true)
		. "<p class='verdana2'>\n"
		. _T('spiplistes:adresse_mail_retour').":<br />\n"
		.	(
			($flag_editable)
			? _T('spiplistes:adresse')."</p>\n"
				. "<div style='text-align:center'>\n"
				. "<input type='text' name='email_envoi' value=\"".$email_envoi."\" size='40' class='fondl' /></div>\n"
				. spiplistes_form_bouton_valider('btn_modifier_replyto')
			: "</p><p style='font-weight:bold;text-align:center;'>$email_envoi</p>\n"
			)
		. spiplistes_form_fin(true)
		. fin_cadre_relief(true)
		;
		
		////////////////////////////
		// Formulaire planifier un courrier automatique
	$page_result .= ""
		. "<a name='form-programmer' id='form-programmer'></a>\n"
		. debut_cadre_relief(_DIR_PLUGIN_SPIPLISTES_IMG_PACK."stock_timer.png", true, '', _T('spiplistes:messages_auto')
			. spiplistes_plugin_aide(_SPIPLISTES_EXEC_AIDE, "temporiser"))
		;
	$page_result .= ""
		. $boite_pour_confirmer_envoi_maintenant
		. spiplistes_form_debut(generer_url_ecrire(_SPIPLISTES_EXEC_LISTE_GERER,"id_liste=$id_liste")."#form-programmer", true)
		. "<table border='0' cellspacing='1' cellpadding='3' width='100%'>\n"
		. "<tr><td align='$spip_lang_left' class='verdana2'>\n"
		;
	if(empty($patron)) {
		$page_result .= ""
			. (
				$flag_editable
				? spiplistes_boite_alerte(_T('spiplistes:patron_manquant_message'), true)
				: "<p class='verdana2'>" . _T('spiplistes:liste_sans_patron') . "</p>\n"
			  )
			. "</td>\n"
			. "</tr>\n"
			. "<tr><td align='$spip_lang_left' class='verdana2'>\n"
			;
	}
	if ($message_auto != "oui") {
		$page_result .= "<div class='verdana2'>"._T('spiplistes:pas_denvoi_auto_programme')."</div>\n";
	}
	else {
		$page_result .= ""
			// petite ligne d'info si envoi programme
			. "<p class='verdana2'>"._T('spiplistes:sujet_courrier_auto')."<br />\n"
			. "<span class='spip_large'> "
				. spiplistes_calculer_balise_titre(extraire_multi($titre_message))
				. "</span></p>\n"
			. "<p class='verdana2'>"
			. spiplistes_items_get_item('alt', $statut)."<br />\n"
			.	(	
					($statut == _SPIPLISTES_LIST_PUB_MONTHLY)
					?	"<strong>" . spiplistes_items_get_item("tab_t", $statut) . "</strong><br />"
					:	""
				)
			.	(
					($periode > 0)
					? _T('spiplistes:periodicite_tous_les_n_s'
						, array('n' => "  <strong>".$periode."</strong>  "
							, 's' => spiplistes_singulier_pluriel_str_get($periode, _T('spiplistes:jour'), _T('spiplistes:jours'), false)
							)
						)
					: ""
				)
			.	(
					(!in_array($statut, explode(";", _SPIPLISTES_LISTES_STATUTS_PERIODIQUES)))
					? " <strong>"._T('spiplistes:Pas_de_periodicite')."</strong><br />"
						._T('spiplistes:Ce_courrier_ne_sera_envoye_qu_une_fois')
					: ""
				)
			.	"<br />"
			.	(
				(intval($maj))
				? _T('spiplistes:Dernier_envoi_le_') . " <strong>" . affdate_heure($maj) . "</strong>"
					.	(
						($last =  round((time() - strtotime($maj)) / _SPIPLISTES_TIME_1_DAY))
							? " (".spiplistes_singulier_pluriel_str_get($last, _T('spiplistes:jour'), _T('spiplistes:jours')).")"
							: ""
					). "<br />"
				: ""
				)
			.	(
				($date_prevue || (intval($date) && (time() < strtotime($date))))
				? _T('spiplistes:prochain_envoi_prevu')." : <strong>" . affdate_heure($date_prevue ? $date_prevue : $date) . "</strong>"
					.	(
						(!$date_prevue && ($next = round((strtotime($date) - time()) / _SPIPLISTES_TIME_1_DAY)))
							? " (".spiplistes_singulier_pluriel_str_get($next, _T('spiplistes:jour'), _T('spiplistes:jours')).")"
							: ""
						)
				: ""
				)
			. "</p>\n"
			;
		if($btn_modifier_courrier_auto) {
			$page_result .= ""
				. "<p class='verdana2'>"._T('spiplistes:date_act')."<br />"
				. _T('spiplistes:env_esquel')." <em>".$patron."</em>"
				. "</p>\n"
				;
		}
	}
	$date_debut_envoi = (!empty($date_prevue) ? $date_prevue : (($date && intval($date)) ? $date : normaliser_date(time())));

	$page_result .= ""
		. "</td>\n"
		. "</tr>\n"
		;
	if($flag_editable) {
		$page_result .= ""
			. "<tr><td align='$spip_lang_left' class='verdana2'>"
			. "<input type='radio' name='message_auto' value='oui' id='auto_oui' "
				. (empty($patron) ? " disabled='disabled' " : "")
				. ($auto_checked = ($message_auto=='oui' ? "checked='checked'" : ""))
				. " />"
			. "<label for='auto_oui' ".($auto_checked ? "style='font-weight:bold;'" : "").">"
				. _T('spiplistes:prog_env')."</label>\n"
			. "<div id='auto_oui_detail' "
				.((empty($patron) || !$auto_checked) ? "style='display:none;'" : "")
				.">"
			. "<ul style='list-style-type:none;'>\n"
			. "<li>"._T('spiplistes:message_sujet')
			. ': <input type="text" name="titre_message" value="'.$titre_message.'" size="50" class="fondl" /> </li>'."\n"
			;
			// 
			// chrono jour
			$ii = ($periode > 0) ? $periode : 1;
		$page_result .= ""
			. "<li style='margin-top:0.5em'>"
				. spiplistes_form_input_radio ('auto_chrono', 'auto_jour'
					, ''
					, ($statut == _SPIPLISTES_LIST_PUB_DAILY)
					, true, false
					)
				. _T('spiplistes:Tous_les')
				. " <input type='text' name='periode' value='".$ii."' size='4' maxlength='4' class='fondl' /> "
				. _T('info_jours')
				. "</li>\n"
			// chrono hebdo
			. "<li>"
				. spiplistes_form_input_radio ('auto_chrono', 'auto_hebdo'
					, _T('spiplistes:Toutes_les_semaines')
					, (($statut == _SPIPLISTES_LIST_PUB_HEBDO) || ($statut == _SPIPLISTES_LIST_PUB_WEEKLY))
					, true, false)
				. spiplistes_form_input_checkbox('auto_weekly', 'oui'
					, _T('spiplistes:en_debut_de_semaine'), ($statut == _SPIPLISTES_LIST_PUB_WEEKLY), true, false)
				. "</li>\n"
			// chrono mois
			. "<li>"
				. spiplistes_form_input_radio ('auto_chrono', 'auto_mensuel'
					, _T('spiplistes:Tous_les_mois')
					, (($statut == _SPIPLISTES_LIST_PUB_MENSUEL) || ($statut == _SPIPLISTES_LIST_PUB_MONTHLY))
					, true, false)
				. spiplistes_form_input_checkbox('auto_mois', 'oui'
					, _T('spiplistes:en_debut_de_mois'), ($statut == _SPIPLISTES_LIST_PUB_MONTHLY), true, false)
				. "</li>\n"
			// chrono annee
			. "<li>"
				. spiplistes_form_input_radio ('auto_chrono', 'auto_an'
					, _T('spiplistes:Tous_les_ans')
					, ($statut == _SPIPLISTES_LIST_PUB_YEARLY)
					, true, false)
				. "</li>\n"
			. "<li style='margin-top:0.5em'>"._T('spiplistes:A_partir_de')." : <br />\n"
			//
			. spiplistes_dater_envoi(
				'liste', $id_liste, $statut
				, $flag_editable
				, _T('spiplistes:date_expedition_')
				, $date_debut_envoi, 'btn_changer_date'
				, false
				)
			. "</li>\n"
			.	(
				(!$envoyer_maintenant)
				? " <li>"
					. spiplistes_form_input_checkbox('envoyer_maintenant', 'oui'
						, _T('spiplistes:env_maint'), false, true)
					. "</li>\n"
				: ""
				)
			. "</ul></div>\n"
			;
		$checked = ($message_auto=='non') ? "checked='checked'" : "";
		$class = $checked ? "class='bold'" : "";
		$disabled = (empty($patron) ? " disabled='disabled' " : "");
		$page_result .= ""
			. "<br /><input type='radio' name='message_auto' value='non' id='auto_non' $disabled $checked />"
			. "<span $class >"
			. " <label for='auto_non'>"._T('spiplistes:prog_env_non')."</label> "
			. "</span>\n"
			. "</td></tr>\n"
			;

		$page_result .= ""
			. "<tr><td style='text-align:$spip_lang_right;'>"
			. 	(
				($id_liste)
				? "<input type='hidden' name='id_liste' value='$id_liste' />"
				: ""
				)
			.	(
				($new)
				? "<input type='hidden' name='new' value='$new' />"
				: ""
				)
			// bouton de validation
			. (!empty($patron) 
				? spiplistes_form_bouton_valider('btn_modifier_courrier_auto', _T('bouton_valider'), true)
				: "")
			. "</td></tr>"
			;
	}
	$page_result .= ""
		. "</table>\n"
		. spiplistes_form_fin(true)
		. fin_cadre_relief(true)
		;
		// fin formulaire planifier
		
	$page_result .= ""
		. fin_cadre_relief(true)
		. $grosse_boite_abonnements
		. $grosse_boite_moderateurs
		;
	
	// le super-admin peut abonner en masse
	if($connect_toutes_rubriques) {
		$page_result .= ""
			. "\n<!-- forcer abo -->\n"
			. debut_cadre_enfonce(_DIR_PLUGIN_SPIPLISTES_IMG_PACK."abonner-24.png", true, '', _T('spiplistes:forcer_les_abonnement_liste').spiplistes_plugin_aide("forcerliste"))."\n"
			. "<p class='verdana2'>\n"
			. _T('spiplistes:forcer_abonnement_desc')
			. "</p>\n"
			. "<p class='verdana2' style='margin-bottom:1em'><em>"
			. _T('spiplistes:forcer_abonnement_aide', array('lien_retour' => generer_url_ecrire(_SPIPLISTES_EXEC_ABONNES_LISTE)))
			. "</em></p>\n"
			. "<form action='".generer_url_ecrire(_SPIPLISTES_EXEC_LISTE_GERER,"id_liste=$id_liste#auteurs")."' id='form_forcer_abo' name='form_forcer_abo' method='post'>\n"
			. debut_cadre_relief("", true)."\n"
			//
			//////////////////////////
			// propose de forcer les membres sauf invites si la liste est privee
			.	(
					($statut==_SPIPLISTES_LIST_PRIVATE)
					? "<div class='verdana2'><input type='radio' name='forcer_abo' value='auteurs' id='forcer_abo_tous' />\n"
						. "<label for='forcer_abo_tous'>"._T('spiplistes:Abonner_tous_les_inscrits_prives')."</label>"
						. "</div>\n"
						. spiplistes_boutons_forcer_format('forcer_format', _T('spiplistes:forcer_abonnements_nouveaux'))
					: ""
				)
			//
			// propose de forcer les invites si la liste est publique ou periodique
			.	(
					(($statut!=_SPIPLISTES_LIST_PRIVATE) && ($statut!=_SPIPLISTES_TRASH_LIST))
					? "<div class='verdana2'><input type='radio' name='forcer_abo' value='6forum' id='forcer_abo_6forum' />\n"
						. "<label for='forcer_abo_6forum'>"._T('spiplistes:Abonner_tous_les_invites_public')."</label></div>\n"
						. spiplistes_boutons_forcer_format('forcer_format', _T('spiplistes:forcer_abonnements_nouveaux'))
					: ""
				)
			. (
				($nb_abonnes)
				? "<hr />\n"
					. "<div class='verdana2'><input type='radio' name='forcer_abo' value='aucun' id='forcer_desabo' />\n"
					. "<label for='forcer_desabo'>"._T('spiplistes:Forcer_desabonner_tous_les_inscrits')."</label></div>\n"
				: ""
				)
			. fin_cadre_relief(true)."\n"
			. "<div style='text-align:right;'><input type='submit' name='btn_valider_forcer_abos' value='"._T('bouton_valider')."' class='fondo' /></div>\n"
			. "</form>\n"
			. fin_cadre_enfonce (true)."\n"
		;
	}
	//
	$page_result .= ""
		. $gros_bouton_supprimer
		;
	
	echo($page_result);

	echo pipeline('affiche_milieu',array('args'=>array('exec'=>$sous_rubrique),'data'=>''))
		, spiplistes_html_signature(_SPIPLISTES_PREFIX)
		, fin_gauche(), fin_page();

} // end exec_spiplistes_liste_gerer()
Exemplo n.º 6
0
function spiplistes_dater_envoi (
	$type_objet, $id_objet, $statut_objet
	, $flag_autorise
	, $titre_boite
	, $date_debut_envoi
	, $btn_nom_valider, $enveloppe_formulaire = true
) {
	global $spip_lang_left, $spip_lang_right;
	
	if($statut_objet=='vide') {
		return(false);
	}
	
	$date_valide = spiplistes_date_heure_valide($date_debut_envoi);

	$courrier_editable = 
		($type_objet == 'courrier')
		&&	(
			($statut_objet == _SPIPLISTES_COURRIER_STATUT_REDAC) 
			|| ($statut_objet == _SPIPLISTES_COURRIER_STATUT_ENCOURS)
		)
		;
	$liste_editable = 
		($type_objet == 'liste')
		&& in_array($statut_objet, explode(";", _SPIPLISTES_LISTES_STATUTS_OK))
		;
		
	if($flag_autorise && ($courrier_editable || $liste_editable)) {

		if(!$date_valide) {
			// propose date maintenant par défaut
			$date_debut_envoi = normaliser_date(time());
			$date_valide = spiplistes_date_heure_valide($date_debut_envoi);
		}

		list($annee, $mois, $jour, $heure, $minute, $seconde) = $date_valide;
		
		$js = "size='1' class='fondl'";
		
		if($enveloppe_formulaire)
			$js .= "onchange=\"findObj_forcer('valider_date').style.visibility='visible';\"";
		
		$invite = ""
			. "<span class='verdana1 titre-boite-date'>"
			. "<span class='titre'>" . $titre_boite . "</span>"
			. ": "
			.	(
				(!$date_valide)
				? "<span class='gray'>" . _T('spiplistes:date_non_precisee') . "</span>" 
				: "<span class='date'>" . affdate_heure($date_debut_envoi) . "</span>"
				)
			.  "</span>\n"
			;
		
		$masque = 
			afficher_jour($jour, "name='jour' $js", true)
			. afficher_mois($mois, "name='mois' $js", true)
			. afficher_annee($annee, "name='annee' $js")
			. " - "
			. afficher_heure($heure, "name='heure' $js")
			. afficher_minute($minute, "name='minute' $js")
			. "&nbsp;\n"
			;

		if($enveloppe_formulaire) {
			$masque = ""
				. "<!-- dater_envoi form -->\n"
				. "<form action='".generer_url_ecrire(_SPIPLISTES_EXEC_COURRIER_GERER,'id_$type_objet='.$id_objet)."' method='post' style='margin: 5px; margin-$spip_lang_left: 20px;'>\n"
				. $masque
				. "<input type='submit' name='$btn_nom_valider' id='valider_date' "
					.	(
						($date_valide)
						? "value=\""._T('bouton_changer')."\" class='fondo visible_au_chargement'"
						: "value=\""._T('bouton_valider')."\" class='fondo'"
						)
				. "/>"
				. "</form>\n"
				;
		}

		$result = block_parfois_visible('daterblock', $invite, $masque, 'text-align: left');
	} 
	else {
		$result = ""
			. "<div style='text-align:center;'>"
			. "<span class='verdana1 titre-boite-date'><span class='titre'>"
			.	(
				($statut_objet == 'encour')
				? _T('spiplistes:courrier_en_cours_')
				: _T('spiplistes:date_expedition_')
				)
			. "</span>: <span class='date'>"
			.	(
				($date_valide)
				? affdate_heure($date_debut_envoi)
				: _T('spiplistes:attente_validation')
				)
			. "</span></span>"
			. "</div>\n"
			;
	}
	if(!empty($result)) {
		$result = ""
			. "<div style='margin-top:1ex;clear:right;'>" 
			. debut_cadre_couleur('',true) 
			. $result 
			. fin_cadre_couleur(true) 
			. "</div>\n"
			;
	}
	return ($result);
}
Exemplo n.º 7
0
function exec_spiplistes_courrier_edit(){

	include_spip('inc/barre');
	include_spip('inc/documents');
	include_spip('base/spiplistes_tables');
	include_spip('inc/spiplistes_api');
	include_spip('inc/spiplistes_api_presentation');
	include_spip('inc/spiplistes_dater_envoi');
	include_spip('inc/spiplistes_api_courrier');
	include_spip('public/assembler');
	include_spip('inc/spiplistes_naviguer_paniers');

	global $connect_statut
		, $connect_toutes_rubriques
		, $connect_id_auteur
		, $spip_ecran
		, $compteur_block
		;
	
	$eol = "\n";
	$id_temp = false;
	
	$type = _request('type');
	$id_courrier = intval(_request('id_courrier'));

	foreach(array('btn_courrier_apercu') as $key) {
		$$key = _request($key);
	}

	if($id_courrier > 0) {
	///////////////////////////
	// Edition /modification d'un courrier
		$sql_select_array = array('titre','texte','message_texte','type','statut','id_auteur');
		if($row = spiplistes_courriers_premier($id_courrier, $sql_select_array)) {
			foreach($sql_select_array as $key) {
				$$key = $row[$key];
			}
			$titre = entites_html($titre);
			$texte = entites_html($texte);
		}
		else {
			$id_courrier = false;
		}
	}
	// n'existe pas encore ?
	// placer un marqueur pour les documents joints
	else {
		$id_temp = 0-intval(substr(creer_uniqid(),0,5));
	}

	// l'edition du courrier est reservee aux super-admins 
	// ou aux admin createur du courrier
	$flag_editable = (($connect_statut == "0minirezo") 
		&& ($connect_toutes_rubriques || ($connect_id_auteur == $id_auteur) || !$id_courrier));

	if($flag_editable) {
		if(!$id_courrier) {
		// si pas de ID courrier, c'est une creation
			$statut = _SPIPLISTES_COURRIER_STATUT_REDAC; 
			$type = _SPIPLISTES_COURRIER_TYPE_NEWSLETTER;
			$new = 'oui';
			$titre = _T('spiplistes:Nouveau_courrier');
			$clearonfocus = " onfocus=\"if(!antifocus){this.value='';antifocus=true;}\"";
		}
		else {
			$clearonfocus = "";
		}
	
		$gros_bouton_retour =
			($id_courrier)
			? icone(
				_T('spiplistes:retour_link')
				, generer_url_ecrire(_SPIPLISTES_EXEC_COURRIER_GERER, "id_courrier=$id_courrier")
				, spiplistes_items_get_item('icon', $statut)
				, "rien.gif"
				, ""
				, false
				)
			: ""
			;
		$boite_documents = afficher_documents_colonne(
							  ($id_courrier ? $id_courrier : $id_temp )
							  , 'courrier');
	}
	
////////////////////////////////////
// PAGE CONTENU
////////////////////////////////////

	$titre_page = _T('spiplistes:edition_du_courrier');
	// Permet entre autres d'ajouter les classes a' la page : <body class='$rubrique $sous_rubrique'>
	$rubrique = _SPIPLISTES_PREFIX;
	$sous_rubrique = "courrier_edit";

	$commencer_page = charger_fonction('commencer_page', 'inc');
	echo($commencer_page(_T('spiplistes:spiplistes') . " - " . $titre_page, $rubrique, $sous_rubrique));

	if(!$flag_editable) {
		die (spiplistes_terminer_page_non_autorisee() . fin_page());
	}
	
	$page_result = ""
		. "<br /><br /><br />\n"
		. spiplistes_gros_titre($titre_page, '', true)
		. barre_onglets($rubrique, $sous_rubrique)
		. debut_gauche($rubrique, true)
		. spiplistes_boite_info_id(_T('spiplistes:Courrier_numero_'), $id_courrier, true)
		. spiplistes_naviguer_paniers_courriers(_T('spiplistes:aller_au_panier_'), true)
		. $boite_documents
		. pipeline('affiche_gauche', array('args'=>array('exec'=>$sous_rubrique),'data'=>''))
		//. creer_colonne_droite($rubrique, true)  // spiplistes_boite_raccourcis() s'en occupe
		. spiplistes_boite_raccourcis(true)
		//. spiplistes_boite_autocron() // ne pas gener l'edition
		. pipeline('affiche_droite', array('args'=>array('exec'=>$sous_rubrique),'data'=>''))
		. debut_droite($rubrique, true)
		;

	$page_result .= ""
		// le bloc pour apercu (retour ajax)
		. "<div id='apercu-courrier' style='clear:both;tex-align:center'></div>\n"
		//
		. debut_cadre_formulaire('', true)
		. "<a name='haut-block' id='haut-block'></a>\n"
		// 
		//
		// bloc titre
		. "\n<table cellpadding='0' cellspacing='0' border='0' width='100%'>\n"
		. "<tr width='100%'>"
		. "<td>"
		. $gros_bouton_retour
		. "</td>"
		. "<td><img src='"._DIR_IMG_PACK."/rien.gif' width='10'></td>\n"
		. "<td width='100%'>"
		. ($id_courrier ? _T('spiplistes:Modifier_un_courrier__') : _T('spiplistes:Creer_un_courrier_') )."<br />\n"
		. spiplistes_gros_titre($titre, '', true)
		. "</td>\n"
		. "</tr></table>\n"
		. "<hr />\n"
		;
		//
		// debut formulaire
	
	$page_result .= ""
		. "<form action='".generer_url_ecrire(_SPIPLISTES_EXEC_COURRIER_GERER
											  , ($id_courrier ? "id_courrier=$id_courrier" : "")
											  )
			."' method='post' name='formulaire_courrier_edit' id='formulaire_courrier_edit'>\n"
		. "<input type='hidden' name='modifier_message' value=\"oui\" />\n"
		. "<input type='hidden' name='id_courrier' value='$id_courrier' />\n"
		//
		// bloc sujet du courrier
		. "<label for='sujet_courrier'>"._T('spiplistes:sujet_courrier').":</label>\n"
		. "<input id='sujet_courrier' type='text' class='formo' name='titre' value=\"$titre\" size='40' $clearonfocus />\n"
		. "<p style='margin-bottom:1.75em;'>"._T('spiplistes:Courrier_edit_desc')."</p>\n"
		;
		
	$titre_block_depliable = _T('spiplistes:Generer_le_contenu');
	$page_result .= ''
		//
		// generer le contenu
		// Reprise du Formulaire adapte de abomailman () // MaZiaR - NetAktiv	// tech@netaktiv.com
		. debut_cadre_relief(_DIR_PLUGIN_SPIPLISTES_IMG_PACK.'stock_insert-slide.gif', true)
		//. bouton_block_invisible(md5(_T('spiplistes:charger_patron')))
		. spiplistes_bouton_block_depliable($titre_block_depliable, false, md5(_T('spiplistes:charger_patron')))
		. "<span class='verdana2 triangle_label' onclick=\"javascript:$('#triangle".$compteur_block."').click();\">"
			. (spiplistes_spip_est_inferieur_193() ? $titre_block_depliable : "")
			. "</span>\n"
		. spiplistes_debut_block_invisible(md5(_T('spiplistes:charger_patron')))
		// 
		. '<div id="ajax-loader" align="right">'
			. '<script type="text/javascript">'.$eol
			. 'document.write(\'<img src="' . _DIR_PLUGIN_SPIPLISTES_IMG_PACK . 'ajax_indicator.gif" alt="" />\');'	
			. '</script>'.$eol
			. '<noscript>'.$eol
			. spiplistes_boite_alerte (_T('spiplistes:javascript_inactif'), true)
			. $eol
			. '</noscript>'.$eol
			//. '<img src="' . _DIR_PLUGIN_SPIPLISTES_IMG_PACK . 'ajax_indicator.gif" alt="" />'
			. '</div>'.$eol
		;
	
	if(strpos($GLOBALS['meta']['langues_multilingue'], ",") !== false) {
		$page_result .= "" 
			// selecteur de langues
			. "<div class='boite-generer-option'>\n"
			. "<label class='verdana2'>"._T('spiplistes:Langue_du_courrier_')
			. "<select name='lang' class='fondo'>\n"
			. liste_options_langues('changer_lang')
			. "</select></label>\n"
			. "</div>\n"
			;
	}
	
	$page_result .= ""
		// Prendre en compte a partir de quelle date ?
		. spiplistes_dater_envoi(
			'courrier', $id_courrier, $statut
			, $flag_editable
			, _T('spiplistes:Contenu_a_partir_de_date_')
			, normaliser_date(time()), 'btn_changer_date'
			, false
			)
		;
		
	$page_result .= ""
		// texte introduction a placer avant le patron et sommaire 
		. '<div class="boite-generer-option">'.$eol
		. '<label class="verdana2">'
		. '<input type="checkbox" id="avec_intro" name="avec_intro" value="non" />'
		. _T('spiplistes:avec_introduction')
		. '</label>'.$eol
		. '<div id="choisir_intro" class="option">'.$eol
		. '<label class="verdana2" style="display:block;" for="message_intro">'
		. _T('spiplistes:introduction_du_courrier_').':</label>'.$eol
		. afficher_barre('document.formulaire_courrier_edit.message_intro')
		. '<textarea id="message_intro" name="message_intro" '.$GLOBALS['browser_caret'].' rows="5" cols="40" wrap="soft" style="width:100%">'.$eol
		. '</textarea>'
		. '</div>'.$eol
		. '</div>'.$eol
		;
		
	// selection du patron
	$page_result .= ''
		. "<div class='boite-generer-option'>\n"
		. "<label class='verdana2'>"
		. "<input type='checkbox' id='avec_patron' name='avec_patron' value='non' />"
		. _T('spiplistes:a_partir_de_patron')
		. "</label>\n"
		. "<div id='choisir_patron' class='option'>"
		. "<label class='verdana2'>"
		. _T('spiplistes:choisir_un_patron_').":</label>\n"
		. spiplistes_boite_selection_patrons ("", true, _SPIPLISTES_PATRONS_DIR, "patron", 1)
		. "<div id='patron_pos' style='display:none'>\n"
		. "<span class='verdana2'>" . _T('spiplistes:generer_patron_'). "</span>\n"
		. spiplistes_form_input_radio ('patron_pos', 'avant', _T('spiplistes:generer_patron_avant'), true, true, false)
		. spiplistes_form_input_radio ('patron_pos', 'apres', _T('spiplistes:generer_patron_apres'), false, true, false)
		. "</div>\n"
		. "</div>\n"
		. "</div>\n"
		;
	
	// Generer un sommaire
	$page_result .= ""
		. "<div class='boite-generer-option'>\n"
		. "<label class='verdana2'>"
		. "<input type='checkbox' id='avec_sommaire' name='avec_sommaire' value='non' />"
		. _T('spiplistes:generer_un_sommaire')
		. "</label>\n"
		. "<div id='choisir_sommaire' class='option'>";		
	$page_result .= ""
		//
		// selecteur de rubriques
		. "<label class='verdana2' for='ajouter_rubrique'>"._T('spiplistes:Lister_articles_de_rubrique').":</label>\n"
		. "<select name='id_rubrique' id='ajouter_rubrique' class='formo'>\n"
		. "<option value=''></option>\n"
		. spiplistes_arbo_rubriques()
		. "</select>\n"
		. "<br />\n"
		//
		// selecteur des mots-cles
		. "<label class='verdana2' for='ajouter_motcle'>"._T('spiplistes:Lister_articles_mot_cle').":</label>\n"
		. "<select name='id_mot' id='ajouter_motcle' class='formo'>\n"
		. "<option value=''></option>\n"
		;
	
	if (version_compare($GLOBALS['spip_version_code'], '1.9300', '<')){
		$rqt_gmc = sql_select (array('id_groupe','titre'), 'spip_groupes_mots', "articles=".sql_quote('oui'));
	}else{
		$rqt_gmc = sql_select (array('id_groupe','titre'), 'spip_groupes_mots', "tables_liees LIKE '%articles%'");		
	}
	
	while ($row = sql_fetch($rqt_gmc)) {
		$id_groupe = intval($row['id_groupe']);
		$titre = $row['titre'];
		$page_result .= "<option value='' disabled='disabled'>". supprimer_numero (typo($titre)) . "</option>\n";
		$rqt_mc = sql_select (array('id_mot','titre'), 'spip_mots', "id_groupe=".sql_quote($id_groupe));
		while ($row = sql_fetch($rqt_mc)) {
			$id_mot = intval($row['id_mot']);
			$titre = supprimer_numero (typo($row['titre']));
			$page_result .= "<option value='$id_mot'>--&nbsp;$titre</option>\n";
		}
	}
	$page_result .= ""
		. "</select><br />\n"
		//
		// a partir de la date selectionnee plus haut
		. spiplistes_form_input_item ('checkbox', 'date_sommaire', 'oui'
			, _T('spiplistes:sommaire_date_debut'), $sommaire_date == 'oui', true, false)
		. "</div>\n"
		. "</div>\n"
		; // fin generer le sommaire
		
		// choisir son patron de pied
	$page_result .= ""
		. "<div class='boite-generer-option'>\n"
			. "<label class='verdana2'>"
		. _T('spiplistes:avec_patron_pied__')
		. spiplistes_boite_selection_patrons (_SPIPLISTES_PATRONS_PIED_DEFAUT, true, _SPIPLISTES_PATRONS_PIED_DIR, "pied_patron", 1)
		. "</label>\n"
		. "</div>\n"
		; 
		
	$page_result .= ""
		. "<p class='verdana2'>\n"
			. _T('spiplistes:Cliquez_Generer_desc'
				, array('titre_bouton'=>_T('spiplistes:generer_Apercu'), 'titre_champ_texte'=>_T('spiplistes:texte_courrier'))
				)
			. "</p>\n"
		. "<p class='verdana2'>\n" ._T('spiplistes:calcul_patron_attention') .  "</p>\n"
		. spiplistes_form_bouton_valider ('Valider', _T('spiplistes:generer_Apercu'))
		. fin_block() // fin_block_invisible
		. fin_cadre_relief(true)
		. "<br />\n"
		;
		
	//
	// bloc du courrier (titre, texte), toujours visible
	$page_result .= ''
		. '<label for="texte_courrier">'._T('spiplistes:texte_courrier').'</label>'
		. afficher_barre('document.formulaire_courrier_edit.message')
		. '<textarea id="texte_courrier" name="message" '.$GLOBALS['browser_caret'].' class="porte_plume_partout barre_inserer formo" rows="20" cols="40" wrap=soft>'.$eol
		. $texte
		. '</textarea>'.$eol
		. (!$id_courrier ? '<input type="hidden" name="new" value="oui" />'.$eol : '')
		//
		. '<p style="text-align:right;">'.$eol
		. '<input type="submit" onclick="this.value=\'oui\';" id="btn_courrier_edit" '
			. ' name="btn_courrier_valider" value="'._T('bouton_valider').'" class="fondo" /></p>'.$eol
		// le marqueur pour les documents joints
		. (($id_temp!==false) ? '<input type="hidden" name="id_temp" value="' . $id_temp . '" />'.$eol : '')
		//
		// fin formulaire
		. '</form>'.$eol
		. fin_cadre_formulaire(true)
		;
	
	echo($page_result);

	// COURRIER EDIT FIN ---------------------------------------------------------------

	echo pipeline('affiche_milieu',array('args'=>array('exec'=>$sous_rubrique),'data'=>''))
		, spiplistes_html_signature(_SPIPLISTES_PREFIX)
		, fin_gauche(), fin_page();
	
}
Exemplo n.º 8
0
function public_parametrer_dist($fond, $contexte = '', $cache = '', $connect = '')
{
    static $composer, $styliser, $notes = null;
    $page = tester_redirection($fond, $contexte, $connect);
    if ($page) {
        return $page;
    }
    if (isset($contexte['lang'])) {
        $lang = $contexte['lang'];
    } elseif (!isset($lang)) {
        $lang = $GLOBALS['meta']['langue_site'];
    }
    $select = ((!isset($GLOBALS['forcer_lang']) or !$GLOBALS['forcer_lang']) and $lang != $GLOBALS['spip_lang']);
    if ($select) {
        $select = lang_select($lang);
    }
    $debug = defined('_VAR_MODE') && _VAR_MODE == 'debug';
    if (!$styliser) {
        $styliser = charger_fonction('styliser', 'public');
    }
    list($skel, $mime_type, $gram, $sourcefile) = $styliser($fond, $contexte, $GLOBALS['spip_lang'], $connect);
    if ($skel) {
        // sauver le nom de l'eventuel squelette en cours d'execution
        // (recursion possible a cause des modeles)
        if ($debug) {
            $courant = @$GLOBALS['debug_objets']['courant'];
            $GLOBALS['debug_objets']['contexte'][$sourcefile] = $contexte;
        }
        // charger le squelette en specifiant les langages cibles et source
        // au cas il faudrait le compiler (source posterieure au resultat)
        if (!$composer) {
            $composer = charger_fonction('composer', 'public');
        }
        $fonc = $composer($skel, $mime_type, $gram, $sourcefile, $connect);
    } else {
        $fonc = '';
    }
    if (!$fonc) {
        // squelette inconnu (==='') ou faux (===false)
        $page = $fonc;
    } else {
        // Preparer l'appel de la fonction principale du squelette
        spip_timer($a = 'calcul page ' . rand(0, 1000));
        // On cree un marqueur de notes unique lie a cette composition
        // et on enregistre l'etat courant des globales de notes...
        if (is_null($notes)) {
            $notes = charger_fonction('notes', 'inc', true);
        }
        if ($notes) {
            $notes('', 'empiler');
        }
        // Rajouter d'office ces deux parametres
        // (mais vaudrait mieux que le compilateur sache le simuler
        // car ca interdit l'usage de criteres conditionnels dessus).
        if (!isset($contexte['date'])) {
            $contexte['date'] = date("Y-m-d H:i:s");
            $contexte['date_default'] = true;
        } else {
            $contexte['date'] = normaliser_date($contexte['date'], true);
        }
        if (!isset($contexte['date_redac'])) {
            $contexte['date_redac'] = date("Y-m-d H:i:s");
            $contexte['date_redac_default'] = true;
        } else {
            $contexte['date_redac'] = normaliser_date($contexte['date_redac'], true);
        }
        // Passer le nom du cache pour produire sa destruction automatique
        $page = $fonc(array('cache' => $cache), array($contexte));
        // Restituer les globales de notes telles qu'elles etaient avant l'appel
        // Si l'inclus n'a pas affiche ses notes, tant pis (elles *doivent*
        // etre dans son resultat, autrement elles ne seraient pas prises en
        // compte a chaque calcul d'un texte contenant un modele, mais seulement
        // quand le modele serait calcule, et on aurait des resultats incoherents)
        if ($notes) {
            $notes('', 'depiler');
        }
        // reinjecter en dynamique la pile des notes
        // si il y a des inclure dynamiques
        // si la pile n'est pas vide
        // la generalisation de cette injection permettrait de corriger le point juste au dessus
        // en faisant remonter les notes a l'incluant (A tester et valider avant application)
        if ($notes) {
            $page['notes'] = $notes('', 'sauver_etat');
        }
        // spip_log: un joli contexte
        $infos = array();
        foreach (array_filter($contexte) as $var => $val) {
            if (is_array($val)) {
                $val = serialize($val);
            }
            if (strlen("{$val}") > 30) {
                $val = substr("{$val}", 0, 27) . '..';
            }
            if (strstr($val, ' ')) {
                $val = "'{$val}'";
            }
            $infos[] = $var . '=' . $val;
        }
        $profile = spip_timer($a);
        spip_log("calcul ({$profile}) [{$skel}] " . join(', ', $infos) . ' (' . strlen($page['texte']) . ' octets)');
        if (defined('_CALCUL_PROFILER') and intval($profile) > _CALCUL_PROFILER) {
            spip_log("calcul ({$profile}) [{$skel}] " . join(', ', $infos) . ' (' . strlen($page['texte']) . ' octets) | ' . $_SERVER['REQUEST_URI'], "profiler" . _LOG_AVERTISSEMENT);
        }
        if ($debug) {
            // si c'est ce que demande le debusqueur, lui passer la main
            $t = strlen($page['texte']) ? $page['texte'] : " ";
            $GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t;
            $GLOBALS['debug_objets']['courant'] = $courant;
            $GLOBALS['debug_objets']['profile'][$sourcefile] = $profile;
            if ($GLOBALS['debug_objets']['sourcefile'] and _request('var_mode_objet') == $fonc and _request('var_mode_affiche') == 'resultat') {
                erreur_squelette();
            }
        }
        // Si #CACHE{} n'etait pas la, le mettre a $delais
        if (!isset($page['entetes']['X-Spip-Cache'])) {
            // Dans l'espace prive ou dans un modeles/ on pose un cache 0 par defaut
            // si aucun #CACHE{} spécifié
            // le contexte implicite qui conditionne le cache assure qu'on retombe pas sur le meme
            // entre public et prive
            if (test_espace_prive() or strncmp($fond, 'modeles/', 8) == 0) {
                $page['entetes']['X-Spip-Cache'] = 0;
            } else {
                $page['entetes']['X-Spip-Cache'] = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : 36000;
            }
        }
        $page['contexte'] = $contexte;
        // faire remonter le fichier source
        static $js_inclus = false;
        if (defined('_VAR_INCLURE') and _VAR_INCLURE) {
            $page['sourcefile'] = $sourcefile;
            $page['texte'] = "<div class='inclure_blocs'><h6>" . $page['sourcefile'] . "</h6>" . $page['texte'] . "</div>" . ($js_inclus ? "" : "<script type='text/javascript'>jQuery(function(){jQuery('.inclure_blocs > h6:first-child').hover(function(){jQuery(this).parent().addClass('hover')},function(){jQuery(this).parent().removeClass('hover')})});</script>");
            $js_inclus = true;
        }
        // Si un modele contenait #SESSION, on note l'info dans $page
        if (isset($GLOBALS['cache_utilise_session'])) {
            $page['invalideurs']['session'] = $GLOBALS['cache_utilise_session'];
            unset($GLOBALS['cache_utilise_session']);
        }
    }
    if ($select) {
        lang_select();
    }
    return $page;
}
function html_f7a72f7c15527e9fefe562fecb18cf87($Cache, $Pile, $doublons = array(), $Numrows = array(), $SP = 0)
{
    if (isset($Pile[0]["doublons"]) and is_array($Pile[0]["doublons"])) {
        $doublons = nettoyer_env_doublons($Pile[0]["doublons"]);
    }
    $connect = '';
    $page = BOUCLE_lien_webfontshtml_f7a72f7c15527e9fefe562fecb18cf87($Cache, $Pile, $doublons, $Numrows, $SP) . '

<!-- META DATA -->
	<meta http-equiv="Content-Type" content="text/html; charset=' . interdire_scripts($GLOBALS['meta']['charset']) . '" />
	<meta http-equiv="Content-language" content="' . spip_htmlentities(@$Pile[0]['lang'] ? @$Pile[0]['lang'] : $GLOBALS['spip_lang']) . '" />
	<meta name="language" content="' . spip_htmlentities(@$Pile[0]['lang'] ? @$Pile[0]['lang'] : $GLOBALS['spip_lang']) . '" />
	<meta http-equiv="Content-Style-Type" content="text/css" />
	<meta http-equiv="Content-Script-Type" content="text/javascript" />
	<meta name="generator" content="SPIP' . (($t1 = strval(spip_version())) !== '' ? ' ' . $t1 : '') . '" />
	<meta name="robots" content="index,follow" />
	<link rel="schema.DCTERMS"  href="http://purl.org/dc/terms/" />
	<link rel="schema.DC"       href="http://purl.org/dc/elements/1.1/" />
' . (($t1 = BOUCLE_article_headhtml_f7a72f7c15527e9fefe562fecb18cf87($Cache, $Pile, $doublons, $Numrows, $SP)) !== '' ? $t1 : '
' . (($t2 = BOUCLE_breve_headhtml_f7a72f7c15527e9fefe562fecb18cf87($Cache, $Pile, $doublons, $Numrows, $SP)) !== '' ? $t2 : (($t3 = BOUCLE_mot_headhtml_f7a72f7c15527e9fefe562fecb18cf87($Cache, $Pile, $doublons, $Numrows, $SP)) !== '' ? $t3 : (($t4 = BOUCLE_rubrique_headhtml_f7a72f7c15527e9fefe562fecb18cf87($Cache, $Pile, $doublons, $Numrows, $SP)) !== '' ? $t4 : (($t5 = BOUCLE_site_headhtml_f7a72f7c15527e9fefe562fecb18cf87($Cache, $Pile, $doublons, $Numrows, $SP)) !== '' ? $t5 : '  
	<!-- META pages recapitulatives - META summary pages -->
' . (($t6 = BOUCLE_keywords_recaphtml_f7a72f7c15527e9fefe562fecb18cf87($Cache, $Pile, $doublons, $Numrows, $SP)) !== '' ? '
  <meta name="keywords" content="' . $t6 . '" />' : '') . '
  ' . (($t6 = strval(interdire_scripts(attribut_html(propre($GLOBALS['meta']['descriptif_site'], $connect, $Pile[0]))))) !== '' ? '<meta name="description" content="' . $t6 . '" />' : '') . '
  <meta name="author" content="' . BOUCLE_author_recaphtml_f7a72f7c15527e9fefe562fecb18cf87($Cache, $Pile, $doublons, $Numrows, $SP) . '" />
  <!-- META Dublin Core - voir: http://uk.dublincore.org/documents/dcq-html/  -->
  ' . (($t6 = strval(interdire_scripts(entites_html(textebrut(typo($GLOBALS['meta']['nom_site'], "TYPO", $connect, $Pile[0])))))) !== '' ? '<meta name="DC.title" content="' . $t6 . '" />
  ' : '') . (($t6 = strval(spip_htmlentities(@$Pile[0]['lang'] ? @$Pile[0]['lang'] : $GLOBALS['spip_lang']))) !== '' ? '<meta name="DC.language" scheme="ISO639-1" content="' . $t6 . '" />
  ' : '') . (($t6 = strval(spip_htmlspecialchars(sinon($GLOBALS['meta']['adresse_site'], '.')))) !== '' ? '<meta name="DC.identifier" scheme="DCTERMS.URI" content="' . $t6 . '" />
  ' : '') . (($t6 = strval(spip_htmlspecialchars(sinon($GLOBALS['meta']['adresse_site'], '.')))) !== '' ? '<meta name="DC.source" scheme="DCTERMS.URI" content="' . $t6 . '" />' : '') . BOUCLE_recap_auteursDChtml_f7a72f7c15527e9fefe562fecb18cf87($Cache, $Pile, $doublons, $Numrows, $SP) . (($t6 = strval(interdire_scripts(attribut_html(couper(propre($GLOBALS['meta']['descriptif_site'], $connect, $Pile[0]), '150'))))) !== '' ? '
  <meta name="DC.description" content="' . $t6 . '" />' : '') . (($t6 = BOUCLE_recap_subjectDChtml_f7a72f7c15527e9fefe562fecb18cf87($Cache, $Pile, $doublons, $Numrows, $SP)) !== '' ? '
  <meta name="DC.subject" content="' . $t6 . '" />' : '') . (($t6 = strval(interdire_scripts(date_iso(normaliser_date(@$Pile[0]['date']))))) !== '' ? '
  <meta name="DC.date" scheme="ISO8601" content="' . $t6 . '" />' : '') . '

'))))) . '

' . (($t1 = strval(interdire_scripts(($a = extraire_attribut(filtrer('image_graver', filtrer('image_format', filtrer('image_recadre', filtrer('image_passe_partout', ($a = ($a = table_valeur(@$Pile[0], (string) 'favicon', null) or is_string($a) and strlen($a)) ? $a : find_in_path('favicon.ico') or is_string($a) and strlen($a)) ? $a : (!is_array($l = quete_logo('id_syndic', 'ON', "'0'", '', 0)) ? '' : "<img class=\"spip_logo spip_logos\" alt=\"\" src=\"{$l['0']}\"" . $l[2] . ($l[1] ? " onmouseover=\"this.src='{$l['1']}'\" onmouseout=\"this.src='{$l['0']}'\"" : "") . ' />'), '32', '32'), '32', '32', 'center'), 'ico')), 'src') or is_string($a) and strlen($a)) ? $a : find_in_path('spip.ico')))) !== '' ? '  <link rel="shortcut icon" href="' . $t1 . '" type="image/x-icon" />' : '') . '

' . (($t1 = strval(interdire_scripts(generer_url_public('backend', '')))) !== '' ? '  <link rel="alternate" type="application/rss+xml" title="' . _T('public|spip|ecrire:syndiquer_site') . ' : ' . interdire_scripts(textebrut(typo($GLOBALS['meta']['nom_site'], "TYPO", $connect, $Pile[0]))) . '" href="' . $t1 . '" />' : '') . '

';
    return analyse_resultat_skel('html_f7a72f7c15527e9fefe562fecb18cf87', $Cache, $page, 'squelettes/inc/inc-meta.html');
}
function BOUCLE_articleshtml_a80389532d86f8e6929960268237a0a8(&$Cache, &$Pile, &$doublons, &$Numrows, $SP)
{
    static $command = array();
    static $connect;
    $command['connect'] = $connect = '';
    $doublons_index = array();
    // Initialise le(s) critère(s) doublons
    if (!isset($doublons[$d = 'articles'])) {
        $doublons[$d] = '';
    }
    if (!isset($command['table'])) {
        $command['table'] = 'articles';
        $command['id'] = '_articles';
        $command['from'] = array('articles' => 'spip_articles');
        $command['type'] = array();
        $command['groupby'] = array();
        $command['select'] = array("articles.date", "articles.lang", "articles.id_article", "articles.texte", "articles.descriptif", "articles.chapo", "articles.titre");
        $command['orderby'] = array('articles.date DESC');
        $command['join'] = array();
        $command['limit'] = '0,3';
        $command['having'] = array();
    }
    $command['where'] = array(quete_condition_statut('articles.statut', 'publie,prop,prepa/auteur', 'publie', ''), array(sql_in('articles.id_article', $doublons[$doublons_index[] = 'articles'], 'NOT')));
    if (defined("_BOUCLE_PROFILER")) {
        $timer = time() + microtime();
    }
    $t0 = "";
    // REQUETE
    $iter = IterFactory::create("SQL", $command, array('squelettes/inc/inc-trad.html', 'html_a80389532d86f8e6929960268237a0a8', '_articles', 6, $GLOBALS['spip_lang']));
    if (!$iter->err()) {
        lang_select($GLOBALS['spip_lang']);
        $SP++;
        // RESULTATS
        while ($Pile[$SP] = $iter->fetch()) {
            foreach ($doublons_index as $k) {
                $doublons[$k] .= "," . $Pile[$SP]['id_article'];
            }
            // doublons
            lang_select_public($Pile[$SP]['lang'], '', $Pile[$SP]['titre']);
            $t0 .= '
          	<li>' . (($t1 = strval(interdire_scripts(affdate(normaliser_date($Pile[$SP]['date']))))) !== '' ? '<span>' . $t1 . ((($t2 = strval(traduire_nom_langue(spip_htmlentities($Pile[$SP]['lang'] ? $Pile[$SP]['lang'] : $GLOBALS['spip_lang'])))) !== '' ? ' - <dfn class="lang">' . $t2 . '</dfn>' : '') . '</span>') : '') . ' 
          	    
              <a href="' . spip_htmlspecialchars(sinon($GLOBALS['meta']['adresse_site'], '.')) . '/spip.php?action=converser&amp;redirect=' . spip_htmlspecialchars(sinon($GLOBALS['meta']['adresse_site'], '.')) . '%2F' . vider_url(urlencode_1738(generer_url_entite($Pile[$SP]['id_article'], 'article', '', '', true))) . '&amp;var_lang=' . spip_htmlentities($Pile[$SP]['lang'] ? $Pile[$SP]['lang'] : $GLOBALS['spip_lang']) . '" hreflang="' . spip_htmlentities($Pile[$SP]['lang'] ? $Pile[$SP]['lang'] : $GLOBALS['spip_lang']) . '" ' . (($t1 = strval(interdire_scripts(entites_html(textebrut(filtre_introduction_dist($Pile[$SP]['descriptif'], strlen($Pile[$SP]['descriptif']) ? '' : $Pile[$SP]['chapo'] . "\n\n" . $Pile[$SP]['texte'], 500, $connect, null)))))) !== '' ? 'title="' . $t1 . '"' : '') . '>' . interdire_scripts(supprimer_numero(typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0]))) . '</a>
          	</li>
            ';
            lang_select();
        }
        lang_select();
        $iter->free();
    }
    if (defined("_BOUCLE_PROFILER") and 1000 * ($timer = time() + microtime() - $timer) > _BOUCLE_PROFILER) {
        spip_log(intval(1000 * $timer) . "ms BOUCLE_articles @ squelettes/inc/inc-trad.html", "profiler" . _LOG_AVERTISSEMENT);
    }
    return $t0;
}
function BOUCLE_archivehtml_76ddbc2b5f1671bea60186a8fa5bb500(&$Cache, &$Pile, &$doublons, &$Numrows, $SP)
{
    static $command = array();
    static $connect;
    $command['connect'] = $connect = '';
    $doublons_index = array();
    // Initialise le(s) critère(s) doublons
    if (!isset($doublons[$d = 'articles' . 'archives'])) {
        $doublons[$d] = '';
    }
    if (!isset($command['table'])) {
        $command['table'] = 'articles';
        $command['id'] = '_archive';
        $command['from'] = array('articles' => 'spip_articles', 'L1' => 'spip_mots_liens', 'L2' => 'spip_mots');
        $command['type'] = array();
        $command['groupby'] = array("articles.id_article");
        $command['select'] = array("articles.date_redac", "articles.id_article", "articles.titre", "articles.lang");
        $command['orderby'] = array('articles.date_redac DESC');
        $command['join'] = array('L1' => array('articles', 'id_objet', 'id_article', 'L1.objet=' . sql_quote('article')), 'L2' => array('L1', 'id_mot'));
        $command['limit'] = '';
        $command['having'] = array();
    }
    $command['where'] = array(quete_condition_statut('articles.statut', 'publie,prop,prepa/auteur', 'publie', ''), array('=', 'L2.titre', "'Agenda'"), array('=', 'articles.lang', sql_quote($GLOBALS['spip_lang'], '', 'varchar(10) NOT NULL DEFAULT \'\'')), array(sql_in('articles.id_article', $doublons[$doublons_index[] = 'articles' . 'archives'], 'NOT')));
    if (defined("_BOUCLE_PROFILER")) {
        $timer = time() + microtime();
    }
    $t0 = "";
    // REQUETE
    $iter = IterFactory::create("SQL", $command, array('squelettes/agenda.html', 'html_76ddbc2b5f1671bea60186a8fa5bb500', '_archive', 77, $GLOBALS['spip_lang']));
    if (!$iter->err()) {
        // COMPTEUR
        $Numrows['_archive']['compteur_boucle'] = 0;
        lang_select($GLOBALS['spip_lang']);
        $SP++;
        // RESULTATS
        while ($Pile[$SP] = $iter->fetch()) {
            $Numrows['_archive']['compteur_boucle']++;
            foreach ($doublons_index as $k) {
                $doublons[$k] .= "," . $Pile[$SP]['id_article'];
            }
            // doublons
            lang_select_public($Pile[$SP]['lang'], '', $Pile[$SP]['titre']);
            $t0 .= '
		' . (($t1 = strval(unique(annee(normaliser_date($Pile[$SP]['date_redac']))))) !== '' ? '
			' . ($Numrows['_archive']['compteur_boucle'] > '1' ? '</ul></li></ul></div>' : '') . '
			<div id="plan">
			<h3>' . $t1 . '</h3>

			<ul>
		' : '') . '
		' . (($t1 = strval(nom_mois(unique(affdate(normaliser_date($Pile[$SP]['date_redac']), 'Y-m'))))) !== '' ? '
			' . (unique(annee(normaliser_date($Pile[$SP]['date_redac'])), 'nouvelle') ? '' : '</ul></li>') . '
			  <li>' . $t1 . '
  				<ul>
		' : '') . '
				  <li><a href="' . vider_url(urlencode_1738(generer_url_entite($Pile[$SP]['id_article'], 'article', '', '', true))) . '">' . interdire_scripts(supprimer_numero(typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0]))) . '</a></li>
	';
            lang_select();
        }
        lang_select();
        $iter->free();
    }
    if (defined("_BOUCLE_PROFILER") and 1000 * ($timer = time() + microtime() - $timer) > _BOUCLE_PROFILER) {
        spip_log(intval(1000 * $timer) . "ms BOUCLE_archive @ squelettes/agenda.html", "profiler" . _LOG_AVERTISSEMENT);
    }
    return $t0;
}
function BOUCLE_articles_rubriquehtml_8bf8bdc0aa13e79e11d908f1699ff96f(&$Cache, &$Pile, &$doublons, &$Numrows, $SP)
{
    static $command = array();
    static $connect;
    $command['connect'] = $connect = '';
    $command['pagination'] = array(isset($Pile[0]['debut_articles_rubrique']) ? $Pile[0]['debut_articles_rubrique'] : null, 10);
    if (!isset($command['table'])) {
        $command['table'] = 'articles';
        $command['id'] = '_articles_rubrique';
        $command['from'] = array('articles' => 'spip_articles');
        $command['type'] = array();
        $command['groupby'] = array();
        $command['select'] = array("articles.id_rubrique", "0+articles.titre AS num", "articles.date", "articles.id_article", "articles.surtitre", "articles.descriptif", "articles.titre", "articles.soustitre", "articles.chapo", "articles.texte", "articles.lang");
        $command['orderby'] = array('num', 'articles.date DESC');
        $command['join'] = array();
        $command['limit'] = '';
        $command['having'] = array();
    }
    $command['where'] = array(quete_condition_statut('articles.statut', 'publie,prop,prepa/auteur', 'publie', ''), sql_in('articles.id_rubrique', calcul_branche_in(sql_quote(@$Pile[0]['id_rubrique']))));
    if (defined("_BOUCLE_PROFILER")) {
        $timer = time() + microtime();
    }
    $t0 = "";
    // REQUETE
    $iter = IterFactory::create("SQL", $command, array('squelettes/inc/inc-rub-articles.html', 'html_8bf8bdc0aa13e79e11d908f1699ff96f', '_articles_rubrique', 1, $GLOBALS['spip_lang']));
    if (!$iter->err()) {
        // COMPTEUR
        $Numrows['_articles_rubrique']['compteur_boucle'] = 0;
        $Numrows['_articles_rubrique']['total'] = @intval($iter->count());
        $debut_boucle = isset($Pile[0]['debut_articles_rubrique']) ? $Pile[0]['debut_articles_rubrique'] : _request('debut_articles_rubrique');
        if (substr($debut_boucle, 0, 1) == '@') {
            $debut_boucle = $Pile[0]['debut_articles_rubrique'] = quete_debut_pagination('id_article', $Pile[0]['@id_article'] = substr($debut_boucle, 1), 10, $iter);
            $iter->seek(0);
        }
        $debut_boucle = intval($debut_boucle);
        $debut_boucle = ($tout = $debut_boucle == -1) ? 0 : $debut_boucle;
        $debut_boucle = max(0, min($debut_boucle, floor(($Numrows['_articles_rubrique']['total'] - 1) / 10) * 10));
        $debut_boucle = intval($debut_boucle);
        $fin_boucle = min($tout ? $Numrows['_articles_rubrique']['total'] : $debut_boucle + 9, $Numrows['_articles_rubrique']['total'] - 1);
        $Numrows['_articles_rubrique']['grand_total'] = $Numrows['_articles_rubrique']['total'];
        $Numrows['_articles_rubrique']["total"] = max(0, $fin_boucle - $debut_boucle + 1);
        if ($debut_boucle > 0 and $debut_boucle < $Numrows['_articles_rubrique']['grand_total'] and $iter->seek($debut_boucle, 'continue')) {
            $Numrows['_articles_rubrique']['compteur_boucle'] = $debut_boucle;
        }
        lang_select($GLOBALS['spip_lang']);
        $SP++;
        // RESULTATS
        while ($Pile[$SP] = $iter->fetch()) {
            $Numrows['_articles_rubrique']['compteur_boucle']++;
            if ($Numrows['_articles_rubrique']['compteur_boucle'] <= $debut_boucle) {
                continue;
            }
            if ($Numrows['_articles_rubrique']['compteur_boucle'] - 1 > $fin_boucle) {
                break;
            }
            lang_select_public($Pile[$SP]['lang'], '', $Pile[$SP]['titre']);
            $t0 .= '
			<br class="nettoyeur" />
			' . (($t1 = strval(filtrer('image_graver', filtrer('image_reduire', strlen($logo = !is_array($l = quete_logo('id_article', 'ON', $Pile[$SP]['id_article'], '', 0)) ? '' : "<img class=\"spip_logo spip_logos\" alt=\"\" src=\"{$l['0']}\"" . $l[2] . ($l[1] ? " onmouseover=\"this.src='{$l['1']}'\" onmouseout=\"this.src='{$l['0']}'\"" : "") . ' />') ? '<a href="' . vider_url(urlencode_1738(generer_url_entite($Pile[$SP]['id_article'], 'article', '', '', true))) . '">' . $logo . '</a>' : '', '120', '0')))) !== '' ? '<div class="logo-liste-art">
				' . $t1 . '
			</div>' : '') . '
			' . (($t1 = strval(interdire_scripts(typo($Pile[$SP]['surtitre'], "TYPO", $connect, $Pile[0])))) !== '' ? '<div class="surtitre">' . $t1 . '</div>' : '') . '
			<h3>
			<a href="' . spip_htmlspecialchars(sinon($GLOBALS['meta']['adresse_site'], '.')) . '/' . vider_url(urlencode_1738(generer_url_entite($Pile[$SP]['id_article'], 'article', '', '', true))) . '" ' . (($t1 = strval(interdire_scripts(entites_html(textebrut(propre($Pile[$SP]['descriptif'], $connect, $Pile[0])))))) !== '' ? 'title="' . $t1 . '"' : '') . '>' . interdire_scripts(supprimer_numero(typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0]))) . '</a>
			' . BOUCLE_articles_rubrique_nomhtml_8bf8bdc0aa13e79e11d908f1699ff96f($Cache, $Pile, $doublons, $Numrows, $SP) . '
			</h3>
      	' . (($t1 = strval(interdire_scripts(typo($Pile[$SP]['soustitre'], "TYPO", $connect, $Pile[0])))) !== '' ? '<div class="sous-titre">' . $t1 . '</div>' : '') . '
		<div class="detail">
			' . (($t1 = strval(interdire_scripts(nom_jour(normaliser_date($Pile[$SP]['date']))))) !== '' ? '<span class="date">' . $t1 : '') . ' ' . (($t1 = strval(interdire_scripts(affdate(normaliser_date($Pile[$SP]['date']))))) !== '' ? $t1 . '</span>' : '') . ' 
			' . (($t1 = strval(recuperer_fond('modeles/lesauteurs', array('objet' => 'article', 'id_objet' => $Pile[$SP]['id_article'], 'id_article' => $Pile[$SP]['id_article']), array('trim' => true, 'compil' => array('squelettes/inc/inc-rub-articles.html', 'html_8bf8bdc0aa13e79e11d908f1699ff96f', '_articles_rubrique', 17, $GLOBALS['spip_lang'])), ''))) !== '' ? '<span class="auteurs">' . _T('public|spip|ecrire:par_auteur') . ' ' . $t1 . '</span>' : '') . '				
		</div><!-- detail -->
      <div class="texte">
	' . (($t1 = strval(interdire_scripts(filtrer('image_graver', filtrer('image_reduire', propre($Pile[$SP]['descriptif'], $connect, $Pile[0]), '552', '0')) ? (($t2 = strval(interdire_scripts(filtrer('image_graver', filtrer('image_reduire', propre($Pile[$SP]['descriptif'], $connect, $Pile[0]), '552', '0'))))) !== '' ? '<div class="">' . $t2 . ('</div>
		<div class="suite"><a href="' . vider_url(urlencode_1738(generer_url_entite($Pile[$SP]['id_article'], 'article', '', '', true))) . '" title="...' . _T('public|spip|ecrire:suite') . ' : ' . interdire_scripts(attribut_html(supprimer_numero(typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0])))) . '" >' . _T('public|spip|ecrire:suite') . '</a></div>') : '') . '
		' : interdire_scripts(propre($Pile[$SP]['chapo'], $connect, $Pile[0]) ? (($t3 = strval(interdire_scripts(filtrer('image_graver', filtrer('image_reduire', propre($Pile[$SP]['chapo'], $connect, $Pile[0]), '552', '0'))))) !== '' ? '<div class="">' . $t3 . ('</div>
      	<div class="suite"><a href="' . vider_url(urlencode_1738(generer_url_entite($Pile[$SP]['id_article'], 'article', '', '', true))) . '" title="...' . _T('public|spip|ecrire:suite') . ' : ' . interdire_scripts(attribut_html(supprimer_numero(typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0])))) . '" >' . _T('public|spip|ecrire:suite') . '</a></div>') : '') . '
      		' : (($t3 = strval(interdire_scripts(couper(propre($Pile[$SP]['texte'], $connect, $Pile[0]), '300')))) !== '' ? '<div class="">' . $t3 . ('</div>
      	<div class="suite"><a href="' . vider_url(urlencode_1738(generer_url_entite($Pile[$SP]['id_article'], 'article', '', '', true))) . '" title="...' . _T('public|spip|ecrire:suite') . ' : ' . interdire_scripts(attribut_html(supprimer_numero(typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0])))) . '" >' . _T('public|spip|ecrire:suite') . '</a></div>') : '') . '
		') . '
	'))) !== '' ? '<div class="extrait">' . $t1 . '</div><!-- fin extrait -->' : '') . '
      </div><!-- fin texte -->
      <br class="nettoyeur" />
		';
            lang_select();
        }
        lang_select();
        $iter->free();
    }
    if (defined("_BOUCLE_PROFILER") and 1000 * ($timer = time() + microtime() - $timer) > _BOUCLE_PROFILER) {
        spip_log(intval(1000 * $timer) . "ms BOUCLE_articles_rubrique @ squelettes/inc/inc-rub-articles.html", "profiler" . _LOG_AVERTISSEMENT);
    }
    return $t0;
}
function BOUCLE_documents_jointshtml_4dc0f36e18dd7a26ebc382429cbc9835(&$Cache, &$Pile, &$doublons, &$Numrows, $SP)
{
    static $command = array();
    static $connect;
    $command['connect'] = $connect = '';
    $in = array();
    $in[] = 'gif';
    $in[] = 'jpg';
    $in[] = 'png';
    if (!isset($command['table'])) {
        $command['table'] = 'documents';
        $command['id'] = '_documents_joints';
        $command['from'] = array('documents' => 'spip_documents', 'L1' => 'spip_documents_liens', 'L2' => 'spip_types_documents');
        $command['type'] = array();
        $command['groupby'] = array();
        $command['select'] = array("0+documents.titre AS num", "documents.date", "documents.titre", "documents.id_document", "L2.titre AS type_document", "documents.taille", "documents.descriptif");
        $command['orderby'] = array('num', 'documents.date DESC');
        $command['join'] = array('L1' => array('documents', 'id_document'), 'L2' => array('documents', 'extension'));
        $command['limit'] = '';
        $command['having'] = array();
    }
    $command['where'] = array(quete_condition_statut('documents.statut', 'publie,prop,prepa', 'publie', ''), array('IN', 'documents.mode', '(\'image\',\'document\')'), array('(documents.taille > 0 OR documents.distant=\'oui\')'), array('=', 'L1.id_objet', sql_quote(@$Pile[0]['id_rubrique'], '', 'bigint(21) NOT NULL DEFAULT \'0\'')), array('=', 'L1.objet', sql_quote('rubrique')), sql_in('documents.extension', sql_quote($in), 'NOT'), array('=', 'L1.vu', "'non'"));
    if (defined("_BOUCLE_PROFILER")) {
        $timer = time() + microtime();
    }
    $t0 = "";
    // REQUETE
    $iter = IterFactory::create("SQL", $command, array('squelettes/inc/inc-rub-documents.html', 'html_4dc0f36e18dd7a26ebc382429cbc9835', '_documents_joints', 39, $GLOBALS['spip_lang']));
    if (!$iter->err()) {
        $l1 = _T('spip:info_document');
        $SP++;
        // RESULTATS
        while ($Pile[$SP] = $iter->fetch()) {
            $t1 = '
				' . (($t1 = strval(interdire_scripts(supprimer_numero(traiter_doublons_documents($doublons, typo(supprimer_numero($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0])))))) !== '' ? '<h3 class="" style="margin-bottom: .6em;"><a href="' . vider_url(urlencode_1738(generer_url_entite($Pile[$SP]['id_document'], 'document', '', '', true))) . '">' . $t1 . '</a></h3>' : '') . '
				' . (($t1 = strval(filtrer('image_graver', filtrer('image_reduire', ($doublons["documents"] .= "," . $Pile[$SP]['id_document']) ? quete_logo_document(quete_document($Pile[$SP]['id_document'], ''), vider_url(urlencode_1738(generer_url_entite($Pile[$SP]['id_document'], 'document', '', '', true))), '', '', 0, 0, '') : '', '60', '0')))) !== '' ? '<div style="float:left;padding-right: .5em;  width:36%;">
					<div style="float:left; margin-right: .5em;">' . $t1 . ('</div>
					<small>
						' . (($t2 = strval(interdire_scripts(affdate(normaliser_date($Pile[$SP]['date']))))) !== '' ? $t2 . '<br />' : '') . '
						' . (($t2 = strval(interdire_scripts($Pile[$SP]['type_document']))) !== '' ? $l1 . ' : ' . $t2 . '<br />' : '') . '
						' . interdire_scripts(taille_en_octets($Pile[$SP]['taille'])) . '
					</small>
				</div>') : '') . '
				' . (($t1 = strval(interdire_scripts(traiter_doublons_documents($doublons, propre($Pile[$SP]['descriptif'], $connect, $Pile[0]))))) !== '' ? '<div class="" style="margin: 0 0 0 40%; border-left: 1px gray dotted;padding-left: 1em">' . $t1 . '</div>' : '') . '
		';
            $t0 .= (strlen($t1) && strlen($t0) ? '<hr style=\'clear:both\' />' : '') . $t1;
        }
        $iter->free();
    }
    if (defined("_BOUCLE_PROFILER") and 1000 * ($timer = time() + microtime() - $timer) > _BOUCLE_PROFILER) {
        spip_log(intval(1000 * $timer) . "ms BOUCLE_documents_joints @ squelettes/inc/inc-rub-documents.html", "profiler" . _LOG_AVERTISSEMENT);
    }
    return $t0;
}
Exemplo n.º 14
0
/**
 * cron_spiplistes_cron() renvoie:
 * - nul, si la tache n'a pas a etre effectuee
 * - positif, si la tache a ete effectuee
 * - negatif, si la tache doit etre poursuivie ou recommencee
 * @return null|int
 */
function cron_spiplistes_cron ($last_time) { 

	include_spip('inc/utils');
	include_spip('inc/spiplistes_api_globales');
	include_spip('base/spiplistes_tables');
	include_spip('inc/spiplistes_api');
	include_spip('inc/spiplistes_api_courrier');
	include_spip('inc/spiplistes_api_abstract_sql');

	$prefix_log = 'CRON: ';

	// initialise les options (prefs spiplistes)
	foreach(array(
		'opt_suspendre_trieuse'
		) as $key) {
		$$key = spiplistes_pref_lire($key);
	}

	if($opt_suspendre_trieuse == 'oui') {
		spiplistes_log($prefix_log.'SUSPEND MODE !!!');
		if(spiplistes_courriers_en_queue_compter('etat='.sql_quote('')) > 0) {
			include_spip('inc/spiplistes_meleuse');
			return(spiplistes_meleuse($last_time));
		}
		else {
			return($last_time);
		}
	}

	$current_time = time();

	$sql_select = array(
		'id_liste', 'titre', 'titre_message', 'date', 'maj'
		, 'message_auto', 'periode', 'lang', 'patron', 'statut'
	);

	// demande les listes auto a' envoyer (date <= maintenant)
	$sql_where = 'message_auto='.sql_quote('oui').'
			AND date > 0  
			AND date <= NOW()
			AND ('.spiplistes_listes_sql_where_or(_SPIPLISTES_LISTES_STATUTS_OK).')
			'
		;
	$listes_privees_et_publiques = sql_select(
		$sql_select
		, 'spip_listes'
		, $sql_where
		);
	
	$nb_listes_ok = sql_count($listes_privees_et_publiques);
	
	spiplistes_debug_log($prefix_log.'nb listes depart: '.$nb_listes_ok);

	if($nb_listes_ok > 0) {
	
		$mod_listes_ids = spiplistes_mod_listes_get_id_auteur('toutes');
		
		while($row = sql_fetch($listes_privees_et_publiques)) {
		
			// initalise les variables
			foreach($sql_select as $key) {
				$$key = $row[$key];
			}
			$id_liste = intval($id_liste);
			$periode = intval($periode);
			$envoyer_quand = $date;
			$dernier_envoi = $maj;
		
			// demande id_auteur de la liste pour signer le courrier
			// si plusieurs moderateurs, prend le premier
			$id_auteur = 
				(isset($mod_listes_ids[$id_liste]) && ($mod_listes_ids[$id_liste][0] > 0))
				? $mod_listes_ids[$id_liste][0]
				: 1 // attribue a l'admin principal si manquant
				;
			
			// Tampon date prochain envoi (dans 'date') et d'envoi (dans 'maj')
			$sql_set = $next_time = false;
			if(in_array($statut, explode(';', _SPIPLISTES_LISTES_STATUTS_PERIODIQUES))) 
			{
				// prendre la date du jour plutot que la dernier date choisie
				// sinon, une lettre quotidienne du mois precedent
				// se verra envoyee autant de fois que de jours en attente
				//$job_time = strtotime($envoyer_quand);
				$job_time = strtotime(spiplistes_sql_now());
					
				$job_heure = date('H', $job_time);
				$job_minute = date('i', $job_time);
				$job_mois = date('m', $job_time);
				$job_jour = (($statut == _SPIPLISTES_LIST_PUB_MONTHLY) ? 1 : date('j', $job_time));
				$job_an = date('Y'); // la date est forcee par celle du systeme (eviter erreurs)
				switch($statut) {
					case _SPIPLISTES_LIST_PRIV_YEARLY:
					case _SPIPLISTES_LIST_PUB_YEARLY:
						$next_time = mktime($job_heure, $job_minute, 0, $job_mois, $job_jour, $job_an+1);
						break;
					case _SPIPLISTES_LIST_PRIV_MENSUEL:
					case _SPIPLISTES_LIST_PRIV_MONTHLY:
					case _SPIPLISTES_LIST_PUB_MENSUEL:
					case _SPIPLISTES_LIST_PUB_MONTHLY:
						$next_time = mktime($job_heure, $job_minute, 0, $job_mois+1, $job_jour, $job_an);
						break;
					case _SPIPLISTES_LIST_PRIV_HEBDO:
					case _SPIPLISTES_LIST_PRIV_WEEKLY:
					case _SPIPLISTES_LIST_PUB_HEBDO:
					case _SPIPLISTES_LIST_PUB_WEEKLY:
						$next_time = mktime($job_heure, $job_minute, 0, $job_mois, $job_jour+7, $job_an);
						break;
					case _SPIPLISTES_LIST_PRIV_DAILY:
					case _SPIPLISTES_LIST_PUB_DAILY:
						$next_time = mktime($job_heure, $job_minute, 0, $job_mois, $job_jour+$periode, $job_an);
						break;
					default:
						$sql_set = array('date' => sql_quote(''), 'message_auto' => sql_quote('non'));
						break;
				}
			}
			else if($periode) {
				$next_time = time() + (_SPIPLISTES_TIME_1_DAY * $periode);
			}
			else {
				// pas de periode ? c'est un envoyer_maintenant.
				// applique le tampon date d'envoi et repasse la liste en auto non
				$sql_set = array('date' => sql_quote(''), 'message_auto' => sql_quote('non'));
			}
			if($next_time || count($sql_set)) {
				if($next_time) {
					// prochaine date d'envoi dans 'date'
					$sql_set = array('date' => sql_quote(normaliser_date($next_time)));
				}
				$sql_set['maj'] = 'NOW()';
				sql_update(
					'spip_listes'
					, $sql_set
					, 'id_liste='.sql_quote($id_liste).' LIMIT 1'
					);
			}
	
			/////////////////////////////
			// preparation du courrier a placer dans le panier (spip_courriers)
			// en cas de periode, la date est dans le passe'
			// pour avoir les elements publies depuis cette date
			if (
				empty($titre_message)
				&& (spiplistes_pref_lire_defaut('opt_completer_titre_nom_site', 'oui') == 'oui')
			) {
					$titre .= _T('spiplistes:_de_')
						. spiplistes_nom_site_texte($lang);
			}
			else {
				$titre = $titre_message;
			}
			
			spiplistes_debug_log ($prefix_log.'utiliser patron '._SPIPLISTES_PATRONS_DIR.$patron);
			
			list($courrier_html, $courrier_texte) = spiplistes_courriers_assembler_patron (
				_SPIPLISTES_PATRONS_DIR . $patron
				, array('date' => $dernier_envoi, 'patron'=>$patron, 'lang'=>$lang));
			
			//$taille_courrier_ok = (($n = spiplistes_strlen(spiplistes_courrier_version_texte($courrier_html))) > 10);
			$taille_courrier_ok = (($n = strlen($courrier_texte)) > 10);
			
			spiplistes_debug_log($prefix_log.'taille courrier pour la liste #'.$id_liste.' : '.$n);

			if($taille_courrier_ok) {
				include_spip('inc/filtres');
				$courrier_html = spiplistes_liens_absolus ($courrier_html);
				$date_debut_envoi = $date_fin_envoi = "''";
				$statut = _SPIPLISTES_COURRIER_STATUT_ENCOURS;
			}
			else {
				$date_debut_envoi = $date_fin_envoi = 'NOW()';
				$statut = _SPIPLISTES_COURRIER_STATUT_VIDE;
				spiplistes_debug_log($prefix_log.'courrier vide');
			}

			// Place le courrier dans le casier
			$id_courrier = sql_insert(
				'spip_courriers'
				,	'('
					. 'titre
						,date
						,statut
						,type
						,id_auteur
						,id_liste
						,date_debut_envoi
						,date_fin_envoi
						,texte
						,message_texte'
					. ')'
				, 	'('
					. sql_quote($titre)
					. ',NOW()'
					. ','.sql_quote($statut)
					. ','.sql_quote(_SPIPLISTES_COURRIER_TYPE_LISTEAUTO)
					. ','.sql_quote($id_auteur)
					. ','.sql_quote($id_liste)
					. ','.$date_debut_envoi
					. ','.$date_fin_envoi
					. ','.sql_quote($courrier_html)
					. ','.sql_quote($courrier_texte)
					. ')'
			);

			if($taille_courrier_ok) {
				// place les etiquettes
				// (ajout des abonnes dans la queue (spip_auteurs_courriers))
				spiplistes_courrier_remplir_queue_envois($id_courrier, $id_liste);
			} 
		} // end while // fin traitement des listes
	}	
	
	/////////////////////////////
	// Si panier des etiquettes plein, appel de la meleuse
	if(
		$n = 
			spiplistes_courriers_en_queue_compter('etat='.sql_quote(''))
	){

		spiplistes_debug_log($prefix_log.$n.' job(s), appel meleuse');

		include_spip('inc/spiplistes_meleuse');
		return(spiplistes_meleuse($last_time));
	}
	else {
		spiplistes_debug_log($prefix_log.'NO JOB');
	}
	return ($last_time); 
} // cron_spiplistes_cron()