diff --git a/modules/editor/components/cc_license/cc_license.class.php b/modules/editor/components/cc_license/cc_license.class.php new file mode 100755 index 000000000..5a4286317 --- /dev/null +++ b/modules/editor/components/cc_license/cc_license.class.php @@ -0,0 +1,100 @@ + + * @brief CCL 출력 에디터 컴포넌트 + **/ + + class cc_license extends EditorHandler { + + // editor_sequence 는 에디터에서 필수로 달고 다녀야 함 + var $editor_sequence = 0; + var $component_path = ''; + + /** + * @brief editor_sequence과 컴포넌트의 경로를 받음 + **/ + function cc_license($editor_sequence, $component_path) { + $this->editor_sequence = $editor_sequence; + $this->component_path = $component_path; + } + + /** + * @brief popup window요청시 popup window에 출력할 내용을 추가하면 된다 + **/ + function getPopupContent() { + // 템플릿을 미리 컴파일해서 컴파일된 소스를 return + $tpl_path = $this->component_path.'tpl'; + $tpl_file = 'popup.html'; + + Context::set("tpl_path", $tpl_path); + + $oTemplate = &TemplateHandler::getInstance(); + return $oTemplate->compile($tpl_path, $tpl_file); + } + + /** + * @brief 에디터 컴포넌트가 별도의 고유 코드를 이용한다면 그 코드를 html로 변경하여 주는 method + * + * 이미지나 멀티미디어, 설문등 고유 코드가 필요한 에디터 컴포넌트는 고유코드를 내용에 추가하고 나서 + * DocumentModule::transContent() 에서 해당 컴포넌트의 transHtml() method를 호출하여 고유코드를 html로 변경 + **/ + function transHTML($xml_obj) { + // 지정된 옵션을 구함 + $ccl_title = $xml_obj->attrs->ccl_title; + $ccl_use_mark = $xml_obj->attrs->ccl_use_mark; + $ccl_allow_commercial = $xml_obj->attrs->ccl_allow_commercial; + $ccl_allow_modification = $xml_obj->attrs->ccl_allow_modification; + + // 가로/ 세로 크기를 구함 + preg_match_all('/(width|height)([^[:digit:]]+)([^;^"^\']*)/i',$xml_obj->attrs->style,$matches); + $width = trim($matches[3][0]); + if(!$width) $width = "90%"; + $height = trim($matches[3][1]); + if(!$height) $height = "50"; + + // 언어파일을 읽음 + Context::loadLang($this->component_path.'/lang'); + $default_title = Context::getLang('ccl_default_title'); + if(!$ccl_title) $ccl_title = $default_title; + + $default_message = Context::getLang('ccl_default_message'); + + $option = Context::getLang('ccl_options'); + + // 영리 이용 체크 + if($ccl_allow_commercial == 'N') $opt1 = '-nc'; + else $opt1 = ''; + + // 수정 표시 체크 + if($ccl_allow_modification == 'N') $opt2 = '-nd'; + elseif($ccl_allow_modification == 'SA') $opt2 = '-sa'; + else $opt2 = ''; + + // 버전 + $version = '/3.0'; + + // 언어에 따른 설정 + $lang_type = Context::getLangType(); + if($lang_type != 'en') $lang_file = 'deed.'.strtolower($lang_file); + + // 마크 이용시 + $ccl_image = ''; + if($ccl_use_mark == "Y") { + $ccl_image = sprintf(' + Creative Commons License
', + $opt1, $opt2, $version, $lang_file, + $opt1, $opt2, $version, $lang_file + ); + } + + // 결과물 생성 + $text = $ccl_image . sprintf($default_message, $opt1, $opt2, $opt3, $opt4, $ccl_title, $option['ccl_allow_commercial'][$ccl_allow_commercial], $option['ccl_allow_modification'][$ccl_allow_modification], $version); + + $style = sprintf('', $width); + $output = sprintf('%s
%s%s
', $style, $ccl_title, $text); + return $output; + } + } + +?> diff --git a/modules/editor/components/cc_license/ccl_logo.gif b/modules/editor/components/cc_license/ccl_logo.gif new file mode 100644 index 000000000..6c9f51220 Binary files /dev/null and b/modules/editor/components/cc_license/ccl_logo.gif differ diff --git a/modules/editor/components/cc_license/icon.gif b/modules/editor/components/cc_license/icon.gif new file mode 100644 index 000000000..275a1de42 Binary files /dev/null and b/modules/editor/components/cc_license/icon.gif differ diff --git a/modules/editor/components/cc_license/info.xml b/modules/editor/components/cc_license/info.xml new file mode 100755 index 000000000..b065175d9 --- /dev/null +++ b/modules/editor/components/cc_license/info.xml @@ -0,0 +1,8 @@ + + + Creative Commons Licenses + + zero + CCL 라이센스를 출력합니다. + + diff --git a/modules/editor/components/cc_license/lang/ko.lang.php b/modules/editor/components/cc_license/lang/ko.lang.php new file mode 100644 index 000000000..c535a447e --- /dev/null +++ b/modules/editor/components/cc_license/lang/ko.lang.php @@ -0,0 +1,29 @@ + + * @brief 위지윅에디터(editor) 모듈 > CCL 출력 에디터 컴포넌트 + **/ + + $lang->ccl_default_title = '크리에이티브 커먼즈 코리아 저작자표시'; + $lang->ccl_default_message = '이 저작물은 %s%s%s%s에 따라 이용하실 수 있습니다'; + + $lang->ccl_title = '제목'; + $lang->ccl_use_mark = '마크 사용'; + $lang->ccl_allow_commercial = '영리목적 허용'; + $lang->ccl_allow_modification = '저작물 변경 허용'; + + $lang->ccl_allow = '허용'; + $lang->ccl_disallow = '금지'; + $lang->ccl_sa = '동일 조건 변경'; + + $lang->ccl_options = array( + 'ccl_allow_commercial' => array('Y'=>'-영리', 'N'=>'-비영리'), + 'ccl_allow_modification' => array('Y'=>'-변경금지', 'N'=>'-변경금지', 'SA'=>'-동일조건변경허락'), + ); + + $lang->about_ccl_title = '제목을 표시합니다. 비워져 있으면 기본 메세지가 출력됩니다.'; + $lang->about_ccl_use_mark = '마크의 출력 여부를 선택할 수 있습니다. (기본: 출력)'; + $lang->about_ccl_allow_commercial = '영리목적 이용을 허가 여부를 선택할 수 있습니다 (기본: 허용안함)'; + $lang->about_ccl_allow_modification = '저작물의 변경 여부를 허용할 수 있습니다. (기본: 동일 조건 변경)'; +?> diff --git a/modules/editor/components/cc_license/tpl/popup.html b/modules/editor/components/cc_license/tpl/popup.html new file mode 100755 index 000000000..40b2396ab --- /dev/null +++ b/modules/editor/components/cc_license/tpl/popup.html @@ -0,0 +1,50 @@ + + + +
+

{$component_info->title} ver. {$component_info->version}

+
+ +
+
+ + + + + + + + + + + + + + + + + + + +
{$lang->ccl_title} + +

{$lang->about_ccl_title}

+
{$lang->ccl_use_mark} + +

{$lang->about_ccl_use_mark}

+
{$lang->ccl_allow_commercial} + +

{$lang->about_ccl_allow_commercial}

+
{$lang->ccl_allow_modification} + +

{$lang->about_ccl_allow_modification}

+
+
+ +
+ {$lang->cmd_insert} + {$lang->cmd_close} + {$lang->about_component} +
+ +
diff --git a/modules/editor/components/cc_license/tpl/popup.js b/modules/editor/components/cc_license/tpl/popup.js new file mode 100755 index 000000000..7cb2cf1b2 --- /dev/null +++ b/modules/editor/components/cc_license/tpl/popup.js @@ -0,0 +1,68 @@ +/** + * popup으로 열렸을 경우 부모창의 위지윅에디터에 select된 멀티미디어 컴포넌트 코드를 체크하여 + * 있으면 가져와서 원하는 곳에 삽입 + **/ +var selected_node = null; +function getCode() { + // 부모 위지윅 에디터에서 선택된 영역이 있는지 확인 + if(typeof(opener)=='undefined') return; + + // 부모창의 선택된 객체가 img가 아니면 pass~ + var node = opener.editorPrevNode; + if(!node || node.nodeName != 'IMG') return; + + selected_node = node; + + // 이미 정의되어 있는 변수에서 데이터를 구함 + var ccl_title = node.getAttribute('ccl_title'); + var ccl_use_mark = node.getAttribute('ccl_use_mark'); + var ccl_allow_commercial = node.getAttribute('ccl_allow_commercial'); + var ccl_allow_modification = node.getAttribute('ccl_allow_modification'); + + // form문에 적용 + var fo_obj = xGetElementById('fo'); + fo_obj.ccl_title.value = ccl_title; + + if(ccl_use_mark == 'Y') fo_obj.ccl_use_mark.selectedIndex = 0; + else fo_obj.ccl_use_mark.selectedIndex = 1; + + if(ccl_allow_commercial == 'Y') fo_obj.ccl_allow_commercial.selectedIndex = 0; + else fo_obj.ccl_allow_commercial.selectedIndex = 1; + + if(ccl_allow_modification == 'Y') fo_obj.ccl_allow_modification.selectedIndex = 0; + else if(ccl_allow_modification== 'N') fo_obj.ccl_allow_modification.selectedIndex = 1; + else fo_obj.ccl_allow_modification.selectedIndex = 2; +} + +/* 추가 버튼 클릭시 부모창의 위지윅 에디터에 인용구 추가 */ +function insertCode() { + if(typeof(opener)=='undefined') return; + + var fo_obj = xGetElementById('fo'); + + var ccl_title = escape(fo_obj.ccl_title.value); + var ccl_use_mark = fo_obj.ccl_use_mark.options[fo_obj.ccl_use_mark.selectedIndex].value; + var ccl_allow_commercial = fo_obj.ccl_allow_commercial.options[fo_obj.ccl_allow_commercial.selectedIndex].value; + var ccl_allow_modification = fo_obj.ccl_allow_modification.options[fo_obj.ccl_allow_modification.selectedIndex].value; + + var content = ''; + + var style = "width:90%; margin:20px auto 20px auto; height:50px; border:1px solid #c0c0c0; background: transparent url('./modules/editor/components/cc_license/ccl_logo.gif') no-repeat center center;"; + + var text = '
ccl
'; + + if(selected_node) { + selected_node.setAttribute('ccl_title', ccl_title); + selected_node.setAttribute('ccl_use_mark', ccl_use_mark); + selected_node.setAttribute('ccl_allow_commercial', ccl_allow_commercial); + selected_node.setAttribute('ccl_allow_modification', ccl_allow_modification); + } else { + opener.editorFocus(opener.editorPrevSrl); + var iframe_obj = opener.editorGetIFrame(opener.editorPrevSrl) + opener.editorReplaceHTML(iframe_obj, text); + } + opener.editorFocus(opener.editorPrevSrl); + window.close(); +} + +xAddEventListener(window, 'load', getCode);