FCKeditor
지각생 연습장
다른 웹 프로그램에 붙일 수 있는 위지윅(WYSIWYG) 에디터
목차 |
사용법
공통
드루팔이나 미디어위키 같이 널리 쓰이는 대중적 CMS는, 대개 FCKeditor 를 붙일 수 있는 모듈/확장기능이 존재한다.
- 모듈 / 확장기능 설치
- FCKeditor 다운로드 -> 모듈/확장기능에 따라 적절한 디렉토리에 업로드
- CMS에서 적절히 설정, 권한 조정
미디어위키
드루팔
- FCKeditor 모듈 설치하고 권한 설정한 후,드루팔을 다운 받는다.
http://drupal.org/project/fckeditor
제로보드
- .../bbs(webbs)/skin/ 에 FCKeditor 디렉토리로 압축 풀고,
- (스킨)디렉토리에 링크 생성
- (스킨)/write.php 에 다음 코드 삽입
<?php include("FCKeditor/fckeditor.php") ; ?> ... HTML 코드 .. FORM... <?php $oFCKeditor = new FCKeditor('FCKeditor1') ; $oFCKeditor->BasePath = 'skin/FCKeditor/'; $oFCKeditor->Value = $memo; $oFCKeditor->ToolbarSets = 'truefriend'; // fckconfig.js 에서 만든 툴바 $oFCKeditor->Create(); ?>
- (제로)/write.php
$memo=stripslashes($data[memo]);
부분을 아래처럼 수정
$memo=stripslashes(html_entity_decode($data[memo]));
- (제로)/view.php
include $dir."/view.php";
앞 앞 줄에 다음 코드 삽입
$subject = html_entity_decode($subject); $memo = html_entity_decode($memo);
- (제로)/write_ok.php
$memo = str_replace(" ","",$memo);
앞 줄에 삽입
if(!$memo && $_POST['FCKeditor1']) $memo = stripslashes($_POST['FCKeditor1']);
문제 해결
쓸때 행간이 너무 길어짐
- 에디터 영역 : .../FCKeditor/editor/css/fck_editorarea.css 수정 - P 태그 부분 주석 해제
- 쓴글 표시 (view.php) : .../bbs/include/list_check.php 에서 아래 부분 변경
if($data[use_html] < 2) $memo=data[memo]=nl2br($data[memo]);
- 모든 게시판에 FCKeditor 를 적용했다면
$memo=$data[memo];//=nl2br($data[memo]);
- 특정 게시판에만 FCKeditor 를 적용했다면
if($data[use_html] < 2) { if($id != '적용한게시판이름') $data[memo]=nl2br($data[memo]); } $memo=$data[memo];
"젨" 같은 이상한 문자 들어감
- 원인 : <tr> 과 <td> 혹은 <table> 등 사이에 (공백문자) 가 들어가 생김 (예 : </tr>& nbsp;& nbsp;</table>) . FCKeditor 의 버그인듯. 공백문자는 다른 특수문자와 달리 html_entity_decode()함수로 변환되지 않음(euc-kr 의 경우 이 함수는 ISO-8859-1 인코딩을 사용 변환작업 수행. ISO-8859-1에서 공백문자는 코드값이 다름)
- 편법 -_-
$memo=stripslashes(html_entity_decode($data[memo])); 부분을 $memo = $data[memo]; $memo = str_replace(" ", "--nbsp--", $memo); $memo = stripslashes(html_entity_decode($memo)); $memo = str_replace("--nbsp--", " ", $memo);
설정하기
엔터를 p 혹은 br 로 인식하기
fckeditor/fckconfig.js 파일 편집: 122번째 줄 부근
FCKConfig.EnterMode = 'p' ; // p | div | br FCKConfig.ShiftEnterMode = 'br' ; // p | div | br
적절히 바꿔주면 된다.
복사해서 붙여넣을때 무조건 평문으로 인식될때
FCKConfig.ForcePasteAsPlainText = false;
로 설정.