diff --git a/VERSIONS_HOTLINE/186821 b/VERSIONS_HOTLINE/186821 new file mode 100644 index 0000000000000000000000000000000000000000..ec35d44d0c94cb0f4f2f975de6bfe59bb25ca692 --- /dev/null +++ b/VERSIONS_HOTLINE/186821 @@ -0,0 +1 @@ + - correctif #186821 : Administration : correction de la gestion du cache du script de CKEDITOR. \ No newline at end of file diff --git a/ckeditor/ckeditor_php5.php b/ckeditor/ckeditor_php5.php index 676a2eea6ef9696ca455b30f1c95a28d59b8cc36..a3bdaddd8dc8beaf3f29d9422a02fa363968c609 100644 --- a/ckeditor/ckeditor_php5.php +++ b/ckeditor/ckeditor_php5.php @@ -54,6 +54,8 @@ class CKEditor * <script> tag loading ckeditor.js in your website. */ public $initialized = false; + + public static $initComplete; /** * Boolean variable indicating whether created code should be printed out or returned by a function. * @@ -435,31 +437,28 @@ class CKEditor */ private function init() { - static $initComplete; $out = ""; - if (!empty($initComplete)) { + if (!empty(static::$initComplete)) { return ""; } if ($this->initialized) { - $initComplete = true; + static::$initComplete = true; return ""; } $args = ""; $ckeditorPath = $this->ckeditorPath(); - if (!empty($this->timestamp) && $this->timestamp != "%"."TIMESTAMP%") { - $args = '?t=' . $this->timestamp; - } - // Skip relative paths... if (strpos($ckeditorPath, '..') !== 0) { $out .= $this->script("window.CKEDITOR_BASEPATH='". $ckeditorPath ."';"); } - $out .= "<script type=\"text/javascript\" src=\"" . $ckeditorPath . 'ckeditor.js' . $args . "\"></script>\n"; + $script_loader = (new Class_ScriptLoader)->addScript($ckeditorPath . 'ckeditor.js'); + + $out .= $script_loader->html(); $extraCode = ""; if ($this->timestamp != self::timestamp) { @@ -469,7 +468,7 @@ class CKEditor $out .= $this->script($extraCode); } - $initComplete = $this->initialized = true; + static::$initComplete = $this->initialized = true; return $out; } @@ -555,4 +554,9 @@ class CKEditor return '"' . str_replace(array("\\", "/", "\n", "\t", "\r", "\x08", "\x0c", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'), $val) . '"'; } + + + public static function reset() : void { + static::$initComplete = null; + } } diff --git a/library/ZendAfi/Form/Decorator/Ckeditor.php b/library/ZendAfi/Form/Decorator/Ckeditor.php index 55940f608e6f6d01ffc003da1a5420f60f46ba6f..51d7050c0fa6602ce889140ed546fb1b4bff7a58 100644 --- a/library/ZendAfi/Form/Decorator/Ckeditor.php +++ b/library/ZendAfi/Form/Decorator/Ckeditor.php @@ -18,16 +18,17 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + + class ZendAfi_Form_Decorator_Ckeditor extends Zend_Form_Decorator_Abstract { /** * @param string $content * @return string */ public function render($content) { - return $content . $this->_element->getView()->ckEditor( - $this->_element->getValue(), - $this->_element->getName(), - $this->_element->getShowFileBrowser()); + return $content + . $this->_element->getView()->ckEditor($this->_element->getValue(), + $this->_element->getName(), + $this->_element->getShowFileBrowser()); } } -?> \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/CmsControllerTest.php b/tests/application/modules/admin/controllers/CmsControllerTest.php index 605c015291ef19b758f2d7d1d956ae2c6e045c7b..7b23df85cd720f71d6be21a29c9db0c2d66f5439 100644 --- a/tests/application/modules/admin/controllers/CmsControllerTest.php +++ b/tests/application/modules/admin/controllers/CmsControllerTest.php @@ -20,6 +20,7 @@ */ require_once 'AdminAbstractControllerTestCase.php'; +include_once(CKBASEPATH . "ckeditor.php"); abstract class CmsControllerTestCase extends Admin_AbstractControllerTestCase { @@ -296,14 +297,22 @@ abstract class CmsControllerWithPermissionTestCase extends CmsControllerTestCase class CmsControllerArticleEditWithoutLanguesTest extends CmsControllerWithPermissionTestCase { + protected string $_cache_hash = ''; + + public function setUp() { parent::setUp(); - Class_Exemplaire::beVolatile(); Class_AdminVar::getLoader() ->newInstanceWithId('LANGUES') ->setValeur(''); + CKEditor::reset(); + + Class_AdminVar::set('CACHE_DATE', '2023-10-10 11:17:00'); + + $this->_cache_hash = (new Class_ScriptLoader)->getCacheHash(); + $this->dispatch('/admin/cms/edit/id/4'); } @@ -318,6 +327,13 @@ class CmsControllerArticleEditWithoutLanguesTest extends CmsControllerWithPermis public function traductionsSelectorShouldNotBeVisible() { $this->assertNotXPath('//div[@class="traduction_navigator"]'); } + + + /** @test */ + public function ckeditorJsShouldBeLoaded() { + $this->assertXPath('//script[contains(@src, "/ckeditor/ckeditor.js?v=' . $this->_cache_hash . '")]'); + } + } diff --git a/tests/application/modules/admin/controllers/IndexControllerTest.php b/tests/application/modules/admin/controllers/IndexControllerTest.php index ecdebad63b1fa516bceebd092046b6fa62eb8ff9..f84a66bef06ee34c36cec0b3b5de1a55568b516e 100644 --- a/tests/application/modules/admin/controllers/IndexControllerTest.php +++ b/tests/application/modules/admin/controllers/IndexControllerTest.php @@ -421,7 +421,7 @@ class Admin_IndexControllerClearCacheActionTest extends Admin_IndexControllerTes $this->_cache_version = $scriptloadder->getCacheHash(); - $this->dispatch('/admin/index/clearcache', true); + $this->dispatch('/admin/index/clearcache'); }