From 6a9de5caca2b34d8b950aeb0bdbf3181fe282d92 Mon Sep 17 00:00:00 2001 From: zero Date: Fri, 6 Apr 2007 04:27:45 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/trunk@990 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- .../editor/components/poll/lang/ko.lang.php | 2 + modules/editor/components/poll/poll.class.php | 38 +++++++++++++++++++ .../poll/tpl/filter/insert_survey.xml | 9 +++++ modules/editor/components/poll/tpl/popup.html | 22 +++++++---- modules/editor/components/poll/tpl/popup.js | 26 ++++++++++--- 5 files changed, 84 insertions(+), 13 deletions(-) create mode 100644 modules/editor/components/poll/tpl/filter/insert_survey.xml diff --git a/modules/editor/components/poll/lang/ko.lang.php b/modules/editor/components/poll/lang/ko.lang.php index 206a3f156..7b41bdcba 100644 --- a/modules/editor/components/poll/lang/ko.lang.php +++ b/modules/editor/components/poll/lang/ko.lang.php @@ -13,4 +13,6 @@ $lang->cmd_add_survey = "설문 추가"; $lang->cmd_del_survey = "설문 제거"; $lang->cmd_add_item = "항목 추가"; + + $lang->cmd_null_item = "설문조사로 등록할 값이 없습니다.\n다시 설정해주세요"; ?> diff --git a/modules/editor/components/poll/poll.class.php b/modules/editor/components/poll/poll.class.php index e8ed772c4..387f4673f 100644 --- a/modules/editor/components/poll/poll.class.php +++ b/modules/editor/components/poll/poll.class.php @@ -19,6 +19,44 @@ $this->component_path = $component_path; } + /** + * @brief 팝업창에서 설문 작성 완료후 저장을 누를때 + **/ + function insertSurvey() { + Context::loadLang($this->component_path.'lang'); + $stop_year = Context::get('stop_year'); + $stop_month = Context::get('stop_month'); + $stop_day = Context::get('stop_day'); + + $stop_date = sprintf('%04d%02d%02d235959', $stop_year, $stop_month, $stop_day); + + $vars = Context::getRequestVars(); + foreach($vars as $key => $val) { + if(strpos($key,'tidx')) continue; + if(!eregi("^(title|checkcount|item)_", $key)) continue; + if(!trim($val)) continue; + + $tmp_arr = explode('_',$key); + + $survey_index = $tmp_arr[1]; + + if($tmp_arr[0]=='title') $tmp_args[$survey_index]->title = $val; + else if($tmp_arr[0]=='checkcount') $tmp_args[$survey_index]->checkcount = $val; + else if($tmp_arr[0]=='item') $tmp_args[$survey_index]->item[] = $val; + } + + foreach($tmp_args as $key => $val) { + if(!$val->checkcount) $val->checkcount = 1; + if($val->title && count($val->item)) $args[] = $val; + } + + if(!count($args)) return new Object(-1, 'cmd_null_item'); + + $survey_srl = getNextSequence(); + + $this->add('survey_srl', $survey_srl); + } + /** * @brief popup window요청시 popup window에 출력할 내용을 추가하면 된다 **/ diff --git a/modules/editor/components/poll/tpl/filter/insert_survey.xml b/modules/editor/components/poll/tpl/filter/insert_survey.xml new file mode 100644 index 000000000..54d5e8dfc --- /dev/null +++ b/modules/editor/components/poll/tpl/filter/insert_survey.xml @@ -0,0 +1,9 @@ + +
+ + + + + + + diff --git a/modules/editor/components/poll/tpl/popup.html b/modules/editor/components/poll/tpl/popup.html index bde8a546e..936a8f154 100644 --- a/modules/editor/components/poll/tpl/popup.html +++ b/modules/editor/components/poll/tpl/popup.html @@ -1,7 +1,13 @@ + - + + + + + +
{$component_info->title} ver. {$component_info->version} {$lang->about_component}
@@ -22,41 +28,41 @@ +
- - +
diff --git a/modules/editor/components/poll/tpl/popup.js b/modules/editor/components/poll/tpl/popup.js index fd120eb74..bbeca03f1 100644 --- a/modules/editor/components/poll/tpl/popup.js +++ b/modules/editor/components/poll/tpl/popup.js @@ -6,7 +6,11 @@ var survey_index = 1; function setSurvey() { var obj = xCreateElement("div"); var source = xGetElementById("survey_source"); - xInnerHtml(obj, xInnerHtml(source)); + + var html = xInnerHtml(source); + html = html.replace(/tidx/g, survey_index); + xInnerHtml(obj, html); + obj.id = "survey_"+survey_index; obj.className = "survey_box"; obj.style.display = "block"; @@ -17,14 +21,21 @@ function setSurvey() { /** * 부모창의 위지윅에디터에 데이터를 삽입 **/ -function insertSurvey() { - if(typeof(opener)=="undefined") return; +function completeInsertSurvey(ret_obj) { + if(typeof(opener)=="undefined") return null; + + var survey_srl = ret_obj["survey_srl"]; + if(!survey_srl) return null; + + var text = ""; var iframe_obj = opener.editorGetIFrame(opener.editorPrevSrl) - opener.editorReplaceHTML(iframe_obj, link); + opener.editorReplaceHTML(iframe_obj, text); opener.focus(); window.close(); + + return null; } xAddEventListener(window, "load", setSurvey); @@ -37,7 +48,11 @@ function doSurveyAdd() { var source = xGetElementById("survey_source"); if(survey_index+1>3) return null; survey_index++; - xInnerHtml(obj, xInnerHtml(source)); + + var html = xInnerHtml(source); + html = html.replace(/tidx/g, survey_index); + xInnerHtml(obj, html); + obj.id = "survey_"+survey_index; obj.className = "survey_box"; obj.style.display = "block"; @@ -88,6 +103,7 @@ function doSurveyAddItem(obj) { var idx = parseInt(idx_match[1],10); html = html.replace( / ([0-9]+)