<?php

/*
 * Squelette : plugins/ckeditor-spip-plugin/rubriques-links-json.html
 * Date :      Fri, 03 Jul 2020 11:43:34 GMT
 * Compile :   Thu, 27 Jul 2023 09:35:31 GMT
 * Boucles :   _re, _sous_rubriques, _rubriques, _pour, _si
 */ 

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

	static $command = array();
	static $connect;
	$command['connect'] = $connect = '';
	$save_numrows = (isset($Numrows['_sous_rubriques']) ? $Numrows['_sous_rubriques'] : array());
	$t0 = BOUCLE_sous_rubriqueshtml_d8c74a37b067f7938026fb8ee8c8c0ca($Cache, $Pile, $doublons, $Numrows, $SP);
	$Numrows['_sous_rubriques'] = ($save_numrows);
	return $t0;
}


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

	static $command = array();
	static $connect;
	$command['connect'] = $connect = '';
	if (!isset($command['table'])) {
		$command['table'] = 'rubriques';
		$command['id'] = '_sous_rubriques';
		$command['from'] = array('rubriques' => 'spip_rubriques');
		$command['type'] = array();
		$command['groupby'] = array();
		$command['select'] = array("0+rubriques.titre AS num",
		"rubriques.titre",
		"rubriques.id_rubrique",
		"rubriques.lang");
		$command['orderby'] = array('num', 'rubriques.titre');
		$command['join'] = array();
		$command['limit'] = '';
		$command['having'] = 
			array();
	}
	$command['where'] = 
			array(
quete_condition_statut('rubriques.statut','!','publie',''), 
			array('=', 'rubriques.id_parent', sql_quote($Pile[$SP]['id_rubrique'], '', '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/rubriques-links-json.html','html_d8c74a37b067f7938026fb8ee8c8c0ca','_sous_rubriques',11,$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 .= (
vide($Pile['vars'][$_zzz=(string)'cpt'] = plus(table_valeur($Pile["vars"], (string)'cpt', null),'1')) .
vide($Pile['vars'][$_zzz=(string)'item'] = array()) .
vide($Pile['vars'][$_zzz=(string)'item'] = filtre_push(table_valeur($Pile["vars"], (string)'item', null),interdire_scripts(json_encode(couper(strip_tags(supprimer_numero(typo($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0])),'30'))))) .
vide($Pile['vars'][$_zzz=(string)'item'] = filtre_push(table_valeur($Pile["vars"], (string)'item', null),interdire_scripts(json_encode(parametre_url(generer_url_public('rubrique', ''),'id_rubrique',$Pile[$SP]['id_rubrique']))))) .
vide($Pile['vars'][$_zzz=(string)'item'] = filtre_push(table_valeur($Pile["vars"], (string)'item', null),$Pile[$SP]['id_rubrique'])) .
vide($Pile['vars'][$_zzz=(string)'item'] = filtre_push(table_valeur($Pile["vars"], (string)'item', null),table_valeur($Pile["vars"], (string)'cpt', null))) .
vide($Pile['vars'][$_zzz=(string)'rubs'] = filtre_push(table_valeur($Pile["vars"], (string)'rubs', null),serialize(table_valeur($Pile["vars"], (string)'item', null)))) .
BOUCLE_rehtml_d8c74a37b067f7938026fb8ee8c8c0ca($Cache, $Pile, $doublons, $Numrows, $SP) .
vide($Pile['vars'][$_zzz=(string)'cpt'] = moins(table_valeur($Pile["vars"], (string)'cpt', null),'1')));
		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_sous_rubriques @ plugins/ckeditor-spip-plugin/rubriques-links-json.html","profiler"._LOG_AVERTISSEMENT);
	return $t0;
}


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

	static $command = array();
	static $connect;
	$command['connect'] = $connect = '';
	if (!isset($command['table'])) {
		$command['table'] = 'rubriques';
		$command['id'] = '_rubriques';
		$command['from'] = array('rubriques' => 'spip_rubriques');
		$command['type'] = array();
		$command['groupby'] = array();
		$command['select'] = array("rubriques.id_rubrique",
		"0+rubriques.titre AS num",
		"rubriques.titre",
		"rubriques.lang");
		$command['orderby'] = array('num', 'rubriques.titre');
		$command['where'] = 
			array(
quete_condition_statut('rubriques.statut','!','publie',''), 
			array('=', 'rubriques.id_parent', 0));
		$command['join'] = array();
		$command['limit'] = '';
		$command['having'] = 
			array();
	}
	if (defined("_BOUCLE_PROFILER")) $timer = time()+(float)microtime();
	$t0 = "";
	// REQUETE
	$iter = IterFactory::create(
		"SQL",
		$command,
		array('plugins/ckeditor-spip-plugin/rubriques-links-json.html','html_d8c74a37b067f7938026fb8ee8c8c0ca','_rubriques',5,$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 .= (
vide($Pile['vars'][$_zzz=(string)'item'] = array()) .
vide($Pile['vars'][$_zzz=(string)'item'] = filtre_push(table_valeur($Pile["vars"], (string)'item', null),interdire_scripts(json_encode(couper(strip_tags(supprimer_numero(typo($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0])),'30'))))) .
vide($Pile['vars'][$_zzz=(string)'item'] = filtre_push(table_valeur($Pile["vars"], (string)'item', null),interdire_scripts(json_encode(parametre_url(generer_url_public('rubrique', ''),'id_rubrique',$Pile[$SP]['id_rubrique']))))) .
vide($Pile['vars'][$_zzz=(string)'item'] = filtre_push(table_valeur($Pile["vars"], (string)'item', null),$Pile[$SP]['id_rubrique'])) .
vide($Pile['vars'][$_zzz=(string)'item'] = filtre_push(table_valeur($Pile["vars"], (string)'item', null),'0')) .
vide($Pile['vars'][$_zzz=(string)'rubs'] = filtre_push(table_valeur($Pile["vars"], (string)'rubs', null),serialize(table_valeur($Pile["vars"], (string)'item', null)))) .
BOUCLE_sous_rubriqueshtml_d8c74a37b067f7938026fb8ee8c8c0ca($Cache, $Pile, $doublons, $Numrows, $SP));
		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_rubriques @ plugins/ckeditor-spip-plugin/rubriques-links-json.html","profiler"._LOG_AVERTISSEMENT);
	return $t0;
}


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

	static $command = array();
	static $connect;
	$command['connect'] = $connect = '';
	$command['source'] = array(table_valeur($Pile["vars"], (string)'rubs', null));
	$command['sourcemode'] = 'table';
	if (!isset($command['table'])) {
		$command['table'] = '';
		$command['id'] = '_pour';
		$command['from'] = array();
		$command['type'] = array();
		$command['groupby'] = array();
		$command['select'] = array(".valeur");
		$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(
		"DATA",
		$command,
		array('plugins/ckeditor-spip-plugin/rubriques-links-json.html','html_d8c74a37b067f7938026fb8ee8c8c0ca','_pour',20,$GLOBALS['spip_lang'])
	);
	if (!$iter->err()) {
	
	// COMPTEUR
	$Numrows['_pour']['compteur_boucle'] = 0;
	$Numrows['_pour']['total'] = @intval($iter->count());
	$SP++;
	// RESULTATS
	while ($Pile[$SP]=$iter->fetch()) {

		$Numrows['_pour']['compteur_boucle']++;
		$t0 .= (
'
	{
		' .
vide($Pile['vars'][$_zzz=(string)'item'] = interdire_scripts(unserialize($Pile[$SP]['valeur']))) .
'"titre" : ' .
table_valeur(table_valeur($Pile["vars"], (string)'item', null),'0') .
',
		"url" : ' .
table_valeur(table_valeur($Pile["vars"], (string)'item', null),'1') .
',
		"id" : "' .
table_valeur(table_valeur($Pile["vars"], (string)'item', null),'2') .
'",
		"level" : "' .
table_valeur(table_valeur($Pile["vars"], (string)'item', null),'3') .
'"
	}' .
(($Numrows['_pour']['compteur_boucle'] != $Numrows['_pour']['total']) ? ',':'') .
'
');
	}
	$iter->free();
	}
	if (defined("_BOUCLE_PROFILER")
	AND 1000*($timer = (time()+(float)microtime())-$timer) > _BOUCLE_PROFILER)
		spip_log(intval(1000*$timer)."ms BOUCLE_pour @ plugins/ckeditor-spip-plugin/rubriques-links-json.html","profiler"._LOG_AVERTISSEMENT);
	return $t0;
}


function BOUCLE_sihtml_d8c74a37b067f7938026fb8ee8c8c0ca(&$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/rubriques-links-json.html','html_d8c74a37b067f7938026fb8ee8c8c0ca','_si',3,$GLOBALS['spip_lang'])
	);
	if (!$iter->err()) {
	$SP++;
	// RESULTATS
	while ($Pile[$SP]=$iter->fetch()) {

		$t0 .= (
'
' .
vide($Pile['vars'][$_zzz=(string)'rubs'] = array()) .
(($t1 = BOUCLE_rubriqueshtml_d8c74a37b067f7938026fb8ee8c8c0ca($Cache, $Pile, $doublons, $Numrows, $SP))!=='' ?
		($t1 . '
') :
		'') .
'
[' .
BOUCLE_pourhtml_d8c74a37b067f7938026fb8ee8c8c0ca($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/rubriques-links-json.html","profiler"._LOG_AVERTISSEMENT);
	return $t0;
}

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

function html_d8c74a37b067f7938026fb8ee8c8c0ca($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_d8c74a37b067f7938026fb8ee8c8c0ca($Cache, $Pile, $doublons, $Numrows, $SP) .
'
');

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