From 102da63208e8492789b95ca5b1917218496de84f Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Tue, 24 Apr 2018 16:11:49 +0200 Subject: [PATCH] hotline #74605 fix file manager selection return value --- VERSIONS_HOTLINE/74605 | 2 ++ library/Class/FileManager.php | 6 ++++++ library/Class/Notice/Xsl.php | 3 ++- library/ZendAfi/Controller/Plugin/Manager/FileManager.php | 2 +- .../modules/admin/controllers/FileManagerControllerTest.php | 2 +- tests/scenarios/Xsl/XslTest.php | 4 ++-- 6 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 VERSIONS_HOTLINE/74605 diff --git a/VERSIONS_HOTLINE/74605 b/VERSIONS_HOTLINE/74605 new file mode 100644 index 00000000000..3d87af72008 --- /dev/null +++ b/VERSIONS_HOTLINE/74605 @@ -0,0 +1,2 @@ + - ticket #74605 : Administration : correction de l'ajout d'images dans les articles. + \ No newline at end of file diff --git a/library/Class/FileManager.php b/library/Class/FileManager.php index 0d8ee7b59f0..a9de5817db3 100644 --- a/library/Class/FileManager.php +++ b/library/Class/FileManager.php @@ -138,12 +138,18 @@ class Class_FileManager extends Class_Entity { public static function find($path) { + $path = static::_urlToPath($path); return ($item = static::directory($path)) ? $item : static::file($path); } + protected static function _urlToPath($path) { + return str_replace(BASE_URL . '/' , '', $path); + } + + public static function delete($item) { if (!$item) return true; diff --git a/library/Class/Notice/Xsl.php b/library/Class/Notice/Xsl.php index a4a23b3ed19..17831604ff1 100644 --- a/library/Class/Notice/Xsl.php +++ b/library/Class/Notice/Xsl.php @@ -99,7 +99,8 @@ class Class_Notice_Xsl { public function getXslFileUrl() { - $settings = $this->_profile->getCfgModulesPreferences('recherche', 'viewnotice', $this->_record->getTypeDoc()); + $settings = $this->_profile->getCfgModulesPreferences('recherche', 'viewnotice', $this->_record->getTypeDoc()); + if(!$settings) return; diff --git a/library/ZendAfi/Controller/Plugin/Manager/FileManager.php b/library/ZendAfi/Controller/Plugin/Manager/FileManager.php index 9479b013176..8230ae7d7ce 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/FileManager.php +++ b/library/ZendAfi/Controller/Plugin/Manager/FileManager.php @@ -46,7 +46,7 @@ class ZendAfi_Controller_Plugin_Manager_FileManager extends ZendAfi_Controller_P }, 'label' => $this->_('Sélectionner "%s"', $model->getName()), 'anchorOptions' => array_filter(['title' => $this->_('Sélectionner "%s"', $model->getName()), - 'onclick' => "$(this).selectItemForCKEditor('" . str_replace(["'", '"'], ['%27', '%22'], $model->getId()) . "');"])], + 'onclick' => "$(this).selectItemForCKEditor('" . str_replace(["'", '"'], ['%27', '%22'], Class_Url::relative($model->getPath())) . "');"])], ['url' => ['action' => 'create', 'into' => $model->getId()], diff --git a/tests/application/modules/admin/controllers/FileManagerControllerTest.php b/tests/application/modules/admin/controllers/FileManagerControllerTest.php index 3decc219697..2af63ced65c 100644 --- a/tests/application/modules/admin/controllers/FileManagerControllerTest.php +++ b/tests/application/modules/admin/controllers/FileManagerControllerTest.php @@ -1595,7 +1595,7 @@ class FileManagerControllerWithSpecialCharTest extends FileManagerControllerTest /** @test */ public function selectButtonShouldBePresent() { - $this->assertXPathContentContains('//div//a[contains(@onclick, "$(this).selectItemForCKEditor(")][contains(@onclick, "selectItemForCKEditor(\'userfiles/my %27direct%22ory/new%27_ima%22ge.jpg")]', 'Sélectionner'); + $this->assertXPathContentContains('//div//a[contains(@onclick, "$(this).selectItemForCKEditor(")][contains(@onclick, "/userfiles/my %27direct%22ory/new%27_ima%22ge.jpg")]', 'Sélectionner'); } diff --git a/tests/scenarios/Xsl/XslTest.php b/tests/scenarios/Xsl/XslTest.php index fb642512198..3357c6ccfb9 100644 --- a/tests/scenarios/Xsl/XslTest.php +++ b/tests/scenarios/Xsl/XslTest.php @@ -159,7 +159,7 @@ class XslNoticeajaxDetailDispatchTest extends AbstractControllerTestCase { Class_Notice_Xsl::setXSLTProcessor($xslt_processor); $profile = Class_Profil::getCurrentProfil(); - $profile->setCfgModulesPreferences(['xslt' => 'tests/scenarios/Xsl/record_description.xsl'], + $profile->setCfgModulesPreferences(['xslt' => '/tests/scenarios/Xsl/record_description.xsl'], 'recherche', 'viewnotice', '1'); @@ -204,7 +204,7 @@ class XslNoticeajaxDetailDispatchWithoutXSLTest extends AbstractControllerTestCa Class_Notice_Xsl::setPhpCommand($php_command); $profile = Class_Profil::getCurrentProfil(); - $profile->setCfgModulesPreferences(['xslt' => 'tests/scenarios/Xsl/record_description.xsl'], + $profile->setCfgModulesPreferences(['xslt' => '/tests/scenarios/Xsl/record_description.xsl'], 'recherche', 'viewnotice', '1'); -- GitLab