Commit 7c0cec4c authored by Ghislain Loas's avatar Ghislain Loas

dev #64573 plug try template feature

parent e8507d4e
Pipeline #2465 failed with stage
in 21 minutes and 28 seconds
......@@ -10,6 +10,7 @@
# Ignore all but the base skins
/skins/*
/public/opac/skins/*
!/public/opac/skins/intonation
!/public/opac/skins/modele
!/public/opac/skins/original
!/public/opac/skins/responsive
......
......@@ -22,12 +22,19 @@
class Admin_SkinController extends ZendAfi_Controller_Action {
public function indexAction() {
$this->view->titre = $this->_('Essayer une autre charte graphique');
$this->view->titre = $this->_('Changer la charte graphique');
$this->view->templates = (new Class_Template)->getTemplates();
}
public function tryAction() {
Class_Profil::setCurrentProfil(Class_Profil::find($this->_getParam('on')));
$this->_forward('index', 'index', 'opac');
if(!$this->view->id_profile = (new Class_Template)
->tryTemplateOn($this->_getParam('template'),
$this->_getParam('on'))) {
$this->_helper->notify($this->_('Une erreur c\'est produite. Vous ne pouvez pas tester le template'));
return $this->_redirectToIndex();
}
$this->_forward('index', 'index', 'opac', ['id_profil' => $this->view->id_profile]);
}
}
\ No newline at end of file
<?php
//(new Class_Profil())->getAvailableSkins();
echo $this->tagPreview(Class_Url::relative('/admin/skin/try/skin/evolution/on/1'),
$this->_('Essayer la charte Evolution'));
?>
\ No newline at end of file
$description = (new Class_TableDescription('templates'))
->addColumn($this->_('Titre'), function($template)
{
return $template->getTitle();
})
->addRowAction(function($template)
{
return $this->tagPreview($template->getTryUrl(),
$this->_('Essayer "%s"', $template->getTitle()));
});
echo $this->renderTable($description,
$this->templates,
['sorter' => true]);
\ 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 Class_Template {
public function getTemplates() {
return [
new Template_Evo(),
new Template_Responsive()
];
}
public function find($id) {
$template = (new Storm_Collection($this->getTemplates()))
->select(function($template) use ($id)
{
return $id == $template->getId();
});
if($template->isEmpty())
return null;
return $template->first();
}
public function tryTemplateOn($id, $id_profile) {
if(!$template = $this->find($id))
return null;
if(!$profile = Class_Profil::find($id_profile))
return null;
$temp_profile = $profile->copy();
return $template->upgrade($temp_profile)
? $temp_profile->getId()
: null;
}
}
class Template_Base extends Class_Entity {
use Trait_Translator;
public function getTryUrl() {
return Class_Url::relative(sprintf('/admin/skin/try/template
/%s/on/1', $this->getId()));
}
}
class Template_Responsive extends Template_Base {
public function __construct() {
$this->_attribs = ['Id' => 'RES',
'Title' => $this->_('Responsive')];
$this
->setId('RES')
->setTitle($this->_('Template responsive'))
->setSkin('intonation');
}
public function upgrade($profile) {
$profile
->setSkin($this->getSkin());
$profile
->setCfgSiteParam('barre_nav_on', '1')
->setCfgSiteParam('accessibilite_on', '')
->setCfgSiteParam('hauteur_banniere', '')
->setCfgSiteParam('responsive', '1')
->setCfgSiteParam('couleur_lien_bandeau', '')
->setCfgSiteParam('couleur_texte_bandeau', '')
->setCfgSiteParam('largeur_site', '90')
->setCfgSiteParam('size_site_scale', 'percent')
->setCfgSiteParam('width_division1_scale', 'percent')
->setCfgSiteParam('width_division2_scale', 'percent')
->setCfgSiteParam('width_division3_scale', 'percent')
->setCfgSiteParam('marge_division1', '')
->setCfgSiteParam('marge_division2', '')
->setCfgSiteParam('marge_division3', '');
$this->_setWidths($profile);
(new Class_Profil_Preferences())
->setModulePref($profile,
(new Class_Entity())
->setController('recherche')
->setAction('resultat')
->setSubAction('simple'),
['header_composition' => 'Advanced;History;Order;PageSize;']);
$profile->save();
return $profile;
}
protected function _setWidths($profile) {
if(1 == $profile->getCfgSiteParam('nb_divisions'))
return $profile
->setCfgSiteParam('largeur_division1', '100');
if(2 == $profile->getCfgSiteParam('nb_divisions'))
return $profile
->setCfgSiteParam('largeur_division1', '20')
->setCfgSiteParam('largeur_division2', '80')
->setCfgSiteParam('largeur_division3', '20');
return $profile
->setCfgSiteParam('largeur_division1', '20')
->setCfgSiteParam('largeur_division2', '60')
->setCfgSiteParam('largeur_division3', '20');
}
}
class Template_Evo extends Template_Responsive {
public function __construct() {
parent::__construct();
$this
->setId('EVO')
->setTitle($this->_('Template evolutif'));
}
}
/* Global */
:root {
--front-text: #3B3B3B;
--front-title: #333333;
--front-anchor: #1B1B1B;
--front-anchor-highlight: #000;
--front-error-text: #F00;
--front-shadow: rgba(0, 0 , 0 ,0.3);
--front-separator: rgba(0 ,0 ,0 , 0.15);
--front-background: #F0F0F0;
--front-widget-background: #FFF;
--front-navbar-background: #CCC;
}
body.opac {
font-family: open sans;
color: var(--front-text);
font-size: 14px;
margin: 0;
padding: 0;
}
#site_web_wrapper * {
font-family: open sans;
font-size: 1em;
}
#site_web_wrapper h1,
#site_web_wrapper h2,
#site_web_wrapper h3,
#site_web_wrapper h4 {
color: var(--front-title);
white-space: normal;
margin: 0;
padding: 0.5ex 0.5em;
font-weight: normal;
cursor: default;
}
#site_web_wrapper h1,
#site_web_wrapper h2 {
font-size: 18px;
}
#site_web_wrapper #menu_horizontal a,
#site_web_wrapper h3 {
font-size: 16px;
}
#site_web_wrapper h4 {
font-size: 15px;
}
#site_web_wrapper #menu_horizontal a,
#site_web_wrapper #menu_horizontal a:visited,
a,
a:visited {
font-weight: normal;
text-decoration: none;
color: var(--front-anchor);
transition: all 0s;
}
#site_web_wrapper #menu_horizontal a:focus,
#site_web_wrapper #menu_horizontal a:hover,
#site_web_wrapper a:focus,
#site_web_wrapper a:hover {
color: var(--front-anchor-highlight);
text-decoration: underline;
}
#site_web_wrapper #header .boite,
#site_web_wrapper #colContenuInner > *:not(.configuration_module):not(.boite),
#site_web_wrapper #menu_horizontal,
#site_web_wrapper #menu_horizontal > ul > li > ul,
#site_web_wrapper #col_wrapper .boite:not(.conteneur_deux_colonnes),
#site_web_wrapper #col_wrapper .barre_nav {
box-shadow: 1px 1px 5px var(--front-shadow);
}
#site_web_wrapper #menu_horizontal > ul > li > ul > li:not(:first-child) {
border-top: 1px solid var(--front-separator);
}
#site_web_wrapper #menu_horizontal > ul > li > ul > li,
#site_web_wrapper #header .boite,
#site_web_wrapper #colContenuInner > *:not(.configuration_module):not(.boite),
#site_web_wrapper #col_wrapper .boite:not(.conteneur_deux_colonnes),
#site_web_wrapper #col_wrapper .barre_nav {
background-color: var(--front-widget-background);
}
/* Conteneur site */
#site_web_wrapper #right_col_color {
display: inline-block;
vertical-align: top;
}
/* Eléments qui sont redimensionnés en fonction de leur conteneur */
.auto_resize img,
.auto_resize object,
.auto_resize embed {
display:none;
}
/* Footer */
/* Menu horizontal */
#site_web_wrapper #menu_horizontal {
background: var(--front-navbar-background);
white-space: nowrap;
height: inherit;
margin: inherit;
padding: inherit;
text-align: center;
}
#site_web_wrapper #site_web_wrapper #menu_horizontal {
height: auto;
}
#site_web_wrapper #menu_horizontal img {
vertical-align: middle;
margin-right: 5px;
}
#site_web_wrapper #menu_horizontal ul,
#site_web_wrapper #menu_horizontal li {
padding: 0;
margin: 0;
}
#site_web_wrapper #menu_horizontal ul li a {
margin: 0.5ex 0.5em;
padding: 0.5ex 0.5em;
display: inline-block;
}
#site_web_wrapper #menu_horizontal li {
vertical-align: middle;
list-style: none;
display: inline-block;
text-align: left;
}
#menu_horizontal ul li ul
{
border: 1px solid #B0BEC7;
background-color: #FFFFFF;
display: none;
position: absolute;
top: 1.5em;
left: 2.5em;
padding: 2px;
z-index: 101;
}
#site_web_wrapper #menu_horizontal ul li {
position: relative;
}
#site_web_wrapper #menu_horizontal ul li ul {
display: none;
position: absolute;
z-index: 101;
top: auto;
}
#site_web_wrapper #menu_horizontal ul li ul li {
display: block;
height: auto;
}
#site_web_wrapper #menu_horizontal ul li.over ul {
display: block;
}
/* Menu Gauche */
#site_web_wrapper .facette ul,
#site_web_wrapper #menu_horizontal ul,
#site_web_wrapper .menuGauche ul {
list-style: none;
margin: 0;
padding: 0;
}
#site_web_wrapper .menuGauche img{
margin-right:5px;
}
/* Boites */
#site_web_wrapper #header .boite,
#site_web_wrapper #colContenuInner > div .contenu,
#site_web_wrapper .boite:not(.conteneur_deux_colonnes) .contenu,
#site_web_wrapper #col_wrapper .barre_nav {
padding: 1ex 1em;
}
#site_web_wrapper #colContenuInner > *:not(.configuration_module):not(.boite),
#site_web_wrapper #col_wrapper .boite:not(.conteneur_deux_colonnes),
#site_web_wrapper #col_wrapper .barre_nav {
margin: 2ex 1em;
}
#site_web_wrapper .boite .rss{
position: absolute;
top: 1ex;
right: 0.5em;
}
.form td.masque{
text-align:right;
}
.form td.saisie{
text-align:left;
}
.submit {
background:transparent url(../images/bouton/btn_ok.gif) no-repeat scroll 0 0;
border:0 none;
cursor:pointer;
height:18px;
width:18px;
}
#site_web_wrapper .panier_index .submit {
font-size: 0px;
}
#site_web_wrapper .bibview_find .submit {
font-size: 0px;
}
.calendar_title td {
text-align:center;
}
.calendar_table {
border: none;
}
.calendar_table td,
.calendar_table th {
text-align: center;
}
/* Error */
.error {
color: var(--front-error-text);
font-weight:bold;
}
/* Boites bannière*/
#site_web_wrapper > div.siteWeb,
#site_web_wrapper > div.siteWeb > div#site_web_content,
#site_web_wrapper > div.siteWeb > div#site_web_content > div#col_wrapper {
width: auto;
float: none;
height: auto;
}
#site_web_wrapper #banniere > a.home > img {
width: auto !important;
}
#site_web_wrapper #header > div {
display: inline-block;
vertical-align: top;
}
#site_web_wrapper #header .boite {
margin: 1ex 1em;
}
#site_web_wrapper [class*="menu"] a[href="#"] {
pointer-events: none;
}
#site_web_wrapper [class*="menu"] li {
cursor: default;
}
#site_web_wrapper #col_wrapper {
background: var(--front-background);
}
<div class="boiteBanniereDroite">
<div class="boiteBanniereDroiteInner">
{IF-TITRE}
<h1>{TITRE}</h1>
{ENDIF}
{CONTENU}
</div>
</div>
<div class="boiteBanniereGauche">
<div class="boiteBanniereGaucheInner">
{IF-TITRE}
<h1>{TITRE}</h1>
{ENDIF}
{CONTENU}
</div>
</div>
<div class="boiteDroite">
<div class="boiteDroiteInner">
{IF-TITRE}
<div class="titre">
<div><h1>{TITRE}</h1></div>
<div class="rss">{RSS}</div>
</div>
{ENDIF}
<div class="contenu">
{CONTENU}
</div>
</div>
</div>
<div class="boiteMilieu">
<div class="boiteMilieuInner">
{IF-TITRE}
<div class="titre">
<div class="titreInner">
<h1>{TITRE}</h1>
<div class="rss">{RSS}</div>
</div>
</div>
{ENDIF}
<div class="contenu">
<div class="contenuInner">
{CONTENU}
</div>
</div>
</div>
</div>
<div class="boiteGauche">
<div class="boiteGaucheInner">
{IF-TITRE}
<div class="titre">
<div><h1>{TITRE}</h1></div>
<div class="rss">{RSS}</div>
</div>
{ENDIF}
<div class="contenu">
{CONTENU}
</div>
</div>
</div>
<div class="{TYPE_MODULE} boite_accueil">
<a href="#" class="app-icon"></a>
<a href="#" class="icon-retour"></a>
{IF-TITRE}
<div class="img-titre"><div class="titre"><h2>{TITRE}</h2></div></div>
{ENDIF}
<div class="contenu">{CONTENU}</div>
</div>
<div class="boiteVide">
<div class="boiteVideInner">
<div class="titre"><h1>{TITRE}</h1></div>
<div class="rss">{RSS}</div>
<div class="contenu">{CONTENU}</div>
</div>
</div>
......@@ -40,12 +40,17 @@ class SkinControllerIndexDispatchTest extends Admin_AbstractControllerTestCase {
class SkinControllerTryDispatchTest extends Admin_AbstractControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/admin/skin/try/skin/evolution/on/1?iframe=true&width=95%25&height=95%25', true);
$this->fixture('Class_Profil',
['id' => 1,
]);
$this->dispatch('/admin/skin/try/template/EVO/on/1?iframe=true&width=95%25&height=95%25', true);
}
/** @test */
public function shouldForwardToBokehIndex() {
$this->assertXPath('//body[contains(@class, "opac")]');
$this->assertXPath('//body[contains(@class, "opac")][contains(@class, "profil_2")]');
}
}
\ No newline at end of file
Markdown is supported
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