Example #1
0
/**
 * Exporter une ligne complete au format CSV, avec delimiteur fourni
 * @param array $ligne
 * @param string $delim
 * @return string
 */
function exporter_csv_ligne($ligne, $delim = ',', $importer_charset = null) {
	$output = join($delim, array_map('exporter_csv_champ', $ligne))."\r\n";
	if ($importer_charset){
		$output = unicode2charset(html2unicode(charset2unicode($output)), $importer_charset);
	}
	return $output;
}
Example #2
0
function plugins_afficher_liste_dist($url_page,$liste_plugins, $liste_plugins_actifs, $dir_plugins=_DIR_PLUGINS,$afficher_un = 'afficher_plugin'){
	$get_infos = charger_fonction('get_infos','plugins');
	$ligne_plug = charger_fonction($afficher_un,'plugins');
	$liste_plugins = array_flip($liste_plugins);
	foreach(array_keys($liste_plugins) as $chemin) {
		if ($info = $get_infos($chemin, false, $dir_plugins))
			$liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($info['nom']))))));
	}
	asort($liste_plugins);
	$exposed = urldecode(_request('plugin'));

	$block_par_lettre = false;//count($liste_plugins)>10;
	$fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
	$res = '';
	$block = '';
	$initiale = '';
	$block_actif = false;
	foreach($liste_plugins as $plug => $nom){
		if (($i=substr($nom,0,1))!==$initiale){
			$res .= $block_par_lettre ? affiche_block_initiale($initiale,$block,$block_actif): $block;
			$initiale = $i;
			$block = '';
			$block_actif = false;
		}
		// le rep suivant
		$actif = @isset($fast_liste_plugins_actifs[$plug]);
		$block_actif = $block_actif | $actif;
		$expose = ($exposed AND ($exposed==$plug OR $exposed==$dir_plugins . $plug OR $exposed==substr($dir_plugins,strlen(_DIR_RACINE)) . $plug));
		$block .= $ligne_plug($url_page, $plug, $actif, $expose, "item", $dir_plugins)."\n";
	}
	$res .= $block_par_lettre ? affiche_block_initiale($initiale,$block,$block_actif): $block;
	$class = basename($dir_plugins);
	return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : "";
}
Example #3
0
function glossaire_accents_callback($matches) {
	$u = unicode2charset($matches[0]);	// charset
	$u2 = init_mb_string()?mb_strtoupper($u):strtoupper($u);	// charset majuscule
	$u3 = htmlentities($u2, ENT_QUOTES, $GLOBALS['meta']['charset']);	// html majuscule
	$u4 = html2unicode($u3); // unicode majuscule
	$a = array_unique(array($u, $u2, htmlentities($u, ENT_QUOTES, $GLOBALS['meta']['charset']), $u3, $matches[0], $u4));
//	$a = array_unique(array($u, htmlentities($u, ENT_QUOTES, $GLOBALS['meta']['charset']), $matches[0]));
	return '(?:'.join('|', $a).')';
}
Example #4
0
function mediabox_insert_head_css($flux)
{
    $config = mediabox_config();
    if ($config['active'] == 'oui' and $f = find_in_path((test_espace_prive() ? "prive/" : "") . "colorbox/" . $config['skin'] . '/colorbox.css')) {
        $flux .= '<link rel="stylesheet" href="' . direction_css($f) . '" type="text/css" media="all" />';
        /**
         * Initialiser la config de la mediabox
         */
        $flux = '<script type="text/javascript">/* <![CDATA[ */
var box_settings = {tt_img:' . ($config['traiter_toutes_images'] == 'oui' ? 'true' : 'false') . ',sel_g:"' . $config['selecteur_galerie'] . '",sel_c:"' . $config['selecteur_commun'] . '",trans:"' . $config['transition'] . '",speed:"' . $config['speed'] . '",ssSpeed:"' . $config['slideshow_speed'] . '",maxW:"' . $config['maxWidth'] . '",maxH:"' . $config['maxHeight'] . '",minW:"' . $config['minWidth'] . '",minH:"' . $config['minHeight'] . '",opa:"' . $config['opacite'] . '",str_ssStart:"' . unicode2charset(html2unicode(_T('mediabox:boxstr_slideshowStart'))) . '",str_ssStop:"' . unicode2charset(html2unicode(_T('mediabox:boxstr_slideshowStop'))) . '",str_cur:"' . _T('mediabox:boxstr_current', array('current' => '{current}', 'total' => '{total}')) . '",str_prev:"' . _T('mediabox:boxstr_previous') . '",str_next:"' . _T('mediabox:boxstr_next') . '",str_close:"' . _T('mediabox:boxstr_close') . '",splash_url:"' . $config['splash_url'] . '"};
/* ]]> */</script>' . "\n" . $flux;
    }
    return $flux;
}
Example #5
0
/**
 * Afficher une liste de plugins dans l'interface
 * http://doc.spip.org/@affiche_liste_plugins
 *
 * @param string $url_page
 * @param array $liste_plugins
 * @param array $liste_plugins_checked
 * @param array $liste_plugins_actifs
 * @param string $dir_plugins
 * @param string $afficher_un
 * @return string
 */
function plugins_afficher_liste_dist($url_page, $liste_plugins, $liste_plugins_checked, $liste_plugins_actifs, $dir_plugins = _DIR_PLUGINS, $afficher_un = 'afficher_plugin')
{
    $get_infos = charger_fonction('get_infos', 'plugins');
    $ligne_plug = charger_fonction($afficher_un, 'plugins');
    $all_infos = $get_infos($liste_plugins, false, $dir_plugins);
    $all_infos = pipeline('filtrer_liste_plugins', array('args' => array('liste_plugins' => $liste_plugins, 'liste_plugins_checked' => $liste_plugins_checked, 'liste_plugins_actifs' => $liste_plugins_actifs, 'dir_plugins' => $dir_plugins), 'data' => $all_infos));
    $liste_plugins = array_flip($liste_plugins);
    foreach ($liste_plugins as $chemin => $v) {
        // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
        if (isset($all_infos[$chemin])) {
            $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
        } else {
            unset($liste_plugins[$chemin]);
        }
    }
    asort($liste_plugins);
    $exposed = urldecode(_request('plugin'));
    $block_par_lettre = false;
    //count($liste_plugins)>10;
    $fast_liste_plugins_actifs = array();
    $fast_liste_plugins_checked = array();
    if (is_array($liste_plugins_actifs)) {
        $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
    }
    if (is_array($liste_plugins_checked)) {
        $fast_liste_plugins_checked = array_flip($liste_plugins_checked);
    }
    $res = '';
    $block = '';
    $initiale = '';
    $block_actif = false;
    foreach ($liste_plugins as $plug => $nom) {
        if (($i = substr($nom, 0, 1)) !== $initiale) {
            $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
            $initiale = $i;
            $block = '';
            $block_actif = false;
        }
        // le rep suivant
        $actif = isset($fast_liste_plugins_actifs[$plug]);
        $checked = isset($fast_liste_plugins_checked[$plug]);
        $block_actif = $block_actif | $actif;
        $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr($dir_plugins, strlen(_DIR_RACINE)) . $plug));
        $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins) . "\n";
    }
    $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
    $class = basename($dir_plugins);
    return $res ? "<ul class='liste-items plugins {$class}'>{$res}</ul>" : "";
}
function mediabox_insert_head_css($flux) {
	$config = mediabox_config();
	if ($config['active'] == 'oui' and $f = find_in_path((test_espace_prive() ? "prive/" : "") . "colorbox/" . $config['skin'] . '/colorbox.css')) {
		$flux .= '<link rel="stylesheet" href="' . direction_css($f) . '" type="text/css" media="all" />';
		/**
		 * Initialiser la config de la mediabox
		 */
		$configmediabox = '<script type="text/javascript">/* <![CDATA[ */
var box_settings = {tt_img:' . ($config['traiter_toutes_images'] == 'oui' ? 'true' : 'false')
			. ',sel_g:"' . $config['selecteur_galerie']
			. '",sel_c:"' . $config['selecteur_commun']
			. '",trans:"' . $config['transition']
			. '",speed:"' . $config['speed']
			. '",ssSpeed:"' . $config['slideshow_speed']
			. '",maxW:"' . $config['maxWidth']
			. '",maxH:"' . $config['maxHeight']
			. '",minW:"' . $config['minWidth']
			. '",minH:"' . $config['minHeight']
			. '",opa:"' . $config['opacite']
			. '",str_ssStart:"' . unicode2charset(html2unicode(_T('mediabox:boxstr_slideshowStart')))
			. '",str_ssStop:"' . unicode2charset(html2unicode(_T('mediabox:boxstr_slideshowStop')))
			. '",str_cur:"' . _T('mediabox:boxstr_current', array('current' => '{current}', 'total' => '{total}'))
			. '",str_prev:"' . _T('mediabox:boxstr_previous')
			. '",str_next:"' . _T('mediabox:boxstr_next')
			. '",str_close:"' . _T('mediabox:boxstr_close')
			. '",splash_url:"' . $config['splash_url']
			. '"};' . "\n";
		// Si c'est une image, on la chargera avec une redimentionnement automatique
		// Sinon, chargement dans une iframe
		$extension = pathinfo($config['splash_url'], PATHINFO_EXTENSION);
		if (match($extension, 'gif|png|jpg|jpeg')) {
			$configmediabox .= 'var box_settings_iframe = false;' . "\n";
		} else {
			$configmediabox .= 'var box_settings_splash_width = "' . $config['splash_width'] . '";
var box_settings_splash_height = "' . $config['splash_height'] . '";' . "\n";
			$configmediabox .= 'var box_settings_iframe = true;' . "\n";
		}
		$flux = $configmediabox . '/* ]]> */</script>' . "\n" . $flux;
	}

	return $flux;
}
Example #7
0
function couper($texte, $taille = 50, $suite = '&nbsp;(...)')
{
    if (!($length = strlen($texte)) or $taille <= 0) {
        return '';
    }
    $offset = 400 + 2 * $taille;
    while ($offset < $length and strlen(preg_replace(",<[^>]+>,Uims", "", substr($texte, 0, $offset))) < $taille) {
        $offset = 2 * $offset;
    }
    if ($offset < $length && ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== NULL) {
        $p_tag_fermant = strpos($texte, '>', $offset);
        if ($p_tag_fermant && $p_tag_fermant < $p_tag_ouvrant) {
            $offset = $p_tag_fermant + 1;
        }
        // prolonger la coupe jusqu'au tag fermant suivant eventuel
    }
    $texte = substr($texte, 0, $offset);
    /* eviter de travailler sur 10ko pour extraire 150 caracteres */
    // on utilise les \r pour passer entre les gouttes
    $texte = str_replace("\r\n", "\n", $texte);
    $texte = str_replace("\r", "\n", $texte);
    // sauts de ligne et paragraphes
    $texte = preg_replace("/\n\n+/", "\r", $texte);
    $texte = preg_replace("/<(p|br)( [^>]*)?" . ">/", "\r", $texte);
    // supprimer les traits, lignes etc
    $texte = preg_replace("/(^|\r|\n)(-[-#\\*]*|_ )/", "\r", $texte);
    // supprimer les tags
    $texte = supprimer_tags($texte);
    $texte = trim(str_replace("\n", " ", $texte));
    $texte .= "\n";
    // marquer la fin
    // travailler en accents charset
    $texte = unicode2charset(html2unicode($texte, true));
    if (!function_exists('nettoyer_raccourcis_typo')) {
        include_spip('inc/lien');
    }
    $texte = nettoyer_raccourcis_typo($texte);
    // corriger la longueur de coupe
    // en fonction de la presence de caracteres utf
    if ($GLOBALS['meta']['charset'] == 'utf-8') {
        $long = charset2unicode($texte);
        $long = spip_substr($long, 0, max($taille, 1));
        $nbcharutf = preg_match_all('/(&#[0-9]{3,5};)/S', $long, $matches);
        $taille += $nbcharutf;
    }
    // couper au mot precedent
    $long = spip_substr($texte, 0, max($taille - 4, 1));
    $u = $GLOBALS['meta']['pcre_u'];
    $court = preg_replace("/([^\\s][\\s]+)[^\\s]*\n?\$/" . $u, "\\1", $long);
    $points = $suite;
    // trop court ? ne pas faire de (...)
    if (spip_strlen($court) < max(0.75 * $taille, 2)) {
        $points = '';
        $long = spip_substr($texte, 0, $taille);
        $texte = preg_replace("/([^\\s][\\s]+)[^\\s]*\n?\$/" . $u, "\\1", $long);
        // encore trop court ? couper au caractere
        if (spip_strlen($texte) < 0.75 * $taille) {
            $texte = $long;
        }
    } else {
        $texte = $court;
    }
    if (strpos($texte, "\n")) {
        // la fin est encore la : c'est qu'on n'a pas de texte de suite
        $points = '';
    }
    // remettre les paragraphes
    $texte = preg_replace("/\r+/", "\n\n", $texte);
    // supprimer l'eventuelle entite finale mal coupee
    $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
    return quote_amp(trim($texte)) . $points;
}
Example #8
0
function translitteration($texte, $charset='AUTO', $complexe='') {
	// 0. Supprimer les caracteres illegaux
	include_spip('inc/filtres');
	$texte = corriger_caracteres($texte);

	// 1. Passer le charset et les &eacute en utf-8
	$texte = unicode_to_utf_8(html2unicode(charset2unicode($texte, $charset, true)));

	return translitteration_rapide($texte,$charset,$complexe);
}
Example #9
0
function filtrer_ical($texte)
{
    include_lcm('inc_charsets');
    $texte = html2unicode($texte);
    $texte = unicode2charset(charset2unicode($texte, read_meta('charset'), 1), 'utf-8');
    $texte = preg_replace("/\n/", " ", $texte);
    $texte = preg_replace("/,/", "\\,", $texte);
    return $texte;
}
Example #10
0
function affiche_progression_javascript($abs_pos,$size, $table="", $retour='') {

	include_spip('inc/charsets');
	echo "\n<script type='text/javascript'><!--\n";

	if ($abs_pos == '100 %') {

		echo "document.progression.taille.value='$abs_pos';\n";
		if ($x = $GLOBALS['erreur_restauration']) {
			echo "document.progression.recharge.value='".str_replace("'", "\\'", unicode_to_javascript(html2unicode(_T('avis_erreur').": $x")))." ';\n";
		}
		else {
			if (!$retour) $retour = self();
			echo "document.progression.recharge.value='".str_replace("'", "\\'", unicode_to_javascript(html2unicode(_T('info_fini'))))."';\n";
			echo "window.setTimeout('location.href=\"$retour\";',0);";
		}
	}
	else {
		if (trim($table))
			echo "document.progression.recharge.value='$table';\n";
		if (!$size)
			$taille = preg_replace("/&nbsp;/", " ", taille_en_octets($abs_pos));
		else
			$taille = floor(100 * $abs_pos / $size)." %";
		echo "document.progression.taille.value='$taille';\n";
	}
	echo "\n--></script>\n";
	if (function_exists('ob_flush')) @ob_flush();
	flush();
}
Example #11
0
	'traitement:TEXTE:pre_propre,
	 traitement:TEXTE/articles:pre_propre,
	 traitement:TEXTE/breves:pre_propre,
	 traitement:TEXTE/forums:post_propre,
	 traitement:TEXTE/rubriques:pre_propre' => 'insertions_pre_propre',
));

// le plugin moderation moderee dans le couteau suisse
include_spip('inc/charsets');
add_outil( array(
	'id' => 'moderation_moderee',
	'auteur' => 'Yohann(potter64)',
	'categorie' => 'admin',
	'version-min' => '1.9300',
	'code:options' => '%%moderation_admin%%%%moderation_redac%%%%moderation_visit%%',
	'code:jq_init' => 'if(window.location.search.match(/page=forum/)!=null) jQuery("legend:contains(\''.addslashes(unicode2charset(html2unicode(_T('bouton_radio_modere_priori')))).'\')", this).next().html(\''.addslashes(_T('couteauprive:moderation_message')).'\');',
	'pipeline:pre_edition' => 'moderation_vip',
));
add_variables( array(
	'nom' => 'moderation_admin',
	'check' => 'couteauprive:moderation_admins',
	'defaut' => 1,
	'code:%s' => "define('_MOD_MOD_0minirezo',%s);",
), array(
	'nom' => 'moderation_redac',
	'check' => 'couteauprive:moderation_redacs',
	'defaut' => 0,
	'code:%s' => "define('_MOD_MOD_1comite',%s);",
), array(
	'nom' => 'moderation_visit',
	'check' => 'couteauprive:moderation_visits',
function produire_image_typo()
{
    /*
    arguments autorises:
    
    $texte : le texte a transformer; attention: c'est toujours le premier argument, et c'est automatique dans les filtres
    $couleur : la couleur du texte dans l'image - pas de dieze
    $police: nom du fichier de la police (inclure terminaison)
    $largeur: la largeur maximale de l'image ; attention, l'image retournee a une largeur inferieure, selon les limites reelles du texte
    $hauteur_ligne: la hauteur de chaque ligne de texte si texte sur plusieurs lignes
    (equivalent a "line-height")
    $padding: forcer de l'espace autour du placement du texte; necessaire pour polices a la con qui "depassent" beaucoup de leur boite 
    $align: alignement left, right, center
    */
    /**
     * On définit les variables par défaut
     */
    $variables_defaut = array('align' => false, 'police' => '', 'largeur' => 0, 'hauteur_ligne' => 0, 'padding' => 0);
    // Recuperer les differents arguments
    $numargs = func_num_args();
    $arg_list = func_get_args();
    $texte = $arg_list[0];
    for ($i = 1; $i < $numargs; $i++) {
        if (($p = strpos($arg_list[$i], "=")) !== false) {
            $nom_variable = substr($arg_list[$i], 0, $p);
            $val_variable = substr($arg_list[$i], $p + 1);
            $variable["{$nom_variable}"] = $val_variable;
        }
    }
    $variable = array_merge($variables_defaut, $variable);
    // Construire requete et nom fichier
    $text = str_replace("&nbsp;", "~", $texte);
    $text = preg_replace(",(\r|\n)+,ms", " ", $text);
    include_spip('inc/charsets');
    $text = html2unicode(strip_tags($text));
    if (strlen($text) == 0) {
        return "";
    }
    $taille = $variable["taille"];
    if ($taille < 1) {
        $taille = 16;
    }
    $couleur = couleur_html_to_hex($variable["couleur"]);
    if (strlen($couleur) < 6) {
        $couleur = "000000";
    }
    $alt = $texte;
    $align = $variable["align"];
    if (!$variable["align"]) {
        $align = "left";
    }
    $police = $variable["police"];
    if (strlen($police) < 2) {
        $police = "dustismo.ttf";
    }
    $largeur = $variable["largeur"];
    if ($largeur < 5) {
        $largeur = 600;
    }
    if ($variable["hauteur_ligne"] > 0) {
        $hauteur_ligne = $variable["hauteur_ligne"];
    } else {
        $hauteur_ligne = 0;
    }
    if ($variable["padding"] > 0) {
        $padding = $variable["padding"];
    } else {
        $padding = 0;
    }
    $string = "{$text}-{$taille}-{$couleur}-{$align}-{$police}-{$largeur}-{$hauteur_ligne}-{$padding}";
    $query = md5($string);
    $dossier = sous_repertoire(_DIR_VAR, 'cache-texte');
    $fichier = "{$dossier}{$query}.png";
    $flag_gd_typo = function_exists("imageftbbox") && function_exists('imageCreateTrueColor');
    if (@file_exists($fichier)) {
        $image = $fichier;
    } else {
        if (!$flag_gd_typo) {
            return $texte;
        } else {
            $font = find_in_path('polices/' . $police);
            if (!$font) {
                spip_log(_T('fichier_introuvable', array('fichier' => $police)));
                $font = find_in_path('polices/' . "dustismo.ttf");
            }
            $imgbidon = imageCreateTrueColor($largeur, 45);
            $retour = printWordWrapped($imgbidon, $taille + 5, 0, $largeur, $font, $couleur, $text, $taille, 'left', $hauteur_ligne);
            $hauteur = $retour["height"];
            $largeur_reelle = $retour["width"];
            $espace = $retour["espace"];
            imagedestroy($imgbidon);
            $im = imageCreateTrueColor($largeur_reelle - $espace + 2 * $padding, $hauteur + 5 + 2 * $padding);
            imagealphablending($im, false);
            imagesavealpha($im, true);
            // Creation de quelques couleurs
            $grey2 = imagecolorallocatealpha($im, hexdec("0x{" . substr($couleur, 0, 2) . "}"), hexdec("0x{" . substr($couleur, 2, 2) . "}"), hexdec("0x{" . substr($couleur, 4, 2) . "}"), 127);
            ImageFilledRectangle($im, 0, 0, $largeur_reelle + 2 * $padding, $hauteur + 5 + 2 * $padding, $grey2);
            // Le texte a dessiner
            printWordWrapped($im, $taille + 5 + $padding, $padding, $largeur, $font, $couleur, $text, $taille, $align, $hauteur_ligne);
            // Utiliser imagepng() donnera un texte plus claire,
            // compare a l'utilisation de la fonction imagejpeg()
            _image_gd_output($im, array('fichier_dest' => $fichier, 'format_dest' => 'png'));
            imagedestroy($im);
            $image = $fichier;
        }
    }
    $dimensions = getimagesize($image);
    $largeur = $dimensions[0];
    $hauteur = $dimensions[1];
    return inserer_attribut("<img src='{$image}' width='{$largeur}' height='{$hauteur}' style='width:" . $largeur . "px;height:" . $hauteur . "px;' />", 'alt', $alt);
}
Example #13
0
File: sax.php Project: rhertzog/lcs
function sax_bug($data)
{
	$r = analyser_doctype($data);

	if (!$r) {
		$data = _MESSAGE_DOCTYPE . _DOCTYPE_ECRIRE
		. preg_replace(_REGEXP_DOCTYPE, '', $data);
		$r =  analyser_doctype($data);
	}

	list($doctype, $topelement, $avail, $grammaire, $rotlvl, $len) = $r;

	include_spip('xml/analyser_dtd');
	$dtc = charger_dtd($grammaire, $avail, $rotlvl);

	// l'entete contient eventuellement < ? xml... ? >, le Doctype, 
	// et des commentaires autour d'eux
	$entete = ltrim(substr($data,0,$len));

	if ($dtc) {
		$trans = array();
		
		foreach($dtc->entites as $k => $v) {
			if (!strpos(" amp lt gt quot ", $k))
			    $trans["&$k;"] = $v;
		}
		$data = strtr(substr($data,$len), $trans);
	} else {
		$data = html2unicode(substr($data,$len), true);
	}
	return array($entete,unicode2charset($data), $dtc);
}
Example #14
0
function translitteration($texte, $charset = 'AUTO', $complexe = '')
{
    static $trans;
    if ($charset == 'AUTO') {
        $charset = read_meta('charset');
    }
    $charset = strtolower($charset);
    $table_translit = 'translit' . $complexe;
    // 1. Passer le charset et les &eacute en utf-8
    $texte = unicode_to_utf_8(html2unicode(charset2unicode($texte, $charset, true)));
    // 2. Translitterer grace a la table predefinie
    if (!$trans[$complexe]) {
        global $CHARSET;
        load_charset($table_translit);
        reset($CHARSET[$table_translit]);
        while (list($key, $val) = each($CHARSET[$table_translit])) {
            $trans[$complexe][caractere_utf_8($key)] = $val;
        }
    }
    if ($GLOBALS['flag_strtr2']) {
        $texte = strtr($texte, $trans[$complexe]);
    } else {
        $tr = $trans[$complexe];
        while (list($from, $to) = each($tr)) {
            $texte = str_replace($from, $to, $texte);
        }
    }
    /*
    	// Le probleme d'iconv c'est qu'il risque de nous renvoyer des ? alors qu'on
    	// prefere garder l'utf-8 pour que la chaine soit indexable.
    	// 3. Translitterer grace a iconv
    	if ($GLOBALS['flag_iconv'] && preg_match('/&#0*([0-9]+);/', $texte)) {
    		$texte = iconv('utf-8', 'ascii//translit', $texte);
    	}
    */
    return $texte;
}
Example #15
0
function _U($texte, $params = array())
{
    include_spip('inc/charsets');
    return unicode2charset(html2unicode(_T($texte, $params)));
}
Example #16
0
function cs_javascript($chaine) { return unicode_to_javascript(addslashes(html2unicode($chaine))); }
Example #17
0
function preparer_diff($texte)
{
    include_spip('inc/charsets');
    $charset = $GLOBALS['meta']['charset'];
    if ($charset == 'utf-8') {
        return unicode_to_utf_8(html2unicode($texte));
    }
    return unicode_to_utf_8(html2unicode(charset2unicode($texte, $charset, true)));
}
Example #18
0
function filtrer_ical($texte)
{
    #include_spip('inc/charsets');
    $texte = html2unicode($texte);
    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
    $texte = preg_replace("/\n/", " ", $texte);
    $texte = preg_replace("/,/", "\\,", $texte);
    return $texte;
}
Example #19
0
	/**
	 * Cree la sortie json pour le javascript des parametres de la barre
	 * et la retourne
	 * 
	 * @return string : declaration json de la barre
	 */
	function creer_json(){
		$barre = $this;
		$type = $barre->nameSpace;
		$fonctions = $barre->functions;
		
		$barre->enlever_elements_non_affiches($this->markupSet);
		$barre->enlever_parametres_inutiles();
		
		$json = Barre_outils::json_export($barre);

		// on lance la transformation des &chose; en veritables caracteres
		// sinon markitup restitue &laquo; au lieu de « directement
		// lorsqu'on clique sur l'icone
		include_spip('inc/charsets');
		$json = unicode2charset(html2unicode($json));
		return "\n\nbarre_outils_$type = ".$json . "\n\n $fonctions";		
	}
Example #20
0
function bouton_copier_local($document, $type, $id, $id_document, $script) {
	global $spip_lang_right;

	// pour etre sur qu'il s'agit bien d'un doc distant
	// et qu'il existe
	$bouton_copier = '';
	if ($document['distant'] == 'oui' /* on pourrait verifier l'existence du
	 	// fichier ici, mais ne risque pas-t-on de degrader les performances ?
	 	// il sera toujours temps de le verifier lorsque l'utilisateur cliquera
	 	// sur le bouton. */) {
		$bouton_copier = ajax_action_auteur("copier_local",
			    "$id_document",
			    $script,
			    "show_docs=$id_document&id_$type=$id#tourner-$id_document",
			    array(http_img_pack('telecharger.gif', _T('copier_en_local'), ''),
				  " class='bouton_rotation'"),
				  // on aurait pu faire un nouveau style 'bouton-telecharger',
				  // mais pour l'instant on se contente de reutiliser celui-ci
				  // afin de garder une homogeneite entre les differents boutons.
			    "&id_document=$id_document&id=$id&type=$type");
			    

		// Hack ?
		// demander confirmation javascript
		$u = str_replace("'", "\\'", unicode_to_javascript(html2unicode(_T('copier_en_local') . ' ' . $document['fichier'])));
		$bouton_copier = str_replace('return AjaxSqueeze',
			"return (!confirm('$u'))?false:AjaxSqueeze", $bouton_copier);
	}

	return $bouton_copier;
}
Example #21
0
File: lang.php Project: JLuc/SPIP
/**
 * Traduit un code de langue (fr, en, etc...) vers le nom de la langue
 * en toute lettres dans cette langue (français, English, etc....).
 *
 * Si le spip ne connait pas le nom de la langue, il retourne le code
 *
 * @param string $lang
 *     Code de langue
 * @return string
 *     Nom de la langue, sinon son code.
**/
function traduire_nom_langue($lang)
{
    include_spip('inc/lang_liste');
    include_spip('inc/charsets');
    return html2unicode(isset($GLOBALS['codes_langues'][$lang]) ? $GLOBALS['codes_langues'][$lang] : $lang);
}
Example #22
0
function afficher_liste_plugins_distants($liste){
	$res = "";
	if (!$liste) return "";
	
	$menu = array();
	$compte = 0;

	$afficher_plugin_distant = charger_fonction('afficher_plugin_distant','plugins');
	$url_page = self();
	foreach ($liste as $url => $info) {
		$titre = $info[0];
		$titre = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($titre))))));
		$menu[$titre] = $afficher_plugin_distant($url_page, $url, $info, _request('plugin')==$url);
	}
	ksort($menu);

	$res .=
		"<h3>"._T('plugins_compte',array('count' => count($menu)))."</h3>"
	  . '<p>'._T('plugin_info_automatique_select',array('rep'=>joli_repertoire(_DIR_PLUGINS_AUTO))).'</p>'
		. "<ul class='liste-items plugins distants'>".join("\n",$menu)."</ul>";

	return $res;
}
Example #23
0
File: sax.php Project: nursit/SPIP
function sax_bug($data, $dtc, $charset = null)
{
    if (is_null($charset)) {
        $charset = $GLOBALS['meta']['charset'];
    }
    if ($dtc) {
        $trans = array();
        foreach ($dtc->entites as $k => $v) {
            if (!strpos(" amp lt gt quot ", $k)) {
                $trans["&{$k};"] = $v;
            }
        }
        $data = strtr($data, $trans);
    } else {
        $data = html2unicode($data, true);
    }
    return unicode2charset($data, $charset);
}
Example #24
0
function debut_javascript($fin='')
{
	global $spip_lang_left, $browser_name, $browser_version;
	include_spip('inc/charsets');

	// tester les capacites JS :

	// On envoie un script ajah ; si le script reussit le cookie passera a +1
	// on installe egalement un <noscript></noscript> qui charge une image qui
	// pose un cookie valant -1

	$testeur = str_replace('&amp;', '\\x26', generer_url_ecrire('test_ajax', 'js=1'));

	if (_SPIP_AJAX AND !defined('_TESTER_NOSCRIPT')) {
	  // pour le pied de page (deja defini si on est validation XML)
		define('_TESTER_NOSCRIPT',
			"<noscript>\n<div style='display:none;'><img src='"
		        . generer_url_ecrire('test_ajax', 'js=-1')
		        . "' width='1' height='1' alt='' /></div></noscript>\n");
	}

	if (!defined('_LARGEUR_ICONES_BANDEAU'))
		include_spip('inc/bandeau');

	$inline =  ((isset($_COOKIE['spip_accepte_ajax']) && $_COOKIE['spip_accepte_ajax'] >= 1)
			? ''
			: "jQuery.ajax({'url':'$testeur'});") .
			(_OUTILS_DEVELOPPEURS ?"var _OUTILS_DEVELOPPEURS=true;":"") .
			"\nvar ajax_image_searching = \n'<img src=\"".url_absolue(chemin_image("searching.gif"))."\" alt=\"\" />';" .
			"\nvar stat = " . (($GLOBALS['meta']["activer_statistiques"] != 'non') ? 1 : 0) .
			"\nvar largeur_icone = " .
			intval(_LARGEUR_ICONES_BANDEAU) .
			"\nvar  bug_offsetwidth = " .
// uniquement affichage ltr: bug Mozilla dans offsetWidth quand ecran inverse!
			((($spip_lang_left == "left") &&
			  (($browser_name != "MSIE") ||
			   ($browser_version >= 6))) ? 1 : 0) .
			"\nvar confirm_changer_statut = '" .
			unicode_to_javascript(addslashes(html2unicode(_T("confirm_changer_statut")))) .
			"';\n";
	return
	  // envoi le fichier JS de config si browser ok.
	  $GLOBALS['browser_layer'] .
	  //plugin needed to fix the select showing through the submenus o IE6
	  (($browser_name == "MSIE" && $browser_version <= 6) ? http_script('', 'bgiframe.js'):'' ) .
	  http_script('', 'presentation.js') . 
	  http_script('', 'gadgets.js') .
	  http_script($inline . $fin);
}