<?php

/*
 * Squelette : plugins/ckeditor-spip-plugin/articles-links-json.html
 * Date :      Fri, 03 Jul 2020 11:43:33 GMT
 * Compile :   Thu, 27 Jul 2023 09:35:32 GMT
 * Boucles :   _articles, _si
 */ 

function BOUCLE_articleshtml_f2a11b1ae6e08e840884de65d46a22a6(&$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');
		$command['type'] = array();
		$command['groupby'] = array();
		$command['select'] = array("0+articles.titre AS num",
		"articles.titre",
		"articles.id_article",
		"articles.lang");
		$command['orderby'] = array('num', 'articles.titre DESC');
		$command['join'] = array();
		$command['limit'] = '';
		$command['having'] = 
			array();
	}
	$command['where'] = 
			array(
quete_condition_statut('articles.statut','publie,prop,prepa/auteur','publie',''), 
quete_condition_postdates('articles.date',''), 
			array('=', 'articles.id_rubrique', sql_quote(interdire_scripts(entites_html(table_valeur(@$Pile[0], (string)'id_rubrique', null),true)), '', 'bigint(21) NOT NULL DEFAULT \'0\'')));
	if (defined("_BOUCLE_PROFILER")) $timer = time()+(float)microtime();
	$t0 = "";
	// REQUETE
	$iter = IterFactory::create(
		"SQL",
		$command,
		array('plugins/ckeditor-spip-plugin/articles-links-json.html','html_f2a11b1ae6e08e840884de65d46a22a6','_articles',4,$GLOBALS['spip_lang'])
	);
	if (!$iter->err()) {
	
	// COMPTEUR
	$Numrows['_articles']['compteur_boucle'] = 0;
	$Numrows['_articles']['total'] = @intval($iter->count());
	lang_select($GLOBALS['spip_lang']);
	$SP++;
	// RESULTATS
	while ($Pile[$SP]=$iter->fetch()) {

		$Numrows['_articles']['compteur_boucle']++;
		lang_select_public($Pile[$SP]['lang'], '', $Pile[$SP]['titre']);
		$t0 .= (
'
	{ 
		"titre": ' .
interdire_scripts(json_encode(couper(strip_tags(supprimer_numero(typo($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0])),'30'))) .
', 
		"url": ' .
interdire_scripts(json_encode(parametre_url(generer_url_public('article', ''),'id_article',$Pile[$SP]['id_article']))) .
',
		"id": ' .
json_encode($Pile[$SP]['id_article']) .
'
	}' .
(($Numrows['_articles']['compteur_boucle'] != $Numrows['_articles']['total']) ? ',':'') .
'
');
		lang_select();
	}
	lang_select();
	$iter->free();
	}
	if (defined("_BOUCLE_PROFILER")
	AND 1000*($timer = (time()+(float)microtime())-$timer) > _BOUCLE_PROFILER)
		spip_log(intval(1000*$timer)."ms BOUCLE_articles @ plugins/ckeditor-spip-plugin/articles-links-json.html","profiler"._LOG_AVERTISSEMENT);
	return $t0;
}


function BOUCLE_sihtml_f2a11b1ae6e08e840884de65d46a22a6(&$Cache, &$Pile, &$doublons, &$Numrows, $SP) {

	static $command = array();
	static $connect;
	$command['connect'] = $connect = '';
	if (!isset($si_init)) { $command['si'] = array(); $si_init = true; }
	$command['si'][] = interdire_scripts(invalideur_session($Cache, (table_valeur($GLOBALS["visiteur_session"], (string)'statut', null) < '2')));

	if (!isset($command['table'])) {
		$command['table'] = '';
		$command['id'] = '_si';
		$command['from'] = array();
		$command['type'] = array();
		$command['groupby'] = array();
		$command['select'] = array("1");
		$command['orderby'] = array();
		$command['where'] = 
			array();
		$command['join'] = array();
		$command['limit'] = '';
		$command['having'] = 
			array();
	}
	if (defined("_BOUCLE_PROFILER")) $timer = time()+(float)microtime();
	$t0 = "";
	// REQUETE
	$iter = IterFactory::create(
		"CONDITION",
		$command,
		array('plugins/ckeditor-spip-plugin/articles-links-json.html','html_f2a11b1ae6e08e840884de65d46a22a6','_si',3,$GLOBALS['spip_lang'])
	);
	if (!$iter->err()) {
	$SP++;
	// RESULTATS
	while ($Pile[$SP]=$iter->fetch()) {

		$t0 .= (
'
[' .
BOUCLE_articleshtml_f2a11b1ae6e08e840884de65d46a22a6($Cache, $Pile, $doublons, $Numrows, $SP) .
']
');
	}
	$iter->free();
	}
	if (defined("_BOUCLE_PROFILER")
	AND 1000*($timer = (time()+(float)microtime())-$timer) > _BOUCLE_PROFILER)
		spip_log(intval(1000*$timer)."ms BOUCLE_si @ plugins/ckeditor-spip-plugin/articles-links-json.html","profiler"._LOG_AVERTISSEMENT);
	return $t0;
}

//
// Fonction principale du squelette plugins/ckeditor-spip-plugin/articles-links-json.html
// Temps de compilation total: 2.446 ms
//

function html_f2a11b1ae6e08e840884de65d46a22a6($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 = (
'<'.'?php header("X-Spip-Cache: 0"); ?'.'>'.'<'.'?php header("Cache-Control: no-cache, must-revalidate"); ?'.'><'.'?php header("Pragma: no-cache"); ?'.'>' .
'<'.'?php header(' . _q((	'Content-type: application/json' .
	(($t2 = strval(interdire_scripts($GLOBALS['meta']['charset'])))!=='' ?
			('; charset=' . $t2) :
			''))) . '); ?'.'>
' .
BOUCLE_sihtml_f2a11b1ae6e08e840884de65d46a22a6($Cache, $Pile, $doublons, $Numrows, $SP) .
'
');

	return analyse_resultat_skel('html_f2a11b1ae6e08e840884de65d46a22a6', $Cache, $page, 'plugins/ckeditor-spip-plugin/articles-links-json.html');
}
?>