<?php

/*
 * Squelette : plugins/ckeditor-spip-plugin/modeles/inc-documents-articles.html
 * Date :      Fri, 03 Jul 2020 11:43:40 GMT
 * Compile :   Thu, 16 Jul 2020 07:08:35 GMT
 * Boucles :   _doc
 */ 

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

	static $command = array();
	static $connect;
	$command['connect'] = $connect = '';
	$in = array();
	$in[]= 'document';
	$in[]= 'image';
	$command['pagination'] = array((isset($Pile[0]['debut_doc']) ? $Pile[0]['debut_doc'] : null), 16);
	if (!isset($command['table'])) {
		$command['table'] = 'documents';
		$command['id'] = '_doc';
		$command['from'] = array('documents' => 'spip_documents','L1' => 'spip_documents_liens');
		$command['type'] = array();
		$command['groupby'] = array();
		$command['select'] = array("documents.id_document",
		"documents.extension",
		"documents.fichier",
		"documents.titre");
		$command['join'] = array('L1' => array('documents','id_document'));
		$command['limit'] = '';
		$command['having'] = 
			array();
	}
	$command['orderby'] = array(((!sql_quote($in) OR sql_quote($in)==="''") ? 0 : ('FIELD(documents.mode,' . sql_quote($in) . ')')));
	$command['where'] = 
			array(
			array('(documents.taille > 0 OR documents.distant=\'oui\')'), 
			array('=', 'L1.id_objet', sql_quote(interdire_scripts(entites_html(table_valeur(@$Pile[0], (string)'article', null),true)), '', 'bigint(21) NOT NULL DEFAULT \'0\'')), 
			array('=', 'L1.objet', sql_quote('article')), sql_in('documents.mode',sql_quote($in)));
	if (defined("_BOUCLE_PROFILER")) $timer = time()+(float)microtime();
	$t0 = "";
	// REQUETE
	$iter = IterFactory::create(
		"SQL",
		$command,
		array('plugins/ckeditor-spip-plugin/modeles/inc-documents-articles.html','html_129274d8ee21a4e54287fd3540116a63','_doc',1,$GLOBALS['spip_lang'])
	);
	if (!$iter->err()) {
	
	// COMPTEUR
	$Numrows['_doc']['compteur_boucle'] = 0;
	$Numrows['_doc']['total'] = @intval($iter->count());
	$debut_boucle = isset($Pile[0]['debut_doc']) ? $Pile[0]['debut_doc'] : _request('debut_doc');
	if(substr($debut_boucle,0,1)=='@'){
		$debut_boucle = $Pile[0]['debut_doc'] = quete_debut_pagination('id_document',$Pile[0]['@id_document'] = substr($debut_boucle,1),16,$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['_doc']['total']-1)/(16))*(16)));
	$debut_boucle = intval($debut_boucle);
	$fin_boucle = min(($tout ? $Numrows['_doc']['total'] : $debut_boucle + 15), $Numrows['_doc']['total'] - 1);
	$Numrows['_doc']['grand_total'] = $Numrows['_doc']['total'];
	$Numrows['_doc']["total"] = max(0,$fin_boucle - $debut_boucle + 1);
	if ($debut_boucle>0 AND $debut_boucle < $Numrows['_doc']['grand_total'] AND $iter->seek($debut_boucle,'continue'))
		$Numrows['_doc']['compteur_boucle'] = $debut_boucle;
	
	$SP++;
	// RESULTATS
	while ($Pile[$SP]=$iter->fetch()) {

		$Numrows['_doc']['compteur_boucle']++;
		if ($Numrows['_doc']['compteur_boucle'] <= $debut_boucle) continue;
		if ($Numrows['_doc']['compteur_boucle']-1 > $fin_boucle) break;
		$t0 .= (
'
	<div class=\'fichier\'>
		<div class=\'fichier-apercu\'>
			<a onclick="SelectFile(\'' .
interdire_scripts(parametre_url(url_absolue((match($Pile[$SP]['extension'],'(jpg|gif|png)') ? interdire_scripts(get_spip_doc($Pile[$SP]['fichier'])):extraire_attribut(filtrer('image_graver', filtrer('image_reduire',quete_logo_document(quete_document($Pile[$SP]['id_document'], ''), '', '', '', 0, 0, ''),'150','50')),'src'))),'docid',$Pile[$SP]['id_document'])) .
'\');">' .
interdire_scripts((match($Pile[$SP]['extension'],'(jpg|gif|png)') ? interdire_scripts(filtrer('image_graver',filtrer('image_reduire',get_spip_doc($Pile[$SP]['fichier']),'150','50'))):filtrer('image_graver',filtrer('image_reduire',quete_logo_document(quete_document($Pile[$SP]['id_document'], ''), '', '', '', 0, 0, ''),'150','50')))) .
'</a>
 		</div>
		<div class=\'fichier-nom\'>' .
interdire_scripts(((($a = supprimer_numero(typo($Pile[$SP]['titre']), "TYPO", $connect, $Pile[0])) OR (is_string($a) AND strlen($a))) ? $a : interdire_scripts(basename(get_spip_doc($Pile[$SP]['fichier']))))) .
'</div>
	</div>
');
	}
	$iter->free();
	}
	if (defined("_BOUCLE_PROFILER")
	AND 1000*($timer = (time()+(float)microtime())-$timer) > _BOUCLE_PROFILER)
		spip_log(intval(1000*$timer)."ms BOUCLE_doc @ plugins/ckeditor-spip-plugin/modeles/inc-documents-articles.html","profiler"._LOG_AVERTISSEMENT);
	return $t0;
}

//
// Fonction principale du squelette plugins/ckeditor-spip-plugin/modeles/inc-documents-articles.html
// Temps de compilation total: 48.449 ms
//

function html_129274d8ee21a4e54287fd3540116a63($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 = (
(($t1 = BOUCLE_dochtml_129274d8ee21a4e54287fd3540116a63($Cache, $Pile, $doublons, $Numrows, $SP))!=='' ?
		((	'
<?php
	include_spip(\'inc/ckeditor_constantes\') ;
 ?>
<div id="fichiers">
	' .
		filtre_pagination_dist($Numrows["_doc"]["grand_total"],
 		'_doc',
		isset($Pile[0]['debut_doc'])?$Pile[0]['debut_doc']:intval(_request('debut_doc')),
		16, false, '', '', array()) .
		'
	<div>' .
		(($t3 = strval(interdire_scripts((((include_spip('inc/config')?lire_config('ckeditor/insertall',null,false):'')) ?' ' :''))))!=='' ?
				($t3 . (	'<a class=\'ckbutton\' href=\'' .
			interdire_scripts(parametre_url(parametre_url(parametre_url(parametre_url(parametre_url(generer_url_public('select_documents', ''),'article',interdire_scripts(entites_html(table_valeur(@$Pile[0], (string)'article', null),true))),'CKEditor',interdire_scripts(entites_html(table_valeur(@$Pile[0], (string)'CKEditor', null),true))),'CKEditorFuncNum',interdire_scripts(entites_html(table_valeur(@$Pile[0], (string)'CKEditorFuncNum', null),true))),'langCode',interdire_scripts(entites_html(table_valeur(@$Pile[0], (string)'langCode', null),true))),'type','tout')) .
			'\' title=\'' .
			_T('ckeditor:tous_documents') .
			'\'>' .
			_T('ckeditor:tous') .
			'</a>')) :
				'') .
		' ' .
		(($t3 = strval(filtre_pagination_dist($Numrows["_doc"]["grand_total"],
 		'_doc',
		isset($Pile[0]['debut_doc'])?$Pile[0]['debut_doc']:intval(_request('debut_doc')),
		16, true, '', '', array())))!=='' ?
				((	(($t4 = strval(interdire_scripts((((include_spip('inc/config')?lire_config('ckeditor/insertall',null,false):'')) ?' ' :''))))!=='' ?
					($t4 . '|') :
					'') .
			' ') . $t3 . ' | ') :
				'') .
		'
	</div>
') . $t1 . '
</div>
') :
		((	'
	' .
	(($t2 = strval(interdire_scripts((((include_spip('inc/config')?lire_config('ckeditor/insertall',null,false):'')) ?' ' :''))))!=='' ?
			($t2 . (	'<div><a class=\'ckbutton\' href=\'' .
		interdire_scripts(parametre_url(parametre_url(parametre_url(parametre_url(parametre_url(generer_url_public('select_documents', ''),'article',interdire_scripts(entites_html(table_valeur(@$Pile[0], (string)'article', null),true))),'CKEditor',interdire_scripts(entites_html(table_valeur(@$Pile[0], (string)'CKEditor', null),true))),'CKEditorFuncNum',interdire_scripts(entites_html(table_valeur(@$Pile[0], (string)'CKEditorFuncNum', null),true))),'langCode',interdire_scripts(entites_html(table_valeur(@$Pile[0], (string)'langCode', null),true))),'type','tout')) .
		'\'>' .
		_T('ckeditor:tous') .
		'</a></div>')) :
			'') .
	'
	' .
	
	((($recurs=(isset($Pile[0]['recurs'])?$Pile[0]['recurs']:0))>=5)? '' :
	recuperer_fond('modeles/inc-aucun-document', array('lang' => $GLOBALS["spip_lang"] ,
	'recurs'=>(++$recurs)), array('compil'=>array('plugins/ckeditor-spip-plugin/modeles/inc-documents-articles.html','html_129274d8ee21a4e54287fd3540116a63','',20,$GLOBALS['spip_lang']), 'trim'=>true), ''))
))) .
'
');

	return analyse_resultat_skel('html_129274d8ee21a4e54287fd3540116a63', $Cache, $page, 'plugins/ckeditor-spip-plugin/modeles/inc-documents-articles.html');
}
?>