From ae61a7f9226b54c24a751a927caa48a26f86ca06 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@afi-sa.fr> Date: Tue, 13 Dec 2016 17:59:23 +0100 Subject: [PATCH] dev #50182 convert dd dt to table for Sigb and digital resources connectors --- library/Class/Systeme/Report.php | 28 ++++++++-------- library/ZendAfi/View/Helper/Status/Html.php | 32 +++++++++++++------ library/ZendAfi/View/Helper/Status/Json.php | 4 ++- .../ZendAfi/View/Helper/Status/HtmlTest.php | 21 ++---------- 4 files changed, 41 insertions(+), 44 deletions(-) diff --git a/library/Class/Systeme/Report.php b/library/Class/Systeme/Report.php index de4ab709125..383ae0e1387 100644 --- a/library/Class/Systeme/Report.php +++ b/library/Class/Systeme/Report.php @@ -123,6 +123,11 @@ class Class_Systeme_Report_Users extends Class_Systeme_Report_Abstract { class Class_Systeme_Report_Ils extends Class_Systeme_Report_Abstract { public function acceptVisitor($visitor) { + $visitor->visitRecordHeader(['type' => $this->_('Type'), + 'url' => $this->_('URL'), + 'communication_status' => $this->_('Etat de la communication'), + ]); + foreach(Class_IntBib::findAll() as $int_bib) $this->reportIntBib($int_bib, $visitor); } @@ -141,14 +146,7 @@ class Class_Systeme_Report_Ils extends Class_Systeme_Report_Abstract { 'url' => $ils_service->getServerRoot(), 'communication_status' => $ils_service->testCommunicationStatus()]; -/* if ($message) - $report_communication = array_merge($report_communication, ['error' => - '<plaintext>'.$message.'</plaintext>']); */ - $visitor->visitRecord(['type' => $this->_('Type'), - 'url' => $this->_('URL'), - 'communication_status' => $this->_('Etat de la communication'), - ], - $report_communication); + $visitor->visitRecordValues($report_communication); return $this; } } @@ -157,23 +155,23 @@ class Class_Systeme_Report_Ils extends Class_Systeme_Report_Abstract { class Class_Systeme_Report_DigitalConnectors extends Class_Systeme_Report_Abstract { public function acceptVisitor($visitor) { + $visitor->visitRecordHeader(['label' => $this->_('Label'), + 'enabled' => $this->_('Activation'), + 'features' => $this->_('Fonctionnalités'), + 'album_count' => $this->_('Nombre d\'albums')]); foreach ((new Class_WebService_BibNumerique_Connectors())->getDescription() as $key => $description) { unset($description['url']); unset($description['image_url']); unset($description['desc']); unset($description['sales_contact']); - + unset($description['code']); if ($description['doctype_id'] && in_array('HARVEST', $description['features'])) $description['album_count'] = Class_Album::countBy(['type_doc_id' => $description['doctype_id']]); unset($description['doctype_id']); - $visitor->visitRecord(['code' => $this->_('Identifiant'), - 'label' => $this->_('Label'), - 'enabled' => $this->_('Activation'), - 'features' => $this->_('Fonctionnalités'), - 'album_count' => $this->_('Nombre d\'albums')], - $description); + + $visitor->visitRecordValues($description); } } } diff --git a/library/ZendAfi/View/Helper/Status/Html.php b/library/ZendAfi/View/Helper/Status/Html.php index c06c4f105c7..b227b7c223e 100644 --- a/library/ZendAfi/View/Helper/Status/Html.php +++ b/library/ZendAfi/View/Helper/Status/Html.php @@ -23,7 +23,8 @@ class ZendAfi_View_Helper_Status_Html extends ZendAfi_View_Helper_Status_Abstract { protected $_html, - $_current_section ; + $_current_section, + $_wrapper_tag; public function status_Html() { (new Class_Systeme_Report())->acceptVisitor($this); @@ -33,10 +34,11 @@ class ZendAfi_View_Helper_Status_Html extends ZendAfi_View_Helper_Status_Abstrac public function visitSection($id, $title, $section) { $this->_current_section = ''; + $this->_wrapper_tag = 'dl'; $section->acceptVisitor($this); $this->_html .= $this->_tag('section', $this->_tag('h2', $title) - . $this->_tag('dl', + . $this->_tag($this->_wrapper_tag, $this->_current_section)); } @@ -69,16 +71,26 @@ class ZendAfi_View_Helper_Status_Html extends ZendAfi_View_Helper_Status_Abstrac } - public function visitRecord($headers, $values) { - $this->_current_section .= '<dl>'; + public function visitRecordHeader($headers) { + $this->_headers = $headers; + $this->_wrapper_tag = 'table'; + $this->_current_section .= $this->_tag('tr', '<th>' . implode('</th><th>', $headers) . '</th>'); + } - foreach($headers as $key => $label) { - if (!isset($values[$key])) - continue; - $this->visitData($key, $label, $values[$key]); - } - $this->_current_section .= '</dl>'; + public function visitRecordValues($values) { + $this->_current_section .= '<tr>'; + + foreach ($this->_headers as $key_header =>$label) { + $value = ''; + if (isset($values[$key_header])) + $value = (is_array($values[$key_header]) ? + implode(',', $values[$key_header]) : + $values[$key_header]); + + $this->_current_section .= $this->_tag('td',$value); + } + $this->_current_section .= '</tr>'; } } diff --git a/library/ZendAfi/View/Helper/Status/Json.php b/library/ZendAfi/View/Helper/Status/Json.php index 904b5483b53..89cb4ed67bd 100644 --- a/library/ZendAfi/View/Helper/Status/Json.php +++ b/library/ZendAfi/View/Helper/Status/Json.php @@ -70,7 +70,9 @@ class ZendAfi_View_Helper_Status_Json extends ZendAfi_View_Helper_Status_Abstrac } - public function visitRecord($headers, $values) { + public function visitRecordHeader($headers) {} + + public function visitRecordValues($values) { $this->_report[$this->_current_section] []= $values; } } diff --git a/tests/library/ZendAfi/View/Helper/Status/HtmlTest.php b/tests/library/ZendAfi/View/Helper/Status/HtmlTest.php index ca5557bea77..affa50a8e89 100644 --- a/tests/library/ZendAfi/View/Helper/Status/HtmlTest.php +++ b/tests/library/ZendAfi/View/Helper/Status/HtmlTest.php @@ -97,40 +97,25 @@ class ZendAfi_View_Helper_Status_HtmlTest extends ZendAfi_View_Helper_Status_Tes /** @test */ public function firstILSShouldBeKoha() { $this->assertXPathContentContains($this->_html, - '//dl/dd[preceding-sibling::dt[text()="Type"]]', + '//tr/td[following-sibling::td[text()="http://localhost/koha"]]', 'koha'); } - /** @test */ - public function threeILSShouldBeKohaOnError() { - $this->assertXPathContentContains($this->_html, - '//dl/dd[preceding-sibling::dt[text()="Etat de la communication"]]', - 'error'); - - } - /** @test */ public function firstILSShouldBeKohaOnError() { $this->assertXPathContentContains($this->_html, - '//dl/dd[preceding-sibling::dd[text()="http://localhost/koha"]]', + '//tr/td[preceding-sibling::td[text()="http://localhost/koha"]]', 'error'); } - /** @test */ - public function sixILSShouldBeKohaOk() { - $this->assertXPathContentContains($this->_html, - '//dl/dd[preceding-sibling::dd[text()="http://localhost/workingkoha"]]', - 'ok'); - - } /** @test */ public function arteVodShouldBeActivated() { $this->assertXPathContentContains($this->_html, - '//dl/dd[preceding-sibling::dd[text()="ArteVOD"]]', + '//tr/td[preceding-sibling::td[text()="ArteVOD"]]', '1'); } -- GitLab