Skip to content

Commit

Permalink
[FIX] Fix Undefined Constant, Use Class Constant
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWeinert committed Dec 9, 2020
1 parent 7b0474a commit 0b20240
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/system/Papaya/Administration/RichText/Toggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
*/
namespace Papaya\Administration\RichText {

use Papaya\Configuration\CMS as CMSSettings;
use Papaya\Response;
use Papaya\UI;
use Papaya\XML\Element as XMLElement;

class Toggle extends UI\Control\Interactive {

const USE_RICHTEXT_FLAG = 'PAPAYA_ADMINISTRATION_USE_RICHTEXT';

/**
* @var bool|null
*/
Expand All @@ -30,16 +34,16 @@ class Toggle extends UI\Control\Interactive {
private $_isActive;

/**
* @param \Papaya\XML\Element $parent
* @param XMLElement $parent
*/
public function appendTo(XMLElement $parent) {
$reference = new UI\Reference($this->papaya()->request->getURL());
if ($this->parameters()->has('PAPAYA_ADMINISTRATION_USE_RICHTEXT')) {
$shouldBeActive = $this->parameters()->get(\Papaya\Configuration\CMS::ADMINISTRATION_USE_RICHTEXT, FALSE);
if ($this->parameters()->has(self::USE_RICHTEXT_FLAG)) {
$shouldBeActive = $this->parameters()->get(self::USE_RICHTEXT_FLAG, FALSE);
if ($shouldBeActive !== $this->isActive()) {
// change and reload
$this->papaya()->session->setValue(
'PAPAYA_ADMINISTRATION_USE_RICHTEXT', $this->_isActive = $shouldBeActive
self::USE_RICHTEXT_FLAG, $this->_isActive = $shouldBeActive
);
$reference->setParameters([]);
$reload = new Response\Redirect($reference->get());
Expand All @@ -57,7 +61,7 @@ public function appendTo(XMLElement $parent) {
$currentValue = $this->isActive() ? 1 : 0;
foreach ([1 => 'On', 0 => 'Off'] as $value => $label) {
$toggleReference = clone $reference;
$toggleReference->setParameters(['PAPAYA_ADMINISTRATION_USE_RICHTEXT' => $value]);
$toggleReference->setParameters([self::USE_RICHTEXT_FLAG => $value]);
$links->appendElement(
'link',
[
Expand All @@ -80,7 +84,7 @@ public function isActive() {
return $this->_isActive;
}
return $this->_isActive = $this->papaya()->session->getValue(
'PAPAYA_ADMINISTRATION_USE_RICHTEXT',
self::USE_RICHTEXT_FLAG,
$this->isAvailable()
);
}
Expand All @@ -94,10 +98,10 @@ public function isAvailable() {
if (NULL !== $this->_isAvailable) {
return $this->_isAvailable;
}
if (isset($this->papaya()->administrationUser->options['PAPAYA_USE_RICHTEXT'])) {
return $this->_isAvailable = (bool)$this->papaya()->administrationUser->options['PAPAYA_USE_RICHTEXT'];
if (isset($this->papaya()->administrationUser->options[CMSSettings::USE_RICHTEXT])) {
return $this->_isAvailable = (bool)$this->papaya()->administrationUser->options[CMSSettings::USE_RICHTEXT];
}
return $this->_isAvailable = (bool)$this->papaya()->options->get(\Papaya\Configuration\CMS::USE_RICHTEXT, FALSE);
return $this->_isAvailable = (bool)$this->papaya()->options->get(CMSSettings::USE_RICHTEXT, FALSE);
}
}

Expand Down

0 comments on commit 0b20240

Please sign in to comment.