웹마스터 팁
에디터 사용 옵션으로 처리하기[EDITOR MODULE][ver 1.0.1][Page4-3]
2008.04.08 20:10
적용하시기전 먼저 http://www.zeroboard.com/16700971 반드시 읽어 주세요.
1.modules/editor/editor.admin.controller.php
line161 부분에 소스를 삽입한다.
$editor_config->enable_autosave = Context::get('enable_autosave');
$editor_config->enable_only_upload_editor = Context::get('enable_only_upload_editor');if($editor_config->enable_height_resizable != 'Y') $editor_config->enable_height_resizable = 'N';
if($editor_config->enable_comment_height_resizable != 'Y') $editor_config->enable_comment_height_resizable = 'N';
if($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N';
if($editor_config->enable_only_upload_editor != 'Y'+ '+ ') $editor_config->enable_only_upload_editor = 'N';2. modules/editor/editor.model.php
line45 부분에 소스를 삽입한다.
if(!$editor_config->editor_height) $editor_config->editor_height = 500;
if(!$editor_config->comment_editor_height) $editor_config->comment_editor_height = 120;
if($editor_config->enable_height_resizable!='N') $editor_config->enable_height_resizable= "Y";
if($editor_config->enable_comment_height_resizable!='Y') $editor_config->enable_comment_height_resizable= "N";
if($editor_config->enable_autosave!='N') $editor_config->enable_autosave = "Y";
if($editor_config->enable_only_upload_editor != 'Y') $editor_config->enable_only_upload_editor = 'N';return $editor_config;
}/**
* @brief 에디터 template을 return
* upload_target_srl은 글의 수정시 호출하면 됨.
* 이 upload_target_srl은 첨부파일의 유무를 체크하기 위한 루틴을 구현하는데 사용됨.
**/
function getEditor($upload_target_srl = 0, $option = null) {
/**
* 기본적인 에디터의 옵션을 정리
**/// 에디터 업로드만 사용 옵션 설정
if(!$option->enable_only_upload_editor) $enable_only_upload_editor = false;
else $enable_only_upload_editor = true;line 166
/**
* 에디터 컴포넌트 체크
**/
if($enable_component) {
if(!Context::get('component_list')) {
$component_list = $this->getComponentList();
Context::set('component_list', $component_list);
}
}
Context::set('enable_component', $enable_component);
Context::set('enable_default_component', $enable_default_component);/**
* 에디터 업로드 기능만 가능한지 변수 설정
**/
Context::set('enable_only_upload_editor', $enable_only_upload_editor);line 220
function getModuleEditor($type = 'document', $module_srl, $upload_target_srl, $primary_key_name, $content_key_name) {
// 지정된 모듈의 에디터 설정을 구해옴
$editor_config = $this->getEditorConfig($module_srl);// type에 따른 설정 정리
if($type == 'document') {
$config->editor_skin = $editor_config->editor_skin;
$config->upload_file_grant = $editor_config->upload_file_grant;
$config->enable_default_component_grant = $editor_config->enable_default_component_grant;
$config->enable_component_grant = $editor_config->enable_component_grant;
$config->enable_html_grant = $editor_config->enable_html_grant;
$config->editor_height = $editor_config->editor_height;
$config->enable_height_resizable = $editor_config->enable_height_resizable;
$config->enable_autosave = $editor_config->enable_autosave;
$config->enable_only_upload_editor = 'N';
} elseif($type == 'extra_vars'){
$config->enable_only_upload_editor = 'Y';
} elseif($type == '+ 'comment') {
$config->editor_skin = $editor_config->comment_editor_skin;
$config->upload_file_grant = $editor_config->comment_upload_file_grant;
$config->enable_default_component_grant = $editor_config->enable_comment_default_component_grant;
$config->enable_component_grant = $editor_config->enable_comment_component_grant;
$config->enable_html_grant = $editor_config->enable_comment_html_grant;
$config->editor_height = $editor_config->comment_editor_height;
$config->enable_height_resizable = $editor_config->enable_comment_height_resizable;
$config->enable_autosave = 'N';
$config->enable_only_upload_editor = 'N';
}
line 293
// HTML 편집 권한
$enable_html = false;
if(count($config->enable_html_grant)) {
foreach($group_list as $group_srl => $group_info) {
if(in_array($group_srl, $config->enable_html_grant)) {
$enable_html = true;
break;
}
}
} else $enable_html = true;if($enable_html) $option->disable_html = false;
else $option->disable_html = true;// 에디터 업로드만 설정
$option->enable_only_upload_editor = $config->enable_only_upload_editor=='Y'?true:false;3. moudles/editor/tpl/js/uploader.js
line 247 부분 소스를 삽입한다.
// 이미지 파일의 경우
} else if(/\.(jpg|jpeg|png|gif)$/i.test(uploaded_filename)) {
html = "<img src=\""+uploaded_filename+"\" border=\"0\" width=\"110\" height=\"110\" onclick=\"copyContent(this.href);return false\" />";line 끝부분에 아래의 소스를 삽입한다.
function copyContent(trb)
{
var IE=(document.all)?true:false;
if (IE) {
if(confirm("이 글의 주소를 클립보드에 복사하시겠습니까?"))
window.clipboardData.setData("Text", trb);
}
};<<보충설명>>
1> 이 소스는 글쓰기 폼에서 이미지 파일이 업로드 되면 미리보기가 지원되는데, 미리보기 이미지를 클릭하면 업로드된 파일의 위치를 클립보드에 복사 합니다.2> 위의 방법으로 복사된 이미지 파일의 주소를 확장변수의 이미지 주소창에 사용자가 붙여넣기하여 사용하기 위함입니다.
4. modules/editor/tpl/editor_module_config.html
전체 파일입니다. 조건식을 넣어 게시글/댓글의 위지웍 에디터 활성/비활성에 따라 추가설정에서 게시글/댓글의 활성/비활성 시킴.
<!--@if($module_info->enable_comment_editor !='N' || $module_info->enable_editor!='N')-->
<!--%import("filter/insert_editor_module_config.xml")--><form action="./" method="post" onsubmit="return procFilter(this, insert_editor_module_config)">
<input type="hidden" name="target_module_srl" value="{$module_info->module_srl?$module_info->module_srl:$module_srls}" /><table cellspacing="0" class="adminTable">
<col width="150" />
<!--@if($module_info->enable_editor!='N')--><col /><!--@end-->
<!--@if($module_info->enable_comment_editor !='N')--><col /><!--@end-->
<caption>{$lang->editor}</caption>
<tr>
<th scope="col"> </th>
<!--@if($module_info->enable_editor!='N')--><th scope="col">{$lang->document}</th><!--@end-->
<!--@if($module_info->enable_comment_editor !='N')--><th scope="col">{$lang->comment}</th><!--@end-->
</tr>
<tr>
<th rowspan="2">{$lang->editor_skin}</th>
<!--@if($module_info->enable_editor!='N')--><td>
<select name="editor_skin">
<!--@foreach($editor_skin_list as $editor)-->
<option value="{$editor}" <!--@if($editor==$editor_config->editor_skin)-->selected="selected"<!--@end-->>{$editor}</option>
<!--@end-->
</select>
</td><!--@end-->
<!--@if($module_info->enable_comment_editor !='N')--><td>
<select name="comment_editor_skin">
<!--@foreach($editor_skin_list as $editor)-->
<option value="{$editor}" <!--@if($editor==$editor_config->comment_editor_skin)-->selected="selected"<!--@end-->>{$editor}</option>
<!--@end-->
</select>
</td><!--@end-->
</tr>
<tr>
<td <!--@if($module_info->enable_comment_editor !='N' && $module_info->enable_editor!='N')-->colspan="2"<!--@end-->>{$lang->about_editor_skin}</td>
</tr>
<tr>
<th rowspan="2">{$lang->enable_html_grant}</th>
<!--@if($module_info->enable_editor!='N')--><td>
<!--@foreach($group_list as $k => $v)-->
<input type="checkbox" name="enable_html_grant" value="{$k}" id="enable_html_{$k}" <!--@if(in_array($k, $editor_config->enable_html_grant))-->checked="checked"<!--@end-->/> <label for="enable_html_{$k}">{$v->title}</label> <br />
<!--@end-->
</td><!--@end-->
<!--@if($module_info->enable_comment_editor !='N')--><td>
<!--@foreach($group_list as $k => $v)-->
<input type="checkbox" name="enable_comment_html_grant" value="{$k}" id="enable_comment_html_{$k}" <!--@if(in_array($k, $editor_config->enable_comment_html_grant))-->checked="checked"<!--@end-->/> <label for="enable_comment_html_{$k}">{$v->title}</label> <br />
<!--@end-->
</td><!--@end-->
</tr>
<tr>
<td <!--@if($module_info->enable_comment_editor !='N' && $module_info->enable_editor!='N')-->colspan="2"<!--@end-->>{$lang->about_enable_html_grant}</td>
</tr>
<tr>
<th rowspan="2">{$lang->upload_file_grant}</th>
<!--@if($module_info->enable_editor!='N')--><td>
<!--@foreach($group_list as $k => $v)-->
<input type="checkbox" name="upload_file_grant" value="{$k}" id="fileupload_{$k}" <!--@if(in_array($k, $editor_config->upload_file_grant))-->checked="checked"<!--@end-->/> <label for="fileupload_{$k}">{$v->title}</label> <br />
<!--@end-->
</td><!--@end-->
<!--@if($module_info->enable_comment_editor !='N')--><td>
<!--@foreach($group_list as $k => $v)-->
<input type="checkbox" name="comment_upload_file_grant" value="{$k}" id="comment_fileupload_{$k}" <!--@if(in_array($k, $editor_config->comment_upload_file_grant))-->checked="checked"<!--@end-->/> <label for="comment_fileupload_{$k}">{$v->title}</label> <br />
<!--@end-->
</td><!--@end-->
</tr>
<tr>
<td <!--@if($module_info->enable_comment_editor !='N' && $module_info->enable_editor!='N')-->colspan="2"<!--@end-->>{$lang->about_upload_file_grant}</td>
</tr>
<tr>
<th rowspan="2">{$lang->enable_default_component_grant}</th>
<!--@if($module_info->enable_editor!='N')--><td>
<!--@foreach($group_list as $k => $v)-->
<input type="checkbox" name="enable_default_component_grant" value="{$k}" id="default_componen_{$k}" <!--@if(in_array($k, $editor_config->enable_default_component_grant))-->checked="checked"<!--@end-->/> <label for="default_componen_{$k}">{$v->title}</label> <br />
<!--@end-->
</td><!--@end-->
<!--@if($module_info->enable_comment_editor !='N')--><td>
<!--@foreach($group_list as $k => $v)-->
<input type="checkbox" name="enable_comment_default_component_grant" value="{$k}" id="comment_default_component_{$k}" <!--@if(in_array($k, $editor_config->enable_comment_default_component_grant))-->checked="checked"<!--@end-->/> <label for="comment_default_component_{$k}">{$v->title}</label> <br />
<!--@end-->
</td><!--@end-->
</tr>
<tr>
<td <!--@if($module_info->enable_comment_editor !='N' && $module_info->enable_editor!='N')-->colspan="2"<!--@end-->>{$lang->about_default_component_grant}</td>
</tr>
<tr>
<th rowspan="2">{$lang->enable_component_grant}</th>
<!--@if($module_info->enable_editor!='N')--><td>
<!--@foreach($group_list as $k => $v)-->
<input type="checkbox" name="enable_component_grant" value="{$k}" id="componen_{$k}" <!--@if(in_array($k, $editor_config->enable_component_grant))-->checked="checked"<!--@end-->/> <label for="componen_{$k}">{$v->title}</label> <br />
<!--@end-->
</td><!--@end-->
<!--@if($module_info->enable_comment_editor !='N')--><td>
<!--@foreach($group_list as $k => $v)-->
<input type="checkbox" name="enable_comment_component_grant" value="{$k}" id="comment_component_{$k}" <!--@if(in_array($k, $editor_config->enable_comment_component_grant))-->checked="checked"<!--@end-->/> <label for="comment_component_{$k}">{$v->title}</label> <br />
<!--@end-->
</td><!--@end-->
</tr>
<tr>
<td <!--@if($module_info->enable_comment_editor !='N' && $module_info->enable_editor!='N')-->colspan="2"<!--@end-->>{$lang->about_component_grant}</td>
</tr>
<tr>
<th rowspan="2">{$lang->editor_height}</th>
<!--@if($module_info->enable_editor!='N')--><td>
<input type="text" name="editor_height" value="{$editor_config->editor_height}" class="inputTypeText w80" />px
</td><!--@end-->
<!--@if($module_info->enable_comment_editor !='N')--><td>
<input type="text" name="comment_editor_height" value="{$editor_config->comment_editor_height}" class="inputTypeText w80" />px
</td><!--@end-->
</tr>
<tr>
<td <!--@if($module_info->enable_comment_editor !='N' && $module_info->enable_editor!='N')-->colspan="2"<!--@end-->>{$lang->about_editor_height}</td>
</tr>
<tr>
<th rowspan="2">{$lang->height_resizable}</th>
<!--@if($module_info->enable_editor!='N')--><td>
<input type="checkbox" value="Y" name="enable_height_resizable" <!--@if($editor_config->enable_height_resizable=='Y')-->checked="checked"<!--@end-->/>
</td><!--@end-->
<!--@if($module_info->enable_comment_editor !='N')--><td>
<input type="checkbox" value="Y" name="enable_comment_height_resizable" <!--@if($editor_config->enable_comment_height_resizable=='Y')-->checked="checked"<!--@end-->/>
</td><!--@end-->
</tr>
<tr>
<td <!--@if($module_info->enable_comment_editor !='N' && $module_info->enable_editor!='N')-->colspan="2"<!--@end-->>{$lang->about_editor_height_resizable}</td>
</tr>
<!--@if($module_info->enable_editor!='N')-->
<tr>
<th rowspan="2">{$lang->enable_autosave}</th>
<td <!--@if($module_info->enable_comment_editor !='N' && $module_info->enable_editor!='N')-->colspan="2"<!--@end-->><input type="checkbox" value="Y" name="enable_autosave" <!--@if($editor_config->enable_autosave=='Y')-->checked="checked"<!--@end-->/></td>
</tr>
<tr>
<td <!--@if($module_info->enable_comment_editor !='N' && $module_info->enable_editor!='N')-->colspan="2"<!--@end-->>{$lang->about_enable_autosave}</td>
</tr>
<!--@end-->
<tr>
<th class="button" <!--@if($module_info->enable_comment_editor !='N'+ ' && $module_info->enable_editor!='N')-->colspan="3"<!--@else-->colspan="2"<!--@end-->>
<span class="button"><input type="submit" value="{$lang->cmd_save}"/></span>
</th>
</tr>
</table></form>
<div class="gap1"></div>
<!--@end-->5. module/editor/skins/default/editor.html
line 9 부분에 소스를 삽입한다.
<!-- 자동저장용 폼 -->
<!--@if($enable_autosave && !$enable_only_upload_editor)-->
<input type="hidden" name="_saved_doc_title" value="{htmlspecialchars($saved_doc->title)}" />
<input type="hidden" name="_saved_doc_content" value="{htmlspecialchars($saved_doc->content)}" />
<input type="hidden" name="_saved_doc_message" value="{$lang->msg_load_saved_doc}" />
<!--@end--><!-- 에디터 -->
line 142 부분에 소스를 삽입한다.
<div class="xeEditor">
<!--@if(!$enable_only_upload_editor)-->
<!-- 에디터 크기 조절 bar -->
<!--@if($enable_resizable)-->
<div class="textAreaDragIndicator"><div class="textAreaDragIndicatorBar" id="editor_drag_bar_{$editor_sequence}"></div></div>
<!--@end-->
<!--@else-->
<!-- 에디터 출력 -->
<div><iframe id="editor_iframe_{$editor_sequence}" frameborder="0" height="0" style="background-color:transparent;" allowTransparency="true"></iframe></div>
<textarea id="editor_textarea_{$editor_sequence}" class="editor_iframe_textarea" style="display:none; height:0" rows="10" cols="10"></textarea>
<!--@end--> line 169 부분에 소스를 삽입한다.
<!-- 파일 업로드 영역 -->
<div class="fileListArea">
<select id="uploaded_file_list_{$editor_sequence}" multiple="multiple" size="5" class="fileList" onclick="editor_preview(this, '{$editor_sequence}');"></select>
</div>
<div class="fileUploadControl">
<a href="#" onclick="editor_upload_file('{$editor_sequence}');return false;" class="button"><span>{$lang->edit->upload_file}</span></a>
<a href="#" onclick="editor_remove_file('{$editor_sequence}');return false;" class="button"><span>{$lang->edit->delete_selected}</span></a>
<!--@if(!$enable_only_upload_editor)-->
<a href="#" onclick="editor_insert_file('{$editor_sequence}');return false;" class="button"><span>{$lang->edit->link_file}</span></a><!--@end-->
</div>