Skip to content
Snippets Groups Projects
Commit 6b91c323 authored by lbrun's avatar lbrun
Browse files

dev#37281 :

refacto bibnum view helper (strategy)
parent ce187fef
Branches
Tags
5 merge requests!1587Master,!1553Master,!1539Master,!1533Dev#37281 nouvelle sitotheque dans une boite bibliotheque numerique pouvoir choisir d afficher les ressources les plus recentes,!1520Dev#37281 nouvelle sitotheque dans une boite bibliotheque numerique pouvoir choisir d afficher les ressources les plus recentes
- ticket #37281 : Configuration : Boite bibliothèque numérique : Possibilite d'affichage pagine
\ No newline at end of file
......@@ -16,26 +16,30 @@
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_Systeme_ModulesAccueil_BibliothequeNumerique extends Class_Systeme_ModulesAccueil_Null {
const DISPLAY_TREE = 'displayTree';
const DISPLAY_ALBUM_TEASER = 'displayAlbumTeaser';
const DISPLAY_PAGINATED = 'displayPaginated';
const ORDER_RESPECT = 'orderRespect';
const ORDER_RANDOM = 'orderRandom';
const ORDER_RECENT = 'orderRecent';
/** @var array */
protected $_displayModes = array(self::DISPLAY_TREE => 'Arborescence',
self::DISPLAY_ALBUM_TEASER => 'Mise en avant d\'un album');
protected $_displayModes = [self::DISPLAY_TREE => 'Arborescence',
self::DISPLAY_ALBUM_TEASER => 'Mise en avant d\'un album',
self::DISPLAY_PAGINATED => 'Affichage paginé'];
/** @var array */
protected $_orderModes = array(self::ORDER_RESPECT => 'Respecter l\'ordre',
self::ORDER_RANDOM => 'Aléatoire');
protected $_orderModes = [self::ORDER_RESPECT => 'Respecter l\'ordre',
self::ORDER_RANDOM => 'Aléatoire',
self::ORDER_RECENT => 'Les plus récents'];
/** @var string */
protected $_group = Class_Systeme_ModulesAccueil::GROUP_INFO;
/** @var string */
protected $_libelle = 'Bibliothèque numérique';
......@@ -66,7 +70,7 @@ class Class_Systeme_ModulesAccueil_BibliothequeNumerique extends Class_Systeme_M
return $this->_displayModes;
}
/** @return array */
public function getOrderModes() {
return $this->_orderModes;
......
......@@ -19,99 +19,188 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_View_Helper_Accueil_BibNumerique extends ZendAfi_View_Helper_Accueil_Base {
protected $_slideshow;
protected $_slideshow, $strategy;
public function __construct($id_module,$params) {
parent::__construct($id_module,$params);
$this->preferences = array_merge(array('id_albums' => ''),
$this->preferences);
$this->preferences = array_merge(['id_albums' => ''], $this->preferences);
}
public function displayNumericRessources() {
if (!$album = Class_Album::getLoader()->find((int)$this->preferences['id_albums']))
return false;
if ($album->getImages())
return false;
$html=$this->view->renderAlbum($album);
return $html;
protected function _renderHeadScriptsOn($script_loader) {
if (!array_isset('id_albums', $this->preferences))
return $this;
if ($this->isDisplayDiaporama())
$this->getSlideshow()->renderSlideShowScripts();
if ($this->isDisplayBooklet())
Class_ScriptLoader::getInstance()->loadBooklet($this->preferences['id_albums'],
'#booklet_'.$this->id_module);
}
public function getHtml() {
$strategy = $this->getStrategy();
$this->titre = $strategy->getTitle();
$this->contenu = $strategy->getContent();
return $this->getHtmlArray();
}
public function getStrategy() {
if ($this->strategy)
return $this->strategy;
$strategy = new BibNumPaginatedStrategy();
if ($this->isAlbumTeaserDisplay())
$strategy = new BibNumAlbumTeaserStrategy();
if ($this->isTreeDisplay())
$strategy = new BibNumTreeStrategy();
$this->strategy = $strategy->setView($this->view)
->setAccueilBibnum($this)
->setIdModule($this->id_module)
->setPreferences($this->preferences);
return $this->strategy;
}
public function isPaginatedDisplay() {
return $this->_isDisplayType(Class_Systeme_ModulesAccueil_BibliothequeNumerique::DISPLAY_PAGINATED);
}
public function isAlbumTeaserDisplay() {
return $this->_isDisplayType(Class_Systeme_ModulesAccueil_BibliothequeNumerique::DISPLAY_ALBUM_TEASER);
}
public function isTreeDisplay() {
return $this->_isDisplayType(Class_Systeme_ModulesAccueil_BibliothequeNumerique::DISPLAY_TREE);
}
protected function _isDisplayType($type) {
return $this->getPreference('type_aff') == $type;
}
public function getSlideshow() {
if (!isset($this->_slideshow)) {
$album = Class_Album::getLoader()->find((int)$this->preferences['id_albums']);
$this->_slideshow = $this->view->getHelper('TagSlideshow')
->setAlbum($album)
->setPreferences($this->preferences);
}
if (isset($this->_slideshow))
return $this->_slideshow;
$album = Class_Album::getLoader()->find((int)$this->preferences['id_albums']);
$this->_slideshow = $this->view->getHelper('TagSlideshow')
->setAlbum($album)
->setPreferences($this->preferences);
return $this->_slideshow;
}
}
public function getTreeRenderer() {
return new ZendAfi_View_Helper_Accueil_BibNumerique_TreeRenderer($this->view, $this->preferences);
class BibNumDisplayStrategy {
protected
$view,
$id_module,
$preferences,
$accueil_bibnum;
public function setView($view) {
$this->view = $view;
return $this;
}
protected function _renderHeadScriptsOn($script_loader) {
if (!array_isset('id_albums', $this->preferences))
return $this;
public function setPreferences($preferences) {
$this->preferences = $preferences;
return $this;
}
if ($this->isDisplayDiaporama())
$this->getSlideshow()->renderSlideShowScripts();
if ($this->isDisplayBooklet())
Class_ScriptLoader::getInstance()->loadBooklet($this->preferences['id_albums'],
'#booklet_'.$this->id_module);
public function setAccueilBibnum($accueil_bibnum) {
$this->accueil_bibnum = $accueil_bibnum;
return $this;
}
public function isDisplayAlbumTeaser() {
return $this->preferences['type_aff'] == Class_Systeme_ModulesAccueil_BibliothequeNumerique::DISPLAY_ALBUM_TEASER;
public function setIdModule($id_module) {
$this->id_module = $id_module;
return $this;
}
public function getTitle() {
return $this->preferences['titre'];
}
}
/** @return array */
public function getHTML() {
$this->titre = $this->preferences['titre'];
if ($this->isDisplayAlbumTeaser())
$this->_renderAlbumTeaser();
class BibNumAlbumTeaserStrategy extends BibNumDisplayStrategy {
public function getContent() {
$contenu = $this->displayNumericRessources();
if ($contenu)
return $contenu;
if ($this->accueil_bibnum->isDisplayDiaporama() or $this->accueil_bibnum->isDisplayListe())
$contenu .= $this->accueil_bibnum->getSlideshow()->renderAlbumMedias();
else
$this->_renderTree();
$contenu .= sprintf('<div id="booklet_%d" class="bib-num-album"></div>', $this->id_module);
return $this->getHtmlArray();
return $contenu;
}
/**
* @return ZendAfi_View_Helper_Accueil_BibNumerique
*/
public function _renderAlbumTeaser() {
if ($this->contenu = $this->displayNumericRessources())
return $this;
if ($this->isDisplayDiaporama() or $this->isDisplayListe()) {
$this->contenu .= $this->getSlideshow()->renderAlbumMedias();
} else {
$this->contenu .= sprintf('<div id="booklet_%d" class="bib-num-album"></div>',
$this->id_module);
$this->titre = $this->view->tagAnchor(array('controller' => 'bib-numerique',
'action' => 'booklet',
'id' => $this->preferences['id_albums']),
$this->titre);
}
public function getTitle() {
return $this->view->tagAnchor(['controller' => 'bib-numerique',
'action' => 'booklet',
'id' => $this->preferences['id_albums']],
$this->preferences['titre']);
}
return $this;
public function displayNumericRessources() {
if (!$album = Class_Album::getLoader()->find((int)$this->preferences['id_albums']))
return false;
if ($album->getImages())
return false;
$html = $this->view->renderAlbum($album);
return $html;
}
}
/**
* @return ZendAfi_View_Helper_Accueil_BibNumerique
*/
protected function _renderTree() {
$this->contenu = $this->getTreeRenderer()->render();
return $this;
class BibNumTreeStrategy extends BibNumDisplayStrategy {
public function getContent() {
return $this->_getTreeRenderer()->render();
}
protected function _getTreeRenderer() {
return new ZendAfi_View_Helper_Accueil_BibNumerique_TreeRenderer($this->view, $this->preferences);
}
}
class BibNumPaginatedStrategy extends BibNumDisplayStrategy {
public function getContent() {
return 'LOL';
}
}
?>
\ No newline at end of file
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