diff --git a/FEATURES/140317 b/FEATURES/140317 new file mode 100644 index 0000000000000000000000000000000000000000..0eacf65ab2e69894b720cd39e7a3c6deb687c6e3 --- /dev/null +++ b/FEATURES/140317 @@ -0,0 +1,10 @@ + '140317' => + ['Label' => $this->_('Boîte notices / disposition carte géographique : paramétrage des champs latitude / longitude'), + 'Desc' => $this->_('La liste des zones/champs unimarcs à utiliser pour lire les coordonnées GPS est maintenant paramétrable. Aligné par défaut avec la grille Nanook'), + 'Image' => '', + 'Video' => '', + 'Category' => $this->_('Administration'), + 'Right' => function($feature_description, $user) {return true;}, + 'Wiki' => 'https://wiki.bokeh-library-portal.org/index.php?title=G%C3%A9olocalisation_de_contenu', + 'Test' => '', + 'Date' => '2022-08-02'], \ No newline at end of file diff --git a/VERSIONS_WIP/140317 b/VERSIONS_WIP/140317 new file mode 100644 index 0000000000000000000000000000000000000000..92f9a8863fa4324cd5505bc8edc792505e0c4c87 --- /dev/null +++ b/VERSIONS_WIP/140317 @@ -0,0 +1 @@ + - fonctionnalité #140317 : Boîte notices / disposition carte géographique : la liste des zones/champs unimarcs à utiliser pour lire les coordonnées GPS est maintenant paramétrable. Aligné par défaut avec la grille Nanook \ No newline at end of file diff --git a/application/modules/admin/controllers/WidgetController.php b/application/modules/admin/controllers/WidgetController.php index a23ed60aede2ecbe62a7562f3e655c5b5935170d..4bf3acff7f53ce12b058f5c0ae1f34b914a9664e 100644 --- a/application/modules/admin/controllers/WidgetController.php +++ b/application/modules/admin/controllers/WidgetController.php @@ -260,11 +260,15 @@ class Admin_WidgetController extends ZendAfi_Controller_Action { $this->custom_values = []; - foreach ($post as $k=>$v) + foreach ($post as $k => $v) { if (preg_match('/field_[0-9]+/', $k)) { $this->custom_values[$k] = $v; unset($post[$k]); } + } + + foreach($form->getMultiInputs() as $multi_input) + $post = $multi_input->packPostValues($post); return $post; } diff --git a/library/ZendAfi/Form.php b/library/ZendAfi/Form.php index f235748265df79445627ec6a5009a00ab2efb1d4..6258b4d2d1748b7f625f4570cf5726959938cc8c 100644 --- a/library/ZendAfi/Form.php +++ b/library/ZendAfi/Form.php @@ -178,15 +178,21 @@ class ZendAfi_Form extends Zend_Form { } - public function getMulticheckboxNames() { + public function getMulticheckboxNames() : array { $names = []; foreach($this->getElements() as $element) - if (is_a($element, 'Zend_Form_Element_MultiCheckbox')) + if (is_a($element, Zend_Form_Element_MultiCheckbox::class)) $names[] = $element->getName(); return $names; } + public function getMultiInputs() : array { + return array_filter($this->getElements(), + fn($element) => is_a($element, ZendAfi_Form_Element_MultiInput::class)); + } + + public function addSummary($summary) { $this->_summary = $summary; return $this; diff --git a/library/ZendAfi/Form/Element/MultiInput.php b/library/ZendAfi/Form/Element/MultiInput.php index a4010482f4efacf9c1759f7ab2636368ef12314c..968b807f6e17c5883ec77ccf065e5d8cc5ed0926 100644 --- a/library/ZendAfi/Form/Element/MultiInput.php +++ b/library/ZendAfi/Form/Element/MultiInput.php @@ -40,6 +40,66 @@ class ZendAfi_Form_Element_MultiInput extends Zend_Form_Element { } + + /** + * $post contains one key per multi input fields, + * like: + * [ 'things_a' => ['a', 'b', 'c'], + * 'things_b' => ['1', '2', '3'] ] + * + * and this functions packs it into a single value + * for the multi-input element: + * + * ['things' => 'a-1;b-2;c-3'] + * + */ + public function packPostValues(array $post) : array { + $packer = new Class_Profil_ConfigPacker(); + + $fields = $this->getFields(); + if (!isset($post[$fields[0]['name']])) + return $post; + + $number_of_values = count($post[$fields[0]['name']]); + + for ($i = 0; $i < $number_of_values; $i++) { + $packer->add(array_map(fn($field) => $post[$field['name']][$i], + $fields)); + } + + $post[$this->getName()] = $packer->pack(); + + foreach($fields as $field) + unset($post[$field['name']]); + + return $post; + } + + + /** + * @see packPostValues + * unpack a multi-input value into values + * for each subfield + */ + public function populateValues(string $strpack) : self { + $values = []; + + foreach($this->getFields() as $field) + $values[$field['name']] = []; + + $lines = (new Class_Profil_ConfigPacker)->unpack($strpack); + array_walk($lines, + function($line) use(&$values) { + foreach($this->getFields() as $i => $field) + $values[$field['name']][] = $line[$i]; + }); + + $this->setValues($values); + + return $this; + } + + /** * element is composite, receive its values in datas array * @return boolean diff --git a/library/ZendAfi/View/Helper/Template/LayoutOsmMap.php b/library/ZendAfi/View/Helper/Template/LayoutOsmMap.php index 3f576701270b8024fe7eeff13f98364c7efc1a15..78464ae3e68e66c454a09fc4afbabd72bdee1cad 100644 --- a/library/ZendAfi/View/Helper/Template/LayoutOsmMap.php +++ b/library/ZendAfi/View/Helper/Template/LayoutOsmMap.php @@ -48,7 +48,9 @@ class ZendAfi_View_Helper_Template_LayoutOsmMap protected function _getOsmMapHelper() { if (!$this->_osm_helper) - $this->_osm_helper = (new ZendAfi_View_Helper_Template_OsmMap)->setView($this->view); + $this->_osm_helper = $this->view->newHelper('OsmMap') + ->setSettings($this->_rendering_options->getSettings()) + ->setView($this->view); $this->_osm_helper->setOSMId($this->_id_module); diff --git a/library/ZendAfi/View/Helper/Template/OsmMap.php b/library/ZendAfi/View/Helper/Template/OsmMap.php index 3fb0f1c3927d0c12097e84d2e940f6e287f2b967..b50d8365ef4b7348dc846c772d3f3dcdb597f14d 100644 --- a/library/ZendAfi/View/Helper/Template/OsmMap.php +++ b/library/ZendAfi/View/Helper/Template/OsmMap.php @@ -22,6 +22,18 @@ class ZendAfi_View_Helper_Template_OsmMap extends ZendAfi_View_Helper_BaseHelper { protected $_wrapper_id, $_map_id; + protected Intonation_System_WidgetSettings $_settings; + + public function __construct() { + $this->_settings = new Intonation_System_WidgetSettings([]); + } + + + public function setSettings(Intonation_System_WidgetSettings $settings) : self { + $this->_settings = $settings; + return $this; + } + public function setOSMId($id) { $this->_wrapper_id = 'osm_wrap_' . $id; @@ -97,7 +109,7 @@ class ZendAfi_View_Helper_Template_OsmMap extends ZendAfi_View_Helper_BaseHelper protected function _buildOSMDatas($element, $html_renderer) { - if (!$data = $element->getOsmData()) + if (!$data = $element->getOsmData($this->_settings)) return null; $data->sethtml($html_renderer($element)); diff --git a/library/ZendAfi/View/Helper/Template/RenderArticle.php b/library/ZendAfi/View/Helper/Template/RenderArticle.php index 05636e92a582d896e9e77ada77bb8442d26a4e85..82d8a8f422b585bb019c2e0ef21172836c0e3363 100644 --- a/library/ZendAfi/View/Helper/Template/RenderArticle.php +++ b/library/ZendAfi/View/Helper/Template/RenderArticle.php @@ -31,7 +31,8 @@ class ZendAfi_View_Helper_Template_RenderArticle extends ZendAfi_View_Helper_Bas $grid_content = $this->_injectLocation($article->getLieu()); - if ( ($osm_data = $wrapper->getOsmData()) && ($osm_wrapper = $osm_data->getwrapper())) + if ( ($osm_data = $wrapper->getOsmData(new Intonation_System_WidgetSettings([]))) + && ($osm_wrapper = $osm_data->getwrapper())) $grid_content [] = $this->_div(['class' => 'article_location_data'], $this->view->renderingVertical($osm_wrapper)); diff --git a/library/templates/Chili/Library/Wrapper/RichContentSection.php b/library/templates/Chili/Library/Wrapper/RichContentSection.php index 56524b4ab5e676a750574a7e484aba77c11d08e5..36b25d1f9b6caf64945345c6b0c97ffadaa82b34 100644 --- a/library/templates/Chili/Library/Wrapper/RichContentSection.php +++ b/library/templates/Chili/Library/Wrapper/RichContentSection.php @@ -65,7 +65,9 @@ class Chili_Library_Wrapper_RichContentSection extends Intonation_Library_View_W public function getDocType(){} public function getDocTypeLabel(){} - public function getOsmData(){} + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { + return null; + } public function getTimelineEventsDates() : Intonation_Library_TimelineEventsDates { diff --git a/library/templates/Chili/Library/Wrapper/RichContentThumbnail.php b/library/templates/Chili/Library/Wrapper/RichContentThumbnail.php index d2eadcd51a1443fba2065798fec33a95c8335a2e..a258eba3c04c7d94ab6c71604220dedf42d52c12 100644 --- a/library/templates/Chili/Library/Wrapper/RichContentThumbnail.php +++ b/library/templates/Chili/Library/Wrapper/RichContentThumbnail.php @@ -69,7 +69,9 @@ class Chili_Library_Wrapper_RichContentThumbnail extends Intonation_Library_View public function getDocType(){} public function getDocTypeLabel(){} - public function getOsmData(){} + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { + return null; + } public function getTimelineEventsDates() : Intonation_Library_TimelineEventsDates { return new Intonation_Library_TimelineEventsDates; diff --git a/library/templates/Intonation/Library/View/Wrapper/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/Abstract.php index e2901a7ba07907a388bc291d82b7557c739a7989..a5c603751331bbd3f50cb5ae2f1c6c401894edc7 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/Abstract.php @@ -291,7 +291,7 @@ abstract class Intonation_Library_View_Wrapper_Abstract { abstract public function getDocTypeLabel(); /** @return Intonation_Library_OsmData */ - abstract public function getOsmData(); + abstract public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData; abstract public function getTimelineEventsDates() : Intonation_Library_TimelineEventsDates; } diff --git a/library/templates/Intonation/Library/View/Wrapper/AbstractCardOperation.php b/library/templates/Intonation/Library/View/Wrapper/AbstractCardOperation.php index de5874824a2a468e9859632d82d85e2a40252f1b..63ca51def303e4b9b64064f084f5c046528944c3 100644 --- a/library/templates/Intonation/Library/View/Wrapper/AbstractCardOperation.php +++ b/library/templates/Intonation/Library/View/Wrapper/AbstractCardOperation.php @@ -156,7 +156,7 @@ abstract class Intonation_Library_View_Wrapper_AbstractCardOperation extends Int } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return null; } @@ -205,4 +205,4 @@ abstract class Intonation_Library_View_Wrapper_AbstractCardOperation extends Int $id = unserialize($id); return new Class_User_CardsOperationDecorator($id[0], Class_Users::find($id[1])); } -} \ No newline at end of file +} diff --git a/library/templates/Intonation/Library/View/Wrapper/ActivitySession.php b/library/templates/Intonation/Library/View/Wrapper/ActivitySession.php index fce6e4eb4c418b5b537985fd97c43ace1826fae5..a598f043a8ded4f48881c7d42aa10f51e81debc9 100644 --- a/library/templates/Intonation/Library/View/Wrapper/ActivitySession.php +++ b/library/templates/Intonation/Library/View/Wrapper/ActivitySession.php @@ -224,7 +224,7 @@ class Intonation_Library_View_Wrapper_ActivitySession } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { if (!$location = $this->_model->getLieu()) return null; diff --git a/library/templates/Intonation/Library/View/Wrapper/Article.php b/library/templates/Intonation/Library/View/Wrapper/Article.php index 241920862ec90f325a00c4ffe6fbb3c7e4c4ce39..a57e94624da5388dda545919242003759af9c29b 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Article.php +++ b/library/templates/Intonation/Library/View/Wrapper/Article.php @@ -276,7 +276,7 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { if (!$location = $this->_model->getLieu()) return null; diff --git a/library/templates/Intonation/Library/View/Wrapper/Author.php b/library/templates/Intonation/Library/View/Wrapper/Author.php index ab32b86c641230630f2823ae4dab9d83c826c254..ebe473972a6ef155d0dd159a08c6571ec4cb5086 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Author.php +++ b/library/templates/Intonation/Library/View/Wrapper/Author.php @@ -203,7 +203,7 @@ class Intonation_Library_View_Wrapper_Author extends Intonation_Library_View_Wra } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return null; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Domain.php b/library/templates/Intonation/Library/View/Wrapper/Domain.php index 46e843f8ad64494c405819feacbe28e4a61dece6..a90470857f0c9e68112aeeb1ae8d332ec636f720 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Domain.php +++ b/library/templates/Intonation/Library/View/Wrapper/Domain.php @@ -119,7 +119,7 @@ class Intonation_Library_View_Wrapper_Domain extends Intonation_Library_View_Wra } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return null; } @@ -128,4 +128,4 @@ class Intonation_Library_View_Wrapper_Domain extends Intonation_Library_View_Wra return new Intonation_Library_TimelineEventsDates($this->_model->getAnneeDebut(), $this->_model->getAnneeFin()); } -} \ No newline at end of file +} diff --git a/library/templates/Intonation/Library/View/Wrapper/DriveCheckoutPlan.php b/library/templates/Intonation/Library/View/Wrapper/DriveCheckoutPlan.php index 2c7fc40925310e1c2a9c6f7232e2ccbb597a0a3f..a09ee804b6b8e6d99d060b86075869eda0670d0d 100644 --- a/library/templates/Intonation/Library/View/Wrapper/DriveCheckoutPlan.php +++ b/library/templates/Intonation/Library/View/Wrapper/DriveCheckoutPlan.php @@ -113,7 +113,7 @@ class Intonation_Library_View_Wrapper_DriveCheckoutPlan } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return null; } @@ -121,4 +121,4 @@ class Intonation_Library_View_Wrapper_DriveCheckoutPlan public function getTimelineEventsDates() : Intonation_Library_TimelineEventsDates { return new Intonation_Library_TimelineEventsDates; } -} \ No newline at end of file +} diff --git a/library/templates/Intonation/Library/View/Wrapper/Item.php b/library/templates/Intonation/Library/View/Wrapper/Item.php index 2c6bcbe3b6904c378a944d734853dfe237b97cce..f8a1e6ff6be62ce7cd728c2345b2969c84e3a272 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Item.php +++ b/library/templates/Intonation/Library/View/Wrapper/Item.php @@ -189,7 +189,7 @@ class Intonation_Library_View_Wrapper_Item extends Intonation_Library_View_Wrapp } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return null; } diff --git a/library/templates/Intonation/Library/View/Wrapper/ItemForOsm.php b/library/templates/Intonation/Library/View/Wrapper/ItemForOsm.php index c7db758f39959b18a56b95dc8b321ce5e0c19db0..86c2b95f6d390b29c748f76f99c843e6333f0d20 100644 --- a/library/templates/Intonation/Library/View/Wrapper/ItemForOsm.php +++ b/library/templates/Intonation/Library/View/Wrapper/ItemForOsm.php @@ -33,11 +33,11 @@ class Intonation_Library_View_Wrapper_ItemForOsm extends Intonation_Library_View } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return ($osm_data = (new Intonation_Library_View_Wrapper_ItemForOsmWithoutSIGB($this->_model, $this->_view)) - ->getOsmData()) + ->getOsmData(new Intonation_System_WidgetSettings([]))) ? ($osm_data ->setstatus(($this->_model->isDisponible() ? ZendAfi_View_Helper_LibrariesMap::OPEN diff --git a/library/templates/Intonation/Library/View/Wrapper/ItemForOsmWithoutSIGB.php b/library/templates/Intonation/Library/View/Wrapper/ItemForOsmWithoutSIGB.php index 2725188c0e352b0d984e4d0de918e0586e217f11..37a876344e5dbae2bec9e7ed5451e2654598ebac 100644 --- a/library/templates/Intonation/Library/View/Wrapper/ItemForOsmWithoutSIGB.php +++ b/library/templates/Intonation/Library/View/Wrapper/ItemForOsmWithoutSIGB.php @@ -34,7 +34,7 @@ class Intonation_Library_View_Wrapper_ItemForOsmWithoutSIGB extends Intonation_L } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { if (!$library = $this->_model->getBib()) return null; diff --git a/library/templates/Intonation/Library/View/Wrapper/Library.php b/library/templates/Intonation/Library/View/Wrapper/Library.php index bcd18df8a51febf581ccfc0d3e92b400381208c6..ab83dd7dbf409ffcc5b623f009c8a9b45ef20589 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Library.php +++ b/library/templates/Intonation/Library/View/Wrapper/Library.php @@ -213,7 +213,7 @@ class Intonation_Library_View_Wrapper_Library extends Intonation_Library_View_Wr } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { if (!$location = $this->_model->getLieu()) return null; diff --git a/library/templates/Intonation/Library/View/Wrapper/Location.php b/library/templates/Intonation/Library/View/Wrapper/Location.php index 3fe1d9d86f654c60b2193364b40a4d046c615c6f..b5c46ef044c60d24c93e30e8279763b0e1e9e1e6 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Location.php +++ b/library/templates/Intonation/Library/View/Wrapper/Location.php @@ -129,7 +129,7 @@ class Intonation_Library_View_Wrapper_Location extends Intonation_Library_View_W } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return null; } @@ -137,4 +137,4 @@ class Intonation_Library_View_Wrapper_Location extends Intonation_Library_View_W public function getTimelineEventsDates() : Intonation_Library_TimelineEventsDates { return new Intonation_Library_TimelineEventsDates; } -} \ No newline at end of file +} diff --git a/library/templates/Intonation/Library/View/Wrapper/MenuEntry.php b/library/templates/Intonation/Library/View/Wrapper/MenuEntry.php index 3b6adcaf3b1a091f8ea755dd150c58b25130d5b1..1b2e7d04958eacbbb84bb6eb48a0a177f03a5769 100644 --- a/library/templates/Intonation/Library/View/Wrapper/MenuEntry.php +++ b/library/templates/Intonation/Library/View/Wrapper/MenuEntry.php @@ -122,8 +122,7 @@ class Intonation_Library_View_Wrapper_MenuEntry extends Intonation_Library_View_ } - /** @return Intonation_Library_OsmData */ - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return null; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Newsletter.php b/library/templates/Intonation/Library/View/Wrapper/Newsletter.php index 2e71274406acaf8bbd71a8d8a9b2c07086871f68..410dcfb56013f901fcd9686fe9f0595d9d287d11 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Newsletter.php +++ b/library/templates/Intonation/Library/View/Wrapper/Newsletter.php @@ -135,7 +135,7 @@ class Intonation_Library_View_Wrapper_Newsletter extends Intonation_Library_View } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return null; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Null.php b/library/templates/Intonation/Library/View/Wrapper/Null.php index 40ad5a54be97d8d606a0a8f2e744f10c7505420c..3b2bb16fd78e6abb3c3b7da11396a09cd297fbf7 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Null.php +++ b/library/templates/Intonation/Library/View/Wrapper/Null.php @@ -109,8 +109,9 @@ class Intonation_Library_View_Wrapper_Null extends Intonation_Library_View_Wrapp } - /** @return Intonation_Library_OsmData */ - public function getOsmData() {} + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { + return null; + } public function getTimelineEventsDates() : Intonation_Library_TimelineEventsDates { diff --git a/library/templates/Intonation/Library/View/Wrapper/Record.php b/library/templates/Intonation/Library/View/Wrapper/Record.php index fda394168a51b01a1324068500601aa52fa955f3..6c51516691352fefe3646070fdf1ee24b9f0e5ce 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record.php @@ -666,15 +666,17 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra } - public function getOsmData() { - $latitude = $this->_model->get_subfield('123', 'f'); - $longitude = $this->_model->get_subfield('123', 'd'); - - if (!$latitude || !$longitude) - return null; + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { + foreach((new Class_Profil_ConfigPacker)->unpack($settings->getGeoFields()) as $zone_lat_lon) { + $latitude = $this->_model->get_subfield($zone_lat_lon[0], $zone_lat_lon[1]); + $longitude = $this->_model->get_subfield($zone_lat_lon[0], $zone_lat_lon[2]); + + if (!empty($latitude) && !empty($longitude)) + return new Intonation_Library_OsmData(['lat' => str_replace(',', '.', $latitude[0]), + 'lon' => str_replace(',', '.', $longitude[0])]); + } - return new Intonation_Library_OsmData(['lat' => $latitude[0], - 'lon' => $longitude[0]]); + return null; } diff --git a/library/templates/Intonation/Library/View/Wrapper/RendezVous.php b/library/templates/Intonation/Library/View/Wrapper/RendezVous.php index a21f9cdc206d4034bb810d9e5522023780ad9932..fba56362963ec388aa18be94c90a4e46d7c4558a 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RendezVous.php +++ b/library/templates/Intonation/Library/View/Wrapper/RendezVous.php @@ -123,7 +123,7 @@ class Intonation_Library_View_Wrapper_RendezVous extends Intonation_Library_View } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { if (!$location = $this->_model->getLocation()) return null; diff --git a/library/templates/Intonation/Library/View/Wrapper/Review.php b/library/templates/Intonation/Library/View/Wrapper/Review.php index 580822d2fe29ae6e7b985f5dcba017272a9d2a5b..f69cf4b7bd295a8979ffa97d7dce4283f2e77113 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Review.php +++ b/library/templates/Intonation/Library/View/Wrapper/Review.php @@ -224,7 +224,7 @@ class Intonation_Library_View_Wrapper_Review extends Intonation_Library_View_Wra } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return $this->_getRecordWrapper()->getOsmData(); } @@ -247,4 +247,4 @@ class Intonation_Library_View_Wrapper_Review extends Intonation_Library_View_Wra public function getTimelineEventsDates() : Intonation_Library_TimelineEventsDates { return new Intonation_Library_TimelineEventsDates((string) $this->_model->getDateAvis()); } -} \ No newline at end of file +} diff --git a/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php b/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php index 9aec523e3515c67ca12941b8bc358519ac880386..b4fac458cd2ae9227692a5324a8ae7abda9563bd 100644 --- a/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php +++ b/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php @@ -156,7 +156,7 @@ class Intonation_Library_View_Wrapper_ReviewsByRecord extends Intonation_Library } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return null; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Rss.php b/library/templates/Intonation/Library/View/Wrapper/Rss.php index 83dd64693ba95abb116719eca59438dc736b8dfe..554012a465660f1ff3961a0d8039e263beb8a9df 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Rss.php +++ b/library/templates/Intonation/Library/View/Wrapper/Rss.php @@ -113,7 +113,7 @@ class Intonation_Library_View_Wrapper_Rss extends Intonation_Library_View_Wrappe } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return null; } diff --git a/library/templates/Intonation/Library/View/Wrapper/RssItem.php b/library/templates/Intonation/Library/View/Wrapper/RssItem.php index e1272c1bbb52a8a4fa0f569cbbce6a532b8b1b73..05a4140d09fe4da2eafdfd52854318962744f16c 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RssItem.php +++ b/library/templates/Intonation/Library/View/Wrapper/RssItem.php @@ -161,7 +161,7 @@ class Intonation_Library_View_Wrapper_RssItem extends Intonation_Library_View_Wr } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return null; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Search.php b/library/templates/Intonation/Library/View/Wrapper/Search.php index 38afe86dc8a53839ec5f79a5d05e490a44a350c1..5d3f8930045c65d3a565b18fa068b192df2c44e5 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Search.php +++ b/library/templates/Intonation/Library/View/Wrapper/Search.php @@ -183,7 +183,7 @@ class Intonation_Library_View_Wrapper_Search } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return null; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Selection.php b/library/templates/Intonation/Library/View/Wrapper/Selection.php index 9654361fce44bd681d8cf45eee1328f4d2513472..b443192c0d275e0fdfb17bcdb5227b98c009567d 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Selection.php +++ b/library/templates/Intonation/Library/View/Wrapper/Selection.php @@ -264,7 +264,7 @@ class Intonation_Library_View_Wrapper_Selection extends Intonation_Library_View_ } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return null; } diff --git a/library/templates/Intonation/Library/View/Wrapper/SerialArticleFromArray.php b/library/templates/Intonation/Library/View/Wrapper/SerialArticleFromArray.php index 4d20a4b5c2d4128f3bab914174401f8c93705910..50f2e29fb81b6a901b9d2f73f015991934739335 100644 --- a/library/templates/Intonation/Library/View/Wrapper/SerialArticleFromArray.php +++ b/library/templates/Intonation/Library/View/Wrapper/SerialArticleFromArray.php @@ -118,8 +118,8 @@ class Intonation_Library_View_Wrapper_SerialArticleFromArray extends Intonation_ } - public function getOsmData() { - return new Intonation_Library_OsmData; + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { + return null; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Suggestion.php b/library/templates/Intonation/Library/View/Wrapper/Suggestion.php index 32de2469001f42f6fa204181f2f4bbb8df1962fd..779279a01c7797c5521ea1cfed2fff655bca7d94 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Suggestion.php +++ b/library/templates/Intonation/Library/View/Wrapper/Suggestion.php @@ -198,7 +198,7 @@ class Intonation_Library_View_Wrapper_Suggestion extends Intonation_Library_View } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return null; } @@ -241,4 +241,4 @@ class Intonation_Library_View_Wrapper_Suggestion extends Intonation_Library_View ? Class_SuggestionAchat::find((int) $_suggest_id_or_remote_suggest_data) : $_suggest_id_or_remote_suggest_data; } -} \ No newline at end of file +} diff --git a/library/templates/Intonation/Library/View/Wrapper/User.php b/library/templates/Intonation/Library/View/Wrapper/User.php index 1cc32f3cf9ba76d4c80ec4d7ebac73d403c4ed4f..9de43130a8f0fe490add097186ad1a0da0780062 100644 --- a/library/templates/Intonation/Library/View/Wrapper/User.php +++ b/library/templates/Intonation/Library/View/Wrapper/User.php @@ -281,7 +281,7 @@ class Intonation_Library_View_Wrapper_User extends Intonation_Library_View_Wrapp } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { return null; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Website.php b/library/templates/Intonation/Library/View/Wrapper/Website.php index 7740b6848c78c3eb8bd4f1a409a674e05f995a9b..70f3a748291d2e1e800ba237c0b2582d4e337cc6 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Website.php +++ b/library/templates/Intonation/Library/View/Wrapper/Website.php @@ -144,7 +144,8 @@ class Intonation_Library_View_Wrapper_Website extends Intonation_Library_View_Wr } - public function getOsmData() { + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { + return null; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Work.php b/library/templates/Intonation/Library/View/Wrapper/Work.php index 6379e2376cb761c233f074bcd50fdfc3dc46e0af..b34a3db0962de66e9f314d978447e797b85a3d87 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Work.php +++ b/library/templates/Intonation/Library/View/Wrapper/Work.php @@ -167,8 +167,8 @@ class Intonation_Library_View_Wrapper_Work extends Intonation_Library_View_Wrapp public function getDocTypeLabel() {} - public function getOsmData() { - return $this->_getRecordWrapper()->getOsmData(); + public function getOsmData(Intonation_System_WidgetSettings $settings) : ?Intonation_Library_OsmData { + return $this->_getRecordWrapper()->getOsmData($settings); } diff --git a/library/templates/Intonation/Library/Widget/Carousel/Definition.php b/library/templates/Intonation/Library/Widget/Carousel/Definition.php index 75e9a55eb691437304d375eff60c3d15cb57497e..a62f48a641f3d0d7f4d86e2b3a1e88fb514444df 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Definition.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Definition.php @@ -59,7 +59,8 @@ class Intonation_Library_Widget_Carousel_Definition extends Class_Systeme_Module 'link_to_all' => false, 'all_layout' => static::LISTING, 'all_rendering' => static::HORIZONTAL_CARD, - 'description_length' => 20 + 'description_length' => 20, + 'geo_fields' => '123-f-d;941-d-f' ]; } @@ -108,4 +109,4 @@ class Intonation_Library_Widget_Carousel_Definition extends Class_Systeme_Module }, ARRAY_FILTER_USE_KEY); } -} \ No newline at end of file +} diff --git a/library/templates/Intonation/Library/Widget/Carousel/Form.php b/library/templates/Intonation/Library/Widget/Carousel/Form.php index d92f3f9023c90b0fcacc04975b8e857a160e776d..dc8d8fb5b38a12ca0dd70fcbe5a5d02a87840f72 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Form.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Form.php @@ -32,6 +32,15 @@ class Intonation_Library_Widget_Carousel_Form extends ZendAfi_Form_Configuration } + public function populate(array $datas) { + if (isset($datas['geo_fields'])) + $this->getElement('geo_fields') + ->populateValues($datas['geo_fields']); + + return parent::populate($datas); + } + + public function init() { parent::init(); @@ -47,8 +56,15 @@ class Intonation_Library_Widget_Carousel_Form extends ZendAfi_Form_Configuration ->addJQueryReady(sprintf('formSelectToggleVisibilityForElement("#layout", $("#order").closest("tr"), ["%s"]);', $this->_getLayoutsWithoutTimeline())) + ->addJQueryReady(sprintf('formSelectToggleVisibilityForElement("#layout", $("tr.geo_fields"), ["%s"]);', Intonation_Library_Widget_Carousel_Definition::MAP)) + ->addScripts([Class_Url::absolute('/library/templates/Intonation/Assets/js/onChangeDoSideEffects/onChangeDoSideEffects.js')]); + $digits_letters = [...range('0', '9'), ...range('a', 'z')]; + $all_fields = array_combine($digits_letters, + array_map(fn($f) => '$' . $f, + $digits_letters)); + $this ->addElement('treeSelect', @@ -64,6 +80,33 @@ class Intonation_Library_Widget_Carousel_Form extends ZendAfi_Form_Configuration ['label' => $this->_('Disposition de la liste'), 'multiOptions' => $this->getLayouts()]) + + ->addElement('multiInput', + 'geo_fields', + ['label' => $this->_('Géolocalisation des documents'), + 'fields' => [ + ['name' => 'geo_zone', + 'type' => 'number', + 'label' => $this->_('Zone'), + 'attribs' => ['min' => 100, + 'size' => 4, + 'max' => 999] + ], + + ['name' => 'geo_lat', + 'type' => 'select', + 'options' => $all_fields, + 'label' => $this->_('champ latitude')], + + + ['name' => 'geo_lon', + 'type' => 'select', + 'options' => $all_fields, + 'label' => $this->_('champ longitude')] + + ]]) + + ->addElement('select', 'rendering', ['label' => $this->_('Rendu d\'un document'), @@ -148,6 +191,7 @@ class Intonation_Library_Widget_Carousel_Form extends ZendAfi_Form_Configuration ->addToSelectionGroup(['data_sources']) ->addToDisplaySettingsGroup(['layout', + 'geo_fields', 'rendering', 'size', 'order', @@ -211,4 +255,4 @@ class Intonation_Library_Widget_Carousel_Form extends ZendAfi_Form_Configuration protected function _getLayoutSideEffects() : string { return '{}'; } -} \ No newline at end of file +} diff --git a/tests/scenarios/Numel/NumelMapTest.php b/tests/scenarios/Numel/NumelMapTest.php index a9ee63319b078be3179ccabbf9f8b58e68ab0081..7df18f4ff17ba1da666b9aa500d56dab52a79219 100644 --- a/tests/scenarios/Numel/NumelMapTest.php +++ b/tests/scenarios/Numel/NumelMapTest.php @@ -31,8 +31,8 @@ abstract class NumelKioskMapTestCase extends AbstractControllerTestCase { ->setUnimarc((new Class_NoticeUnimarc_Fluent) ->zoneWithContent('001', '1111') ->zoneWithChildren('200', ['a' => 'Rue Pomme']) - ->zoneWithChildren('123', ['d' => '2.65', - 'f' => '48.53'])->render()) + ->zoneWithChildren('122', ['e' => '2.65', + 'd' => '48.53'])->render()) ->assertSave(); @@ -40,14 +40,28 @@ abstract class NumelKioskMapTestCase extends AbstractControllerTestCase { $nowhere ->setClefAlpha('NULLE PART') ->setUnimarc((new Class_NoticeUnimarc_Fluent) - ->zoneWithContent('001', '1111') + ->zoneWithContent('001', '1112') ->zoneWithChildren('200', ['a' => 'nulle part'])->render()) ->assertSave(); + + + $tux_street = new Class_Notice; + $tux_street + ->setClefAlpha('RUE TUX') + ->setUnimarc((new Class_NoticeUnimarc_Fluent) + ->zoneWithContent('001', '1113') + ->zoneWithChildren('200', ['a' => 'Rue Tux']) + ->zoneWithChildren('941', ['d' => '2,66', + 'f' => '48,54'])->render()) + ->assertSave(); + + $selection = new Class_PanierNotice; $selection ->addNotice($apple_street) ->addNotice($nowhere) + ->addNotice($tux_street) ->assertSave(); $this->_buildTemplateProfil(['id' => 1, @@ -56,6 +70,7 @@ abstract class NumelKioskMapTestCase extends AbstractControllerTestCase { Intonation_Library_Widget_Carousel_Record_Definition::CODE, ['layout' => Intonation_Library_Widget_Carousel_Definition::MAP, 'order' => 'selection', + 'geo_fields' => '122-e-d;941-d-f', 'id_panier' => $selection->getId()]) ->assertSave(); } @@ -69,14 +84,91 @@ class NumelKioskMapWidgetAdminTest extends NumelKioskMapTestCase { parent::setUp(); Class_Users::getIdentity()->beAdminPortail(); - $this->dispatch('/admin/widget/edit-widget/id/1/id_profil/1', true); + $this->dispatch('/admin/widget/edit-widget/id/1/id_profil/1'); } /** @test */ public function selectInputForLayousShouldContainsCarteGeographique() { $this->assertXPathContentContains('//select[@name="layout"]//option[@value="map"][@selected]', - 'Carte géographique'); + 'Carte géographique'); + } + + + /** @test */ + public function multiInputGeoZonesShouldContainsUnpackedValues() { + $this->assertXPathContentContains('//script', + 'values:{"geo_zone":["122","941"],"geo_lat":["e","d"],"geo_lon":["d","f"]}'); + } +} + + + + +class NumelKioskMapWidgetAdminDefaultValueTest extends NumelKioskMapTestCase { + public function setUp() { + parent::setUp(); + $profile_patcher = (new Class_Template_ProfilePatcher(null)) + ->setProfile(Class_Profil::find(1)); + + $profile_patcher + ->addWidget(Intonation_Library_Widget_Carousel_Record_Definition::CODE, + Class_Profil::DIV_MAIN, + ['layout' => Intonation_Library_Widget_Carousel_Definition::MAP, + 'order' => 'selection']); + + Class_Users::getIdentity()->beAdminPortail(); + $this->dispatch('/admin/widget/edit-widget/id/2/id_profil/1'); + } + + + /** @test */ + public function multiInputGeoZonesShouldDefaultTo123dfAnd941dfZones() { + $this->assertXPathContentContains('//script', + 'values:{"geo_zone":["123","941"],"geo_lat":["f","d"],"geo_lon":["d","f"]}'); + } +} + + + + +class NumelKioskMapWidgetAdminPostCoordinatesTest extends NumelKioskMapTestCase { + public function setUp() { + parent::setUp(); + Class_Users::getIdentity()->beAdminPortail(); + + $this->postDispatch('/admin/widget/edit-widget/id/1/id_profil/1', + ['geo_zone' => ['959', '933'], + 'geo_lat' => ['d', 'e'], + 'geo_lon' => ['f', 'g']]); + Class_Systeme_Widget_Widget::reset(); + } + + + + + /** @test */ + public function widgetCarouselGeoFieldsShouldBe959df_933eg() { + $carousel = ((new Class_Systeme_Widget_Widget) + ->setId(1) + ->setProfileId(1) + ->load()); + + $this->assertEquals('959-d-f;933-e-g', + $carousel->get('geo_fields')); + } + + + /** @test */ + public function widgetCarouselShouldNotHaveSettingsGeoZoneLatAndLon() { + $carousel = ((new Class_Systeme_Widget_Widget) + ->setId(1) + ->setProfileId(1) + ->load()); + + foreach(['geo_zone', 'geo_lat', 'geo_lon'] as $key) + $this->assertNotContains($key, + array_keys($carousel->toArray())); } } @@ -107,6 +199,12 @@ class NumelKioskMapTest extends NumelKioskMapTestCase { } + /** @test */ + public function dataOSMShouldContainsTuxStreetWithLatitudeAndLongitude() { + $this->assertXPath('//div[contains(@data-osm, "Rue Tux")][contains(@data-osm, "2.66")][contains(@data-osm, "48.54")]', $this->_response->getBody()); + } + + /** @test */ public function dataOSMShouldNotContainsNullePart() { $this->assertNotXPath('//div[contains(@data-osm, "NULL PART")]'); @@ -146,10 +244,7 @@ class NumelKioskMapTest extends NumelKioskMapTestCase { /* hotline: #128879 */ class NumelKioskMapLimit1000Test extends AbstractControllerTestCase { - - protected - $_storm_default_to_volatile = true, - $_mock_sql; + protected $_mock_sql; public function setUp() { parent::setUp(); diff --git a/tests/scenarios/Templates/TemplatesArticlesTest.php b/tests/scenarios/Templates/TemplatesArticlesTest.php index dd1320bba510babe35d5eae205175f262d0deb4b..2daeafa6059431961481def81f13fcc94d6374ec 100644 --- a/tests/scenarios/Templates/TemplatesArticlesTest.php +++ b/tests/scenarios/Templates/TemplatesArticlesTest.php @@ -1022,6 +1022,7 @@ class TemplatesArticlesWithWidgetRenderWallNotLoggedTest 'all_layout' => 'list', 'all_rendering' => 'card-horizontal', 'description_length' => 20, + 'geo_fields' => '123-f-d;941-d-f', 'titre' => '', 'order' => 'RAND()', 'boite' => '', diff --git a/tests/scenarios/Widgets/WidgetsTest.php b/tests/scenarios/Widgets/WidgetsTest.php index c696292a2b6d5aa377d58681c6d27ce6e96d8082..c476c8022adeaeb286eb0b05dea2b7b250b2c113 100644 --- a/tests/scenarios/Widgets/WidgetsTest.php +++ b/tests/scenarios/Widgets/WidgetsTest.php @@ -688,7 +688,7 @@ class WidgetsCacheTest extends AbstractControllerTestCase { public function imageUrlShouldBeRelativeInCache() { $this->assertContains('<img src="' . Class_Url::relative('/userfiles/test.png'), Storm_Cache::getDefaultZendCache() - ->load('seed_cd8b07c4c219ffe0566ca53bcecd90c2')); + ->load('seed_170f2fbece44b9f4f4af3a51c18ed998')); } @@ -707,4 +707,4 @@ class WidgetsCacheTest extends AbstractControllerTestCase { . Class_Url::relative('public/opac/images/buttons/increase_font_size.png') . '"]'); } -} \ No newline at end of file +}