Skip to content

Commit

Permalink
Dev Firsts tests in 'Edit survey text elements'
Browse files Browse the repository at this point in the history
Dev Tony, can you please have a look at the editor placement in that screen? At the moment it stretches all over

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ck@10106 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed May 20, 2011
1 parent 62f1ae7 commit cdc299a
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 220 deletions.
2 changes: 1 addition & 1 deletion admin/editansweroptions.php
Expand Up @@ -81,7 +81,7 @@
}

// Print Key Control JavaScript
$vasummary = PrepareEditorScript("editanswer");
$vasummary = PrepareEditorScript();

$query = "SELECT sortorder FROM ".db_table_name('answers')." WHERE qid='{$qid}' AND language='".GetBaseLanguageFromSurveyID($surveyid)."' ORDER BY sortorder desc";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg()); //Checked
Expand Down
2 changes: 1 addition & 1 deletion admin/editsubquestions.php
Expand Up @@ -103,7 +103,7 @@
}

// Print Key Control JavaScript
$vasummary .= PrepareEditorScript("editanswer");
$vasummary .= PrepareEditorScript();

$query = "SELECT question_order FROM ".db_table_name('questions')." WHERE parent_qid='{$qid}' AND language='".GetBaseLanguageFromSurveyID($surveyid)."' ORDER BY question_order desc";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg()); //Checked
Expand Down
2 changes: 1 addition & 1 deletion admin/editsurveysettings.php
Expand Up @@ -1022,7 +1022,7 @@
. "<input type='hidden' name='action' value='importsurveyresources' />\n"
. "<ul>\n"
. "<li><label>&nbsp;</label>\n"
. "<input type='button' onclick='window.open(\"$sFCKEditorURL/editor/filemanager/browser/default/browser.html?Connector=../../connectors/php/connector.php\", \"_blank\")' value=\"".$clang->gT("Browse Uploaded Resources")."\" $disabledIfNoResources /></li>\n"
. "<input type='button' onclick='window.open(\"$sCKEditorURL/editor/filemanager/browser/default/browser.html?Connector=../../connectors/php/connector.php\", \"_blank\")' value=\"".$clang->gT("Browse Uploaded Resources")."\" $disabledIfNoResources /></li>\n"
. "<li><label>&nbsp;</label>\n"
. "<input type='button' onclick='window.open(\"$scriptname?action=exportsurvresources&amp;sid={$surveyid}\", \"_blank\")' value=\"".$clang->gT("Export Resources As ZIP Archive")."\" $disabledIfNoResources /></li>\n"
. "<li><label for='the_file'>".$clang->gT("Select ZIP File:")."</label>\n"
Expand Down
9 changes: 3 additions & 6 deletions admin/editsurveytextelements.php
Expand Up @@ -48,16 +48,13 @@
. "<li><label for=''>".$clang->gT("Survey title").":</label>\n"
. "<input type='text' size='80' name='short_title_".$esrow['surveyls_language']."' value=\"{$esrow['surveyls_title']}\" /></li>\n"
. "<li><label for=''>".$clang->gT("Description:")."</label>\n"
. "<textarea cols='80' rows='15' name='description_".$esrow['surveyls_language']."'>{$esrow['surveyls_description']}</textarea>\n"
. getEditor("survey-desc","description_".$esrow['surveyls_language'], "[".$clang->gT("Description:", "js")."](".$esrow['surveyls_language'].")",$surveyid,'','',$action)
. "<textarea class='fulledit' cols='80' rows='15' name='description_".$esrow['surveyls_language']."'>{$esrow['surveyls_description']}</textarea>\n"
. "</li>\n"
. "<li><label for=''>".$clang->gT("Welcome message:")."</label>\n"
. "<textarea cols='80' rows='15' name='welcome_".$esrow['surveyls_language']."'>{$esrow['surveyls_welcometext']}</textarea>\n"
. getEditor("survey-welc","welcome_".$esrow['surveyls_language'], "[".$clang->gT("Welcome:", "js")."](".$esrow['surveyls_language'].")",$surveyid,'','',$action)
. "<textarea class='fulledit' cols='80' rows='15' name='welcome_".$esrow['surveyls_language']."'>{$esrow['surveyls_welcometext']}</textarea>\n"
. "</li>\n"
. "<li><label for=''>".$clang->gT("End message:")."</label>\n"
. "<textarea cols='80' rows='15' name='endtext_".$esrow['surveyls_language']."'>{$esrow['surveyls_endtext']}</textarea>\n"
. getEditor("survey-endtext","endtext_".$esrow['surveyls_language'], "[".$clang->gT("End message:", "js")."](".$esrow['surveyls_language'].")",$surveyid,'','',$action)
. "<textarea class='fulledit' cols='80' rows='15' name='endtext_".$esrow['surveyls_language']."'>{$esrow['surveyls_endtext']}</textarea>\n"
. "</li>\n"
. "<li><label for=''>".$clang->gT("End URL:")."</label>\n"
. "<input type='text' size='80' name='url_".$esrow['surveyls_language']."' value=\"{$esrow['surveyls_url']}\" />\n"
Expand Down
2 changes: 1 addition & 1 deletion admin/fck_LimeReplacementFields.php
Expand Up @@ -37,7 +37,7 @@
. "\t\t<title>LimeReplacementFields</title>\n"
. "\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"
. "\t\t<meta content=\"noindex, nofollow\" name=\"robots\">\n"
. "\t\t<script src=\"$sFCKEditorURL/editor/dialog/common/fck_dialog_common.js\" type=\"text/javascript\"></script>\n"
. "\t\t<script src=\"$sCKEditorURL/editor/dialog/common/fck_dialog_common.js\" type=\"text/javascript\"></script>\n"
. "\t\t<script src=\"$rooturl/scripts/jquery/jquery.js\" type=\"text/javascript\"></script>\n"
. "\t\t<script language=\"javascript\">\n"
. "\t\t\tvar mydialog = window.parent ;\n"
Expand Down
213 changes: 10 additions & 203 deletions admin/htmleditor-functions.php
Expand Up @@ -16,213 +16,20 @@
//include_once("login_check.php");
//Security Checked: POST/GET/SESSION/DB/returnglobal

/*****
function PrepareEditorPopupScript()
{
global $clang,$imageurl,$homeurl;
$script = "<script type='text/javascript'>\n"
. "<!--\n"
. "var editorwindowsHash = new Object();\n"
. "function find_popup_editor(fieldname)\n"
. "\t{\t\n"
. "var window = null;\n"
. "for (var key in editorwindowsHash)\n"
. "{\n"
. "\tif (key==fieldname && !editorwindowsHash[key].closed)\n"
. "\t{\n"
. "window = editorwindowsHash[key];\n"
. "return window;\n"
. "\t}\n"
. "}\n"
. "\treturn null;\n"
. "\t}\t\n"
. "\n"
. "function start_popup_editor(fieldname, fieldtext, sid, gid, qid, fieldtype, action)\n"
. "\t{\t\n"
// . "controlid = fieldname + '_popupctrl';\n"
. "controlidena = fieldname + '_popupctrlena';\n"
. "controliddis = fieldname + '_popupctrldis';\n"
. "numwindows = editorwindowsHash.length;\n"
. "activepopup = find_popup_editor(fieldname);\n"
. "if (activepopup == null)\n"
. "{\n"
. "\tdocument.getElementsByName(fieldname)[0].readOnly=true;\n"
. "\tdocument.getElementsByName(fieldname)[0].className='readonly';\n"
// . "\tdocument.getElementById(controlid).src='".$imageurl."/edithtmlpopup_disabled.png';\n"
. "\tdocument.getElementById(controlidena).style.display='none';\n"
. "\tdocument.getElementById(controliddis).style.display='';\n"
. "\tpopup = window.open('".$homeurl."/htmleditor-popup.php?fieldname='+fieldname+'&fieldtext='+fieldtext+'&fieldtype='+fieldtype+'&action='+action+'&sid='+sid+'&gid='+gid+'&qid='+qid+'&lang=".$clang->getlangcode()."','', 'location=no, status=yes, scrollbars=auto, menubar=no, resizable=yes, width=600, height=400');\n"
. "\teditorwindowsHash[fieldname] = popup;\n"
. "}\n"
. "else\n"
. "{\n"
. "\tactivepopup.focus();\n"
. "}\n"
. "\t}\n"
. "\n"
. "function updateFCKeditor(fieldname,value)\n"
. "{\t\n"
. "\tvar mypopup= editorwindowsHash[fieldname];\n"
. "\tif (mypopup)\n"
. "\t{\n"
. "var oMyEditor = mypopup.FCKeditorAPI.GetInstance('MyTextarea');\n"
. "if (oMyEditor) {oMyEditor.SetHTML(value);}\n"
. "mypopup.focus();\n"
. "\t}\n"
. "}\n"
. "--></script>\n";

return $script;
}
*******/

function PrepareEditorGeneric()
function PrepareEditorScript()
{
global $clang,$imageurl,$homeurl;
global $sFCKEditorURL;

$script ="<script type=\"text/javascript\" src=\"".$sFCKEditorURL."/fckeditor.js\"></script>\n";
$script .= "<script type='text/javascript'>\n"
. "<!--\n"
. "var editorwindowsHash = new Object();\n"
. "function find_popup_editor(fieldname)\n"
. "\t{\t\n"
. "var window = null;\n"
. "for (var key in editorwindowsHash)\n"
. "{\n"
. "\tif (key==fieldname && !editorwindowsHash[key].closed)\n"
. "\t{\n"
. "window = editorwindowsHash[key];\n"
. "return window;\n"
. "\t}\n"
. "}\n"
. "\treturn null;\n"
. "\t}\t\n"
. "\n"
. "function start_popup_editor(fieldname, fieldtext, sid, gid, qid, fieldtype, action)\n"
. "\t{\t\n"
// . "controlid = fieldname + '_popupctrl';\n"
. "controlidena = fieldname + '_popupctrlena';\n"
. "controliddis = fieldname + '_popupctrldis';\n"
. "numwindows = editorwindowsHash.length;\n"
. "activepopup = find_popup_editor(fieldname);\n"
. "if (activepopup == null)\n"
. "{\n"
. "\tdocument.getElementsByName(fieldname)[0].readOnly=true;\n"
. "\tdocument.getElementsByName(fieldname)[0].className='readonly';\n"
// . "\tdocument.getElementById(controlid).src='".$imageurl."/edithtmlpopup_disabled.png';\n"
. "\tdocument.getElementById(controlidena).style.display='none';\n"
. "\tdocument.getElementById(controliddis).style.display='';\n"
. "\tpopup = window.open('".$homeurl."/htmleditor-popup.php?fieldname='+fieldname+'&fieldtext='+fieldtext+'&fieldtype='+fieldtype+'&action='+action+'&sid='+sid+'&gid='+gid+'&qid='+qid+'&lang=".$clang->getlangcode()."','', 'location=no, status=yes, scrollbars=auto, menubar=no, resizable=yes, width=600, height=400');\n"
. "\teditorwindowsHash[fieldname] = popup;\n"
. "}\n"
. "else\n"
. "{\n"
. "\tactivepopup.focus();\n"
. "}\n"
. "\t}\n"
. "\n"
. "function updateFCKeditor(fieldname,value)\n"
. "{\t\n"
. "\tvar mypopup= editorwindowsHash[fieldname];\n"
. "\tif (mypopup)\n"
. "\t{\n"
. "\t\tvar oMyEditor = mypopup.FCKeditorAPI.GetInstance('MyTextarea');\n"
. "\t\tif (oMyEditor) {oMyEditor.SetHTML(value);}\n"
. "\t\tmypopup.focus();\n"
. "\t}\n"
. "\telse\n"
. "\t{\n"
. "\t\tvar oMyEditor = FCKeditorAPI.GetInstance(fieldname);\n"
. "\t\toMyEditor.SetHTML(value);\n"
. "\t}\n"
. "}\n"
. "--></script>\n";

return $script;
}

/*********
function PrepareEditorInlineScript()
{
global $homeurl, $sFCKEditorURL;
$script ="<script type=\"text/javascript\" src=\"".$sFCKEditorURL."/fckeditor.js\"></script>\n"
. "<script type=\"text/javascript\">\n"
. "<!--\n"
. "function updateFCKeditor(fieldname,value)\n"
. "{\n"
. "\tvar oMyEditor = FCKeditorAPI.GetInstance(fieldname);\n"
. "\toMyEditor.SetHTML(value);\n"
. "}\n"
. "-->\n"
. "</script>\n";
global $sCKEditorURL, $js_admin_includes;

$js_admin_includes[]=$sCKEditorURL.'/ckeditor.js';
$js_admin_includes[]=$sCKEditorURL.'/adapters/jquery.js';
$js_admin_includes[]='scripts/editor.js';

// $script .= ""
// . "<script type='text/javascript'>\n"
// . "<!--\n"
// ."function FCKeditor_OnComplete( editorInstance )\n"
// . "{\n"
// . "\teditorInstance.Events.AttachEvent( 'OnBlur' , FCKeditor_OnBlur ) ;\n"
// . "\teditorInstance.Events.AttachEvent( 'OnFocus', FCKeditor_OnFocus ) ;\n"
// ."}\n"
// . "function FCKeditor_OnBlur( editorInstance )\n"
// . "{\n"
// . "\teditorInstance.ToolbarSet.Collapse() ;\n"
// . "}\n"
// . "function FCKeditor_OnFocus( editorInstance )\n"
// . "{\n"
// ."\teditorInstance.ToolbarSet.Expand() ;\n"
// ."}\n"
// . "--></script>\n";
return $script;
return '';
}
********/

function PrepareEditorScript($fieldtype=null)
{
/*** global $defaulthtmleditormode;

if (isset($_SESSION['htmleditormode']) &&
$_SESSION['htmleditormode'] == 'none')
{
return "<script type=\"text/javascript\">\n"
. "<!--\n"
. "function updateFCKeditor(fieldname,value) { return true;}\n"
. "-->\n"
. "</script>\n";
}
if (!isset($_SESSION['htmleditormode']) ||
($_SESSION['htmleditormode'] != 'inline' &&
$_SESSION['htmleditormode'] != 'popup') )
{
$htmleditormode = $defaulthtmleditormode;
}
else
{
$htmleditormode = $_SESSION['htmleditormode'];
}
if ($htmleditormode == 'popup' ||
$fieldtype == 'editanswer' ||
$fieldtype == 'addanswer' ||
$fieldtype == 'editlabel' ||
$fieldtype == 'addlabel')
{
return PrepareEditorPopupScript();
}
elseif ($htmleditormode == 'inline')
{
return PrepareEditorInlineScript();
}
else
{
return '';
}
****/
return PrepareEditorGeneric();
}

function getEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=null,$qID=null,$action=null)
{
Expand Down Expand Up @@ -301,7 +108,7 @@ function getPopupEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=nu

function getInlineEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=null,$qID=null,$action=null)
{
global $clang, $imageurl, $homeurl, $rooturl, $sFCKEditorURL, $fckeditexpandtoolbar, $uploadurl;
global $clang, $imageurl, $homeurl, $rooturl, $sCKEditorURL, $fckeditexpandtoolbar, $uploadurl;

$htmlcode = '';
$imgopts = '';
Expand Down Expand Up @@ -344,8 +151,8 @@ function getInlineEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=n
$htmlcode .= ""
. "<script type=\"text/javascript\">\n"
. "var $oFCKeditorVarName = new FCKeditor('$fieldname');\n"
. "$oFCKeditorVarName.BasePath = '".$sFCKEditorURL."/';\n"
. "$oFCKeditorVarName.Config[\"CustomConfigurationsPath\"] = \"".$sFCKEditorURL."/limesurvey-config.js\";\n"
. "$oFCKeditorVarName.BasePath = '".$sCKEditorURL."/';\n"
. "$oFCKeditorVarName.Config[\"CustomConfigurationsPath\"] = \"".$sCKEditorURL."/limesurvey-config.js\";\n"
. "$oFCKeditorVarName.Config[\"LimeReplacementFieldsType\"] = \"".$fieldtype."\";\n"
. "$oFCKeditorVarName.Config[\"LimeReplacementFieldsSID\"] = \"".$surveyID."\";\n"
. "$oFCKeditorVarName.Config[\"LimeReplacementFieldsGID\"] = \"".$gID."\";\n"
Expand Down
6 changes: 3 additions & 3 deletions admin/htmleditor-popup.php
Expand Up @@ -87,7 +87,7 @@
<title>'.$clang->gT("Editing").' '.$fieldtext.'</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
<script type="text/javascript" src="'.$sFCKEditorURL.'/fckeditor.js"></script>
<script type="text/javascript" src="'.$sCKEditorURL.'/fckeditor.js"></script>
</head>';


Expand All @@ -113,11 +113,11 @@ function closeme()
var saveChanges = false;
var oFCKeditor = new FCKeditor( 'MyTextarea' );
oFCKeditor.BasePath = '".$sFCKEditorURL."/';
oFCKeditor.BasePath = '".$sCKEditorURL."/';
oFCKeditor.Height = '350';
oFCKeditor.Width = '98%';
oFCKeditor.Value = window.opener.document.getElementsByName(\"".$fieldname."\")[0].value;
oFCKeditor.Config[\"CustomConfigurationsPath\"] = \"".$sFCKEditorURL."/limesurvey-config.js\";
oFCKeditor.Config[\"CustomConfigurationsPath\"] = \"".$sCKEditorURL."/limesurvey-config.js\";
oFCKeditor.Config[\"ToolbarStartExpanded\"] = true;
oFCKeditor.Config[\"ToolbarCanCollapse\"] = false;
oFCKeditor.ToolbarSet = '".$toolbarname."';
Expand Down
4 changes: 2 additions & 2 deletions admin/labels.php
Expand Up @@ -289,7 +289,7 @@
$rwlabelset=$rslabelset->FetchRow();
$lslanguages=explode(" ", trim($rwlabelset['languages']));

$labelsoutput.= PrepareEditorScript("editlabel");
$labelsoutput.= PrepareEditorScript();

$maxquery = "SELECT max(sortorder) as maxsortorder FROM ".db_table_name('labels')." WHERE lid=$lid and language='{$lslanguages[0]}'";
$maxresult = db_execute_assoc($maxquery) or safe_die($connect->ErrorMsg());
Expand Down Expand Up @@ -484,7 +484,7 @@
. "\t<input type='hidden' name='action' value='importlabelresources' />\n"
. "\t<ul style='list-style-type:none; text-align:center'>\n"
. "\t\t<li><label>&nbsp;</label>\n"
. "\t\t<input type='button' $disabledIfNoResources onclick='window.open(\"$sFCKEditorURL/editor/filemanager/browser/default/browser.html?Connector=../../connectors/php/connector.php?\", \"_blank\")' value=\"".$clang->gT("Browse Uploaded Resources")."\" /></li>\n"
. "\t\t<input type='button' $disabledIfNoResources onclick='window.open(\"$sCKEditorURL/editor/filemanager/browser/default/browser.html?Connector=../../connectors/php/connector.php?\", \"_blank\")' value=\"".$clang->gT("Browse Uploaded Resources")."\" /></li>\n"
. "\t\t<li><label>&nbsp;</label>\n"
. "\t\t<input type='button' $disabledIfNoResources onclick='window.open(\"$scriptname?action=exportlabelresources&amp;lid={$lid}\", \"_blank\")' value=\"".$clang->gT("Export Resources As ZIP Archive")."\" /></li>\n"
. "\t\t<li><label for='the_file'>".$clang->gT("Select ZIP File:")."</label>\n"
Expand Down
5 changes: 5 additions & 0 deletions admin/scripts/editor.js
@@ -0,0 +1,5 @@
// $Id: labels.js 8649 2010-04-28 21:38:53Z c_schmitz $

$(document).ready(function(){
$('textarea.fulledit').ckeditor();
});
2 changes: 1 addition & 1 deletion admin/translate.php
Expand Up @@ -179,7 +179,7 @@

// Create tab names and heading
$translateoutput .= "\t<div id='tab-".$type."'>\n";
$translateoutput .= PrepareEditorScript("noneedforvalue");
$translateoutput .= PrepareEditorScript();
// Setup form
// start a counter in order to number the input fields for each record
$i = 0;
Expand Down
2 changes: 1 addition & 1 deletion config-defaults.php
Expand Up @@ -567,7 +567,7 @@

// Note: For OS/2 the $tempdir may need to be defined as an actual directory
// example: "x:/limesurvey/tmp". We don't know why.
$sFCKEditorURL = "$homeurl/scripts/fckeditor.266";
$sCKEditorURL = "$homeurl/scripts/ckeditor.36";
$fckeditexpandtoolbar = true; // defines if the FCKeditor toolbar should be opened by default
$pdfexportdir = "$homedir/classes/tcpdf"; //Directory with the tcpdf.php extensiontcpdf.php
$pdffonts = $pdfexportdir.'/fonts'; //Directory for the TCPDF fonts
Expand Down

0 comments on commit cdc299a

Please sign in to comment.