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

dev#23223_sito_widget_pagination : add reload picto for random paged config

parent 5daf38c2
Branches
Tags 5.28
6 merge requests!1553Master,!1502Master,!1501Stable,!1289Master,!1288Dev#23223 sito widget pagination,!1275Dev#23223 sito widget pagination
...@@ -102,3 +102,21 @@ See _Class\_Users>>registerNotificationsOn_ for notifications usage. ...@@ -102,3 +102,21 @@ See _Class\_Users>>registerNotificationsOn_ for notifications usage.
## ILS Web services ## ILS Web services
Add _Class\_WebService\_SIGB\_Reservation>>isWaitingToBePulled_ that returns _true_ when holded document is available in library. Works for: Nanook, Koha, Microbib, Aloes, Carthame, Orphée, Pergame. Add _Class\_WebService\_SIGB\_Reservation>>isWaitingToBePulled_ that returns _true_ when holded document is available in library. Works for: Nanook, Koha, Microbib, Aloes, Carthame, Orphée, Pergame.
# Reload module content with AJAX
On module ajax link, add tag attributes: 'data-reload-module = true'.
For example:
```php
$this->view->tagAnchor($reload_link,
'',
['data-ajax-reload' => 'true',
'class' => 'reload-module',
'title' => $this->view->_('Recharger')]);
```
See public/opac/js/reload_module.js
\ No newline at end of file
...@@ -23,7 +23,7 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base ...@@ -23,7 +23,7 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base
const ORDER_RANDOM = 'Random'; const ORDER_RANDOM = 'Random';
const ORDER_SELECTION = 'Selection'; const ORDER_SELECTION = 'Selection';
const DISPLAY_SELECTION = 1; const DISPLAY_PAGED = 1;
const DISPLAY_GROUPED = 2; const DISPLAY_GROUPED = 2;
const DISPLAY_HIERARCHY = 3; const DISPLAY_HIERARCHY = 3;
...@@ -38,10 +38,10 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base ...@@ -38,10 +38,10 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base
if($this->strategy) if($this->strategy)
return $this->strategy; return $this->strategy;
$strategy = new SelectedStrategy(); $strategy = new PagedStrategy();
if($this->isHierarchicalDisplay()) if($this->isHierarchicalDisplay())
$strategy = new HierrachicalStrategy(); $strategy = new HierachicalStrategy();
if($this->isTypeAffichageGrouped()) if($this->isTypeAffichageGrouped())
$strategy = new GroupedStrategy(); $strategy = new GroupedStrategy();
...@@ -68,8 +68,8 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base ...@@ -68,8 +68,8 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base
} }
public function isTypeAffichageSelection() { public function isTypeAffichagePaged() {
return $this->_isDisplayType(static::DISPLAY_SELECTION); return $this->_isDisplayType(static::DISPLAY_PAGED);
} }
...@@ -218,17 +218,18 @@ class SitoDisplayStrategy { ...@@ -218,17 +218,18 @@ class SitoDisplayStrategy {
class SelectedStrategy extends SitoDisplayStrategy { class PagedStrategy extends SitoDisplayStrategy {
public function getContent() { public function getContent() {
$nb_aff = $this->getPreference('nb_aff') ? $this->getPreference('nb_aff') : $this->_getDefaultNbAff(); $nb_aff = $this->getPreference('nb_aff') ? $this->getPreference('nb_aff') : $this->_getDefaultNbAff();
$sites = $this->_loadSites(); $sites = $this->_loadSites();
if (static::ORDER_RANDOM == $this->getPreference('display_order')) { if (static::ORDER_RANDOM == $this->getPreference('display_order'))
shuffle($sites); shuffle($sites);
return $this->renderSitesSlice($sites, $nb_aff);
} return
return $this->renderSitesWithPagination($sites, $nb_aff); $this->renderSitesSlice($sites, $nb_aff)
. $this->getPaginator($sites, $nb_aff, $this->page);
} }
protected function _getDefaultNbAff() { protected function _getDefaultNbAff() {
...@@ -237,25 +238,33 @@ class SelectedStrategy extends SitoDisplayStrategy { ...@@ -237,25 +238,33 @@ class SelectedStrategy extends SitoDisplayStrategy {
} }
protected function renderSitesWithPagination($sites, $nb_sites_by_pages) { protected function getPaginator($items, $items_by_page, $page = 1) {
if(count($sites) <= $nb_sites_by_pages) if (count($items) <= $items_by_page)
return $this->renderSitesSlice($sites, $nb_sites_by_pages); return '';
return $this->renderSitesSlice($sites, $nb_sites_by_pages) . $this->getPaginator($sites, $nb_sites_by_pages, $this->page); $reload_link = ['module' => 'opac',
} 'controller' => 'sito',
'action' => 'widget-page',
'id_module' => $this->id_module,
'id_division' => $this->division];
if (static::ORDER_RANDOM == $this->getPreference('display_order'))
return $this->view->tagAnchor($reload_link,
'',
['data-ajax-reload' => 'true',
'class' => 'reload-module',
'title' => $this->view->_('Recharger')]);
protected function getPaginator($items, $items_by_page, $page = 1) {
$paginator = (new Zend_Paginator(new Zend_Paginator_Adapter_Null(count($items)))) $paginator = (new Zend_Paginator(new Zend_Paginator_Adapter_Null(count($items))))
->setItemCountPerPage(max($items_by_page, 1)) ->setItemCountPerPage(max($items_by_page, 1))
->setCurrentPageNumber($page); ->setCurrentPageNumber($page);
return $this->view->paginationControl($paginator, null, null, ['url_link' => ['module' => 'opac',
'controller' => 'sito', return $this->view->paginationControl($paginator,
'action' => 'widget-page', null,
'id_module' => $this->id_module, null,
'id_division' => $this->division], ['url_link' => $reload_link,
'link_attribs' => [ 'data-ajax-reload' => 'true' ] 'link_attribs' => [ 'data-ajax-reload' => 'true' ]
]); ]);
} }
} }
...@@ -314,7 +323,7 @@ class GroupedStrategy extends SitoDisplayStrategy { ...@@ -314,7 +323,7 @@ class GroupedStrategy extends SitoDisplayStrategy {
class HierrachicalStrategy extends SitoDisplayStrategy { class HierachicalStrategy extends SitoDisplayStrategy {
public function getContent() { public function getContent() {
return $this->view->sitoTree($this->getPreference('id_categorie')); return $this->view->sitoTree($this->getPreference('id_categorie'));
} }
......
public/admin/images/picto/reload.png

1.04 KiB

...@@ -727,6 +727,12 @@ select{color:#666666;font-family:Arial;font-size:1em;} ...@@ -727,6 +727,12 @@ select{color:#666666;font-family:Arial;font-size:1em;}
padding-top: 10px; padding-top: 10px;
} }
.boite.sito a.reload-module {
background: url('../../admin/images/picto/reload.png') no-repeat;
display: block;
width: 16px;
height: 16px;
}
ul.sitotheque, ul.sitotheque,
ul.sitotheque ul { ul.sitotheque ul {
......
...@@ -205,6 +205,30 @@ class SitoViewHelperSelectItemsByRandomOrderTest extends SitoViewHelperTestCase ...@@ -205,6 +205,30 @@ class SitoViewHelperSelectItemsByRandomOrderTest extends SitoViewHelperTestCase
$this->assertEquals(2, count(array_unique($htmls))); $this->assertEquals(2, count(array_unique($htmls)));
} }
/** @test */
public function pageShouldNotContainsLinkToReloadModule() {
$this->assertNotXPath($this->html, '//a[contains(@href, "sito/widget-page/id_module/2/id_division/1")]');
}
}
class SitoViewHelperSelectItemsByRandomOrderWithOneSiteTest extends SitoViewHelperTestCase {
protected $_preferences = ['titre' => 'Ma sito',
'type_aff' => 1,
'id_items' => '12-15',
'id_categorie' => '',
'nb_aff' => 1,
'display_order' => 'Random'];
/** @test */
public function pageShouldContainsLinkToReloadModule() {
$this->assertXPath($this->html, '//a[@class="reload-module"][contains(@href, "sito/widget-page/id_module/2/id_division/1")]');
}
} }
......
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