From 448d89804dde620d3a8a11bd9fb25408eef70bd3 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT <hdlaurent@afi-sa.fr> Date: Thu, 4 Feb 2021 16:35:14 +0100 Subject: [PATCH] hotline MT #127427 : fix Jumbotron fatal Error when tab headers were customized --- VERSIONS_HOTLINE/127427 | 1 + .../opac/controllers/CmsController.php | 15 +++++--- .../Library/Wrapper/Record/RichContent.php | 21 ++++++---- .../Wrapper/Record/RichContent/Related.php | 3 +- library/templates/Chili/Template.php | 2 +- .../templates/Chili/View/Jumbotron/Record.php | 2 +- .../Library/View/Wrapper/Abstract.php | 5 +++ .../View/Wrapper/Author/RichContent.php | 16 ++++---- .../Wrapper/DriveCheckoutPlan/RichContent.php | 10 ++--- .../View/Wrapper/Library/RichContent.php | 24 ++++++++---- .../View/Wrapper/Record/RichContent.php | 19 +++++----- .../Wrapper/Record/RichContent/Related.php | 3 +- .../Library/View/Wrapper/ReviewsByRecord.php | 2 +- .../View/Wrapper/RichContent/Abstract.php | 25 +++++------- .../View/Wrapper/RichContent/Section.php | 23 ++++++----- .../Library/View/Wrapper/User/RichContent.php | 20 +++++----- .../Library/View/Wrapper/Work/RichContent.php | 10 ++--- .../View/Abonne/AddRecordsToSelection.php | 4 +- .../Intonation/View/Abonne/ChangeImage.php | 4 +- .../templates/Intonation/View/Abonne/Edit.php | 4 +- .../Intonation/View/Abonne/EditPassword.php | 4 +- .../Intonation/View/Abonne/FollowASearch.php | 4 +- .../Intonation/View/Abonne/LoansBoard.php | 4 +- .../Intonation/View/Abonne/NewSuggestion.php | 4 +- .../Intonation/View/Abonne/RateRecords.php | 4 +- .../Intonation/View/Abonne/RenderSession.php | 3 +- .../Intonation/View/Abonne/SelectionBoard.php | 3 +- .../Intonation/View/Jumbotron/Abstract.php | 11 ++++-- .../Intonation/View/Library/ProArticles.php | 4 +- .../Intonation/View/Library/ProReviews.php | 4 +- .../Intonation/View/Library/SelectionsPro.php | 4 +- .../Templates/TemplatesAbonneTest.php | 38 +++++++++++++++++++ 32 files changed, 170 insertions(+), 130 deletions(-) create mode 100644 VERSIONS_HOTLINE/127427 diff --git a/VERSIONS_HOTLINE/127427 b/VERSIONS_HOTLINE/127427 new file mode 100644 index 00000000000..6a1d8c75068 --- /dev/null +++ b/VERSIONS_HOTLINE/127427 @@ -0,0 +1 @@ + - ticket #127427 : Magasin de Thèmes : Correction de l'affichage des pages lorsque les onglets étaient renommés \ No newline at end of file diff --git a/application/modules/opac/controllers/CmsController.php b/application/modules/opac/controllers/CmsController.php index b259b1a2f24..f5666b6f930 100644 --- a/application/modules/opac/controllers/CmsController.php +++ b/application/modules/opac/controllers/CmsController.php @@ -320,14 +320,17 @@ class CmsController extends ZendAfi_Controller_Action { protected function _loadLibraryAgenda($id) { - $wrapper = new Intonation_Library_View_Wrapper_Library_RichContent_Agenda; - $wrapper - ->setModel(Class_Bib::find($id)) - ->setView($this->view); + $model_wrapper = + new Intonation_Library_View_Wrapper_Library(Class_Bib::find($id), + $this->view); + + $wrapper = + new Intonation_Library_View_Wrapper_Library_RichContent_Agenda($model_wrapper); $this->view->preferences = $wrapper->getPreferences(); - $this->view->calendar = $wrapper->getCalendar($this->_request->getParams(), - $this->_helper->selectedFilters()); + $this->view->calendar = + $wrapper->getCalendar($this->_request->getParams(), + $this->_helper->selectedFilters()); } diff --git a/library/templates/Chili/Library/Wrapper/Record/RichContent.php b/library/templates/Chili/Library/Wrapper/Record/RichContent.php index 43923a5911f..de3ad3f2a8d 100644 --- a/library/templates/Chili/Library/Wrapper/Record/RichContent.php +++ b/library/templates/Chili/Library/Wrapper/Record/RichContent.php @@ -18,17 +18,22 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -use Chili\Library\Wrapper\Record\RichContent\Related; +use Chili\Library\Wrapper\Record\RichContent\Related; class Chili_Library_Wrapper_Record_RichContent extends Intonation_Library_View_Wrapper_Record_RichContent { - protected function _getSectionsInstances() { - return [new Intonation_Library_View_Wrapper_Record_RichContent_Items, - new Intonation_Library_View_Wrapper_Record_RichContent_Details, - new Intonation_Library_View_Wrapper_Record_RichContent_Media, - new Intonation_Library_View_Wrapper_Record_RichContent_Reviews, - new Related, - new Intonation_Library_View_Wrapper_Record_RichContent_Author]; + protected function _getSectionsMap() { + return [Intonation_Library_View_Wrapper_Record_RichContent_Items::class, + Intonation_Library_View_Wrapper_Record_RichContent_Details::class, + Intonation_Library_View_Wrapper_Record_RichContent_Media::class, + Intonation_Library_View_Wrapper_Record_RichContent_Reviews::class, + Related::class, + Intonation_Library_View_Wrapper_Record_RichContent_Author::class]; + } + + + protected function _getWrapper() { + return Chili_Library_Wrapper_Record::class; } } diff --git a/library/templates/Chili/Library/Wrapper/Record/RichContent/Related.php b/library/templates/Chili/Library/Wrapper/Record/RichContent/Related.php index 34334206d09..594222c458c 100644 --- a/library/templates/Chili/Library/Wrapper/Record/RichContent/Related.php +++ b/library/templates/Chili/Library/Wrapper/Record/RichContent/Related.php @@ -21,11 +21,10 @@ namespace Chili\Library\Wrapper\Record\RichContent; - use Intonation\Library\View\Wrapper\Record\RichContent\Related as IntonationRelated; - class Related extends IntonationRelated { + protected function _renderElementCallback() { return function($record) { return $this->_view->cardify(\Class_Template::current()->newWrapper($record, $this->_view)); diff --git a/library/templates/Chili/Template.php b/library/templates/Chili/Template.php index 25fa421ced7..fecfe52c05f 100644 --- a/library/templates/Chili/Template.php +++ b/library/templates/Chili/Template.php @@ -124,7 +124,7 @@ class Chili_Template extends Intonation_Template { public function customUserRichContents($sections) { unset($sections[Intonation_Library_View_Wrapper_User_RichContent::HOME]); - array_unshift($sections, new Chili_Library_Wrapper_User_RichContent_Home()); + array_unshift($sections, 'Chili_Library_Wrapper_User_RichContent_Home'); return $sections; } diff --git a/library/templates/Chili/View/Jumbotron/Record.php b/library/templates/Chili/View/Jumbotron/Record.php index 2d412e02953..2558ddb1c47 100644 --- a/library/templates/Chili/View/Jumbotron/Record.php +++ b/library/templates/Chili/View/Jumbotron/Record.php @@ -22,7 +22,7 @@ class Chili_View_Jumbotron_Record extends Intonation_View_Jumbotron_Record { public function jumbotron_Record($record) { - $this->setShowCurrentSection((new Intonation_Library_View_Wrapper_Record_RichContent_Items()) + $this->setShowCurrentSection((new Intonation_Library_View_Wrapper_Record_RichContent_Items($this->_getRichContent($record)->getWrapperInstance())) ->getClass()); return $this->_core($record); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/Abstract.php index e9744ae38a3..a7e783740c2 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/Abstract.php @@ -55,6 +55,11 @@ abstract class Intonation_Library_View_Wrapper_Abstract { } + public function getView() { + return $this->_view; + } + + public function setModel($model) { $this->_model = $model; return $this; diff --git a/library/templates/Intonation/Library/View/Wrapper/Author/RichContent.php b/library/templates/Intonation/Library/View/Wrapper/Author/RichContent.php index d1994785472..48d3ce31d1c 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Author/RichContent.php +++ b/library/templates/Intonation/Library/View/Wrapper/Author/RichContent.php @@ -37,17 +37,17 @@ class Intonation_Library_View_Wrapper_Author_RichContent extends Intonation_Libr } - protected function _getSectionsInstances() { - return [new Intonation_Library_View_Wrapper_Author_RichContent_Home, - new Intonation_Library_View_Wrapper_Author_RichContent_Biography, - new Intonation_Library_View_Wrapper_Author_RichContent_Records, - new Intonation_Library_View_Wrapper_Author_RichContent_Collaborations, - new Intonation_Library_View_Wrapper_Author_RichContent_Interviews, - new Intonation_Library_View_Wrapper_Author_RichContent_Youtube]; + protected function _getSectionsMap() { + return [Intonation_Library_View_Wrapper_Author_RichContent_Home::class, + Intonation_Library_View_Wrapper_Author_RichContent_Biography::class, + Intonation_Library_View_Wrapper_Author_RichContent_Records::class, + Intonation_Library_View_Wrapper_Author_RichContent_Collaborations::class, + Intonation_Library_View_Wrapper_Author_RichContent_Interviews::class, + Intonation_Library_View_Wrapper_Author_RichContent_Youtube::class]; } protected function _getWrapper() { - return 'Intonation_Library_View_Wrapper_Author'; + return Intonation_Library_View_Wrapper_Author::class; } } diff --git a/library/templates/Intonation/Library/View/Wrapper/DriveCheckoutPlan/RichContent.php b/library/templates/Intonation/Library/View/Wrapper/DriveCheckoutPlan/RichContent.php index 02d3aab0668..b2aeebbdd56 100644 --- a/library/templates/Intonation/Library/View/Wrapper/DriveCheckoutPlan/RichContent.php +++ b/library/templates/Intonation/Library/View/Wrapper/DriveCheckoutPlan/RichContent.php @@ -38,14 +38,14 @@ class Intonation_Library_View_Wrapper_DriveCheckoutPlan_RichContent } - protected function _getSectionsInstances() { - return [new Intonation_Library_View_Wrapper_DriveCheckoutPlan_RichContent_Library, - new Intonation_Library_View_Wrapper_DriveCheckoutPlan_RichContent_Date, - new Intonation_Library_View_Wrapper_DriveCheckoutPlan_RichContent_Time]; + protected function _getSectionsMap() { + return [Intonation_Library_View_Wrapper_DriveCheckoutPlan_RichContent_Library::class, + Intonation_Library_View_Wrapper_DriveCheckoutPlan_RichContent_Date::class, + Intonation_Library_View_Wrapper_DriveCheckoutPlan_RichContent_Time::class]; } protected function _getWrapper() { - return 'Intonation_Library_View_Wrapper_DriveCheckoutPlan'; + return Intonation_Library_View_Wrapper_DriveCheckoutPlan::class; } } \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Library/RichContent.php b/library/templates/Intonation/Library/View/Wrapper/Library/RichContent.php index 5b36a5645ec..181eb67045b 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Library/RichContent.php +++ b/library/templates/Intonation/Library/View/Wrapper/Library/RichContent.php @@ -22,6 +22,14 @@ class Intonation_Library_View_Wrapper_Library_RichContent extends Intonation_Library_View_Wrapper_RichContent_Abstract { + const + HOME = 0, + OPENINGS = 1, + DETAILS = 2, + MAP = 3, + AGENDA = 4, + TEAM = 5; + protected $_navigation; @@ -45,17 +53,17 @@ class Intonation_Library_View_Wrapper_Library_RichContent extends Intonation_Lib } - protected function _getSectionsInstances() { - return [new Intonation_Library_View_Wrapper_Library_RichContent_Home, - new Intonation_Library_View_Wrapper_Library_RichContent_Openings, - new Intonation_Library_View_Wrapper_Library_RichContent_Details, - new Intonation_Library_View_Wrapper_Library_RichContent_Map, - new Intonation_Library_View_Wrapper_Library_RichContent_Agenda, - new Intonation_Library_View_Wrapper_Library_RichContent_Team]; + protected function _getSectionsMap() { + return [self::HOME => Intonation_Library_View_Wrapper_Library_RichContent_Home::class, + self::OPENINGS => Intonation_Library_View_Wrapper_Library_RichContent_Openings::class, + self::DETAILS => Intonation_Library_View_Wrapper_Library_RichContent_Details::class, + self::MAP => Intonation_Library_View_Wrapper_Library_RichContent_Map::class, + self::AGENDA => Intonation_Library_View_Wrapper_Library_RichContent_Agenda::class, + self::TEAM =>Intonation_Library_View_Wrapper_Library_RichContent_Team::class]; } protected function _getWrapper() { - return 'Intonation_Library_View_Wrapper_Library'; + return Intonation_Library_View_Wrapper_Library::class; } } \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent.php b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent.php index 78b0e0d2af0..16520a40c46 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent.php @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + use Intonation\Library\View\Wrapper\Record\RichContent\Related as IntonationRelated; @@ -49,20 +50,20 @@ class Intonation_Library_View_Wrapper_Record_RichContent public function getRowActions() { $actions = array_merge([$this->getNavigation()->getPosition(), $this->getNavigation()->getBackUrl()], - $this->_getWrapperInstance()->getActions()); + $this->getWrapperInstance()->getActions()); return $this->_view->renderActions($actions, ['class' => 'rich_content_row_actions']); } - protected function _getSectionsInstances() { - return [new Intonation_Library_View_Wrapper_Record_RichContent_Home, - new Intonation_Library_View_Wrapper_Record_RichContent_Items, - new Intonation_Library_View_Wrapper_Record_RichContent_Details, - new Intonation_Library_View_Wrapper_Record_RichContent_Media, - new Intonation_Library_View_Wrapper_Record_RichContent_Reviews, - new IntonationRelated, - new Intonation_Library_View_Wrapper_Record_RichContent_Author]; + protected function _getSectionsMap() { + return [Intonation_Library_View_Wrapper_Record_RichContent_Home::class, + Intonation_Library_View_Wrapper_Record_RichContent_Items::class, + Intonation_Library_View_Wrapper_Record_RichContent_Details::class, + Intonation_Library_View_Wrapper_Record_RichContent_Media::class, + Intonation_Library_View_Wrapper_Record_RichContent_Reviews::class, + IntonationRelated::class, + Intonation_Library_View_Wrapper_Record_RichContent_Author::class]; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Related.php b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Related.php index dfb57312be6..4c7f1e3cdea 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Related.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Related.php @@ -18,9 +18,10 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -namespace Intonation\Library\View\Wrapper\Record\RichContent; +namespace Intonation\Library\View\Wrapper\Record\RichContent; + class Related extends \Intonation_Library_View_Wrapper_Record_RichContent_Section { diff --git a/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php b/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php index 0e2e5899cfd..d577ac18541 100644 --- a/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php +++ b/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php @@ -64,7 +64,7 @@ class Intonation_Library_View_Wrapper_ReviewsByRecord extends Intonation_Library public function getMainLink() { - $nav_url = (new Intonation_Library_View_Wrapper_Record_RichContent_Reviews)->getNavUrl(); + $nav_url = (new Intonation_Library_View_Wrapper_Record_RichContent_Reviews($this->_record))->getNavUrl(); $nav_url ['id'] = $this->_record->getModel()->getId(); return new Intonation_Library_Link(['Url' => $nav_url, 'Image' => Class_Template::current()->getIco($this->_view, diff --git a/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php index 09fb489ac67..a38c2d62515 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php @@ -64,23 +64,18 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Abstract { if ($this->_sections) return $this->_sections; - $instances = $this->_getSectionsInstances(); - - return $this->_sections = array_map(function($instance) - { - $wrapper = $this->_getWrapper(); - return $instance - ->setModel($this->_model) - ->setWrapped((new $wrapper()) - ->setModel($this->_model) - ->setView($this->_view)) - ->setView($this->_view); - }, - $instances); + $map = $this->_getSectionsMap(); + + return $this->_sections = + array_map(function($class) + { + return new $class($this->getWrapperInstance()); + }, + $map); } - protected function _getWrapperInstance() { + public function getWrapperInstance() { $wrapper_class = $this->_getWrapper() ? $this->_getWrapper() : Intonation_Library_View_Wrapper_Null::class; @@ -111,7 +106,7 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Abstract { abstract public function getRowActions(); - abstract protected function _getSectionsInstances(); + abstract protected function _getSectionsMap(); abstract protected function _getWrapper(); } diff --git a/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php b/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php index ab5ab59169d..e55f8c7a0ae 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php +++ b/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php @@ -27,17 +27,18 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Section { protected $_view, $_model, - $_wrapped, + $_wrapper, $_content, $_visible = false, $_ajax = false, $_is_active = false; - public function __construct($model = null , $view = null) { + public function __construct($wrapper) { $this - ->setModel($model) - ->setView($view); + ->setWrapper($wrapper) + ->setModel($this->getWrapper()->getModel()) + ->setView($this->getWrapper()->getView()); } @@ -58,14 +59,14 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Section { } - public function setWrapped($wrapped) { - $this->_wrapped = $wrapped; + public function setWrapper($wrapper) { + $this->_wrapper = $wrapper; return $this; } - public function getWrapped() { - return $this->_wrapped; + public function getWrapper() { + return $this->_wrapper; } @@ -113,8 +114,9 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Section { $data_name = 'getLabel_' . $this->getClass(); return $settings->$data_name(); }); + return $title - ? sprintf($title, $this->_wrapped->getMainTitle()) + ? sprintf($title, $this->getWrapper()->getMainTitle()) : $this->getTitle(); } @@ -125,8 +127,9 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Section { $data_name = 'getTitle_' . $this->getClass(); return $settings->$data_name(); }); + return $nav_title - ? sprintf($nav_title, $this->_wrapped->getMainTitle()) + ? sprintf($nav_title, $this->getWrapper()->getMainTitle()) : $this->getNavTitle(); } diff --git a/library/templates/Intonation/Library/View/Wrapper/User/RichContent.php b/library/templates/Intonation/Library/View/Wrapper/User/RichContent.php index dd444471837..2a017af6756 100644 --- a/library/templates/Intonation/Library/View/Wrapper/User/RichContent.php +++ b/library/templates/Intonation/Library/View/Wrapper/User/RichContent.php @@ -50,16 +50,16 @@ class Intonation_Library_View_Wrapper_User_RichContent } - protected function _getSectionsInstances() { - $sections = [self::HOME => new Intonation_Library_View_Wrapper_User_RichContent_Home, - self::INFO => new Intonation_Library_View_Wrapper_User_RichContent_Informations, - self::LOANS => new Intonation_Library_View_Wrapper_User_RichContent_Loans, - self::HOLDS => new Intonation_Library_View_Wrapper_User_RichContent_Holds, - self::SUGGESTIONS => new Intonation_Library_View_Wrapper_User_RichContent_Suggestions, - self::SELECTIONS => new Intonation_Library_View_Wrapper_User_RichContent_Selections, - self::REVIEWS => new Intonation_Library_View_Wrapper_User_RichContent_Reviews, - self::AGENDA => new Intonation_Library_View_Wrapper_User_RichContent_Agenda, - self::SETTINGS => new Intonation_Library_View_Wrapper_User_RichContent_Settings + protected function _getSectionsMap() { + $sections = [self::HOME => Intonation_Library_View_Wrapper_User_RichContent_Home::class, + self::INFO => Intonation_Library_View_Wrapper_User_RichContent_Informations::class, + self::LOANS => Intonation_Library_View_Wrapper_User_RichContent_Loans::class, + self::HOLDS => Intonation_Library_View_Wrapper_User_RichContent_Holds::class, + self::SUGGESTIONS => Intonation_Library_View_Wrapper_User_RichContent_Suggestions::class, + self::SELECTIONS => Intonation_Library_View_Wrapper_User_RichContent_Selections::class, + self::REVIEWS => Intonation_Library_View_Wrapper_User_RichContent_Reviews::class, + self::AGENDA => Intonation_Library_View_Wrapper_User_RichContent_Agenda::class, + self::SETTINGS => Intonation_Library_View_Wrapper_User_RichContent_Settings::class ]; return Class_Template::current()->customUserRichContents($sections); diff --git a/library/templates/Intonation/Library/View/Wrapper/Work/RichContent.php b/library/templates/Intonation/Library/View/Wrapper/Work/RichContent.php index 8d6791a5458..5af9bf8df25 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Work/RichContent.php +++ b/library/templates/Intonation/Library/View/Wrapper/Work/RichContent.php @@ -55,16 +55,16 @@ class Intonation_Library_View_Wrapper_Work_RichContent public function getRowActions() { $actions = array_merge([$this->getNavigation()->getPosition(), $this->getNavigation()->getBackUrl()], - $this->_getWrapperInstance()->getActions()); + $this->getWrapperInstance()->getActions()); return $this->_view->renderActions($actions, ['class' => 'rich_content_row_actions']); } - protected function _getSectionsInstances() { - return [new Intonation_Library_View_Wrapper_Work_RichContent_Home, - new Intonation_Library_View_Wrapper_Work_RichContent_Items, - new Intonation_Library_View_Wrapper_Work_RichContent_Author]; + protected function _getSectionsMap() { + return [Intonation_Library_View_Wrapper_Work_RichContent_Home::class, + Intonation_Library_View_Wrapper_Work_RichContent_Items::class, + Intonation_Library_View_Wrapper_Work_RichContent_Author::class]; } diff --git a/library/templates/Intonation/View/Abonne/AddRecordsToSelection.php b/library/templates/Intonation/View/Abonne/AddRecordsToSelection.php index cc7f7a947b0..220a87340eb 100644 --- a/library/templates/Intonation/View/Abonne/AddRecordsToSelection.php +++ b/library/templates/Intonation/View/Abonne/AddRecordsToSelection.php @@ -36,11 +36,9 @@ class Intonation_View_Abonne_AddRecordsToSelection extends Intonation_View_Abonn protected function _hookOn($rich_content) { $sections = $rich_content->getSections(); - $sections [Intonation_Library_View_Wrapper_User_RichContent::SELECTIONS] = (new Intonation_Library_View_Wrapper_User_RichContent_AddRecordsToSelection) - ->setModel($rich_content->getModel()) + $sections [Intonation_Library_View_Wrapper_User_RichContent::SELECTIONS] = (new Intonation_Library_View_Wrapper_User_RichContent_AddRecordsToSelection($rich_content->getWrapperInstance())) ->setCriteria($this->_criteria) ->setSelection($this->_selection) - ->setView($this->view) ->beActive() ->beVisible(); diff --git a/library/templates/Intonation/View/Abonne/ChangeImage.php b/library/templates/Intonation/View/Abonne/ChangeImage.php index aa8ecb45123..0d939f0f546 100644 --- a/library/templates/Intonation/View/Abonne/ChangeImage.php +++ b/library/templates/Intonation/View/Abonne/ChangeImage.php @@ -30,9 +30,7 @@ class Intonation_View_Abonne_ChangeImage extends Intonation_View_Abonne_Tab { protected function _hookOn($rich_content) { $sections = $rich_content->getSections(); - $sections [Intonation_Library_View_Wrapper_User_RichContent::SETTINGS] = (new Intonation_Library_View_Wrapper_User_RichContent_ChangeImage) - ->setModel($this->view->user) - ->setView($this->view) + $sections [Intonation_Library_View_Wrapper_User_RichContent::SETTINGS] = (new Intonation_Library_View_Wrapper_User_RichContent_ChangeImage($rich_content->getWrapperInstance())) ->beActive() ->beVisible(); diff --git a/library/templates/Intonation/View/Abonne/Edit.php b/library/templates/Intonation/View/Abonne/Edit.php index 0d6fc14a407..906d1f6810a 100644 --- a/library/templates/Intonation/View/Abonne/Edit.php +++ b/library/templates/Intonation/View/Abonne/Edit.php @@ -30,9 +30,7 @@ class Intonation_View_Abonne_Edit extends Intonation_View_Abonne_Tab { protected function _hookOn($rich_content) { $sections = $rich_content->getSections(); - $sections [Intonation_Library_View_Wrapper_User_RichContent::INFO] = (new Intonation_Library_View_Wrapper_User_RichContent_EditInformations) - ->setModel($this->view->user) - ->setView($this->view) + $sections [Intonation_Library_View_Wrapper_User_RichContent::INFO] = (new Intonation_Library_View_Wrapper_User_RichContent_EditInformations($rich_content->getWrapperInstance())) ->setContent($this->view->renderForm($this->view->form)) ->beActive() ->beVisible(); diff --git a/library/templates/Intonation/View/Abonne/EditPassword.php b/library/templates/Intonation/View/Abonne/EditPassword.php index d118468e9c6..7ad7a5dcad9 100644 --- a/library/templates/Intonation/View/Abonne/EditPassword.php +++ b/library/templates/Intonation/View/Abonne/EditPassword.php @@ -39,9 +39,7 @@ class Intonation_View_Abonne_EditPassword extends Intonation_View_Abonne_Tab { ->setTitle($this->_('Réinitialisé mon mot de passe'))); - $sections [Intonation_Library_View_Wrapper_User_RichContent::INFO] = (new Intonation_Library_View_Wrapper_User_RichContent_EditPassword) - ->setModel($this->view->user) - ->setView($this->view) + $sections [Intonation_Library_View_Wrapper_User_RichContent::INFO] = (new Intonation_Library_View_Wrapper_User_RichContent_EditPassword($rich_content->getWrapperInstance())) ->setContent($content) ->beActive() ->beVisible(); diff --git a/library/templates/Intonation/View/Abonne/FollowASearch.php b/library/templates/Intonation/View/Abonne/FollowASearch.php index b34f104307d..8a3867b86e4 100644 --- a/library/templates/Intonation/View/Abonne/FollowASearch.php +++ b/library/templates/Intonation/View/Abonne/FollowASearch.php @@ -33,10 +33,8 @@ class Intonation_View_Abonne_FollowASearch extends Intonation_View_Abonne_Tab { protected function _hookOn($rich_content) { $sections = $rich_content->getSections(); - $sections [Intonation_Library_View_Wrapper_User_RichContent::SELECTIONS] = (new Intonation_Library_View_Wrapper_User_RichContent_FollowASearch) - ->setModel($rich_content->getModel()) + $sections [Intonation_Library_View_Wrapper_User_RichContent::SELECTIONS] = (new Intonation_Library_View_Wrapper_User_RichContent_FollowASearch($rich_content->getWrapperInstance())) ->setCriteria($this->_criteria) - ->setView($this->view) ->beActive() ->beVisible(); diff --git a/library/templates/Intonation/View/Abonne/LoansBoard.php b/library/templates/Intonation/View/Abonne/LoansBoard.php index 5a3206e0fac..112fd5d3f7e 100644 --- a/library/templates/Intonation/View/Abonne/LoansBoard.php +++ b/library/templates/Intonation/View/Abonne/LoansBoard.php @@ -40,9 +40,7 @@ class Intonation_View_Abonne_LoansBoard extends ZendAfi_View_Helper_BaseHelper { $sections = $rich_content->getSections(); - $sections [Intonation_Library_View_Wrapper_User_RichContent::LOANS] = (new Intonation_Library_View_Wrapper_User_RichContent_LoansHistory) - ->setModel($this->view->user) - ->setView($this->view) + $sections [Intonation_Library_View_Wrapper_User_RichContent::LOANS] = (new Intonation_Library_View_Wrapper_User_RichContent_LoansHistory($rich_content->getWrapperInstance())) ->beActive() ->beVisible(); diff --git a/library/templates/Intonation/View/Abonne/NewSuggestion.php b/library/templates/Intonation/View/Abonne/NewSuggestion.php index 07c9f5f6b8d..b169b09d4c7 100644 --- a/library/templates/Intonation/View/Abonne/NewSuggestion.php +++ b/library/templates/Intonation/View/Abonne/NewSuggestion.php @@ -39,9 +39,7 @@ class Intonation_View_Abonne_NewSuggestion extends Intonation_View_Abonne_Tab { protected function _hookOn($rich_content) { $sections = $rich_content->getSections(); - $sections [Intonation_Library_View_Wrapper_User_RichContent::SUGGESTIONS] = (new Intonation_Library_View_Wrapper_User_RichContent_NewSuggestion) - ->setModel($this->view->user) - ->setView($this->view) + $sections [Intonation_Library_View_Wrapper_User_RichContent::SUGGESTIONS] = (new Intonation_Library_View_Wrapper_User_RichContent_NewSuggestion($rich_content->getWrapperInstance())) ->setForm($this->_form) ->setPreferences($this->_preferences) ->setRecords($this->_records) diff --git a/library/templates/Intonation/View/Abonne/RateRecords.php b/library/templates/Intonation/View/Abonne/RateRecords.php index 9ee158b45f0..5ed60fdbcbd 100644 --- a/library/templates/Intonation/View/Abonne/RateRecords.php +++ b/library/templates/Intonation/View/Abonne/RateRecords.php @@ -32,10 +32,8 @@ class Intonation_View_Abonne_RateRecords extends Intonation_View_Abonne_Tab { protected function _hookOn($rich_content) { $sections = $rich_content->getSections(); - $sections [Intonation_Library_View_Wrapper_User_RichContent::REVIEWS] = (new Intonation_Library_View_Wrapper_User_RichContent_RateRecords) - ->setModel($rich_content->getModel()) + $sections [Intonation_Library_View_Wrapper_User_RichContent::REVIEWS] = (new Intonation_Library_View_Wrapper_User_RichContent_RateRecords($rich_content->getWrapperInstance())) ->setCriteria($this->_criteria) - ->setView($this->view) ->beActive() ->beVisible(); diff --git a/library/templates/Intonation/View/Abonne/RenderSession.php b/library/templates/Intonation/View/Abonne/RenderSession.php index 8dbd268a29e..20ba9624487 100644 --- a/library/templates/Intonation/View/Abonne/RenderSession.php +++ b/library/templates/Intonation/View/Abonne/RenderSession.php @@ -33,9 +33,8 @@ class Intonation_View_Abonne_RenderSession extends Intonation_View_Abonne_Tab { protected function _hookOn($rich_content) { $sections = $rich_content->getSections(); - $sections [Intonation_Library_View_Wrapper_User_RichContent::AGENDA] = (new Intonation_Library_View_Wrapper_User_RichContent_Session) + $sections [Intonation_Library_View_Wrapper_User_RichContent::AGENDA] = (new Intonation_Library_View_Wrapper_User_RichContent_Session($rich_content->getWrapperInstance())) ->setModel($this->_activity_session) - ->setView($this->view) ->beActive() ->beVisible(); diff --git a/library/templates/Intonation/View/Abonne/SelectionBoard.php b/library/templates/Intonation/View/Abonne/SelectionBoard.php index 26c19d14ea2..b792c2566b6 100644 --- a/library/templates/Intonation/View/Abonne/SelectionBoard.php +++ b/library/templates/Intonation/View/Abonne/SelectionBoard.php @@ -31,9 +31,8 @@ class Intonation_View_Abonne_SelectionBoard extends Intonation_View_Abonne_Tab { protected function _hookOn($rich_content) { $sections = $rich_content->getSections(); - $sections [Intonation_Library_View_Wrapper_User_RichContent::SELECTIONS] = (new Intonation_Library_View_Wrapper_User_RichContent_Selection) + $sections [Intonation_Library_View_Wrapper_User_RichContent::SELECTIONS] = (new Intonation_Library_View_Wrapper_User_RichContent_Selection($rich_content->getWrapperInstance())) ->setModel($this->view->selection) - ->setView($this->view) ->beActive() ->beVisible(); diff --git a/library/templates/Intonation/View/Jumbotron/Abstract.php b/library/templates/Intonation/View/Jumbotron/Abstract.php index c792c0aabcb..2a87a6022f6 100644 --- a/library/templates/Intonation/View/Jumbotron/Abstract.php +++ b/library/templates/Intonation/View/Jumbotron/Abstract.php @@ -34,9 +34,7 @@ abstract class Intonation_View_Jumbotron_Abstract extends ZendAfi_View_Helper_Ba ->setView($this->view) ->setModel($model); - $rich_content = $this->_getRichContentInstance() - ->setView($this->view) - ->setModel($model); + $rich_content = $this->_getRichContent($model); $this->_hookOn($rich_content); $this->_showSections($rich_content->getSections()); @@ -49,6 +47,13 @@ abstract class Intonation_View_Jumbotron_Abstract extends ZendAfi_View_Helper_Ba } + protected function _getRichContent($model) { + return $this->_getRichContentInstance() + ->setView($this->view) + ->setModel($model); + } + + protected function _renderHTML($wrapped) { return $this->view->jumbotron($wrapped); } diff --git a/library/templates/Intonation/View/Library/ProArticles.php b/library/templates/Intonation/View/Library/ProArticles.php index 08bbce4a904..d05726dedba 100644 --- a/library/templates/Intonation/View/Library/ProArticles.php +++ b/library/templates/Intonation/View/Library/ProArticles.php @@ -42,9 +42,7 @@ class Intonation_View_Library_ProArticles extends Intonation_View_Library { protected function _hookOn($rich_content) { $sections = $rich_content->getSections(); - $sections [5] = (new Intonation_Library_View_Wrapper_Library_RichContent_ProArticles) - ->setModel($this->view->library) - ->setView($this->view) + $sections [Intonation_Library_View_Wrapper_Library_RichContent::TEAM] = (new Intonation_Library_View_Wrapper_Library_RichContent_ProArticles($rich_content->getWrapperInstance())) ->setPro($this->_pro) ->beActive() ->beVisible(); diff --git a/library/templates/Intonation/View/Library/ProReviews.php b/library/templates/Intonation/View/Library/ProReviews.php index da8d8d81342..b2783c93d6a 100644 --- a/library/templates/Intonation/View/Library/ProReviews.php +++ b/library/templates/Intonation/View/Library/ProReviews.php @@ -42,9 +42,7 @@ class Intonation_View_Library_ProReviews extends Intonation_View_Library { protected function _hookOn($rich_content) { $sections = $rich_content->getSections(); - $sections [5] = (new Intonation_Library_View_Wrapper_Library_RichContent_ProReviews) - ->setModel($this->view->library) - ->setView($this->view) + $sections [Intonation_Library_View_Wrapper_Library_RichContent::TEAM] = (new Intonation_Library_View_Wrapper_Library_RichContent_ProReviews($rich_content->getWrapperInstance())) ->setPro($this->_pro) ->beActive() ->beVisible(); diff --git a/library/templates/Intonation/View/Library/SelectionsPro.php b/library/templates/Intonation/View/Library/SelectionsPro.php index 5aa7e52b17a..44ca87775cd 100644 --- a/library/templates/Intonation/View/Library/SelectionsPro.php +++ b/library/templates/Intonation/View/Library/SelectionsPro.php @@ -42,9 +42,7 @@ class Intonation_View_Library_SelectionsPro extends Intonation_View_Library { protected function _hookOn($rich_content) { $sections = $rich_content->getSections(); - $sections [5] = (new Intonation_Library_View_Wrapper_Library_RichContent_SelectionsPro) - ->setModel($this->view->library) - ->setView($this->view) + $sections [Intonation_Library_View_Wrapper_Library_RichContent::TEAM] = (new Intonation_Library_View_Wrapper_Library_RichContent_SelectionsPro($rich_content->getWrapperInstance())) ->setPro($this->_pro) ->beActive() ->beVisible(); diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index e79a616e9d3..6637201f2bc 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -1101,4 +1101,42 @@ class TemplatesDispatchAbonneCardsTest extends TemplatesIntonationAccountTestCas public function shouldForwardToConfigurationsAction() { $this->assertXPathContentContains('//div//h2[contains(@class, "jumbotron_section_title")]', 'Mes configurations'); } +} + + +class TemplatesDispatchAbonnePagesTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + $this->_buildTemplateProfil(['id' => 200]); + + $conf = (new Class_Systeme_Widget_Action) + ->setId('abonne_fiche') + ->setProfileId(200) + ->load(); + + $conf + ->setNewDatas(['IntonationLabelUserSelections' => 'Favoris', + 'IntonationTitleUserSelections' => 'Favoris', + 'IntonationLabelUserReviews' => '%s donne ton avis', + 'IntonationTitleUserReviews' => '%s donne ton avis']) + ->updateProfile(); + + Class_Users::getIdentity()->setLogin('josh'); + } + + + /** @test */ + public function followASearchPageTitleShouldBeSuivreUneRecherche() { + $this->dispatch('/opac/abonne/suivre-une-recherche/'); + $this->assertXPath('//li/a[@title="Favoris"]'); + } + + + /** @test */ + public function donnerDesAvissectionTitleShouldBeDonnerDesAvis() { + $this->dispatch('/opac/abonne/donner-des-avis/'); + $this->assertXPath('//li/a[@title="josh donne ton avis"]'); + } } \ No newline at end of file -- GitLab