Skip to content

Commit

Permalink
Dev: renewed CKeditor to the latest version
Browse files Browse the repository at this point in the history
Overhaul and refactorization of the menu compnents
Small optical amendmends.
Surveymenu editing working
  • Loading branch information
lacrioque committed Jul 14, 2017
1 parent 88744e4 commit f9ee35a
Show file tree
Hide file tree
Showing 692 changed files with 49,917 additions and 458 deletions.
21 changes: 21 additions & 0 deletions application/config/packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,27 @@
'bootstrap-slider',
)
),
'ckeditor' => array(
'devBaseUrl' => 'assets/packages/ckeditor/',
'basePath' => 'core.ckeditor',
'js' => array(
'ckeditor.js',
),
'depends' => array(
'jquery',
'bootstrap'
),
),
'ckeditoradditions' => array(
'devBaseUrl' => 'assets/packages/ckeditoradditions/',
'basePath' => 'core.ckeditoradditions',
'js' => array(
'ckeditoradditions.js',
),
'depends' => array(
'ckeditor'
)
),
'adminpanel' => array(
'devBaseUrl' => 'assets/packages/adminpanel/build/',
'basePath' => 'core.adminpanel.build',
Expand Down
2 changes: 2 additions & 0 deletions application/controllers/admin/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,8 @@ private function actionInsertCopyQuestion($iSurveyID)
if (is_object($oAttributeValues && $oAttributeValues->value)){
$aAttributeValues['question_template'] = $oAttributeValues->value;
}
} else {
$cqr = null;
}

$validAttributes = Question::getQuestionTemplateAttributes($validAttributes, $aAttributeValues, $cqr );
Expand Down
8 changes: 5 additions & 3 deletions application/controllers/admin/surveyadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,11 @@ public function getAjaxQuestionGroupArray($surveyid){
*
*
*/
public function getAjaxMenuArray($surveyid){
public function getAjaxMenuArray($surveyid,$position=''){
$iSurveyID = sanitize_int($surveyid);
$survey = Survey::model()->findByPk($iSurveyID);
$baselang = $survey->language;
$menus = $survey->getSurveyMenus();
$menus = $survey->getSurveyMenus($position);
$userSettings = [];
return Yii::app()->getController()->renderPartial(
'/admin/super/_renderJson',
Expand Down Expand Up @@ -1784,7 +1784,7 @@ private function _tabResourceManagement($survey)
//$aData['esrow'] = $esrow;
$aData['ZIPimportAction'] = $ZIPimportAction;
$aData['disabledIfNoResources'] = $disabledIfNoResources;
$dqata['sCKEditorURL'] = $sCKEditorURL;
$aData['sCKEditorURL'] = $sCKEditorURL;

return $aData;
}
Expand Down Expand Up @@ -1912,6 +1912,8 @@ private function _registerScriptFiles()
App()->clientScript->registerPackage('bootstrap-switch');
App()->getClientScript()->registerPackage('jquery-datatable');
App()->clientScript->registerPackage('adminpanel');
App()->clientScript->registerPackage('ckeditor');
App()->clientScript->registerPackage('ckeditoradditions');

}

Expand Down
3 changes: 1 addition & 2 deletions application/core/Survey_Common_Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ protected function _renderWrappedTemplate($sAction = '', $aViewUrls = array(), $
//// Each view will call the correct bar as a subview.
$this->_surveysidemenu($aData);
//// TODO : Move this div inside each correct view ASAP !
echo '<div class="ls-flex-column align-items-flex-start align-content-center col-12 ls-flex-item">';
echo '<div class="ls-flex-column align-items-flex-start align-content-center col-12 ls-flex-item" id="pjax-content">';
$this->_surveybar($aData);
$this->_nquestiongroupbar($aData);
$this->_questionbar($aData);
Expand Down Expand Up @@ -310,7 +310,6 @@ protected function _renderWrappedTemplate($sAction = '', $aViewUrls = array(), $
//// Here the rendering of all the subviews process. Will not be use anymore, because each subview will be directly called from her parent view.

//// TODO : while refactoring, we must replace the use of $aViewUrls by $aData[.. conditions ..], and then call to function such as $this->_nsurveysummary($aData);

// Load views
foreach ($aViewUrls as $sViewKey => $viewUrl)
{
Expand Down
7 changes: 1 addition & 6 deletions application/helpers/admin/htmleditor_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ function getPopupEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=nu

function getInlineEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=null,$qID=null,$action=null)
{

$htmlcode = '';
$toolbaroption="";
$sFileBrowserAvailable='';
Expand Down Expand Up @@ -261,15 +262,9 @@ function(){ var $oCKeditorVarName = CKEDITOR.replace('$fieldname', {
. $toolbaroption
."});
CKEDITOR.editorConfig = function( config )
{
config.uiColor = '#FFF';
};
\$('#$fieldname').parents('ul:eq(0)').addClass('editor-parent');
});";


$htmlcode.= '</script>';

return $htmlcode;
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/update/updatedb_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ function db_upgrade_all($iOldDBVersion, $bSilent=false) {
* Survey menue table update
* @since 2017-07-12
*/
if ($iOldDBVersion < 295) {
if ($iOldDBVersion < 296) {
$oTransaction = $oDB->beginTransaction();

$oDB->createCommand()->addColumn('{{surveymenu}}', 'user_id', "int DEFAULT NULL");
Expand Down
2 changes: 2 additions & 0 deletions application/models/AdminTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ public function registerStylesAndScripts()
App()->getClientScript()->registerPackage('js-cookie'); // js-cookie
App()->getClientScript()->registerPackage('fontawesome'); // fontawesome ??? TODO: check if neede
App()->getClientScript()->registerPackage('adminpanel'); // Combined scripts and style for the new admin panel
App()->clientScript->registerPackage('ckeditor'); //
App()->clientScript->registerPackage('ckeditoradditions'); // CKEDITOR in a global sope
}

$aCssFiles = array();
Expand Down
56 changes: 31 additions & 25 deletions application/models/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,45 +586,51 @@ public function getGoogleanalyticsapikey(){
}


private function _getDefaultSurveyMenu(){
$oDefaultMenu = Surveymenu::model()->findByPk(1);
private function _getDefaultSurveyMenus($position=''){
$criteria=new CDbCriteria;
$criteria->condition='survey_id=NULL';
if($position != ''){
$criteria->condition='position=:position';
$criteria->params=array(':position'=>$position);
}

$oDefaultMenus = Surveymenu::model()->findAll($criteria);
//Posibility to add more languages to the database is given, so it is possible to add a call by language
//Also for peripheral menues we may add submenus someday.

$entries = [];
$defaultMenuEntries = $oDefaultMenu->surveymenuEntries;
foreach($defaultMenuEntries as $menuEntry){
$aEntry = $menuEntry->attributes;
if((!empty($entry['permission']) && !empty($entry['permission_grade']) && !Permission::model()->hasSurveyPermission($this->sid,$entry['permission'],$entry['permission_grade'])))
continue;
$aResultCollected = [];
foreach($oDefaultMenus as $oDefaultMenu){
$entries = [];
$defaultMenuEntries = $oDefaultMenu->surveymenuEntries;
foreach($defaultMenuEntries as $menuEntry){
$aEntry = $menuEntry->attributes;
if((!empty($entry['permission']) && !empty($entry['permission_grade']) && !Permission::model()->hasSurveyPermission($this->sid,$entry['permission'],$entry['permission_grade'])))
continue;


$aEntry['link'] = $aEntry['menu_link']
? App()->getController()->createUrl($aEntry['menu_link'],['surveyid' => $this->sid])
: App()->getController()->createUrl("admin/survey/sa/rendersidemenulink",['surveyid' => $this->sid, 'subaction' => $aEntry['name'] ]);
$entries[] = $aEntry;
$aEntry['link'] = $aEntry['menu_link']
? App()->getController()->createUrl($aEntry['menu_link'],['surveyid' => $this->sid])
: App()->getController()->createUrl("admin/survey/sa/rendersidemenulink",['surveyid' => $this->sid, 'subaction' => $aEntry['name'] ]);
$entries[] = $aEntry;
}
$aResultCollected[] = [
"title" => $oDefaultMenu->title,
"description" => $oDefaultMenu->description,
"entries" => $entries
];
}

$aResult = [
"title" => $oDefaultMenu->title,
"description" => $oDefaultMenu->description,
"entries" => $entries
];

return $aResult;
return $aResultCollected;
}


/**
* Get surveymenu configuration
* This will be made bigger in future releases, but right now it only collects the default menu-entries
*/
public function getSurveyMenus(){

$aSurveyMenus = [];
public function getSurveyMenus($position=''){

//Get the default menu
$aSurveyMenus[] = $this->_getDefaultSurveyMenu();
//Get the default menus
$aSurveyMenus = $this->_getDefaultSurveyMenus($position);

//get all survey specific menus
foreach($this->surveymenus as $menu){
Expand Down
2 changes: 1 addition & 1 deletion application/models/TemplateConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public function setTemplateConfiguration($sTemplateName='', $iSurveyId='')
$this->setIsStandard(); // Check if it is a CORE template
$this->path = ($this->isStandard)?Yii::app()->getConfig("standardtemplaterootdir").DIRECTORY_SEPARATOR.$this->template->folder:Yii::app()->getConfig("usertemplaterootdir").DIRECTORY_SEPARATOR.$this->template->folder;
$this->setMotherTemplates(); // Recursive mother templates configuration
$this->setThisTemplate(); // Set the main config values of this template
@$this->setThisTemplate(); // Set the main config values of this template
$this->createTemplatePackage($this); // Create an asset package ready to be loaded
return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion application/models/TemplateManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function setTemplateConfiguration($sTemplateName='', $iSurveyId='')
$this->setPath(); // Check and set path
$this->readManifest(); // Check and read the manifest to set local params
$this->setMotherTemplates(); // Recursive mother templates configuration
$this->setThisTemplate(); // Set the main config values of this template
@$this->setThisTemplate(); // Set the main config values of this template
$this->createTemplatePackage($this); // Create an asset package ready to be loaded
return $this;
}
Expand Down
4 changes: 3 additions & 1 deletion application/views/admin/htmleditor/pop_editor_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
<?php
App()->getClientScript()->registerPackage('jqueryui');
App()->getClientScript()->registerPackage('jquery-superfish');
App()->getClientScript()->registerPackage('ckeditor');
App()->getClientScript()->registerPackage('ckeditoradditions');
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl') . 'jquery-ui.css');
?>
<script type="text/javascript" src="<?php echo Yii::app()->getConfig('sCKEditorURL') . '/ckeditor.js'; ?>"></script>
<!--<script type="text/javascript" src="<?php echo Yii::app()->getConfig('sCKEditorURL') . '/ckeditor.js'; ?>"></script>-->
</head>

<body>
Expand Down
11 changes: 7 additions & 4 deletions application/views/admin/super/sidemenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
{
$showSideMenu = true;
}
$getQuestionsUrl = $this->createUrl("/admin/survey/sa/getAjaxQuestionGroupArray/surveyid/$surveyid");
$getMenuUrl = $this->createUrl("/admin/survey/sa/getAjaxMenuArray/surveyid/$surveyid");
$createQuestionGroupLink = $this->createUrl("admin/questiongroups/sa/add/surveyid/".$surveyid);
$createQuestionLink = $this->createUrl("admin/questions/sa/newquestion/surveyid/".$surveyid);
$getQuestionsUrl = $this->createUrl("/admin/survey/sa/getAjaxQuestionGroupArray/" ,["surveyid" => $surveyid]);
$getMenuUrl = $this->createUrl("/admin/survey/sa/getAjaxMenuArray/" ,["surveyid" => $surveyid]);
$createQuestionGroupLink = $this->createUrl("admin/questiongroups/sa/add/" ,["surveyid" => $surveyid]);
if(isset($oQuestionGroup))
$createQuestionLink = $this->createUrl("admin/questions/sa/newquestion/" ,["surveyid" => $surveyid, "gid" => $oQuestionGroup->gid]);
else
$createQuestionLink = $this->createUrl("admin/questions/sa/newquestion/" ,["surveyid" => $surveyid]);

if ($activated)
{
Expand Down
24 changes: 12 additions & 12 deletions application/views/admin/survey/breadcrumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
<div class="">
<ol class="breadcrumb <?=$extraClass?>">
<li>
<a class="animate home-icon" href="<?php echo App()->createUrl('admin/survey/sa/listsurveys');?>">
<a class="pjax animate home-icon" href="<?php echo App()->createUrl('admin/survey/sa/listsurveys');?>">
<i class="fa fa-list-alt bigIcon" title="<?php et('Survey List')?>" >&nbsp;</i>
</a>
</li>
<?php if(isset($oQuestion)): ?>
<li>
<a class="animate" href="<?php echo App()->createUrl('/admin/survey/sa/view/',['surveyid' => $oQuestion->sid] );?>">
<a class="pjax animate" href="<?php echo App()->createUrl('/admin/survey/sa/view/',['surveyid' => $oQuestion->sid] );?>">
<?php echo flattenText($oQuestion->survey->defaultlanguage->surveyls_title);?>
</a>
</li>

<li>
<a class="animate" href="<?php echo App()->createUrl('admin/questiongroups/sa/view/',['surveyid' => $oQuestion->sid,'gid'=>$oQuestion->gid] );?>">
<a class="pjax animate" href="<?php echo App()->createUrl('admin/questiongroups/sa/view/',['surveyid' => $oQuestion->sid,'gid'=>$oQuestion->gid] );?>">
<?php echo flattenText($oQuestion->groups->group_name);?>
</a>
</li>
Expand All @@ -25,7 +25,7 @@
</li>
<?php else: ?>
<li>
<a class="animate" href="<?php echo App()->createUrl('/admin/questions/sa/view/',['surveyid' => $oQuestion->sid,'gid' => $oQuestion->gid,'qid' => $oQuestion->qid] );?>">
<a class="pjax animate" href="<?php echo App()->createUrl('/admin/questions/sa/view/',['surveyid' => $oQuestion->sid,'gid' => $oQuestion->gid,'qid' => $oQuestion->qid] );?>">
<?php echo flattenText($oQuestion->title);?>
</a>
</li>
Expand All @@ -35,7 +35,7 @@
<?php endif; ?>
<?php elseif(isset($oQuestionGroup)): ?>
<li>
<a class="animate" href="<?php echo App()->createUrl('/admin/survey/sa/view/',['surveyid' => $oQuestionGroup->sid] );?>">
<a class="pjax animate" href="<?php echo App()->createUrl('/admin/survey/sa/view/',['surveyid' => $oQuestionGroup->sid] );?>">
<?php echo flattenText($oQuestionGroup->survey->defaultlanguage->surveyls_title);?>
</a>
</li>
Expand All @@ -46,7 +46,7 @@
</li>
<?php else: ?>
<li>
<a class="animate" href="<?php echo App()->createUrl('admin/questiongroups/sa/view/',['surveyid' => $oQuestionGroup->sid,'gid'=>$oQuestionGroup->gid] );?>">
<a class="pjax animate" href="<?php echo App()->createUrl('admin/questiongroups/sa/view/',['surveyid' => $oQuestionGroup->sid,'gid'=>$oQuestionGroup->gid] );?>">
<?php echo flattenText($oQuestionGroup->group_name);?>
</a>
</li>
Expand All @@ -56,12 +56,12 @@
<?php endif; ?>
<?php elseif(isset($token)): ?>
<li>
<a class="animate" href="<?php echo App()->createUrl('/admin/survey/sa/view/',['surveyid' => $oSurvey->sid] );?>">
<a class="pjax animate" href="<?php echo App()->createUrl('/admin/survey/sa/view/',['surveyid' => $oSurvey->sid] );?>">
<?php echo flattenText($oSurvey->defaultlanguage->surveyls_title);?>
</a>
</li>
<li>
<a class="animate" href="<?php echo App()->createUrl('admin/tokens/sa/index/',['surveyid' => $oSurvey->sid] );?>">
<a class="pjax animate" href="<?php echo App()->createUrl('admin/tokens/sa/index/',['surveyid' => $oSurvey->sid] );?>">
<?php eT('Survey participants');?>
</a>
</li>
Expand All @@ -70,25 +70,25 @@
</li>
<?php elseif(isset($oSurvey) && isset($sSubaction)): ?>
<li>
<a class="animate" href="<?php echo App()->createUrl('/admin/survey/sa/view/', ['surveyid' => $oSurvey->sid] );?>">
<a class="pjax animate" href="<?php echo App()->createUrl('/admin/survey/sa/view/', ['surveyid' => $oSurvey->sid] );?>">
<?php echo flattenText($oSurvey->defaultlanguage->surveyls_title);?>
</a>
</li>
<li>
<a class="animate" href="<?php echo App()->createUrl('/admin/survey/sa/view/', ['surveyid' => $oSurvey->sid , 'subaction' => $sSubaction] );?>">
<a class="pjax animate" href="<?php echo App()->createUrl('/admin/survey/sa/view/', ['surveyid' => $oSurvey->sid , 'subaction' => $sSubaction] );?>">
<?php echo $sSubaction;?>
</a>
</li>
<?php elseif(isset($oSurvey)): ?>
<?php if(!isset($active)): ?>
<li>
<a class="animate" href="<?php echo App()->createUrl('/admin/survey/sa/view/',['surveyid' => $oSurvey->sid] );?>">
<a class="pjax animate" href="<?php echo App()->createUrl('/admin/survey/sa/view/',['surveyid' => $oSurvey->sid] );?>">
<?php echo flattenText($oSurvey->defaultlanguage->surveyls_title);?>
</a>
</li>
<?php else: ?>
<li>
<a class="animate" href="<?php echo App()->createUrl('/admin/survey/sa/view/surveyid/'. $oSurvey->sid );?>">
<a class="pjax animate" href="<?php echo App()->createUrl('/admin/survey/sa/view/surveyid/'. $oSurvey->sid );?>">
<?php echo flattenText($oSurvey->defaultlanguage->surveyls_title);?>
</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script type="text/javascript" src="<?php echo Yii::app()->getConfig('sCKEditorURL'); ?>/ckeditor.js"></script>
<!--<script type="text/javascript" src="<?php echo Yii::app()->getConfig('sCKEditorURL'); ?>/ckeditor.js"></script>-->
<script type='text/javascript'>
<!--
CKEDITOR.on('dialogDefinition', function (ev) {
Expand Down
2 changes: 2 additions & 0 deletions application/views/admin/survey/subview/tab_edit_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
$count=0;
if(isset($scripts))
echo $scripts;

PrepareEditorScript(false, $this);
?>
<ul class="nav nav-tabs" id="edit-survey-text-element-language-selection">
<?php foreach ($aTabTitles as $i=>$eachtitle):?>
Expand Down

0 comments on commit f9ee35a

Please sign in to comment.