Skip to content

Commit

Permalink
Task/qe 873 editor enabled ce (#3824)
Browse files Browse the repository at this point in the history
* QE-873: change editorEnabled via plugin (important for cloud edition)

* QE-873: disabled functionality for EditorButton, Mousover  for button,
using event to set editor to enabled

---------

Co-authored-by: Kevin Foster <kevin.foster.uk@gmail.com>
  • Loading branch information
Trischi80 and kevin-foster-uk committed Apr 22, 2024
1 parent a957a82 commit 6089f50
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 20 deletions.
13 changes: 11 additions & 2 deletions application/core/TopbarConfiguration.php
Expand Up @@ -204,7 +204,15 @@ public static function getSurveyTopbarData($sid)
|| $hasSurveyContentPermission
|| !is_null($extraToolsMenuItems);

$editorEnabled = Yii::app()->getConfig('editorEnabled') ?? false;
$editorEnabled = $event->get('isEditorEnabled');
if ($editorEnabled===null) {
$editorEnabled = Yii::app()->getConfig('editorEnabled') ?? false;
}

$enableEditorButton = true;
if ($oSurvey->getTemplateEffectiveName() !== 'fruity_twentythree') {
$enableEditorButton = false;
}

$editorUrl = Yii::app()->request->getUrlReferrer(
Yii::app()->createUrl(
Expand Down Expand Up @@ -244,7 +252,8 @@ public static function getSurveyTopbarData($sid)
'showToolsMenu' => $showToolsMenu,
'surveyLanguages' => self::getSurveyLanguagesArray($oSurvey),
'editorEnabled' => $editorEnabled,
'editorUrl' => $editorUrl
'editorUrl' => $editorUrl,
'enableEditorButton' => $enableEditorButton,
);
}

Expand Down
Expand Up @@ -2,10 +2,45 @@
/**
* @var string $closeUrl
* @var string $returnUrl
* @var string $editorUrl
* @var bool $enableEditorButton
*/

?>

<?php
// new question editor
if (isset($editorEnabled) && $editorEnabled && $editorUrl) {
$disabled = '';
$tooltip = '';
if (!$enableEditorButton) {
$disabled = 'disabled';
$tooltip = gT('New question editor is only allowed for Fruity23');
}
?>
<span data-bs-toggle="tooltip" data-bs-original-title="<?=$tooltip?>">
<?php
$this->widget(
'ext.ButtonWidget.ButtonWidget',
[
'name' => 'editor-link-button',
'id' => 'editor-link-button',
'text' => gT('Open in new editor'),
'icon' => 'ri-article-line',
'link' => $editorUrl,
'htmlOptions' => [
'class' => 'btn btn-secondary',
'role' => 'button',
'disabled' => $disabled,
],
]
);
?>
</span>
<?php
}
?>

<!-- White Close button -->
<?php
if (!empty($showWhiteCloseButton)) {
Expand Down Expand Up @@ -145,21 +180,3 @@
}
?>

<?php
if (isset($editorEnabled) && $editorEnabled && $editorUrl) {
$this->widget(
'ext.ButtonWidget.ButtonWidget',
[
'name' => 'editor-link-button',
'id' => 'editor-link-button',
'text' => gT('Open in new editor'),
'icon' => 'ri-article-line',
'link' => $editorUrl,
'htmlOptions' => [
'class' => 'btn btn-secondary',
'role' => 'button',
],
]
);
}
?>

0 comments on commit 6089f50

Please sign in to comment.