Skip to content
Snippets Groups Projects

Dev#14944 record to album link indexing

Merged Ghislain Loas requested to merge dev#14944_record_to_album_link_indexing into WIP
Compare and
+ 717
87
Preferences
Compare changes
Files
@@ -159,16 +159,20 @@ class Admin_AlbumController extends ZendAfi_Controller_Action {
}
public function linkalbumtoAction() {
$this->_renderAlbumForm(Class_Album::newInstance(),
'Ajouter un album');
}
public function addalbumtoAction() {
if (!$categorie = Class_AlbumCategorie::find((int)$this->_getParam('id'))) {
$this->_redirect('admin/album');
return;
}
$categorie = '';
$title = 'Ajouter un album';
if ($categorie = Class_AlbumCategorie::find((int)$this->_getParam('id')))
$title .= ' dans la collection "' . $categorie->getLibelle() . '"';
$this->_renderAlbumForm(
Class_Album::newInstance()->setCategorie($categorie),
'Ajouter un album dans la collection "' . $categorie->getLibelle() . '"'
);
Class_Album::newInstance()->setCategorie($categorie), $title);
}
@@ -512,14 +516,16 @@ class Admin_AlbumController extends ZendAfi_Controller_Action {
if ($album->save()
&& $album->receiveFile()
&& $album->receivePDF()
&& $album->index()) {
&& $album->receivePDF()) {
$album->index();
$frbr_links = [];
foreach(Class_FRBR_Link::findAllRecordLinksForAlbum($album) as $link)
$frbr_links[md5($link->getSource().$link->getTarget())] = $link;
$absoluteUrl = $this->view->absoluteUrl($album->getPermalink());
$absoluteUrl = $this->view->absoluteUrl(array_merge(['id' => $album->getId()],
$album->getPermalink()), null, true);
$received_links = [];
$urls = $frbr_multi['frbr_url'];
@@ -550,8 +556,11 @@ class Admin_AlbumController extends ZendAfi_Controller_Action {
(new Storm_Cache())->clean();
$this->_helper->notify('Album sauvegardé');
$this->_redirect('admin/album/edit_album/id/' . $album->getId());
$this->_redirectClose('admin/album/edit_album/id/' . $album->getId());
return true;
}
return false;
}
@@ -572,7 +581,8 @@ class Admin_AlbumController extends ZendAfi_Controller_Action {
* @param string $titre
*/
protected function _renderAlbumForm($album, $titre) {
$this->_validateAndSaveAlbum($album);
if ($this->_validateAndSaveAlbum($album))
return;
$this->view->titre = $titre;
$this->view->errors = $album->getErrors();
@@ -581,7 +591,30 @@ class Admin_AlbumController extends ZendAfi_Controller_Action {
->setValue($album->getFichier());
$this->view->form->getElement('pdf')
->setValue($album->getPdf());
$this->render('album_form');
if ($this->isPopupRequest())
$this->_prepareAlbumAjaxFrom();
$this->getHelper('ViewRenderer')->setScriptAction('album_form');
}
protected function _prepareAlbumAjaxFrom() {
$id_notice = $this->_getParam('id_notice')
? $this->_getParam('id_notice')
: '';
$this->view->form->beSimple()
->setAction($this->view->url(['action' => 'link_album_to',
'id_notice' => $id_notice]))
->setEnctype('application/x-www-form-urlencoded');
if (!$this->_request->isPost()) {
$notice = Class_Notice::find($id_notice);
$this->view->form->populateFrbrUrl(
$this->view->absoluteUrl($this->view->urlNotice($notice, [], null, true), null, true));
$this->view->form->getElement('titre')->setValue($notice->getTitrePrincipal());
}
}