/
pop_editor_view.php
104 lines (86 loc) · 4.75 KB
/
pop_editor_view.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
<title><?php printf($clang->gT('Editing %s'), $sFieldText); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
<script type="text/javascript" src="<?php echo Yii::app()->getConfig('generalscripts') . 'jquery/jquery.js'; ?>"></script>
<script type="text/javascript" src="<?php echo Yii::app()->getConfig('sCKEditorURL') . '/ckeditor.js'; ?>"></script>
</head>
<body>
<?php echo CHtml::form('', 'post', array('onsubmit'=>'saveChanges=true;'));?>
<script type='text/javascript'>
<!--
function closeme()
{
window.onbeforeunload = new Function('var a = 1;');
self.close();
}
window.onbeforeunload= function (evt) {
close_editor();
closeme();
}
var saveChanges = false;
var sReplacementFieldTitle = '<?php $clang->eT('LimeSurvey replacement field properties','js');?>';
var sReplacementFieldButton = '<?php $clang->eT('Insert/edit LimeSurvey replacement field','js');?>';
$(document).ready(function(){
CKEDITOR.on('instanceReady',CKeditor_OnComplete);
var oCKeditor = CKEDITOR.replace( 'MyTextarea' , { height : '350',
width : '98%',
customConfig : "<?php echo Yii::app()->getConfig('adminscripts') . '/ckeditor-config.js'; ?>",
toolbarStartupExpanded : true,
ToolbarCanCollapse : false,
toolbar : '<?php echo $toolbarname; ?>',
LimeReplacementFieldsSID : "<?php echo $iSurveyId; ?>",
LimeReplacementFieldsGID : "<?php echo $iGroupId; ?>",
LimeReplacementFieldsQID : "<?php echo $iQuestionId; ?>",
LimeReplacementFieldsType: "<?php echo $sFieldType; ?>",
LimeReplacementFieldsAction: "<?php echo $sAction; ?>",
smiley_path: "<?php echo Yii::app()->getConfig('rooturl') . '/upload/images/smiley/msn/'; ?>",
LimeReplacementFieldsPath : "<?php echo Yii::app()->getConfig('rooturl') . '/index.php/admin/limereplacementfields/sa/index'; ?>",
language : "<?php echo $ckLanguage ?>"
<?php echo $htmlformatoption; ?> });
});
function CKeditor_OnComplete( evt )
{
var editor = evt.editor;
editor.setData(window.opener.document.getElementsByName("<?php echo $sFieldName; ?>")[0].value);
editor.execCommand('maximize');
window.status='LimeSurvey <?php $clang->eT('Editing', 'js') . ' ' . 'javascriptEscape(' . $sFieldText . ', true)'; ?>';
}
function html_transfert()
{
var oEditor = CKEDITOR.instances['MyTextarea'];
<?php
if (in_array($sFieldType, array('editanswer', 'addanswer', 'editlabel', 'addlabel')))
{
?>
var editedtext = oEditor.getData().replace(new RegExp( "\n", "g" ),'');
var editedtext = oEditor.getData().replace(new RegExp( "\r", "g" ),'');
<?php
}
else
{
?>
var editedtext = oEditor.getData('no strip new line'); // adding a parameter avoids stripping \n
<?php
}
?>
window.opener.document.getElementsByName('<?php echo $sFieldName; ?>')[0].value = editedtext;
}
function close_editor()
{
html_transfert();
window.opener.document.getElementsByName('<?php echo $sFieldName; ?>')[0].readOnly= false;
window.opener.document.getElementsByName('<?php echo $sFieldName; ?>')[0].className='htmlinput';
window.opener.document.getElementById('<?php echo $sControlIdEna; ?>').style.display='';
window.opener.document.getElementById('<?php echo $sControlIdDis; ?>').style.display='none';
window.opener.focus();
return true;
}
//-->
</script>
<textarea id='MyTextarea' name='MyTextarea'></textarea>
</form>
</body>
</html>