From 7ae32b8afc4253918d67491b66cc2d850d9c160a Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Thu, 8 Nov 2018 11:31:19 +0100 Subject: [PATCH] dev #79082 : fix rt comments --- .../controllers/UrlManagerController.php | 21 +++------- .../views/scripts/url-manager/index.phtml | 4 ++ library/Class/UrlManager.php | 5 +-- library/Class/UrlManager/Description.php | 42 ++++++++++++------- public/admin/js/url-manager/url-manager.js | 24 +++++++++++ .../controllers/UrlManagerControllerTest.php | 6 +++ 6 files changed, 68 insertions(+), 34 deletions(-) diff --git a/application/modules/admin/controllers/UrlManagerController.php b/application/modules/admin/controllers/UrlManagerController.php index 37153c718bd..94c2d11112b 100644 --- a/application/modules/admin/controllers/UrlManagerController.php +++ b/application/modules/admin/controllers/UrlManagerController.php @@ -31,9 +31,8 @@ class Admin_UrlManagerController extends ZendAfi_Controller_Action { $this->_request->getPost()))); $this->view->titre = $this->_('Contrôle des URL'); - $this->view->urls = (new Class_UrlManager)->findAll(['protocol' => $this->_getParam('protocol', 'no'), - 'term' => $this->_getParam('term'), - 'group_by' => $this->_getParam('group_by')]); + $this->view->urls = (new Class_UrlManager)->findAll(['protocol' => $this->_getParam('protocol', 'http'), + 'term' => $this->_getParam('term')]); $this->view->searchform = $this->_searchForm(); } @@ -89,10 +88,8 @@ class Admin_UrlManagerController extends ZendAfi_Controller_Action { return $this->_redirectClose($this->view->url(['action' => 'index'])); } $this->view->titre = $this->_('Liste des documents qui contiennent "%s"',$url); - $urls = ( new Class_UrlManager)->findAll(['group_by' => 'no', - 'protocol' => 'no', - 'term' => $url] - ); + $urls = ( new Class_UrlManager)->findAll(['protocol' => 'no', + 'term' => $url]); $this->view->models = []; foreach ($urls as $instances) @@ -142,17 +139,9 @@ class Admin_UrlManagerController extends ZendAfi_Controller_Action { 'multioptions' => ['no' => $this->_('Aucun'), 'http' => $this->_('http'), 'https' => $this->_('https')], - 'value' => $this->_getParam('protocol', 'no')]) - - ->addElement('radio', - 'group_by', - ['label' => $this->_('Regrouper par'), - 'multioptions' => ['domain' => $this->_('Domaine'), - 'no' => $this->_('Aucun')], - 'value' => $this->_getParam('group_by', 'no')]) + 'value' => $this->_getParam('protocol', 'http')]) ->addUniqDisplayGroup('search', ['legend' => $this->_('Filtrer les URL')]); - } diff --git a/application/modules/admin/views/scripts/url-manager/index.phtml b/application/modules/admin/views/scripts/url-manager/index.phtml index 358fbe69903..6daeeed5326 100644 --- a/application/modules/admin/views/scripts/url-manager/index.phtml +++ b/application/modules/admin/views/scripts/url-manager/index.phtml @@ -5,6 +5,10 @@ Class_ScriptLoader::getInstance() $html = [ + $this->tag('p', $this->_('Cet outil collecte les URL dans les articles, les lettres d\'information et les domaines.')), + + $this->tag('p', $this->_('Pour chaque URL collectée, vous pouvez convertir son protocole en HTTPS ainsi qu\'explorer les contenus qui l\'utilise.')), + $this->renderForm($this->searchform), BR, diff --git a/library/Class/UrlManager.php b/library/Class/UrlManager.php index 7cf5612f01f..1bd5c7548e1 100644 --- a/library/Class/UrlManager.php +++ b/library/Class/UrlManager.php @@ -34,9 +34,7 @@ class Class_UrlManager extends Class_Entity { ? 'http' : $params['protocol']; - $search_pattern = ('domain' == $params['group_by']) - ? '[\w\.\-\%\+]' - : '[\w\/\.\-\%\+]'; + $search_pattern = '[\w\/\.\-\%\+]'; $preg = '@(' . $protocol . '://'. $search_pattern.'+)[\b\s]?@i'; @@ -75,7 +73,6 @@ class Class_UrlManager extends Class_Entity { return $result; $urls = $this->findAll(['protocol' => 'no', - 'group_by' => 'no', 'term' => $url]); $success = true; diff --git a/library/Class/UrlManager/Description.php b/library/Class/UrlManager/Description.php index 5155a059b0b..a96a72799c9 100644 --- a/library/Class/UrlManager/Description.php +++ b/library/Class/UrlManager/Description.php @@ -35,9 +35,7 @@ class Class_UrlManager_Description { $instance = current($instances); $url = $instance->getUrl(); return $view->tagAnchor($url, - (strlen($url) > 40) - ? substr($url, 0, 40) . '...' - : $instance->getUrl(), + $instance->getUrl(), ['title' => $url]); }) @@ -83,32 +81,44 @@ class Class_UrlManager_Description { $instance = current($instances); $id = $instance->getId(); $url = $instance->getUrl(); + $https_url = str_replace('http://', + 'https://', $url); $url_request = urlencode($url); $convert_url = Class_Url::absolute(['module' => 'admin', 'controller' => 'url-manager', 'action' =>'update-url-in-models', 'url' => $url_request, - 'by' => urlencode(str_replace('http://', - 'https://', $url))],null,true); + 'by' => urlencode($https_url)] + , null, true); $actions = [$view->tagAnchor('#', Class_Admin_Skin::current() ->renderActionIconOn('inactive', $view, - ['alt' => $this->_('Sélectioner ou déselectionner l\'URL.')]), - ['data-id' => $id, + ['alt' => '']), + ['title' => $this->_('Sélectioner ou déselectionner l\'URL.'), + 'data-id' => $id, 'data-url' => $url, 'data-convert' => $convert_url, 'data-image-selected' => Class_Admin_Skin::current()->getIconUrl('actions', 'active'), 'data-image-not-selected' => Class_Admin_Skin::current()->getIconUrl('actions', 'inactive'), 'data-selected-status' => $instance->getSelectedStatus()]), + $view->tagAnchor('#', + Class_Admin_Skin::current() + ->renderActionIconOn('help', + $view, + ['alt' => '']), + ['data-test-row' => 1, + 'title' => $this->_('Tester l\'URL')]), + $view->tagAnchor($convert_url, Class_Admin_Skin::current() ->renderActionIconOn('test', $view, - ['alt' => $this->_('Mettre à jour l\'URL sélectionnée en HTTPS dans les contenus')]), - ['data-popup' => 'true']), + ['alt' => '']), + ['data-popup' => 'true', + 'title' => $this->_('Mettre à jour l\'URL sélectionnée en HTTPS dans les contenus')]), $view->tagAnchor($view->url(['controller' => 'url-manager', 'action' =>'url-details', @@ -116,8 +126,9 @@ class Class_UrlManager_Description { Class_Admin_Skin::current() ->renderActionIconOn('loupe', $view, - ['alt' => $this->_('Voir les contenus fournissant cette URL')]), - ['data-popup' => 'true']), + ['alt' => '']), + ['data-popup' => 'true', + 'title' => $this->_('Voir les contenus fournissant cette URL')]), $view->tagAnchor($view->url(['controller' => 'url-manager', 'action' =>'edit-url', @@ -125,11 +136,14 @@ class Class_UrlManager_Description { Class_Admin_Skin::current() ->renderActionIconOn('edit', $view, - ['alt' => $this->_('Modifier l\'adresse URL')]), - ['data-popup' => 'true']) + ['alt' => '']), + ['data-popup' => 'true', + 'title' => $this->_('Modifier l\'adresse URL')]) ]; - return implode($actions); + return $view->tag('div', + implode($actions), + ['style' => 'width: 120px']); }); } } \ No newline at end of file diff --git a/public/admin/js/url-manager/url-manager.js b/public/admin/js/url-manager/url-manager.js index 00f4417353a..320438a8422 100644 --- a/public/admin/js/url-manager/url-manager.js +++ b/public/admin/js/url-manager/url-manager.js @@ -26,6 +26,11 @@ testProtocolOnAllLinks(); }); + html.find('[data-test-row]').click(function(event) { + event.preventDefault(); + testProtocolOnRow($(event.target).closest('tr')); + }); + html.find('#select_all_https_protocol').click(function(event) { event.preventDefault(); selectAllHttpsProtocol(); @@ -84,6 +89,25 @@ }); } + + function testProtocolOnRow(row) { + row.find('div[data-protocol^="http"]').each(function() { + var element = $(this); + var url = element.attr('data-test-url'); + var id = element.attr('data-id'); + + $.ajax({ + url : url, + type : "GET", + dataType : "html", + success : function(data) { + if ('error' != $(data).attr('class')) + element.attr('data-selectable', true); + element.html(data); + }}); + }); + } + function selectAllHttpsProtocol() { html.find('[data-selected-status]').each(function() { diff --git a/tests/application/modules/admin/controllers/UrlManagerControllerTest.php b/tests/application/modules/admin/controllers/UrlManagerControllerTest.php index 3c5da8aa1a2..335aaeb0857 100644 --- a/tests/application/modules/admin/controllers/UrlManagerControllerTest.php +++ b/tests/application/modules/admin/controllers/UrlManagerControllerTest.php @@ -139,6 +139,12 @@ class UrlManagerControllerIndexDispatchWithURLFilteredTest extends UrlManagerTes } + /** @test */ + public function testRowActionShouldBePresent() { + $this->assertXPath('//td//a[@data-test-row]'); + } + + /** @test */ public function detailsActionShouldBePresent() { $this->assertXPath('//td//a[contains(@href, "/admin/url-manager/url-details/url/")]'); -- GitLab