Commit 933e4c25 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev: #156997: refacto MT view helper

parent 30e9c086
- fonctionnalité #156997 : Amélioration du système de fichiers du magasin de thèmes.
\ No newline at end of file
......@@ -272,8 +272,8 @@ class CmsController extends ZendAfi_Controller_Action {
if (!$this->_getParam('render') === 'ajax')
return;
$content = $this->view->calendarLinkToAll($this->view->calendar,
$this->view->preferences);
$content = $this->view->calendarContentForAjax($this->view->calendar,
$this->view->preferences);
$this->_helper->getHelper('HTMLAjaxResponse')
->htmlAjaxResponseWithScript($content);
......
......@@ -15,9 +15,9 @@ Un profil te donnera toujours un thème courant : historique si la colonne templ
Intonation est le theme "parent". Tous les autres themes apportent des petites variations,
a l'exception du theme Chili qui surcharge certaines fonctions de Intonation.
La librairie de composant graphique utilisee se trouve dans Intonation/View.
La librairie de composant graphique utilisee se trouve dans library/ZendAfi/View/Helper/Template ainsi que dans library/ZendAfi/View/Helper/[thème courant ex:Intonation].
C'est un objet wrapper qui utilise une interface qui va faire la liaison entre un modele et un composant d'affichage.
C'est un objet wrapper qui utilise une API qui va faire la liaison entre un modele et un composant d'affichage.
Le Wrapper est l'objet qui va permettre a la vue de recuperer des proprietes d'objets, quelle que soit le type d'objet qui est affiché.
......@@ -41,9 +41,10 @@ Intonation/Library/Widget/Carousell/View.php
Intonation_View_RenderWallGrid
Intonation_View_RenderMap
Les rendus de wrapper Intonation/View:
CardifyFullDescription.php
CardifyHorizontal.php
CardifyOnlyDescription.php
Cardify.php
CardifyWithOverlay.php
\ No newline at end of file
Les rendus de wrapper library/ZendAfi/View/Helper/Template:
RenderingAllDescription.php
RenderingHorizontal.php
RenderingDescription.php
RenderingVertical.php
RenderingOnlyImage.php
\ No newline at end of file
......@@ -34,7 +34,7 @@ class ZendAfi_Controller_Action_Helper_Ajax extends ZendAfi_Controller_Action_He
if (!$html = $callback())
return $this->getResponse()->setHttpResponseCode(404);
$ajax = (new Intonation_View_Ajax(Class_Template::current(), $this->_view))
$ajax = (new ZendAfi_View_Helper_Template_Ajax(Class_Template::current(), $this->_view))
->setBody($html);
$this->_response->setHeader('Content-Type', 'text/html;charset=utf-8');
......
......@@ -84,6 +84,7 @@ class ZendAfi_Controller_Action_Helper_ViewRenderer extends Zend_Controller_Acti
$this->view->addHelperPath('ZendAfi/View/Helper/Java', 'ZendAfi_View_Helper_Java');
$this->view->addHelperPath('ZendAfi/View/Helper/Accueil', 'ZendAfi_View_Helper_Accueil');
$this->view->addScriptPath('.' . $profil_path . 'html');
Class_Template::current()->addAdminHelperPath($this->view);
Class_Template::current()->addHelperPath($this->view);
return $this;
......
<?php
/**
* Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved.
* Copyright (c) 2012-2022, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
......@@ -20,7 +20,7 @@
*/
class Intonation_View_Abonne extends ZendAfi_View_Helper_BaseHelper {
class ZendAfi_View_Helper_Template_Abonne extends ZendAfi_View_Helper_BaseHelper {
public function abonne($user) {
return $this->view->jumbotron_Abonne($user);
......
......@@ -20,7 +20,7 @@
*/
class Intonation_View_AddBootstrap extends ZendAfi_View_Helper_BaseHelper {
class ZendAfi_View_Helper_Template_AddBootstrap extends ZendAfi_View_Helper_BaseHelper {
public function addBootstrap($script_loader = null) {
$script_loader = $script_loader
? $script_loader
......
<?php
/**
* Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved.
* Copyright (c) 2012-2022, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
......@@ -20,8 +20,10 @@
*/
class Intonation_View_AdvancedSearch extends ZendAfi_View_Helper_AdvancedSearch {
protected function _renderHtml($html) {
class ZendAfi_View_Helper_Template_AdvancedSearch
extends ZendAfi_View_Helper_AdvancedSearch {
protected function _renderHtml($html) {
$this->view->titre = $this->view->_current_module['preferences']['titre'];
$title = $this->_tag('h1',
......
......@@ -20,7 +20,7 @@
*/
class Intonation_View_Ajax extends Intonation_View_Opac {
class ZendAfi_View_Helper_Template_Ajax extends Intonation_View_Opac {
protected $_body;
......@@ -40,4 +40,4 @@ class Intonation_View_Ajax extends Intonation_View_Opac {
return $head . $this->_body;
}
}
\ No newline at end of file
}
......@@ -20,7 +20,8 @@
*/
class Intonation_View_AlbumAudioJsPlayer extends ZendAfi_View_Helper_BaseHelper {
class ZendAfi_View_Helper_Template_AlbumAudioJsPlayer extends ZendAfi_View_Helper_BaseHelper {
public function albumAudioJsPlayer($album) {
$tracks = (new Storm_Model_Collection($album->getAudioTracks()))
->collect(function($track)
......
......@@ -20,7 +20,7 @@
*/
class Intonation_View_BookmarkedSearches extends ZendAfi_View_Helper_BaseHelper {
class ZendAfi_View_Helper_Template_BookmarkedSearches extends ZendAfi_View_Helper_BaseHelper {
public function bookmarkedSearches($searches) {
$searches = array_map(function($search)
......@@ -31,7 +31,7 @@ class Intonation_View_BookmarkedSearches extends ZendAfi_View_Helper_BaseHelper
}, $searches);
$callback = function($wrapped) {
return $this->view->cardifyHorizontal($wrapped);
return $this->view->renderingHorizontal($wrapped);
};
$html = $this->_tag('h3',
......@@ -57,4 +57,4 @@ class Intonation_View_BookmarkedSearches extends ZendAfi_View_Helper_BaseHelper
->setImage($this->view->templateIco('no-selection',
'library'))]);
}
}
\ No newline at end of file
}
......@@ -20,7 +20,8 @@
*/
class Intonation_View_CalendarContent extends ZendAfi_View_Helper_CalendarContent {
class ZendAfi_View_Helper_Template_CalendarContent extends ZendAfi_View_Helper_CalendarContent {
protected function _renderHTML($calendar, $settings) {
Class_ScriptLoader::getInstance()->addOPACScript('calendrier');
......
......@@ -20,8 +20,8 @@
*/
class Intonation_View_CalendarLinkToAll extends Intonation_View_CalendarContent {
public function calendarLinkToAll($calendar, $settings) {
class ZendAfi_View_Helper_Template_CalendarContentForAjax extends ZendAfi_View_Helper_Template_CalendarContent {
public function calendarContentForAjax($calendar, $settings) {
$temp_settings = [];
if (is_array($settings)) {
foreach($settings as $key => $value)
......
......@@ -20,7 +20,8 @@
*/
class Intonation_View_CardHelper extends ZendAfi_View_Helper_BaseHelper {
abstract class ZendAfi_View_Helper_Template_CardHelper extends ZendAfi_View_Helper_BaseHelper {
protected function _addTitle($element, $content) {
$element_class = get_class($element);
if (!$main_title = $element->getMainTitle())
......@@ -35,8 +36,7 @@ class Intonation_View_CardHelper extends ZendAfi_View_Helper_BaseHelper {
}
public function _getTitleLink($main_title, $element) {
protected function _getTitleLink($main_title, $element) {
if (! $link = $element->getMainLink())
return $main_title;
......
......@@ -20,7 +20,9 @@
*/
class Intonation_View_DriveCheckoutPlan extends Intonation_View_Jumbotron_Abstract {
class ZendAfi_View_Helper_Template_DriveCheckoutPlan
extends Intonation_View_Jumbotron_Abstract {
public function driveCheckoutPlan($plan) {
return $this->_core($plan);
}
......
......@@ -20,8 +20,10 @@
*/
class Intonation_View_DNone extends ZendAfi_View_Helper_BaseHelper {
public function dNone($html) {
class ZendAfi_View_Helper_Template_HideContentForJS
extends ZendAfi_View_Helper_BaseHelper {
public function hideContentForJS($html) {
$text = preg_replace('/(<(script|style|link)\b[^>]*>).*?(<\/\2>)/is', "", $html);
$text = str_replace( '<', ' <', $text);
......@@ -30,6 +32,6 @@ class Intonation_View_DNone extends ZendAfi_View_Helper_BaseHelper {
$text = preg_replace('/(\p{P}|\t|\n|\v|\f|\r| |\xC2\x85|\xc2\xa0|\xe1\xa0\x8e|\xe2\x80[\x80-\x8D]|\xe2\x80\xa8|\xe2\x80\xa9|\xe2\x80\xaF|\xe2\x81\x9f|\xe2\x81\xa0|\xe3\x80\x80|\xef\xbb\xbf)+/', ' ', $text);
return $this->view->div(['class' => 'hidde_content'], $text);
return $this->_div(['class' => 'hidde_content'], $text);
}
}
......@@ -20,9 +20,9 @@
*/
class Intonation_View_CardifyFullDescription extends Intonation_View_CardHelper {
class ZendAfi_View_Helper_Template_RenderingAllDescription extends ZendAfi_View_Helper_Template_CardHelper {
public function cardifyFullDescription($element) {
public function renderingAllDescription($element) {
$content = [$element->getContentForJSSearch()];
$content = $this->_addTitle($element, $content);
......@@ -48,7 +48,7 @@ class Intonation_View_CardifyFullDescription extends Intonation_View_CardHelper
$html [] = $this->view->renderActionsInRow(array_merge([$element->getMainLink()],
$element->getActions()));
return $this->view->div(['class' => 'card'],
return $this->view->div(['class' => 'card rendering_all_description'],
implode($html));
}
}
\ No newline at end of file
}
......@@ -20,9 +20,9 @@
*/
class Intonation_View_CardifyOnlyDescription extends Intonation_View_CardHelper {
class ZendAfi_View_Helper_Template_RenderingDescription extends ZendAfi_View_Helper_Template_CardHelper {
public function cardifyOnlyDescription($element, $img = '') {
public function renderingDescription($element, $img = '') {
$element_class = get_class($element);
$content = [$element->getContentForJSSearch()];
$content = $this->_addTitle($element, $content);
......@@ -68,4 +68,4 @@ class Intonation_View_CardifyOnlyDescription extends Intonation_View_CardHelper
. implode($html),
['class' => 'card card_template card_' . $element_class]);
}
}
\ No newline at end of file
}
......@@ -20,7 +20,7 @@
*/
class Intonation_View_CardifyHorizontal extends Intonation_View_CardHelper {
class ZendAfi_View_Helper_Template_RenderingHorizontal extends ZendAfi_View_Helper_Template_CardHelper {
protected
......@@ -29,7 +29,7 @@ class Intonation_View_CardifyHorizontal extends Intonation_View_CardHelper {
$_actions_class = 'cardify_horizontal_actions';
public function cardifyHorizontal($element) {
public function renderingHorizontal($element) {
$img = $this->view->tagMedia($element, ['class' => 'img-thumbnail',
'aria-hidden' => 'true']);
......
......@@ -20,10 +20,10 @@
*/
class Intonation_View_CardifyWithOverlay extends ZendAfi_View_Helper_BaseHelper {
class ZendAfi_View_Helper_Template_RenderingOnlyImage
extends ZendAfi_View_Helper_BaseHelper {
public function cardifyWithOverlay($element) {
public function renderingOnlyImage($element) {
return $this->_tag('div',
$element->getAnchor()
. $this->_cardWithPicture($element),
......@@ -42,4 +42,4 @@ class Intonation_View_CardifyWithOverlay extends ZendAfi_View_Helper_BaseHelper
return $img
. $this->view->div(['class' => 'card_overlay'], $overlay);
}
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment