Ejemplo n.º 1
0
function yaml_article($id_article)
{
    include_spip('inc/yaml');
    $a = array_filter(sql_fetsel('*', 'spip_articles', 'id_article=' . $id_article));
    $a['rubrique'] = array_filter(sql_fetsel('*', 'spip_rubriques', 'id_rubrique=' . $a['id_rubrique']));
    foreach (sql_allfetsel('*', 'spip_mots AS m LEFT JOIN spip_mots_articles AS c ON m.id_mot=c.id_mot', 'c.id_article=' . $id_article) as $m) {
        $a['mots'][] = array_filter($m);
    }
    return yaml_encode(array_filter($a));
}
Ejemplo n.º 2
0
function dump_yaml($opts, $pipe = null, $offset = 0)
{
    $opts = get_opts_or_pipe($opts, $pipe);
    if (is_int($pipe)) {
        $offset = $pipe;
    }
    if ($pipe === true) {
        $offset = $GLOBALS['yaml_indent'];
    }
    if ($offset == 0) {
        message('dump_yaml', ':', 'echo');
        $offset = 1;
    }
    echo yaml_encode($opts, null, $offset);
    return $opts;
}
Ejemplo n.º 3
0
/**
 * Exporte un contenu (description de champs extras) au format YAML
 *
 * Envoie les données au navigateur !
 *
 * @param array $export
 * @param string $nom_fichier
 * @param string $format
 *     Format d'export (yaml ou php)
**/
function iextras_envoyer_export($export, $nom_fichier, $format = 'yaml') {

	switch ($format) {
		case 'php':
			$export = iextras_preparer_export_php($export);
			$export = iextras_ecrire_export_php($export);
			
			break;

		case 'yaml':
		default:
			// On envode en yaml
			include_spip('inc/yaml');
			$export = yaml_encode($export);
			break;
	}


	$date = date("Ymd-His");
	Header("Content-Type: text/x-yaml;");
	Header("Content-Disposition: attachment; filename=champs_extras_export-$date-$nom_fichier.$format");
	Header("Content-Length: " . strlen($export));
	echo $export;
	exit;
}