예제 #1
0
function ckeditor_efface_repertoire($dir) {
   $files = array_diff(scandir($dir), array('.','..'));
    foreach ($files as $file) {
      (is_dir("$dir/$file")) ? ckeditor_efface_repertoire("$dir/$file") : unlink("$dir/$file");
    }
    return rmdir($dir);
  } 
function formulaires_configurer_ckeditor_p3_traiter_dist() {
	if (_request('_cfg_delete')) {
		$valeurs = formulaires_configurer_ckeditor_p3_charger_dist() ;
		foreach($valeurs as $cle =>$valeur) {
			effacer_config('ckeditor/'.$cle) ;
			unset($_POST[$cle]) ;
		}
		return array('message_ok' => _T('ckeditor:ck_delete')) ;
	} else if (_request('nettoyer')) {
		$cke_path = dirname(_CKE_JS) ;
		$sources = $cke_path.'/_source' ;
		$exemples = $cke_path.'/_samples' ;
		switch (_request('nettoyage')) {
			case 'sources':
				if (is_dir($sources)) {
					ckeditor_efface_repertoire($sources) ;
					return array('message_ok' => _T('ckeditor:ok_nettoyage_des_sources')) ;
				} else {
					return array('message_ok', _T('ckeditor:ok_repertoire_introuvable',array('repertoire'=>$sources))) ;
				}
				break ;
			case 'exemples':
				if (is_dir($exemples)) {
					ckeditor_efface_repertoire($exemples) ;
					return array('message_ok' => _T('ckeditor:ok_nettoyage_des_exemples')) ;
				} else {
					return array('message_ok', _T('ckeditor:ok_repertoire_introuvable',array('repertoire'=>$exemples))) ;
				}
				break ;
			case 'tout':
				$result = array() ;
				if (is_dir($sources)) {
					ckeditor_efface_repertoire($sources) ;
					$result[] = _T('ckeditor:ok_nettoyage_des_sources') ;
				} else {
					$result[] = _T('ckeditor:ok_repertoire_introuvable',array('repertoire'=>$sources)) ;
				}
				if (is_dir($exemples)) {
					ckeditor_efface_repertoire($exemples) ;
					$result[] = _T('ckeditor:ok_nettoyage_des_sources') ;
				} else {
					$result[] = _T('ckeditor:ok_repertoire_introuvable',array('repertoire'=>$exemples)) ;
				}
				return array('message_ok' => join("<br/>\n",$result)) ;
				break ;
			default: 
				return array('message_erreur' => _T('ckeditor:ko_nettoyage_indetermine')) ;
				break ;
		}
	} else {
		foreach(preg_split('~\s*;\s*~', _request("protectedtags")) as $tag) {
			$tag = trim($tag) ;
			$tag_closed = false ;
			if (preg_match('~^/(.*)$~', trim($tag), $m)) {
				$tag = $m[1] ;
				$tag_closed = true ;
			}
			$type = '' ;
			if (preg_match('~(.+)(xx|XX)$~', $tag, $m)) {
				$tag = $m[1] ;
				if ($m[2] == 'xx') {
					$type = 'num-facultatif' ;
				}
				if ($m[2] == 'XX') {
					$type = 'num-obligatoire' ;
				}
			}
			if (!is_array(lire_config("ckeditor/tags/".$tag)) || $tag_closed) {
				ecrire_config("ckeditor/tags/".$tag."/fermante", $tag_closed) ;
			}
			if (!$tag_closed) {
				ecrire_config("ckeditor/tags/".$tag."/type",$type) ;
			}
		}
		ecrire_config("ckeditor/conversion", _request("conversion")) ;
		ecrire_config("ckeditor/html2spip_limite", (bool) _request("html2spip_limite")) ;
		ecrire_config("ckeditor/html2spip_identite", _request("html2spip_identite")) ;
		ecrire_config("ckeditor/spiplinks", (bool) _request("spiplinks")) ;
		ecrire_config("ckeditor/insertall",(bool) _request("insertall")) ;
		ecrire_config("ckeditor/pastetext",(bool) _request("pastetext")) ;
		ecrire_config("ckeditor/selecteurs_public", _request("selecteurs_public")) ;
		ecrire_config("ckeditor/selecteurs_prive", _request("selecteurs_prive")) ;

		ecrire_config("ckeditor/cktoolslenlarge", _request("cktoolslenlarge")) ;
		ecrire_config("ckeditor/cktoolslenetroit", _request("cktoolslenetroit")) ;
		ecrire_config("ckeditor/cklanguage", _request("cklanguage")) ;
		ecrire_config("ckeditor/entermode", _request("entermode")) ;
		ecrire_config("ckeditor/shiftentermode", _request("shiftentermode")) ;
		ecrire_config("ckeditor/csssite", _request("csssite")) ;
		ecrire_config("ckeditor/contextes", _request("contextes")) ;
		ecrire_config("ckeditor/siteurl", _request("siteurl")) ;
		return array('message_ok' => _T('ckeditor:ck_ok')) ;
	}
}