타 DHTML 에디터도 사용 할수 있도록 수정, cheditor5 추가

This commit is contained in:
gnuboard
2013-07-17 15:43:52 +09:00
parent fdd3342cb0
commit ce0814da58
278 changed files with 110 additions and 42 deletions

1
.gitignore vendored
View File

@ -11,3 +11,4 @@ thumb.lib.php
test.php
itzimara*
nemoluv*
cheditor*

View File

@ -18,7 +18,7 @@ if ($row['cnt'])
// 게시판 테이블 생성
$sql = get_table_define($g4['write_prefix'] . $bo_table);
$sql = str_replace($g4['write_prefix'] . $bo_table, $g4['write_prefix'] . $target_table, $sql);
sql_query($sql);
sql_query($sql, false);
$file_copy = array();
@ -118,7 +118,7 @@ $sql = " insert into {$g4['board_table']}
bo_8 = '{$board['bo_8']}',
bo_9 = '{$board['bo_9']}',
bo_10 = '{$board['bo_10']}' ";
sql_query($sql);
sql_query($sql, false);
// 게시판 폴더 생성
@mkdir(G4_DATA_PATH.'/file/'.$target_table, G4_DIR_PERMISSION);
@ -141,8 +141,8 @@ if ($copy_case == 'schema_data_both') {
// 김선용 201007 :
if(is_dir(G4_DATA_PATH.'/file/'.$bo_table.'/'.$entry)){
$dd = dir(G4_DATA_PATH.'/file/'.$bo_table.'/'.$entry);
@mkdir(G4_DATA_PATH.'/file/'.$target_table.'/'.$entry G4_DIR_PERMISSION);
@chmod(G4_DATA_PATH.'/file/'.$target_table.'/'.$entry G4_DIR_PERMISSION);
@mkdir(G4_DATA_PATH.'/file/'.$target_table.'/'.$entry, G4_DIR_PERMISSION);
@chmod(G4_DATA_PATH.'/file/'.$target_table.'/'.$entry, G4_DIR_PERMISSION);
while ($entry2 = $dd->read()) {
if ($entry2 == '.' || $entry2 == '..') continue;
@copy(G4_DATA_PATH.'/file/'.$bo_table.'/'.$entry.'/'.$entry2, G4_DATA_PATH.'/file/'.$target_table.'/'.$entry.'/'.$entry2);
@ -153,7 +153,7 @@ if ($copy_case == 'schema_data_both') {
}
else {
@copy(G4_DATA_PATH.'/file/'.$bo_table.'/'.$entry, G4_DATA_PATH.'/file/'.$target_table.'/'.$entry);
@chmod(G4_DATA_PATH.'/file/'.$target_table.'/'.$entry G4_DIR_PERMISSION);
@chmod(G4_DATA_PATH.'/file/'.$target_table.'/'.$entry, G4_DIR_PERMISSION);
$copy_file++;
}
}
@ -161,18 +161,18 @@ if ($copy_case == 'schema_data_both') {
// 글복사
$sql = " insert into {$g4['write_prefix']}$target_table select * from {$g4['write_prefix']}$bo_table ";
sql_query($sql);
sql_query($sql, false);
// 게시글수 저장
$sql = " select bo_count_write, bo_count_comment from {$g4['board_table']} where bo_table = '$bo_table' ";
$row = sql_fetch($sql);
$sql = " update {$g4['board_table']} set bo_count_write = '{$row['bo_count_write']}', bo_count_comment = '{$row['bo_count_comment']}' where bo_table = '$target_table' ";
sql_query($sql);
sql_query($sql, false);
// 4.00.01
// 위의 코드는 같은 테이블명을 사용하였다는 오류가 발생함. (희한하네 ㅡㅡ;)
$sql = " select * from {$g4['board_file_table']} where bo_table = '$bo_table' ";
$result = sql_query($sql);
$result = sql_query($sql, false);
for ($i=0; $row=sql_fetch_array($result); $i++)
$file_copy[$i] = $row;
}
@ -192,7 +192,7 @@ if (count($file_copy)) {
bf_height = '{$file_copy[$i]['bf_height']}',
bf_type = '{$file_copy[$i]['bf_type']}',
bf_datetime = '{$file_copy[$i]['bf_datetime']}' ";
sql_query($sql, FALSE);
sql_query($sql, false);
}
}

View File

@ -1,7 +1,7 @@
<?php
$sub_menu = "300100";
include_once('./_common.php');
include_once(G4_CKEDITOR_PATH.'/ckeditor.lib.php');
include_once(G4_EDITOR_LIB);
auth_check($auth[$sub_menu], 'w');

View File

@ -30,6 +30,16 @@ if(!isset($config['cf_gcaptcha_mp3'])) {
ADD `cf_gcaptcha_mp3` VARCHAR(255) NOT NULL DEFAULT '' AFTER `cf_mobile_member_skin` ", true);
}
if(!isset($config['cf_gcaptcha_mp3'])) {
sql_query(" ALTER TABLE `{$g4['config_table']}`
ADD `cf_gcaptcha_mp3` VARCHAR(255) NOT NULL DEFAULT '' AFTER `cf_mobile_member_skin` ", true);
}
if(!isset($config['cf_editor'])) {
sql_query(" ALTER TABLE `{$g4['config_table']}`
ADD `cf_editor` VARCHAR(255) NOT NULL DEFAULT '' AFTER `cf_gcaptcha_mp3` ", true);
}
if(!isset($config['cf_googl_shorturl_apikey'])) {
sql_query(" ALTER TABLE `{$g4['config_table']}`
ADD `cf_googl_shorturl_apikey` VARCHAR(255) NOT NULL DEFAULT '' AFTER `cf_gcaptcha_mp3` ", true);
@ -286,6 +296,21 @@ $pg_anchor = '<ul class="anchor">
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="cf_editor">에디터 선택</label></th>
<td colspan="3">
<?php echo help(G4_EDITOR_URL.' 밑의 DHTML 에디터 폴더를 선택합니다.') ?>
<select name="cf_editor" id="cf_editor">
<?php
$arr = get_skin_dir('', G4_EDITOR_PATH);
for ($i=0; $i<count($arr); $i++) {
if ($i == 0) echo "<option value=\"\">사용안함</option>";
echo "<option value=\"".$arr[$i]."\"".get_selected($config['cf_editor'], $arr[$i]).">".$arr[$i]."</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="cf_gcaptcha_mp3">음성캡챠 선택<strong class="sound_only">필수</strong></label></th>
<td colspan="3">

View File

@ -101,6 +101,7 @@ $sql = " update {$g4['config_table']}
cf_mobile_connect_skin = '{$_POST['cf_mobile_connect_skin']}',
cf_mobile_member_skin = '{$_POST['cf_mobile_member_skin']}',
cf_gcaptcha_mp3 = '{$_POST['cf_gcaptcha_mp3']}',
cf_editor = '{$_POST['cf_editor']}',
cf_googl_shorturl_apikey = '{$_POST['cf_googl_shorturl_apikey']}',
cf_kcpcert_site_cd = '{$_POST['cf_kcpcert_site_cd']}',
cf_kcpcert_use = '{$_POST['cf_kcpcert_use']}',

View File

@ -1,7 +1,7 @@
<?php
$sub_menu = "200300";
include_once('./_common.php');
include_once(G4_CKEDITOR_PATH.'/ckeditor.lib.php');
include_once(G4_EDITOR_LIB);
auth_check($auth[$sub_menu], 'r');
@ -44,7 +44,7 @@ include_once('./admin.head.php');
</tr>
<tr>
<th scope="row"><label for="ma_content">메일 내용<strong class="sound_only">필수</strong></label></th>
<td><?php echo editor_html("ma_content", $ma['ma_content'], '400'); ?></td>
<td><?php echo editor_html("ma_content", $ma['ma_content']); ?></td>
</tr>
</tbody>
</table>
@ -65,13 +65,17 @@ function fmailform_check(f)
errfld = "";
check_field(f.ma_subject, "제목을 입력하세요.");
check_field(f.ma_content, "내용을 입력하세요.");
//check_field(f.ma_content, "내용을 입력하세요.");
if (errmsg != "") {
alert(errmsg);
errfld.focus();
return false;
}
<?php echo get_editor_js("ma_content"); ?>
<?php echo chk_editor_js("ma_content"); ?>
return true;
}

View File

@ -1,6 +1,6 @@
<?php
include_once('./_common.php');
include_once(G4_CKEDITOR_PATH.'/ckeditor.lib.php');
include_once(G4_EDITOR_LIB);
include_once(G4_GCAPTCHA_PATH.'/gcaptcha.lib.php');
set_session('ss_bo_table', $_REQUEST['bo_table']);
@ -371,14 +371,14 @@ if ($is_guest) {
}
$is_dhtml_editor = false;
$editor_js = '';
// 모바일에서는 DHTML 에디터 사용불가
if (!G4_IS_MOBILE && $board['bo_use_dhtml_editor'] && $member['mb_level'] >= $board['bo_html_level']) {
if ($config['cf_editor'] && !G4_IS_MOBILE && $board['bo_use_dhtml_editor'] && $member['mb_level'] >= $board['bo_html_level']) {
$is_dhtml_editor = true;
$editor_js .= get_editor_js('wr_content', $is_dhtml_editor);
$editor_js .= chk_editor_js('wr_content', $is_dhtml_editor);
}
$editor_html = editor_html('wr_content', $content, $is_dhtml_editor);
$editor_js = '';
$editor_js .= get_editor_js('wr_content', $is_dhtml_editor);
$editor_js .= chk_editor_js('wr_content', $is_dhtml_editor);
// 임시 저장된 글 갯수
$autosave_count = autosave_count($member['mb_id']);

View File

@ -163,8 +163,12 @@ ini_set("session.cookie_domain", G4_COOKIE_DOMAIN);
// 기본적으로 사용하는 필드만 얻은 후 상황에 따라 필드를 추가로 얻음
$config = sql_fetch(" select * from {$g4['config_table']} ");
define('G4_HTTP_BBS_URL', https_url(G4_BBS_DIR, false));
define('G4_HTTPS_BBS_URL', https_url(G4_BBS_DIR, true));
define('G4_HTTP_BBS_URL', https_url(G4_BBS_DIR, false));
define('G4_HTTPS_BBS_URL', https_url(G4_BBS_DIR, true));
if ($config['cf_editor'])
define('G4_EDITOR_LIB', G4_EDITOR_PATH."/{$config['cf_editor']}/editor.lib.php");
else
define('G4_EDITOR_LIB', G4_LIB_PATH."/editor.lib.php");
//==============================================================================
// Mobile 모바일 설정

View File

@ -46,7 +46,7 @@ define('G4_LIB_DIR', 'lib');
define('G4_PLUGIN_DIR', 'plugin');
define('G4_SKIN_DIR', 'skin');
define('G4_GCAPTCHA_DIR', 'gcaptcha');
define('G4_CKEDITOR_DIR', 'ckeditor');
define('G4_EDITOR_DIR', 'editor');
define('G4_MOBILE_DIR', 'mobile');
define('G4_KCPCERT_DIR', 'kcpcert');
@ -79,7 +79,7 @@ define('G4_JS_URL', G4_URL.'/'.G4_JS_DIR);
define('G4_SKIN_URL', G4_URL.'/'.G4_SKIN_DIR);
define('G4_PLUGIN_URL', G4_URL.'/'.G4_PLUGIN_DIR);
define('G4_GCAPTCHA_URL', G4_PLUGIN_URL.'/'.G4_GCAPTCHA_DIR);
define('G4_CKEDITOR_URL', G4_PLUGIN_URL.'/'.G4_CKEDITOR_DIR); // CKEDITOR 의 라이브러리 경로
define('G4_EDITOR_URL', G4_PLUGIN_URL.'/'.G4_EDITOR_DIR);
define('G4_KCPCERT_URL', G4_PLUGIN_URL.'/'.G4_KCPCERT_DIR);
define('G4_SNS_URL', G4_PLUGIN_URL.'/'.G4_SNS_DIR);
define('G4_SYNDI_URL', G4_PLUGIN_URL.'/'.G4_SYNDI_DIR);
@ -94,7 +94,7 @@ define('G4_LIB_PATH', G4_PATH.'/'.G4_LIB_DIR);
define('G4_PLUGIN_PATH', G4_PATH.'/'.G4_PLUGIN_DIR);
define('G4_SKIN_PATH', G4_PATH.'/'.G4_SKIN_DIR);
define('G4_GCAPTCHA_PATH', G4_PLUGIN_PATH.'/'.G4_GCAPTCHA_DIR);
define('G4_CKEDITOR_PATH', G4_PLUGIN_PATH.'/'.G4_CKEDITOR_DIR);
define('G4_EDITOR_PATH', G4_PLUGIN_PATH.'/'.G4_EDITOR_DIR);
define('G4_KCPCERT_PATH', G4_PLUGIN_PATH.'/'.G4_KCPCERT_DIR);

View File

@ -61,6 +61,7 @@ var g4_is_admin = "<?php echo isset($is_admin)?$is_admin:''; ?>";
var g4_is_mobile = "<?php echo G4_IS_MOBILE ?>";
var g4_bo_table = "<?php echo isset($bo_table)?$bo_table:''; ?>";
var g4_sca = "<?php echo isset($sca)?$sca:''; ?>";
var g4_editor = "<?php echo isset($config['cf_editor'])?$config['cf_editor']:''; ?>";
var g4_cookie_domain = "<?php echo G4_COOKIE_DOMAIN ?>";
<?php
if ($is_admin) {

View File

@ -279,6 +279,7 @@ CREATE TABLE IF NOT EXISTS `g4s_config` (
`cf_mobile_connect_skin` varchar(255) NOT NULL DEFAULT '',
`cf_mobile_member_skin` varchar(255) NOT NULL DEFAULT '',
`cf_gcaptcha_mp3` varchar(255) NOT NULL DEFAULT '',
`cf_editor` varchar(255) NOT NULL DEFAULT '',
`cf_googl_shorturl_apikey` varchar(255) NOT NULL DEFAULT '',
`cf_kcpcert_site_cd` varchar(255) NOT NULL DEFAULT '',
`cf_kcpcert_use` enum('','test','service') NOT NULL DEFAULT '',

View File

@ -7,8 +7,9 @@ var save_wr_content = null;
function autosave() {
$("form#fwrite").each(function() {
if (typeof(CKEDITOR.instances.wr_content)!="undefined")
if (g4_editor=="ckeditor4" && typeof(CKEDITOR.instances.wr_content)!="undefined") {
this.wr_content.value = CKEDITOR.instances.wr_content.getData();
}
// 변수에 저장해 놓은 값과 다를 경우에만 임시 저장함
if (save_wr_subject != this.wr_subject.value || save_wr_content != this.wr_content.value) {
$.ajax({
@ -72,7 +73,7 @@ $(function(){
var subject = $(data).find("item").find("subject").text();
var content = $(data).find("item").find("content").text();
$("#wr_subject").val(subject);
if (typeof(CKEDITOR.instances.wr_content)!="undefined") {
if (g4_editor=="ckeditor4" && typeof(CKEDITOR.instances.wr_content)!="undefined") {
CKEDITOR.instances.wr_content.setData(content);
} else {
$("#fwrite #wr_content").val(content);

27
lib/editor.lib.php Normal file
View File

@ -0,0 +1,27 @@
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
/*
환경설정에서 에디터 선택이 없는 경우에 사용하는 라이브러리 입니다.
에디터 선택시 "선택없음"이 아닌 경우 plugin/editor 하위 디렉토리의 각 에디터이름/editor.lib.php 를 수정하시기 바랍니다.
*/
function editor_html($id, $content)
{
return "<textarea id=\"$id\" name=\"$id\" style=\"width:100%;\" maxlength=\"65536\">$content</textarea>";
}
// textarea 로 값을 넘긴다. javascript 반드시 필요
function get_editor_js($id)
{
return "var {$id}_editor = document.getElementById('{$id}');\n";
}
// textarea 의 값이 비어 있는지 검사
function chk_editor_js($id)
{
return "if (!{$id}_editor.value) { alert(\"내용을 입력해 주십시오.\"); {$id}_editor.focus(); return false; }\n";
}
?>

View File

@ -108,7 +108,7 @@ CKEDITOR.editorConfig = function( config ) {
config.fontSize_sizes = "7pt/9px;8pt/11px;9pt/12px;10pt/13px;11pt/15px;14pt/19px;18pt/24px;24pt/32px;36/48px;";
config.enterMode = CKEDITOR.ENTER_DIV;
config.shiftEnterMode = CKEDITOR.ENTER_DIV;
config.filebrowserUploadUrl = g4_ckeditor_url+"/upload.php?type=Images";
config.filebrowserUploadUrl = g4_editor_url+"/upload.php?type=Images";
config.keystrokes=[
// Formatting
[ CKEDITOR.CTRL + 81 /*Q*/, 'blockquote' ],

View File

@ -1,20 +1,22 @@
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
function editor_html($id, $content, $ckeditor=true, $class="")
function editor_html($id, $content, $is_dhtml_editor=true)
{
global $g4;
global $g4, $config;
static $js = true;
$editor_url = G4_EDITOR_URL.'/'.$config['cf_editor'];
$html = "";
$html .= "<span class=\"sound_only\">웹에디터 시작</span>";
if ($ckeditor)
if ($is_dhtml_editor)
$html .= '<script>document.write("<div class=\'cke_sc\'><button type=\'button\' class=\'btn_cke_sc\'>단축키 일람</button></div>");</script>';
if ($js) {
$html .= "\n".'<script src="'.G4_CKEDITOR_URL.'/ckeditor.js"></script>';
$html .= "\n".'<script>var g4_ckeditor_url = "'.G4_CKEDITOR_URL.'";</script>';
$html .= "\n".'<script src="'.G4_CKEDITOR_URL.'/config.js"></script>';
$html .= "\n".'<script src="'.$editor_url.'/ckeditor.js"></script>';
$html .= "\n".'<script>var g4_editor_url = "'.$editor_url.'";</script>';
$html .= "\n".'<script src="'.$editor_url.'/config.js"></script>';
$html .= "\n<script>";
$html .= '
$(function(){
@ -23,7 +25,7 @@ function editor_html($id, $content, $ckeditor=true, $class="")
$(this).next("div.cke_sc_def").remove();
$(this).text("단축키 일람");
} else {
$(this).after("<div class=\'cke_sc_def\' />").next("div.cke_sc_def").load("'.G4_CKEDITOR_URL.'/shortcut.html");
$(this).after("<div class=\'cke_sc_def\' />").next("div.cke_sc_def").load("'.$editor_url.'/shortcut.html");
$(this).text("단축키 일람 닫기");
}
});
@ -35,17 +37,17 @@ function editor_html($id, $content, $ckeditor=true, $class="")
$js = false;
}
$ckeditor_class = $ckeditor ? "ckeditor" : "";
$html .= "\n<textarea id=\"$id\" name=\"$id\" class=\"$ckeditor_class $class\" style=\"width:100%;\" maxlength=\"65536\">$content</textarea>";
$ckeditor_class = $is_dhtml_editor ? "ckeditor" : "";
$html .= "\n<textarea id=\"$id\" name=\"$id\" class=\"$ckeditor_class\" style=\"width:100%;\" maxlength=\"65536\">$content</textarea>";
$html .= "\n<span class=\"sound_only\">웹 에디터 끝</span>";
return $html;
}
// textarea 로 값을 넘긴다. javascript 반드시 필요
function get_editor_js($id, $ckeditor=true)
function get_editor_js($id, $is_dhtml_editor=true)
{
if ( $ckeditor ) {
if ($is_dhtml_editor) {
return "var {$id}_editor_data = CKEDITOR.instances.{$id}.getData();\n";
} else {
return "var {$id}_editor = document.getElementById('{$id}');\n";
@ -54,12 +56,12 @@ function get_editor_js($id, $ckeditor=true)
// textarea 의 값이 비어 있는지 검사
function chk_editor_js($id, $ckeditor=true, $textarea_name="내용을")
function chk_editor_js($id, $is_dhtml_editor=true)
{
if ( $ckeditor ) {
return "if (!{$id}_editor_data) { alert(\"$textarea_name 입력해 주십시오.\"); CKEDITOR.instances.{$id}.focus(); return false; }\nif (typeof(f.wr_content)!=\"undefined\") f.wr_content.value = {$id}_editor_data;\n";
if ($is_dhtml_editor) {
return "if (!{$id}_editor_data) { alert(\"내용을 입력해 주십시오.\"); CKEDITOR.instances.{$id}.focus(); return false; }\nif (typeof(f.wr_content)!=\"undefined\") f.wr_content.value = {$id}_editor_data;\n";
} else {
return "if (!{$id}_editor.value) { alert(\"$textarea_name 입력해 주십시오.\"); {$id}_editor.focus(); return false; }\n";
return "if (!{$id}_editor.value) { alert(\"내용을 입력해 주십시오.\"); {$id}_editor.focus(); return false; }\n";
}
}
?>

Some files were not shown because too many files have changed in this diff Show More