Skip to content
Snippets Groups Projects
Commit 825281f4 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

plugins for controllers working in sito

parent eb463ff1
Branches
Tags
5 merge requests!2080Sandbox detach zf from storm,!2061Master,!1989Dev#45275 3155 contractuel application nouvelle methode d edition par lot des articles aux collections,!1968full plugin mod for multiselection,!1959Dev#45275 3155 contractuel application nouvelle methode d edition par lot des articles aux collections
Pipeline #101 failed with stage
in 7 minutes and 53 seconds
......@@ -24,24 +24,25 @@ class Admin_SitoController extends ZendAfi_Controller_Action {
public function getRessourceDefinitions() {
return [
'model' => [
'class' => 'Class_Sitotheque',
'name' => 'sitotheque',
'order' => 'id',
'scope' => 'id_cat'],
'messages' => [
'successful_save' => $this->_('Site "%s" sauvegardé'),
'successful_add' => $this->_('Le site "%s" a été sauvegardé'),
'successful_delete' => $this->_('Site "%s" supprimé')],
'actions' => [
'add' => ['title' => $this->_("Ajouter un site")],
'edit' => ['title' => $this->_("Modifier le site: %s")],
'delete' => ['title' => $this->_("Supprimer le site: %s")]
],
'form_class_name' => 'ZendAfi_Form_Admin_Sitotheque'];
'model' => [
'class' => 'Class_Sitotheque',
'name' => 'sitotheque',
'order' => 'id',
'scope' => 'id_cat'],
'messages' => [
'successful_save' => $this->_('Site "%s" sauvegardé'),
'successful_add' => $this->_('Le site "%s" a été sauvegardé'),
'successful_delete' => $this->_('Site "%s" supprimé')],
'actions' => [
'add' => ['title' => $this->_("Ajouter un site")],
'edit' => ['title' => $this->_("Modifier le site: %s")],
'delete' => ['title' => $this->_("Supprimer le site: %s")]
],
'form_class_name' => 'ZendAfi_Form_Admin_Sitotheque',
'plugins' => ['ZendAfi_Controller_Plugin_Manager_Sitotheque']];
}
......
<?php
/**
* Copyright (c) 2012-2017, 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
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* 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
*/
class ZendAfi_Controller_Plugin_Manager_Sitotheque {
public function render() {
return '';
}
public function getActions($model) {
if('Class_Sitotheque' == get_class($model))
return $this->_getLeafActions($model);
if('Class_SitothequeCategorie' == get_class($model))
return $this->_getNodeActions($model);
return [];
}
protected function _getNodeActions($model) {
return [
['url' => '/admin/sito/catedit/id/%s',
'icon' => 'edit',
'label' => 'Modifier'],
['url' => '/admin/sito/catdel/id/%s',
'icon' => 'delete',
'label' => 'Supprimer',
'condition' => 'hasNoChild',
'anchorOptions' => ['onclick' => "return confirm('Etes-vous sûr de vouloir supprimer cette catégorie ?')"]],
['url' => '/admin/sito/add/id_cat/%s',
'icon' => 'add_page',
'label' => 'Ajouter un site'],
['url' => '/admin/sito/catadd/id/%s',
'icon' => 'add_category',
'label' => 'Ajouter une sous-catégorie']
];
}
private function _getLeafActions($model) {
return
[
[
'url' => $this->_getUrlForActionAndIdName('sitoview').'?&amp;iframe=true&amp;width=80%%&amp;height=80%%',
'icon' => 'show',
'label' => 'Visualiser',
'anchorOptions' => [
'rel' => 'prettyPhoto'
]
],
[
'url' => $this->_getUrlForActionAndIdName('edit'),
'icon' => 'edit',
'label' => 'Modifier',
],
[
'url' => $this->_getUrlForActionAndIdName('delete'),
'icon' => 'delete',
'label' => 'Supprimer',
'anchorOptions' => [
'onclick' => "return confirm('Etes-vous sûr de vouloir supprimer ce site ?')"
],
]
];
}
}
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, 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
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* 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
*/
class ManagerArticleTest extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setup() {
parent::setUp();
$this->fixture('Class_ArticleCategorie',
['id' => 56,
'libelle' => 'News']);
$this->fixture('Class_Article',
['id' => 78,
'titre' => 'Happy new Year 2017',
'contenu' => 'Happy new Year 2017',
'id_cat' => 56]);
$this->dispatch('/admin/cms/index', true);
}
/** @test */
public function editNewsShouldBePresent() {
$this->assertXPath('//a[contains(@href, "/admin/cms-category/edit/id/56")]');
}
/** @test */
public function addNewArticleToNewsShouldbePresent() {
$this->assertXPath('//a[contains(@href, "/admin/cms/add/id_cat/56")]');
}
/** @test */
public function addSubCategoryToNewsShouldBePresent() {
$this->assertXPath('//a[contains(@href, "/admin/cms-category/add/id/56")]');
}
/** @test */
public function makeInvisibleHappyNewYearShouldBePresent() {
$this->assertXPath('//a[contains(@href, "/admin/cms/makeinvisible/id/78")]');
}
/** @test */
public function editHappyNewYearShouldBePresent() {
$this->assertXPath('//a[contains(@href, "/admin/cms/edit/id/78")]');
}
/** @test */
public function copyHappyNewYearShouldBePresent() {
$this->assertXPath('//a[contains(@href, "/admin/cms/newsduplicate/id/78")]');
}
/** @test */
public function deleteHappyNewYearShouldBePresent() {
$this->assertXPath('//a[contains(@href, "/admin/cms/delete/id/78")]');
}
}
class ManagerAlbumTest extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->fixture('Class_AlbumCategorie',
['id' => 65,
'libelle' => 'Instrumental']);
$this->fixture('Class_Album',
['id' => 32,
'libelle' => 'Tokyo ghoul']);
$this->dispatch('/admin/album/index', true);
}
/** @test */
public function addSubCategoryToInstrumentalShouldBePresent() {
$this->assertXPath('//a[contains(@href,"/admin/album/add_categorie_to/id/65")]');
}
/** @test */
public function addAlbumToInstrumentalShouldBePresent() {
$this->assertXPath('//a[contains(@href,"/admin/album/add_album_to/id/65")]');
}
/** @test */
public function editInstrumentalShouldBePresent() {
$this->assertXPath('//a[contains(@href,"/admin/album/edit_categorie/id/65")]');
}
/** @test */
public function deleteInstrumentalShouldBePresent() {
$this->assertXPath('//a[contains(@href,"/admin/album/delete_categorie/id/65")]');
}
/** @test */
public function editTokyoGhoulShouldBePresent() {
$this->assertXPath('//a[contains(@href,"/admin/album/edit_album/id/32")]');
}
/** @test */
public function editImagesTokyoGhoulShouldBePresent() {
$this->assertXPath('//a[contains(@href,"/admin/album/edit_images/id/32")]');
}
/** @test */
public function previewTokyoGhoulShouldBePresent() {
$this->assertXPath('//a[contains(@href,"/admin/album/preview_album/id/32")]');
}
/** @test */
public function deleteTokyoGhoulShouldBePresent() {
$this->assertXPath('//a[contains(@href,"/admin/album/delete_album/id/32")]');
}
}
class ManagerSitothequeTest extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->fixture('Class_SitothequeCategorie',
['id' => 21,
'libelle' => 'Free software']);
$this->fixture('Class_SitothequeCategorie',
['id' => 75,
'libelle' => 'Software']);
$this->fixture('Class_Sitotheque',
['id' => 98,
'titre' => 'Framapad',
'url' => 'https://framapad.org/',
'id_cat' => 21]);
$this->dispatch('/admin/sito/index', true);
}
/** @test */
public function editFreeSoftwareShouldBePresent() {
$this->assertXPath('//a[contains(@href,"/admin/sito/catedit/id/21")]');
}
}
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