From dd1e0e343a4843b5ebe20e956d5a12cda2da520a Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Mon, 6 Aug 2012 14:04:12 +0200 Subject: [PATCH] Removed kcfinder controller, added a function to the htmleditor helper that initiates the sessionvariables. --- application/config/config-defaults.php | 4 +- application/controllers/admin/kcfinder.php | 353 ------------------ .../helpers/admin/htmleditor_helper.php | 59 ++- .../admin/htmleditor/pop_editor_view.php | 2 +- application/views/admin/super/header.php | 3 +- .../admin/survey/editLocalSettings_view.php | 6 + scripts/admin/editor.js | 2 +- 7 files changed, 70 insertions(+), 359 deletions(-) delete mode 100644 application/controllers/admin/kcfinder.php diff --git a/application/config/config-defaults.php b/application/config/config-defaults.php index e3d57db5f75..4184e1a5e6f 100644 --- a/application/config/config-defaults.php +++ b/application/config/config-defaults.php @@ -508,9 +508,11 @@ $config['standardtemplaterooturl'] = $config['publicurl'].'templates'; // Location of the standard templates $config['adminscripts'] = $config['publicurl'].'scripts/admin/'; $config['generalscripts'] = $config['publicurl'].'scripts/'; +$config['vendors'] = $config['publicurl'].'vendors/'; $config['styleurl'] = $config['publicurl'].'styles/'; $config['publicstyleurl'] = $config['publicurl'].'styles-public/'; -$config['sCKEditorURL'] = $config['adminscripts'].'/ckeditor.36'; +$config['sCKEditorURL'] = $config['vendors'].'ckeditor'; +//$config['sCKEditorURL'] = '/scripts/admin/ckeditor.36'; $config['usertemplaterooturl'] = $config['uploadurl'].'/templates'; // Location of the user templates $config['adminimageurl'] = $config['styleurl'].$config['admintheme'].'/images/'; // Location of button bar files for admin script $config['adminstyleurl'] = $config['styleurl'].$config['admintheme'].'/'; // Location of button bar files for admin script diff --git a/application/controllers/admin/kcfinder.php b/application/controllers/admin/kcfinder.php deleted file mode 100644 index 70764246b8f..00000000000 --- a/application/controllers/admin/kcfinder.php +++ /dev/null @@ -1,353 +0,0 @@ -session['KCFINDER'] = array(); - - $sAllowedExtensions = implode(' ', array_map('trim', explode(',', Yii::app()->getConfig('allowedresourcesuploads')))); - $_SESSION['KCFINDER']['types'] = array( - 'files' => $sAllowedExtensions, - 'flash' => $sAllowedExtensions, - 'images' => $sAllowedExtensions - ); - - if (Yii::app()->getConfig('demoMode') === false && - isset(Yii::app()->session['loginID']) && - isset(Yii::app()->session['FileManagerContext'])) - { - // disable upload at survey creation time - // because we don't know the sid yet - if (preg_match('/^(create|edit):(question|group|answer)/', Yii::app()->session['FileManagerContext']) != 0 || - preg_match('/^edit:survey/', Yii::app()->session['FileManagerContext']) != 0 || - preg_match('/^edit:assessments/', Yii::app()->session['FileManagerContext']) != 0 || - preg_match('/^edit:emailsettings/', Yii::app()->session['FileManagerContext']) != 0) - { - $contextarray = explode(':', Yii::app()->session['FileManagerContext'], 3); - $surveyid = $contextarray[2]; - - if (hasSurveyPermission($surveyid, 'surveycontent', 'update')) - { - $_SESSION['KCFINDER']['disabled'] = false; - if (preg_match('/^edit:emailsettings/',$_SESSION['FileManagerContext']) != 0) - { - $_SESSION['KCFINDER']['uploadURL'] = Yii::app()->getRequest()->getHostInfo($schema).Yii::app()->getConfig('uploadurl')."/surveys/{$surveyid}/"; - } - else - { - $_SESSION['KCFINDER']['uploadURL'] = Yii::app()->getConfig('uploadurl')."/surveys/{$surveyid}/"; - } - $_SESSION['KCFINDER']['uploadDir'] = Yii::app()->getConfig('uploaddir') .DIRECTORY_SEPARATOR.'surveys'.DIRECTORY_SEPARATOR.$surveyid.DIRECTORY_SEPARATOR; - } - } - elseif (preg_match('/^edit:label/', Yii::app()->session['FileManagerContext']) != 0) - { - $contextarray = explode(':', Yii::app()->session['FileManagerContext'], 3); - $labelid = $contextarray[2]; - // check if the user has label management right and labelid defined - if (Yii::app()->session['USER_RIGHT_MANAGE_LABEL'] == 1 && isset($labelid) && $labelid != '') - { - $_SESSION['KCFINDER']['disabled'] = false; - $_SESSION['KCFINDER']['uploadURL'] = Yii::app()->getConfig('uploadurl')."/labels/{$labelid}/"; - $_SESSION['KCFINDER']['uploadDir'] = Yii::app()->getConfig('uploaddir') .DIRECTORY_SEPARATOR.'labels'.DIRECTORY_SEPARATOR.$labelid.DIRECTORY_SEPARATOR; - } - } - } - - Yii::registerAutoloader(array($this, 'kcfinder_autoload')); - if (!empty($load) && file_exists(Yii::app()->getConfig('generalscripts')."admin/kcfinder/" . $load . EXT)) - { - chdir(Yii::app()->getConfig('generalscripts')."admin/kcfinder/"); - require_once(Yii::app()->getConfig('generalscripts')."admin/kcfinder/" . $load . EXT); - } - } - - function kcfinder_autoload($class) - { - if ($class == "uploader") - require Yii::app()->getConfig('generalscripts')."kcfinder/core/uploader.php"; - elseif ($class == "browser") - require Yii::app()->getConfig('generalscripts')."admin/kcfinder/core/browser.php"; - elseif (file_exists(Yii::app()->getConfig('generalscripts')."admin/kcfinder/core/types/$class.php")) - require Yii::app()->getConfig('generalscripts')."admin/kcfinder/core/types/$class.php"; - elseif (file_exists(Yii::app()->getConfig('generalscripts')."admin/kcfinder/lib/class_$class.php")) - require Yii::app()->getConfig('generalscripts')."admin/kcfinder/lib/class_$class.php"; - elseif (file_exists(Yii::app()->getConfig('generalscripts')."admin/kcfinder/lib/helper_$class.php")) - require Yii::app()->getConfig('generalscripts')."admin/kcfinder/lib/helper_$class.php"; - } - - function css() - { - $this->index(); - - $mtime = @filemtime(__FILE__); - if ($mtime) - httpCache::checkMTime($mtime); - $browser = new browser(); - $config = $browser->config; - ob_start(); - ?> - html, body { - overflow: hidden; - } - - body, form, th, td { - margin: 0; - padding: 0; - } - - a { - cursor:pointer; - } - - * { - font-family: Tahoma, Verdana, Arial, sans-serif; - font-size: 11px; - } - - table { - border-collapse: collapse; - } - - #all { - visibility: hidden; - } - - #left { - float: left; - display: block; - width: 25%; - } - - #right { - float: left; - display: block; - width: 75%; - } - - #settings { - display: none; - padding: 0; - float: left; - width: 100%; - } - - #settings > div { - float: left; - } - - #folders { - padding: 5px; - overflow: auto; - } - - #toolbar { - padding: 5px; - } - - #files { - padding: 5px; - overflow: auto; - } - - #status { - padding: 5px; - float: left; - overflow: hidden; - } - - #fileinfo { - float: left; - } - - #clipboard div { - width: 16px; - height: 16px; - } - - .folders { - margin-left: 16px; - } - - div.file { - overflow-x: hidden; - width: px; - float: left; - text-align: center; - cursor: default; - white-space: nowrap; - } - - div.file .thumb { - width: px; - height: px; - background: no-repeat center center; - } - - #files table { - width: 100%; - } - - tr.file { - cursor: default; - } - - tr.file > td { - white-space: nowrap; - } - - tr.file > td.name { - background-repeat: no-repeat; - background-position: left center; - padding-left: 20px; - width: 100%; - } - - tr.file > td.time, - tr.file > td.size { - text-align: right; - } - - #toolbar { - cursor: default; - white-space: nowrap; - } - - #toolbar a { - padding-left: 20px; - text-decoration: none; - background: no-repeat left center; - } - - #toolbar a:hover, a[href="#upload"].uploadHover { - color: #000; - } - - #upload { - position: absolute; - overflow: hidden; - opacity: 0; - filter: alpha(opacity:0); - } - - #upload input { - cursor: pointer; - } - - #uploadResponse { - display: none; - } - - span.brace { - padding-left: 11px; - cursor: default; - } - - span.brace.opened, span.brace.closed { - cursor: pointer; - } - - #shadow { - position: absolute; - top: 0; - left: 0; - display: none; - background: #fff; - z-index: 100; - opacity: 0.5; - filter: alpha(opacity:50); - } - - #dialog, #clipboard { - position: absolute; - display: none; - z-index: 101; - cursor: default; - } - - #clipboard { - z-index: 99; - } - - #loading { - display: none; - float: right; - } - - .menu { - background: #888; - white-space: nowrap; - } - - .menu a { - display: block; - } - - .menu .list { - max-height: 0; - overflow-y: auto; - overflow-x: hidden; - white-space: nowrap; - } - - .file .access, .file .hasThumb { - display: none; - } - - #dialog img { - cursor: pointer; - } - - #resizer { - position: absolute; - z-index: 98; - top: 0; - background: #000; - opacity: 0; - filter: alpha(opacity:0); - } - index(); - - if (function_exists('set_magic_quotes_runtime')) - @set_magic_quotes_runtime(false); - - $input = new input(); - if (!isset($input->get['lng']) || ($input->get['lng'] == 'en')) - die; - $file = Yii::app()->getConfig('generalscripts')."admin/kcfinder/lang/" . $input->get['lng'] . ".php"; - $files = glob(Yii::app()->getConfig('generalscripts')."admin/kcfinder/lang/*.php"); - if (!in_array($file, $files)) - die; - $mtime = @filemtime($file); - if ($mtime) - httpCache::checkMTime($mtime); - require $file; - header("Content-Type: text/javascript; charset={$lang['_charset']}"); - foreach ($lang as $english => $native) - if (substr($english, 0, 1) != "_") - echo "browser.labels['" . text::jsValue($english) . "']=\"" . text::jsValue($native) . "\";"; - } - -} \ No newline at end of file diff --git a/application/helpers/admin/htmleditor_helper.php b/application/helpers/admin/htmleditor_helper.php index 7a6854700fb..601b4e3c938 100644 --- a/application/helpers/admin/htmleditor_helper.php +++ b/application/helpers/admin/htmleditor_helper.php @@ -14,7 +14,60 @@ */ //include_once("login_check.php"); //Security Checked: POST/GET/SESSION/DB/returnGlobal + function initKcfinder() + { + Yii::app()->session['KCFINDER'] = array(); + + $sAllowedExtensions = implode(' ', array_map('trim', explode(',', Yii::app()->getConfig('allowedresourcesuploads')))); + $_SESSION['KCFINDER']['types'] = array( + 'files' => $sAllowedExtensions, + 'flash' => $sAllowedExtensions, + 'images' => $sAllowedExtensions + ); + + if (Yii::app()->getConfig('demoMode') === false && + isset(Yii::app()->session['loginID']) && + isset(Yii::app()->session['FileManagerContext'])) + { + // disable upload at survey creation time + // because we don't know the sid yet + if (preg_match('/^(create|edit):(question|group|answer)/', Yii::app()->session['FileManagerContext']) != 0 || + preg_match('/^edit:survey/', Yii::app()->session['FileManagerContext']) != 0 || + preg_match('/^edit:assessments/', Yii::app()->session['FileManagerContext']) != 0 || + preg_match('/^edit:emailsettings/', Yii::app()->session['FileManagerContext']) != 0) + { + $contextarray = explode(':', Yii::app()->session['FileManagerContext'], 3); + $surveyid = $contextarray[2]; + + if (hasSurveyPermission($surveyid, 'surveycontent', 'update')) + { + $_SESSION['KCFINDER']['disabled'] = false; + if (preg_match('/^edit:emailsettings/',$_SESSION['FileManagerContext']) != 0) + { + $_SESSION['KCFINDER']['uploadURL'] = Yii::app()->getRequest()->getHostInfo($schema).Yii::app()->getConfig('uploadurl')."/surveys/{$surveyid}/"; + } + else + { + $_SESSION['KCFINDER']['uploadURL'] = Yii::app()->getConfig('uploadurl')."/surveys/{$surveyid}/"; + } + $_SESSION['KCFINDER']['uploadDir'] = Yii::app()->getConfig('uploaddir') .DIRECTORY_SEPARATOR.'surveys'.DIRECTORY_SEPARATOR.$surveyid.DIRECTORY_SEPARATOR; + } + } + elseif (preg_match('/^edit:label/', Yii::app()->session['FileManagerContext']) != 0) + { + $contextarray = explode(':', Yii::app()->session['FileManagerContext'], 3); + $labelid = $contextarray[2]; + // check if the user has label management right and labelid defined + if (Yii::app()->session['USER_RIGHT_MANAGE_LABEL'] == 1 && isset($labelid) && $labelid != '') + { + $_SESSION['KCFINDER']['disabled'] = false; + $_SESSION['KCFINDER']['uploadURL'] = Yii::app()->getConfig('uploadurl')."/labels/{$labelid}/"; + $_SESSION['KCFINDER']['uploadDir'] = Yii::app()->getConfig('uploaddir') .DIRECTORY_SEPARATOR.'labels'.DIRECTORY_SEPARATOR.$labelid.DIRECTORY_SEPARATOR; + } + } + } + } function sTranslateLangCode2CK($sLanguageCode){ @@ -57,8 +110,10 @@ function PrepareEditorScript($load=false, $controller = null) function getEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=null,$qID=null,$action=null) { + initKcfinder(); //error_log("TIBO fieldtype=$fieldtype,fieldname=$fieldname,fieldtext=$fieldtext,surveyID=$surveyID,gID=$gID,qID=$qID,action=$action"); $session = &Yii::app()->session; + if ($session['htmleditormode'] && $session['htmleditormode'] == 'none') { @@ -170,7 +225,7 @@ function getInlineEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=n $htmlcode .= "" . "'; diff --git a/application/views/admin/htmleditor/pop_editor_view.php b/application/views/admin/htmleditor/pop_editor_view.php index cb4249b58aa..9aba4f9ae36 100644 --- a/application/views/admin/htmleditor/pop_editor_view.php +++ b/application/views/admin/htmleditor/pop_editor_view.php @@ -31,7 +31,7 @@ function closeme() CKEDITOR.on('instanceReady',CKeditor_OnComplete); var oCKeditor = CKEDITOR.replace( 'MyTextarea' , { height : '350', width : '98%', - customConfig : "getConfig('sCKEditorURL') . '/limesurvey-config.js'; ?>", + customConfig : "getConfig('adminscripts') . '/ckeditor-config.js'; ?>", toolbarStartupExpanded : true, ToolbarCanCollapse : false, toolbar : '', diff --git a/application/views/admin/super/header.php b/application/views/admin/super/header.php index 5b099e57627..3e8d5296c31 100644 --- a/application/views/admin/super/header.php +++ b/application/views/admin/super/header.php @@ -14,6 +14,7 @@ + -
\ No newline at end of file +
diff --git a/application/views/admin/survey/editLocalSettings_view.php b/application/views/admin/survey/editLocalSettings_view.php index bbc663de99f..28390f8c5c4 100644 --- a/application/views/admin/survey/editLocalSettings_view.php +++ b/application/views/admin/survey/editLocalSettings_view.php @@ -3,15 +3,21 @@ ' name='short_title_' value="" />
  • +
    +
    gT("Description:", "js")."](".$esrow['surveyls_language'].")",$surveyid,'','',$action); ?>
  • +
    +
    gT("Welcome:", "js")."](".$esrow['surveyls_language'].")",$surveyid,'','',$action); ?>
  • +
    +
    gT("End message:", "js")."](".$esrow['surveyls_language'].")",$surveyid,'','',$action); ?>
  • diff --git a/scripts/admin/editor.js b/scripts/admin/editor.js index d373f4d57c9..6d479531cd3 100644 --- a/scripts/admin/editor.js +++ b/scripts/admin/editor.js @@ -6,7 +6,7 @@ $(document).ready(function(){ $('textarea.fulledit').ckeditor(function() { /* callback code */ }, { toolbar : sHTMLEditorMode, language : sEditorLanguage, width: 660, - customConfig : 'limesurvey-config.js' }); + customConfig : '/scripts/admin/ckeditor-config.js' }); } });