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

dev#37281 : fix rt

parent 223583e8
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
......@@ -26,28 +26,21 @@ class Admin_BibnumController extends ZendAfi_Controller_Action {
}
public function collectionsAction() {
$this->_helper->viewRenderer->setNoRender();
$categories = Class_AlbumCategorie::getCollections();
$categories[] = Class_AlbumCategorie::defaultCategory()
->setAlbums(Class_Album::findAllBy(['cat_id' => 0]));
$jsons = [];
$albums = [];
foreach ($categories as $category) {
$jsons[] = $category->toJson();
$albums[] = $category->toArray();
}
$bib = Class_Bib::getPortail();
$jsons = '{'.
'"id":'.$bib->getId().','.
'"label": "'.htmlspecialchars($bib->getLibelle()).'",'.
'"categories": ['.implode(",", $jsons).'],'.
'"items": []'.
'}';
$this->getResponse()->setHeader('Content-Type', 'application/json; charset=utf-8');
$this->getResponse()->setBody('[' . $jsons .']');
$this->_helper->json([['id' => $bib->getId(),
'label' => htmlspecialchars($bib->getLibelle()),
'categories' => $albums,
'items' => []]]);
}
}
\ No newline at end of file
......@@ -244,24 +244,22 @@ class Class_AlbumCategorie extends Storm_Model_Abstract {
}
public function albumsToJSON($albums) {
public function albumsToArray($albums) {
$json_albums = [];
$albums_array = [];
foreach ($albums as $album) {
$json_albums []= $album->toJSON();
$albums_array []= $album->toArray();
}
return $json_albums;
return $albums_array;
}
public function toJSON() {
public function toArray() {
return
'{'.
'"id":'.$this->getId().','.
'"label": "'.htmlspecialchars($this->getLibelle()).'",'.
'"categories": ['.implode(",", $this->albumsToJSON($this->getSousCategories())).'],'.
'"items": []'.
'}';
['id' => $this->getId(),
'label' => htmlspecialchars($this->getLibelle()),
'categories' => $this->albumsToArray($this->getSousCategories()),
'items' => []];
}
}
\ No newline at end of file
......@@ -172,17 +172,13 @@ class BibNumDisplayStrategy {
class BibNumAlbumTeaserStrategy extends BibNumDisplayStrategy {
public function getContent() {
$contenu = $this->displayNumericRessources();
if ($contenu)
if ($contenu = $this->displayNumericRessources())
return $contenu;
if ($this->accueil_bibnum->isDisplayDiaporama() or $this->accueil_bibnum->isDisplayListe())
$contenu .= $this->accueil_bibnum->getSlideshow()->renderAlbumMedias();
else
$contenu .= sprintf('<div id="booklet_%d" class="bib-num-album"></div>', $this->id_module);
return $contenu . $this->accueil_bibnum->getSlideshow()->renderAlbumMedias();
return $contenu;
return $contenu . sprintf('<div id="booklet_%d" class="bib-num-album"></div>', $this->id_module);
}
public function getTitle() {
......@@ -286,7 +282,6 @@ class BibNumPaginatedStrategy extends BibNumDisplayStrategy {
'id_module' => $this->id_module,
'id_division' => $this->division];
xdebug_break();
if (Class_Systeme_ModulesAccueil_BibliothequeNumerique::ORDER_RANDOM == $this->preferences['display_order'])
return $this->view->tagAnchor($reload_link,
'',
......
......@@ -88,9 +88,34 @@ class Admin_BibnumControllerTreeSelectTest extends Admin_AbstractControllerTestC
/** @test */
public function jsonShouldContainsNatureAndFaune() {
$expected = '[{"id":0,"label": "Portail","categories": [{"id":6,"label": "arbre","categories": [],"items": []},{"id":2,"label": "nature","categories": [{"id":4,"label": "faune","categories": [{"id":6,"label": "arbre","categories": [],"items": []}],"items": []}],"items": []},{"id":0,"label": "Albums non classés","categories": [],"items": []}],"items": []}]';
$this->assertEquals($expected, $this->_response->getBody());
$expected = [['id' => 0,
'label' => 'Portail',
'categories' => [
['id' => 6,
'label' => 'arbre',
'categories' => [],
'items' => []],
['id' => 2,
'label' => 'nature',
'categories' => [
['id' => 4,
'label' => 'faune',
'categories' => [
['id' => 6,
'label' => 'arbre',
'categories' => [],
'items' => []]],
'items' => []]],
'items' => []],
['id' => 0,
'label' => 'Albums non classés',
'categories' => [],
'items' => []]],
'items' => []]];
$this->assertEquals(json_encode($expected), $this->_response->getBody());
}
}
\ 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