Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes issue #15715: Adjust the message when accessing for first time …
…theme editor
  • Loading branch information
thedirtypanda committed Jan 15, 2020
1 parent 80555b8 commit 7f01cb9
Showing 1 changed file with 36 additions and 16 deletions.
52 changes: 36 additions & 16 deletions application/controllers/admin/themes.php
Expand Up @@ -518,8 +518,6 @@ public function index($editfile = '', $screenname = 'welcome', $templatename = '
/* Keep Bootstrap Package clean after loading template : because template can update boostrap */
$aBootstrapPackage = Yii::app()->clientScript->packages['bootstrap-admin'];



$aViewUrls = $this->_initialise($templatename, $screenname, $editfile, true, true);

App()->getClientScript()->reset();
Expand Down Expand Up @@ -1024,24 +1022,20 @@ protected function _templatesummary($templatename, $screenname, $editfile, $rela
*/
protected function _initialise($templatename, $screenname, $editfile, $showsummary = true)
{


// LimeSurvey style
$oEditedTemplate = Template::getInstance($templatename, null, null, true, true)->prepareTemplateRendering($templatename, null, true);

//App()->getClientScript()->reset();
//App()->getClientScript()->reset();
Yii::app()->loadHelper('surveytranslator');
Yii::app()->loadHelper('admin/template');

$files = $oEditedTemplate->getValidScreenFiles("view", $screenname);
$sLayoutFile = $oEditedTemplate->getLayoutForScreen($screenname);
$sContentFile = $oEditedTemplate->getContentForScreen($screenname);
$cssfiles = $oEditedTemplate->getValidScreenFiles("css");
$jsfiles = $oEditedTemplate->getValidScreenFiles("js");
$jsfiles = $oEditedTemplate->getValidScreenFiles("js");
$editfile = (empty($editfile) || ! ( in_array($editfile, $files) || in_array( $editfile ,$cssfiles) || in_array( $editfile ,$jsfiles) )) ? $sLayoutFile : $editfile;



// Standard screens
$screens = $oEditedTemplate->getScreensList();

Expand Down Expand Up @@ -1073,7 +1067,7 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma
$normalfiles = $normalfiles + $files + $cssfiles;
// Some global data
$aData['sitename'] = Yii::app()->getConfig('sitename');
$siteadminname = Yii::app()->getConfig('siteadminname');
$siteadminname = Yii::app()->getConfig('siteadminname');
$siteadminemail = Yii::app()->getConfig('siteadminemail');

// NB: Used by answer print PDF layout.
Expand All @@ -1086,19 +1080,15 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma
// Save these variables in an array
// TODO: check if this aData is still used
$aData['thissurvey'] = $thissurvey;


$aGlobalReplacements = array();
$myoutput[] = "";


switch ($screenname) {
case 'welcome':

break;

case 'question':

// NOTE: this seems not to be used anymore
// TODO: try if it can be removed
$aReplacements = array(
Expand All @@ -1122,14 +1112,12 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma
break;

case 'register':

break;

case 'completed':
break;

case 'assessments':

break;

case 'printablesurvey':
Expand Down Expand Up @@ -1258,7 +1246,16 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma
$aData['relativePathEditfile'] = $editfile;
$aViewUrls['templateeditorbar_view'][] = $aData;

$this->showIntroNotification();
$usedVersion = App()->getConfig('versionnumber');
$delimiter = '.';
$version = explode($delimiter, $usedVersion);
$versionAsInteger = (int) $version[0];

if ($versionAsInteger >= 4) {
$this->showIntroNotificationForLS4();
} elseif ($versionAsInteger <= 3) {
$this->showIntroNotification();
}

if ($showsummary) {
Yii::app()->clientScript->registerPackage($oEditedTemplate->sPackageName);
Expand Down Expand Up @@ -1291,6 +1288,29 @@ protected function showIntroNotification()
$not->save();
}

/**
* First time user visits theme editor on 4.0.
* Show a notificiation about manual and forum.
*
* @return void
*/
private function showIntroNotificationForLS4(): void {
$user = User::model()->findByPk(App()->session['loginID']);
$notificationData = [
'user_id' => $user->uid,
'title' => gT('LimeSurvey 4.0 theme editor'),
'markAsNew' => false,
'importance' => Notification::HIGH_IMPORTANCE,
'message' => sprintf(
gT('Welcome to the theme editor of LimeSurvey 4.0. To get an overview of all functionality and possibilities, please visit the %s LimeSurvey manual %s. For further questions and information, feel free to post your questions on the %s LimeSurvey forums %s.', 'unescaped'),
'<a target="_blank" href="https://manualv4.limesurvey.org/LimeSurvey_Manual">', '</a>',
'<a target="_blank" href="https://www.limesurvey.org/community/forums">', '</a>'
)
];
$notification = new UniqueNotification($notificationData);
$notification->save();
}

/**
* Renders template(s) wrapped in header and footer
*
Expand Down

0 comments on commit 7f01cb9

Please sign in to comment.