diff --git a/application/modules/api/controllers/UserController.php b/application/modules/api/controllers/UserController.php index 489ff847b69ee00b07e92bcac2b8746739d72506..416abf4d8c7d88252b5dcfa9e4cd0e1c4f38c61f 100644 --- a/application/modules/api/controllers/UserController.php +++ b/application/modules/api/controllers/UserController.php @@ -98,7 +98,7 @@ class Api_UserController extends ZendAfi_Controller_Action { if (Class_AdminVar_OAuthAcceptHTTP::shouldRejectRequest($this->_request)) return $this->_helper->throwHTTPError($this->_('Protocole HTTPS obligatoire'), 403); - if (!$authorization = $this->_request->getHeader('authorization')) + if (!$authorization = $this->_request->getHeader('Authorization')) return $this->_helper->throwHTTPError($this->_('Autorisation non spécifiée'), 401); $parts = explode(' ', $authorization); diff --git a/application/modules/opac/views/scripts/subModal.phtml b/application/modules/opac/views/scripts/subModal.phtml index 2773b25cd9d7eb4e4babf306592e66e49113772b..13dd92c08fcb93a2ec5a0d941faa7344860262a3 100644 --- a/application/modules/opac/views/scripts/subModal.phtml +++ b/application/modules/opac/views/scripts/subModal.phtml @@ -1,25 +1,2 @@ -<?php -$script_loader = Class_ScriptLoader::getInstance() - ->loadJQuery() - ->loadJQueryUI() - ->showNotifications() - ->addAdminStyleSheet('subModalContenu') - ->addAdminScript('global') - ->addOpacScript('subModal') - ->addOpacStyleSheet('global') - ->addSkinStyleSheets(['iframe', 'global']); - -ob_start(); -echo $this->render($this->actionScript); -$html_contents = ob_get_contents(); -ob_end_clean(); -?> - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html lang="<?php echo $this->_translate()->getLocale() ?>" xml:lang="<?php echo $this->_translate()->getLocale() ?>" xmlns="http://www.w3.org/1999/xhtml"> - <head> - <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> - <?php echo $script_loader->html();?> - </head> - <body <?php echo $this->bodyParam ?>><?php echo $html_contents ?></body> -</html> \ No newline at end of file +<?php echo $this->Layout_SubModal(); diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index 7d3429f41812d860cacd015c1f89364a40647e38..0ddec246f6897299e51de163b883850e949cd5ce 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -138,10 +138,22 @@ class Class_AdminVarLoader extends Storm_Model_Loader { 'file-manager' => $this->_getFileManagerVars(), 'federation-reviews' => $this->_getFederationVars(), 'usergroup-agenda' => $this->_getRendezVousVars(), + 'templating' => $this->_getTemplatingVars() ]; } + protected function _getTemplatingVars() { + return [ + 'TEMPLATING' => Class_AdminVar_Meta::newOnOff('Active l\'accès au magasin de thèmes', + ['value' => 0])->bePrivate(), + + 'MYBIBAPP_TEMPLATE' => Class_AdminVar_Meta::newOnOff('Active la génération automatique du thème pour MyBibApp', + ['value' => 0])->bePrivate() + ]; + } + + protected function _getAlbumVars() { return $this->_getStaticAlbumVars() + $this->_getDynamicAlbumVars(); } @@ -393,8 +405,6 @@ class Class_AdminVarLoader extends Storm_Model_Loader { 'INSPECTOR_GADGET_MARC_XML' => Class_AdminVar_Meta::newOnOff('Affiche le MARC XML de la notice dans Inspector Gadget')->enable(), 'BUSINESS_EMAIL' => Class_AdminVar_Meta::newDefault($this->_('Email utilisé pour les demandes d\'accompagnement de mise en place ou d\'utilisation des fonctionnalités du logiciel'), ['value' => 'cial-bib@afi-sa.fr'])->bePrivate(), 'CODIFICATION_BROWSER' => Class_AdminVar_Meta::newOnOff($this->_('Activer l\'outil de parcours des codifications'))->enable(), - 'TEMPLATING' => Class_AdminVar_Meta::newOnOff('Active l\'accès au magasin de thèmes', - ['value' => 0])->bePrivate(), 'NOTIFICATION_TEMPLATE_NEW_RESERVATION' => Class_AdminVar_Meta::newEditor($this->_('Modèle utilisé pour les courriels de notification des réservations.'), ['value'=> '<p>Bonjour,</p> <p>L\'usager {user.nom_complet} {user.idabon} a fait une demande de réservation sur l\'exemplaire :</p><p><ul><li>Code Barre : {item.code_barres}</li><li>Titre : {item.titre_et_sous_titre}</li><li>Type de Document : {notice.type_doc_label}</li><li>Annexe de retrait : {annexe_code.libelle} </li></ul></p>']), 'GENERATION_SITE' => Class_AdminVar_Meta::newOnOff($this->_('Activation de la génération de site.')), diff --git a/library/Class/AdminVar/MyBibAppTemplate.php b/library/Class/AdminVar/MyBibAppTemplate.php new file mode 100644 index 0000000000000000000000000000000000000000..c4216312179df05f441fd32ab80b54d06d1c9463 --- /dev/null +++ b/library/Class/AdminVar/MyBibAppTemplate.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright (c) 2012-2019, 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_AdminVar_MyBibAppTemplate { + public function isEnabled() { + return Class_AdminVar::isModuleEnabled('MYBIBAPP_TEMPLATE') && Class_AdminVar::isModuleEnabled('TEMPLATING'); + } +} diff --git a/library/Class/Article.php b/library/Class/Article.php index cf0eff1193935c780bb788baba03720de508cdd1..73c4fd36b329ebd61c538371b8af2897393e0d04 100644 --- a/library/Class/Article.php +++ b/library/Class/Article.php @@ -1072,7 +1072,7 @@ class Class_Article extends Storm_Model_Abstract { */ public function getFirstImageURL() { $matches = array(); - if (preg_match('/< *img[^>]*src *= *["\']?([^"\'>]*)/i', $this->getFullContent(), $matches) > 0) + if (preg_match('/< *img[^>]*src *= *["\']?([^"\'>]*)/i', $this->getSummary(), $matches) > 0) return $matches[1]; return ''; diff --git a/library/Class/Profil.php b/library/Class/Profil.php index d451ff59ff5944a29680e676dcca0b93bce021bf..ad65d8b2a268ed4c315413e78ad2ffc89160414a 100644 --- a/library/Class/Profil.php +++ b/library/Class/Profil.php @@ -2030,7 +2030,7 @@ class Class_Profil extends Storm_Model_Abstract { $id_module = 0; $i = 0; foreach($cfg_accueil['modules'] as $module_id => $module) { - if ($module['division'] == $div) { + if (isset($module['division']) && $module['division'] == $div) { if ($pos == $i) { $id_module = $module_id; break; @@ -2071,6 +2071,9 @@ class Class_Profil extends Storm_Model_Abstract { $new_modules = []; $i = 0; foreach($cfg_accueil['modules'] as $module_id => $module) { + if (!isset($module['division'])) + continue; + $in_new_div = $module['division'] == $new_div; if (($i == $new_pos) && $in_new_div) diff --git a/library/Class/Systeme/Widget/Settings.php b/library/Class/Systeme/Widget/Settings.php new file mode 100644 index 0000000000000000000000000000000000000000..b1cbadb207a528600e697b2486ada39f038e4f60 --- /dev/null +++ b/library/Class/Systeme/Widget/Settings.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright (c) 2012-2019, 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_Systeme_Widget_Settings extends Class_Entity { +} diff --git a/library/Class/Template.php b/library/Class/Template.php index b2cb13e26be123cd9a7bc56a3ee056fbeb99bb0d..5d4ddae2108dc231946ab27bafa2af265001753e 100644 --- a/library/Class/Template.php +++ b/library/Class/Template.php @@ -46,7 +46,14 @@ class Class_Template { return $this; } - return call_user_func([$settings, $name], isset($params[0]) ? $params[0] : null); + $result = null; + + if (preg_match('/(get)(\w+)/', $name, $matches)) + $result = call_user_func([$settings, 'get' . $this->withNameSpace($matches[2])], isset($params[0]) ? $params[0] : null); + + return $result + ? $result + : call_user_func([$settings, $name], isset($params[0]) ? $params[0] : null); } @@ -59,7 +66,12 @@ class Class_Template { public static function setCurrentFrom($profile_id) { - return static::setCurrent((new Class_Template_Loader)->findFromProfile($profile_id)); + $loader = new Class_Template_Loader; + $template = (new Class_UserAgent)->isMyBibApp() && (new Class_AdminVar_MyBibAppTemplate)->isEnabled() + ? $loader->findMyBibApp() + : $loader->findFromProfile($profile_id); + + return static::setCurrent($template); } @@ -103,10 +115,11 @@ class Class_Template { } - public function getControlKey() { + public function getControlKey($profile) { if ($this->_control_key) return $this->_control_key; - return $this->_control_key = md5($this->getId()); + + return $this->_control_key = md5($this->getId().$profile->getId()); } @@ -124,12 +137,12 @@ class Class_Template { protected function _findOrCreateTryProfileFrom($profile) { - if ($try_profile = Class_Profil::findFirstBy(['commentaire' => $this->getControlKey()])) + if ($try_profile = Class_Profil::findFirstBy(['commentaire' => $this->getControlKey($profile)])) return $try_profile; return $profile ->deepCopy() - ->setCommentaire($this->getControlKey()) + ->setCommentaire($this->getControlKey($profile)) ->setAccessLevel(ZendAfi_Acl_AdminControllerRoles::MODO_BIB) ->setLibelle($this->_('Test charte : "%s"', $this->getTitle())) @@ -161,7 +174,7 @@ class Class_Template { public function withNameSpace($text) { - return Storm_Inflector::camelize($this->getId() . '_' . $text); + return Storm_Inflector::camelize($this->getId() . '_' . Storm_Inflector::underscorize($text)); } @@ -210,11 +223,21 @@ class Class_Template { } + public function getWidgetSettingsWrapper($settings) { + return new Class_Systeme_Widget_Settings($settings); + } + + public function renderOpac($view) { return ''; } + public function renderSubModal($view) { + return ''; + } + + public function renderKO($view) { return ''; } diff --git a/library/Class/Template/Loader.php b/library/Class/Template/Loader.php index c0a68803e29cdd936d93d46ef5e947c98b932013..4248f4d477a2fefe8d9cefca754da4b8e116c34b 100644 --- a/library/Class/Template/Loader.php +++ b/library/Class/Template/Loader.php @@ -26,7 +26,13 @@ class Class_Template_Loader { public function getTemplates() { return [new Historic_Template, - new Intonation_Template]; + new Intonation_Template, + new MyBibApp_Template]; + } + + + public function findMyBibApp() { + return $this->find(MyBibApp_Template::ID); } diff --git a/library/Class/Template/ProfilePatcher.php b/library/Class/Template/ProfilePatcher.php new file mode 100644 index 0000000000000000000000000000000000000000..91325b965e2c788eb5a2b192b78568475232ff32 --- /dev/null +++ b/library/Class/Template/ProfilePatcher.php @@ -0,0 +1,69 @@ +<?php +/** + * Copyright (c) 2012-2019, 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_ProfilePatcher { + + use Trait_Translator; + + + protected + $_profile, + $_template; + + + public function __construct($template) { + $this->_template = $template; + } + + + protected function _removeWidgets() { + $cfg_accueil = $this->_profile->getCfgAccueilAsArray(); + + foreach($cfg_accueil['modules'] as $id => $config) + unset($cfg_accueil['modules'][$id]); + + $this->_profile + ->setCfgAccueil($cfg_accueil) + ->save(); + + return $this; + } + + + protected function _addWidget($type, $division, $settings = []) { + $new_id = $this->_profile->createNewModuleAccueilId(); + + $preferences = array_merge(Class_Systeme_ModulesAccueil::getInstance() + ->getModuleByCode($type) + ->getDefaultValues(), + $settings); + + $this->_profile->updateModuleConfigAccueil($new_id, + ['type_module' => $type, + 'division' => $division, + 'preferences' => $preferences]); + + $this->_profile->save(); + + return $this; + } +} diff --git a/library/Class/Template/Settings.php b/library/Class/Template/Settings.php index 4c00600af418cfe38232b5e19929466af7cf55ea..279b647dc0e135be565c661509ef97019cd24b5e 100644 --- a/library/Class/Template/Settings.php +++ b/library/Class/Template/Settings.php @@ -101,7 +101,7 @@ class Class_Template_Settings extends Storm_Model_Abstract { if ($this->_hydrating_mapping) return $this->_hydrating_mapping; $settings = $this->getSettingsInstance(); - return $this->_hydrating_mapping = $settings->getIntonationHydratingMapping(); + return $this->_hydrating_mapping = $settings->getHydratingMapping(); } diff --git a/library/Class/UserAgent.php b/library/Class/UserAgent.php index f8182b0a5090af408d639c98a8f16fbd724ccb10..52f80c1e8ec80efe6ba66f2406979c92466cd717 100644 --- a/library/Class/UserAgent.php +++ b/library/Class/UserAgent.php @@ -56,6 +56,12 @@ class Class_UserAgent { } + public function isMyBibApp() { + return 0 !== preg_match('/mybibapp/i', + $this->_user_agent_string); + } + + public function isBotAndNotAllowedBetweenHours($start_hour, $end_hour) { if (!$this->isBot()) return false; diff --git a/library/ZendAfi/Controller/Plugin/DefineURLs.php b/library/ZendAfi/Controller/Plugin/DefineURLs.php index 382042c028415fb4b48e794c5b5a0697c75ecb6c..d228b7990b6bb95544ba778f0f46f2cbb115f7df 100644 --- a/library/ZendAfi/Controller/Plugin/DefineURLs.php +++ b/library/ZendAfi/Controller/Plugin/DefineURLs.php @@ -20,7 +20,6 @@ */ class ZendAfi_Controller_Plugin_DefineURLs extends Zend_Controller_Plugin_Abstract { - const PHONE = 'telephone', ADMIN = 'admin', diff --git a/library/ZendAfi/View/Helper/Accueil/Base.php b/library/ZendAfi/View/Helper/Accueil/Base.php index 35217781e83c66581ab46094488df362f55ff5b4..edc2820b0065acc28f828a7028753a049fc61f83 100644 --- a/library/ZendAfi/View/Helper/Accueil/Base.php +++ b/library/ZendAfi/View/Helper/Accueil/Base.php @@ -70,7 +70,7 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac foreach($this->preferences as $key => $value) $settings[Storm_Inflector::camelize(Storm_Inflector::underscorize($key))] = $value; - $this->_settings = new Class_Entity($settings); + $this->_settings = Class_Template::current()->getWidgetSettingsWrapper($settings); } diff --git a/library/ZendAfi/View/Helper/Layout/SubModal.php b/library/ZendAfi/View/Helper/Layout/SubModal.php new file mode 100644 index 0000000000000000000000000000000000000000..f5f754bc2a69ee4e365530a4734f017625c1f70a --- /dev/null +++ b/library/ZendAfi/View/Helper/Layout/SubModal.php @@ -0,0 +1,28 @@ +<?php +/** + * Copyright (c) 2012-2019, 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_View_Helper_Layout_SubModal extends ZendAfi_View_Helper_BaseHelper { + public function Layout_SubModal() { + return Class_Template::current() + ->renderSubModal($this->view); + } +} \ No newline at end of file diff --git a/library/templates/Historic/Template.php b/library/templates/Historic/Template.php index bbeaf86a67cd8c9509aeef4959bbae5fccdffa0c..089c3f0b0b9dcaa030e4fc2b278ec585432ed9b0 100644 --- a/library/templates/Historic/Template.php +++ b/library/templates/Historic/Template.php @@ -83,4 +83,30 @@ class Historic_Template extends Class_Template { ['titre' => $view->getTitre()])) . $html; } + + + public function renderSubModal($view) { + $script_loader = Class_ScriptLoader::getInstance() + ->loadJQuery() + ->loadJQueryUI() + ->showNotifications() + ->addAdminStyleSheet('subModalContenu') + ->addAdminScript('global') + ->addOpacScript('subModal') + ->addOpacStyleSheet('global') + ->addSkinStyleSheets(['iframe', 'global']); + + ob_start(); + echo '<html lang="' . $this->_translate()->getLocale() . '" xml:lang="' . $this->_translate()->getLocale() . '" xmlns="http://www.w3.org/1999/xhtml">'; + echo '<head>'; + echo '<meta http-equiv="Content-Type" content="text/html;charset=utf-8">'; + echo $script_loader->html(); + echo '</head>'; + echo '<body '. $view->bodyParam . '>' . $view->render($view->actionScript). '</body>'; + echo '</html>'; + + $html = ob_get_contents(); + ob_end_clean(); + return $html; + } } \ No newline at end of file diff --git a/library/templates/Intonation/Assets/css/intonation.css b/library/templates/Intonation/Assets/css/intonation.css index f70c8f43eeceaa1737828ff422f9295665c67934..427712e701c57a03832cceea19562d98469649f0 100644 --- a/library/templates/Intonation/Assets/css/intonation.css +++ b/library/templates/Intonation/Assets/css/intonation.css @@ -42,6 +42,10 @@ body { font-size: 3em; } +.card-title { + font-size: 1.25rem; +} + .card-img-overlay { background-color: var(--front-background-overlay); opacity: 0; @@ -503,7 +507,8 @@ dl.row { display: none !important; } -.button_text_d_none > a > .button_text { +.button_text_d_none > a > .button_text, +.button_text_d_none > .dropdown > a > .button_text { display: none !important; } diff --git a/library/templates/Intonation/Library/ProfilePatcher.php b/library/templates/Intonation/Library/ProfilePatcher.php index 9efc0f2c5c9c491424dd2f4f658afb1b3f7d88de..e52952d35a494891cd6c9dc52121856b4ce2e3e2 100644 --- a/library/templates/Intonation/Library/ProfilePatcher.php +++ b/library/templates/Intonation/Library/ProfilePatcher.php @@ -20,10 +20,7 @@ */ -class Intonation_Library_ProfilePatcher { - protected $_profile; - protected $_profile_id; - +class Intonation_Library_ProfilePatcher extends Class_Template_ProfilePatcher { public function upgrade($profile) { $this->_profile = $profile; @@ -95,19 +92,23 @@ class Intonation_Library_ProfilePatcher { $cfg_accueil = $this->_profile->getCfgAccueilAsArray(); $ids = []; - foreach($cfg_accueil['modules'] as $id => $config) + foreach($cfg_accueil['modules'] as $id => $config) { + if (!isset($config['type_module'])) + return $this; + if ($config['type_module'] == 'ARIANE') return $this; + } $new_id = $this->_profile->createNewModuleAccueilId(); $this->_profile->updateModuleConfigAccueil($new_id, ['type_module' => 'ARIANE', 'division' => 4, - 'preferences' => ['IntonationShowHeader' => 0, - 'IntonationShowContent' => 1, - 'IntonationShowFooter' => 0, - 'IntonationWidthXsmall' => 12]]); + 'preferences' => [$this->_template->withNameSpace('show_header') => 0, + $this->_template->withNameSpace('show_content') => 1, + $this->_template->withNameSpace('footer') => 0, + $this->_template->withNameSpace('width_xsmall') => 12]]); $this->_profile->moveModuleOldDivPosNewDivPos(4, $this->_profile->getModulePositionInDiv($new_id, 4), @@ -136,7 +137,7 @@ class Intonation_Library_ProfilePatcher { $cfg_accueil = $this->_profile->getCfgAccueilAsArray(); $ids = []; foreach($cfg_accueil['modules'] as $id => $config) { - if (!$config['type_module'] == 'SCROLL') + if (!isset($config['type_module']) || !$config['type_module'] == 'SCROLL') continue; if (!isset($config['preferences']['direction'])) @@ -151,9 +152,9 @@ class Intonation_Library_ProfilePatcher { $this->_profile->updateModuleConfigAccueil($new_id, ['type_module' => 'SCROLL', 'division' => 6, - 'preferences' => ['IntonationShowHeader' => 0, - 'IntonationShowContent' => 0, - 'IntonationShowFooter' => 0]]); + 'preferences' => [$this->_template->withNameSpace('show_header') => 0, + $this->_template->withNameSpace('show_content') => 0, + $this->_template->withNameSpace('show_footer') => 0]]); $this->_profile->moveModuleOldDivPosNewDivPos(6, $this->_profile->getModulePositionInDiv($new_id, 6), @@ -202,9 +203,9 @@ class Intonation_Library_ProfilePatcher { $this->_profile->updateModuleConfigAccueil($new_id, ['type_module' => 'SCROLL', 'division' => 4, - 'preferences' => ['IntonationShowHeader' => 0, - 'IntonationShowContent' => 0, - 'IntonationShowFooter' => 0]]); + 'preferences' => [$this->_template->withNameSpace('show_header') => 0, + $this->_template->withNameSpace('show_content') => 0, + $this->_template->withNameSpace('show_footer') => 0]]); $this->_profile->save(); @@ -228,18 +229,22 @@ class Intonation_Library_ProfilePatcher { $cfg_accueil = $this->_profile->getCfgAccueilAsArray(); $ids = []; - foreach($cfg_accueil['modules'] as $id => $config) + foreach($cfg_accueil['modules'] as $id => $config) { + if (!isset($config['type_module'])) + return $this; + if ($config['type_module'] == 'ADMIN_TOOLS') return $this; + } $new_id = $this->_profile->createNewModuleAccueilId(); $this->_profile->updateModuleConfigAccueil($new_id, ['type_module' => 'ADMIN_TOOLS', 'division' => 4, - 'preferences' => ['IntonationShowHeader' => 0, - 'IntonationShowContent' => 0, - 'IntonationShowFooter' => 0]]); + 'preferences' => [$this->_template->withNameSpace('show_header') => 0, + $this->_template->withNameSpace('show_content') => 0, + $this->_template->withNameSpace('show_footer') => 0]]); $this->_profile->moveModuleOldDivPosNewDivPos(4, $this->_profile->getModulePositionInDiv($new_id, 4), @@ -266,18 +271,22 @@ class Intonation_Library_ProfilePatcher { $cfg_accueil = $this->_profile->getCfgAccueilAsArray(); $ids = []; - foreach($cfg_accueil['modules'] as $id => $config) + foreach($cfg_accueil['modules'] as $id => $config) { + if (!isset($config['type_module'])) + return $this; + if ($config['type_module'] == 'CREDITS') return $this; + } $new_id = $this->_profile->createNewModuleAccueilId(); $this->_profile->updateModuleConfigAccueil($new_id, ['type_module' => 'CREDITS', 'division' => 6, - 'preferences' => ['IntonationShowHeader' => 0, - 'IntonationShowContent' => 1, - 'IntonationShowFooter' => 0]]); + 'preferences' => [$this->_template->withNameSpace('show_Header') => 0, + $this->_template->withNameSpace('show_content') => 1, + $this->_template->withNameSpace('show_footer') => 0]]); $this->_profile->moveModuleOldDivPosNewDivPos(6, $this->_profile->getModulePositionInDiv($new_id, 6), @@ -304,18 +313,22 @@ class Intonation_Library_ProfilePatcher { $cfg_accueil = $this->_profile->getCfgAccueilAsArray(); $ids = []; - foreach($cfg_accueil['modules'] as $id => $config) + foreach($cfg_accueil['modules'] as $id => $config) { + if (!isset($config['type_module'])) + return $this; + if ($config['type_module'] == 'ACCESSIBILITY') return $this; + } $new_id = $this->_profile->createNewModuleAccueilId(); $this->_profile->updateModuleConfigAccueil($new_id, ['type_module' => 'ACCESSIBILITY', 'division' => 4, - 'preferences' => ['IntonationShowHeader' => 0, - 'IntonationShowContent' => 0, - 'IntonationShowFooter' => 0]]); + 'preferences' => [$this->_template->withNameSpace('show_header') => 0, + $this->_template->withNameSpace('show_content') => 0, + $this->_template->withNameSpace('show_footer') => 0]]); $this->_profile->moveModuleOldDivPosNewDivPos(4, $this->_profile->getModulePositionInDiv($new_id, 4), @@ -342,19 +355,23 @@ class Intonation_Library_ProfilePatcher { $cfg_accueil = $this->_profile->getCfgAccueilAsArray(); $ids = []; - foreach($cfg_accueil['modules'] as $id => $config) + foreach($cfg_accueil['modules'] as $id => $config) { + if (!isset($config['type_module'])) + return $this; + if ($config['type_module'] == 'NOTIFY') return $this; + } $new_id = $this->_profile->createNewModuleAccueilId(); $this->_profile->updateModuleConfigAccueil($new_id, ['type_module' => 'NOTIFY', 'division' => 6, - 'preferences' => ['IntonationWidthXsmall' => 9, - 'IntonationShowHeader' => 0, - 'IntonationShowContent' => 0, - 'IntonationShowFooter' => 0]]); + 'preferences' => [$this->_template->withNameSpace('width_xsmall') => 9, + $this->_template->withNameSpace('show_header') => 0, + $this->_template->withNameSpace('show_content') => 0, + $this->_template->withNameSpace('show_footer') => 0]]); $this->_profile->moveModuleOldDivPosNewDivPos(6, $this->_profile->getModulePositionInDiv($new_id, 6), diff --git a/library/templates/Intonation/Library/View/Wrapper/Article.php b/library/templates/Intonation/Library/View/Wrapper/Article.php index bbc6471109d61bc6bdc0506cb90f6c371ce75a1e..ad4c90a3635ef19386feea3dc73b5e0963f59f21 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Article.php +++ b/library/templates/Intonation/Library/View/Wrapper/Article.php @@ -110,7 +110,32 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr public function getActions() { - return []; + if (!Class_Users::isCurrentUserCanAccesBackend()) + return []; + + $actions_pro = [new Intonation_Library_Link(['Url' => $this->_view->url(['module' => 'admin', + 'controller' => 'cms', + 'action' => 'edit', + 'id' => $this->_model->getId()], null, true), + + 'Attribs' => ['class' => 'menu_admin_front_anchor'], + 'Image' => Class_Template::current()->getIco($this->_view, + 'edit', + 'utils'), + 'Text' => $this->_('Modifier …'), + 'Popup' => true, + 'Title' => $this->_('Modifier l\'article %s', + $this->_model->getLibelle())])]; + + $button = new Intonation_Library_Link(['Text' => $this->_('Plus'), + 'Attribs' => ['class' => 'text-primary'], + 'Title' => $this->_('Voir plus d\'actions pour %s', + $this->_model->getLibelle()), + 'Image' => Class_Template::current()->getIco($this->_view, + 'more', + 'utils')]); + + return [$this->_view->renderDropdown($this->_view->renderActions($actions_pro), $button, 'dropleft dropup')]; } diff --git a/library/templates/Intonation/Library/Widget/Carousel/Library/View.php b/library/templates/Intonation/Library/Widget/Carousel/Library/View.php index c502d5fd92f77accdced7d2baaec8150f5394c03..6002e5fdc94cd1a95d83e757c3dce79f898b63d0 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Library/View.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Library/View.php @@ -73,6 +73,7 @@ class Intonation_Library_Widget_Carousel_Library_View extends Intonation_Library $this->view->librariesMap($this->_findElements(), '#' . $id, ['fields' => $fields, + 'linked' => 1, 'osm_layer' => 1, ])) . parent::_getHtml(); diff --git a/library/templates/Intonation/Library/Widget/Login/View.php b/library/templates/Intonation/Library/Widget/Login/View.php index 25f475ac92f197ec9fee9a9006dd3428e42361bb..55daefa3901cbc6d7eabebae24a0dc4fb1b80ec8 100644 --- a/library/templates/Intonation/Library/Widget/Login/View.php +++ b/library/templates/Intonation/Library/Widget/Login/View.php @@ -49,7 +49,7 @@ class Intonation_Library_Widget_Login_View extends Zendafi_View_Helper_Accueil_B protected function _getRenderStrategy() { - $form_style = $this->_settings->getIntonationFormStyle(); + $form_style = $this->_settings->getFormStyle(); if('inline' == $form_style) return new IntonationLoginRenderInline($this->view, $this->_settings, $this->_user); diff --git a/library/templates/Intonation/Library/Widget/Nav/View.php b/library/templates/Intonation/Library/Widget/Nav/View.php index 6395bbdfed7271383aa0249292e63f328034418b..85a8dae283dad7c148fa9f930a2f3f0f674cb3e0 100644 --- a/library/templates/Intonation/Library/Widget/Nav/View.php +++ b/library/templates/Intonation/Library/Widget/Nav/View.php @@ -68,7 +68,7 @@ class Intonation_Library_Widget_Nav_View extends Zendafi_View_Helper_Accueil_Bas protected function _addExpandBreakPoint() { - $value = $this->_settings->getIntonationExpandBreakpoint(); + $value = $this->_settings->getExpandBreakpoint(); if ($value == Intonation_Library_Constants::RESPONSIVE_MODE_ALWAYS) return ' navbar-collapse'; diff --git a/library/templates/Intonation/Library/Widget/Search/Definition.php b/library/templates/Intonation/Library/Widget/Search/Definition.php index 44c361125142910f604309653e25701bc65f3eae..a6a2d412f64d2b368b4edfc44116b4f333314ba9 100644 --- a/library/templates/Intonation/Library/Widget/Search/Definition.php +++ b/library/templates/Intonation/Library/Widget/Search/Definition.php @@ -25,6 +25,6 @@ class Intonation_Library_Widget_Search_Definition extends Class_Systeme_ModulesA parent::__construct(); $this->_view_helper = 'Intonation_Library_Widget_Search_View'; $this->_defaultValues = array_merge($this->_defaultValues, - ['IntonationFormStyle' => 'default']); + [Class_Template::current()->withNameSpace('FormStyle') => 'default']); } } \ No newline at end of file diff --git a/library/templates/Intonation/Library/Widget/Search/View.php b/library/templates/Intonation/Library/Widget/Search/View.php index b5408d37f4629395dbb6fb9de9a7b536d146cf74..977b0bbd61c85305bae118d0c336bc7ff54de504 100644 --- a/library/templates/Intonation/Library/Widget/Search/View.php +++ b/library/templates/Intonation/Library/Widget/Search/View.php @@ -43,7 +43,7 @@ class Intonation_Library_Widget_Search_View extends ZendAfi_View_Helper_Accueil_ protected function _getRenderStrategy() { - if(!$style = $this->_settings->getIntonationFormStyle()) + if(!$style = $this->_settings->getFormStyle()) return new IntonationSearchRenderDefault($this->view, $this->_settings, $this->_user); if('inline' == $style) diff --git a/library/templates/Intonation/System/Abstract.php b/library/templates/Intonation/System/Abstract.php index 759a3fea2df229afd32aeb978702c7ffb0378499..35972b7c4241ec9393c0b7b8d973ebf302e02b96 100644 --- a/library/templates/Intonation/System/Abstract.php +++ b/library/templates/Intonation/System/Abstract.php @@ -31,7 +31,14 @@ abstract class Intonation_System_Abstract { return $this; } - return call_user_func([$this->_settings, $name], isset($params[0]) ? $params[0] : null); + $result = null; + + if (preg_match('/(get)(\w+)/', $name, $matches)) + $result = call_user_func([$this->_settings, 'get' . Class_Template::current()->withNameSpace($matches[2])], isset($params[0]) ? $params[0] : null); + + return (null !== $result) + ? $result + : call_user_func([$this->_settings, $name], isset($params[0]) ? $params[0] : null); } @@ -59,7 +66,7 @@ abstract class Intonation_System_Abstract { protected function _getHiddenClass() { - if(!$mode = $this->getIntonationHiddenMode()) + if(!$mode = $this->getHiddenMode()) return ''; return sprintf('d-none d-%s-block', $mode); @@ -88,19 +95,19 @@ abstract class Intonation_System_Abstract { protected function _getOrderClass() { $orders = []; - if($xsmall = $this->getIntonationOrderXsmall()) + if($xsmall = $this->getOrderXsmall()) $orders [] = 'order-' . $xsmall; - if($small = $this->getIntonationOrderSmall()) + if($small = $this->getOrderSmall()) $orders [] = 'order-' . Intonation_Library_Constants::RESPONSIVE_MODE_SMALL . '-' . $small; - if($medium = $this->getIntonationOrderMedium()) + if($medium = $this->getOrderMedium()) $orders [] = 'order-' . Intonation_Library_Constants::RESPONSIVE_MODE_MEDIUM . '-' . $medium; - if($large = $this->getIntonationOrderLarge()) + if($large = $this->getOrderLarge()) $orders [] = 'order-' . Intonation_Library_Constants::RESPONSIVE_MODE_LARGE . '-' . $large; - if($xlarge = $this->getIntonationOrderXlarge()) + if($xlarge = $this->getOrderXlarge()) $orders [] = 'order-' . Intonation_Library_Constants::RESPONSIVE_MODE_XLARGE . '-' . $xlarge; return trim(implode(' ', array_filter($orders))); @@ -110,19 +117,19 @@ abstract class Intonation_System_Abstract { protected function _getResponsiveWidths() { $widths = []; - if($xsmall = $this->getIntonationWidthXsmall()) + if($xsmall = $this->getWidthXsmall()) $widths [] = 'col-' . $xsmall; - if($small = $this->getIntonationWidthSmall()) + if($small = $this->getWidthSmall()) $widths [] = 'col-' . Intonation_Library_Constants::RESPONSIVE_MODE_SMALL . '-' . $small; - if($medium = $this->getIntonationWidthMedium()) + if($medium = $this->getWidthMedium()) $widths [] = 'col-' . Intonation_Library_Constants::RESPONSIVE_MODE_MEDIUM . '-' . $medium; - if($large = $this->getIntonationWidthLarge()) + if($large = $this->getWidthLarge()) $widths [] = 'col-' . Intonation_Library_Constants::RESPONSIVE_MODE_LARGE . '-' . $large; - if($xlarge = $this->getIntonationWidthXlarge()) + if($xlarge = $this->getWidthXlarge()) $widths [] = 'col-' . Intonation_Library_Constants::RESPONSIVE_MODE_XLARGE . '-' . $xlarge; $classes = trim(implode(' ', array_filter($widths))); @@ -135,19 +142,19 @@ abstract class Intonation_System_Abstract { protected function _getOffsetClass() { $offsets = []; - if($xsmall = $this->getIntonationOffsetXsmall()) + if($xsmall = $this->getOffsetXsmall()) $offsets [] = 'offset-' . $xsmall; - if($small = $this->getIntonationOffsetSmall()) + if($small = $this->getOffsetSmall()) $offsets [] = 'offset-' . Intonation_Library_Constants::RESPONSIVE_MODE_SMALL . '-' . $small; - if($medium = $this->getIntonationOffsetMedium()) + if($medium = $this->getOffsetMedium()) $offsets [] = 'offset-' . Intonation_Library_Constants::RESPONSIVE_MODE_MEDIUM . '-' . $medium; - if($large = $this->getIntonationOffsetLarge()) + if($large = $this->getOffsetLarge()) $offsets [] = 'offset-' . Intonation_Library_Constants::RESPONSIVE_MODE_LARGE . '-' . $large; - if($xlarge = $this->getIntonationOffsetXlarge()) + if($xlarge = $this->getOffsetXlarge()) $offsets [] = 'offset-' . Intonation_Library_Constants::RESPONSIVE_MODE_XLARGE . '-' . $xlarge; return trim(implode(' ', array_filter($offsets))); @@ -276,22 +283,22 @@ abstract class Intonation_System_Abstract { public function isVisibleFromXL() { - return $this->getIntonationHiddenMode() == Intonation_Library_Constants::RESPONSIVE_MODE_XLARGE; + return $this->getHiddenMode() == Intonation_Library_Constants::RESPONSIVE_MODE_XLARGE; } public function isVisibleFromL() { - return $this->getIntonationHiddenMode() == Intonation_Library_Constants::RESPONSIVE_MODE_LARGE; + return $this->getHiddenMode() == Intonation_Library_Constants::RESPONSIVE_MODE_LARGE; } public function isVisibleFromM() { - return $this->getIntonationHiddenMode() == Intonation_Library_Constants::RESPONSIVE_MODE_MEDIUM; + return $this->getHiddenMode() == Intonation_Library_Constants::RESPONSIVE_MODE_MEDIUM; } public function isVisibleFromS() { - return $this->getIntonationHiddenMode() == Intonation_Library_Constants::RESPONSIVE_MODE_SMALL; + return $this->getHiddenMode() == Intonation_Library_Constants::RESPONSIVE_MODE_SMALL; } diff --git a/library/Class/Template/SettingsWrapper.php b/library/templates/Intonation/System/WidgetSettings.php similarity index 58% rename from library/Class/Template/SettingsWrapper.php rename to library/templates/Intonation/System/WidgetSettings.php index c039b9dcfe408643d50fbf91ef242de151d360e9..eda179dcd86172f5766f3e7563bb29092f43453e 100644 --- a/library/Class/Template/SettingsWrapper.php +++ b/library/templates/Intonation/System/WidgetSettings.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved. + * Copyright (c) 2012-2019, 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 @@ -20,36 +20,25 @@ */ -class Class_Template_SettingsWrapper { - use Trait_Versionable; - - protected $_settings; - +class Intonation_System_WidgetSettings { public function __call($name, $params) { if (preg_match('/(^set)(\w+)/', $name, $matches)) { call_user_func([$this->_settings, $name], $params[0]); return $this; } - return call_user_func([$this->_settings, $name], isset($params[0]) ? $params[0] : null); - } - - - public function __construct($template) { - $this->_template = $template; - $this->_settings = (($settings = Class_Template_Settings::findFirstBy(['template' => $this->_template->getId()])) - ? $settings - : Class_Template_Settings::newInstance()); - $this->_injectDefaultSettings(); - } + $result = null; + if (preg_match('/(get)(\w+)/', $name, $matches)) + $result = call_user_func([$this->_settings, 'get' . Class_Template::current()->withNameSpace($matches[2])], isset($params[0]) ? $params[0] : null); - protected function _injectDefaultSettings() { - return $this; + return (null !== $result) + ? $result + : call_user_func([$this->_settings, $name], isset($params[0]) ? $params[0] : null); } - public function getWidgets() { - return []; + public function __construct($settings) { + $this->_settings = $settings; } -} \ No newline at end of file +} diff --git a/library/templates/Intonation/Template.php b/library/templates/Intonation/Template.php index 45ed82624622452a97cd7ac6098a20541421046e..a2b3d400565a5ed633084650b26691c9f58eaa97 100644 --- a/library/templates/Intonation/Template.php +++ b/library/templates/Intonation/Template.php @@ -30,7 +30,7 @@ class Intonation_Template extends Class_Template { ->setId('INTONATION') ->setTitle($this->_('Intonation')) ->setSettings(new Intonation_Library_Settings($this)) - ->setPatcher(new Intonation_Library_ProfilePatcher); + ->setPatcher(new Intonation_Library_ProfilePatcher($this)); } @@ -39,6 +39,11 @@ class Intonation_Template extends Class_Template { } + public function renderSubModal($view) { + return (new Intonation_View_SubModal($this, $view))->render(); + } + + public function renderWidgetOn($instance, $view) { return $instance->renderOn($view); } @@ -157,6 +162,11 @@ class Intonation_Template extends Class_Template { } + public function getWidgetSettingsWrapper($settings) { + return new Intonation_System_WidgetSettings(parent::getWidgetSettingsWrapper($settings)); + } + + public function customWidgetForm($form) { $helper = new Intonation_Library_FormCustomizer($this); return $helper->getWidgetForm($form); diff --git a/library/templates/Intonation/View/AddBootstrap.php b/library/templates/Intonation/View/AddBootstrap.php index f3af977af2f166f1f593d2d999001ac6fc691805..0c612f44f2ade261d041f4dca6f321f34ef263ee 100644 --- a/library/templates/Intonation/View/AddBootstrap.php +++ b/library/templates/Intonation/View/AddBootstrap.php @@ -28,7 +28,7 @@ class Intonation_View_AddBootstrap extends ZendAfi_View_Helper_BaseHelper { $template = Class_Template::current(); - if($template->getIntonationBootstrapCss()) + if($template->getBootstrapCss()) $script_loader->cssAddLine( $this->_tag('link', null, @@ -37,14 +37,14 @@ class Intonation_View_AddBootstrap extends ZendAfi_View_Helper_BaseHelper { 'integrity' => 'sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T', 'crossorigin' => 'anonymous'])); - if($template->getIntonationBootstrapDependencyPopper()) + if($template->getBootstrapDependencyPopper()) $script_loader->scriptsAddLine($this->view->tag('script', '', ['src' => 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js', 'integrity' => 'sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1', 'crossorigin' => 'anonymous'])); - if($template->getIntonationBootstrapJs()) + if($template->getBootstrapJs()) $script_loader->scriptsAddLine($this->view->tag('script', '', ['src' => 'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js', diff --git a/library/templates/Intonation/View/Cardify.php b/library/templates/Intonation/View/Cardify.php index 24c898041ee55fb6add8c288e2375812e194a025..6cd6b2834ba1a75b9b46a224b08a94b9342e7c7c 100644 --- a/library/templates/Intonation/View/Cardify.php +++ b/library/templates/Intonation/View/Cardify.php @@ -26,13 +26,6 @@ class Intonation_View_Cardify extends ZendAfi_View_Helper_BaseHelper { ['class' => 'card-img-top text-center'], ['class' => 'card-img']); - if ($link = $element->getMainLink()) - $img = $this->view->tagAnchor($link->getUrl(), - $img, - ['title' => $link->getTitle(), - 'data-popup' => $link->getPopup(), - 'class' => 'card-img-top text-center']); - return $this->view->cardifyOnlyDescription($element, $img); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/CardifyOnlyDescription.php b/library/templates/Intonation/View/CardifyOnlyDescription.php index ce5e018c58ee2ff96bb9aa29ce99d051a1033270..94756a227131593e6e8335622de413df2aeaa07e 100644 --- a/library/templates/Intonation/View/CardifyOnlyDescription.php +++ b/library/templates/Intonation/View/CardifyOnlyDescription.php @@ -26,12 +26,12 @@ class Intonation_View_CardifyOnlyDescription extends ZendAfi_View_Helper_BaseHel $content = [$element->getContentForJSSearch()]; if ($title = $element->getMainTitle()) - $content [] = $title = $this->_tag('h5', + $content [] = $title = $this->_tag('div', $title, ['class' => 'card-title']); if ($second_link = $element->getSecondaryLink()) - $content [] = $this->_tag('h6', + $content [] = $this->_tag('div', $this->view->tagAnchor($second_link->getUrl(), $second_link->getText(), ['title' => $second_link->getTitle(), diff --git a/library/templates/Intonation/View/Iframe.php b/library/templates/Intonation/View/Iframe.php index a96f82e6ded735ca0f05ffbc5253333fb1bce8b9..5208a3d7a7f89bcccb2203fde6c5b3608f30bb43 100644 --- a/library/templates/Intonation/View/Iframe.php +++ b/library/templates/Intonation/View/Iframe.php @@ -20,19 +20,9 @@ */ -class Intonation_View_Iframe extends ZendAfi_View_Helper_BaseHelper { +class Intonation_View_Iframe extends Intonation_View_Opac { - protected - $_body, - $_profile, - $_template; - - - public function __construct($template, $view) { - $this->view = $view; - $this->_template = $template; - $this->_profile = $template->getProfile(); - } + protected $_body; public function setBody($content) { @@ -54,95 +44,4 @@ class Intonation_View_Iframe extends ZendAfi_View_Helper_BaseHelper { $head . $body, ['lang' => $this->_translate()->getLocale()]); } - - - protected function _headContent() { - $script_loader = Class_ScriptLoader::getInstance(); - $head_scripts = Class_ScriptLoader::newInstance() - ->addInlineScript(sprintf('var baseUrl="%s"; var imagesUrl="%s"; var cssUrl="%s"; var userFilesUrl="%s"', - BASE_URL, - URL_ADMIN_IMG, - URL_ADMIN_CSS, - USERFILESURL)); - - if($this->_template->getIntonationJquery()) - $head_scripts->loadJQuery(); - - if($this->_template->getIntonationJqueryUi()) - $head_scripts->loadJQueryUI(); - - $this->_addFontAwesome($head_scripts); - $this->_addBootstrap4($head_scripts); - - if($this->_template->getIntonationCoreJs()) { - $head_scripts->addOPACScript('subModal') - ->addAdminScripts(['onload_utils', 'global']) - ->showNotifications(); - $script_loader->addJQueryReady('initializePopups();'); - } - - if($this->_template->getIntonationCoreCss()) - $head_scripts->addOPACStyleSheet('core'); - - - if($this->_template->getIntonationIntonationCss()) - $head_scripts->addStyleSheets([Class_Url::absolute('/library/templates/Intonation/Assets/css/intonation.css')]); - - if($custom_css_urls = $this->_template->getCustomCssUrl()) - $head_scripts->addStyleSheets($custom_css_urls); - - if($custom_js_urls = $this->_template->getCustomJsUrl()) - $head_scripts->addScripts($custom_js_urls); - - $content = [$this->_tag('meta', null, ['http-equiv' => 'Content-Type', - 'content' => 'text/html;charset=UTF-8']), - - $this->_tag('meta', null, ['name' => 'viewport', - 'content' => 'width=device-width, initial-scale=1, shrink-to-fit=no']), - - $this->_tag('meta', null, ['name' => 'description', - 'content' => $this->_profile->getCommentaire()]), - - $this->_tag('meta', null, ['name' => 'keywords', - 'content' => $this->_profile->getRefTags()]), - - $this->_tag('meta', null, ['name' => 'robots', - 'content' => 'all']), - - $this->_tag('meta', null, ['name' => 'revisit-after', - 'content' => '10 days']), - - $this->_tag('title', $this->view->getTitre()), - - $head_scripts->styleSheetsHTML(), - $script_loader->styleSheetsHTML(), - $head_scripts->javaScriptsHTML(), - $script_loader->javaScriptsHTML(), - $this->view->heartbeat(), - $this->view->headScript(), - $this->view->headLink()]; - - return implode($content); - } - - - protected function _addFontAwesome($script_loader) { - if (!$this->_template->getIntonationFontAwesomeCss()) - return $this; - - $script_loader - ->cssAddLine($this->_tag('link', - null, - ['rel' => 'stylesheet', - 'href' => 'https://use.fontawesome.com/releases/v5.5.0/css/all.css', - 'integrity' => 'sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU', - 'crossorigin' => 'anonymous'])); - return $this; - } - - - protected function _addBootstrap4($script_loader) { - $this->view->addBootstrap($script_loader); - return $this; - } } \ No newline at end of file diff --git a/library/templates/Intonation/View/Opac.php b/library/templates/Intonation/View/Opac.php index cc157ae7c567932e5f5e9947a518e1be4ec8fe27..cfed14115e5f4bbd3a1f923dca78fd4a3f157bd7 100644 --- a/library/templates/Intonation/View/Opac.php +++ b/library/templates/Intonation/View/Opac.php @@ -122,27 +122,26 @@ class Intonation_View_Opac extends ZendAfi_View_Helper_BaseHelper { URL_ADMIN_CSS, USERFILESURL)); - if($this->_template->getIntonationJquery()) + if($this->_template->getJquery()) $head_scripts->loadJQuery(); - if($this->_template->getIntonationJqueryUi()) + if($this->_template->getJqueryUi()) $head_scripts->loadJQueryUI(); $this->_addFontAwesome($head_scripts); $this->_addBootstrap4($head_scripts); - if($this->_template->getIntonationCoreJs()) { + if($this->_template->getCoreJs()) { $head_scripts->addOPACScript('subModal') ->addAdminScripts(['onload_utils', 'global']) ->showNotifications(); $script_loader->addJQueryReady('initializePopups();'); } - if($this->_template->getIntonationCoreCss()) + if($this->_template->getCoreCss()) $head_scripts->addOPACStyleSheet('core'); - - if($this->_template->getIntonationIntonationCss()) + if($this->_template->getIntonationCss()) $head_scripts->addStyleSheets([Class_Url::absolute('/library/templates/Intonation/Assets/css/intonation.css')]); if($custom_css_urls = $this->_template->getCustomCssUrl()) @@ -194,7 +193,7 @@ class Intonation_View_Opac extends ZendAfi_View_Helper_BaseHelper { protected function _addFontAwesome($script_loader) { - if (!$this->_template->getIntonationFontAwesomeCss()) + if (!$this->_template->getFontAwesomeCss()) return $this; $script_loader diff --git a/library/templates/Intonation/View/SubModal.php b/library/templates/Intonation/View/SubModal.php new file mode 100644 index 0000000000000000000000000000000000000000..a483a00b8b5e38e2a02a8bb012debd63a2456118 --- /dev/null +++ b/library/templates/Intonation/View/SubModal.php @@ -0,0 +1,44 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 Intonation_View_SubModal extends Intonation_View_Opac { + + protected function _renderMain() { + return $this->view->div(['class' => 'col-10'], + $this->view->render($this->view->actionScript)); + } + + + protected function _renderHeader() { + return ''; + } + + + protected function _renderFloatSide() { + return ''; + } + + + protected function _renderFooter() { + return ''; + } +} diff --git a/library/templates/Intonation/View/TagAction.php b/library/templates/Intonation/View/TagAction.php index 60922f48ba6f36f4144db11f56f29a5dbe1ea05d..132dc92f3f19515a4b0bf8e63b048b13629d7e66 100644 --- a/library/templates/Intonation/View/TagAction.php +++ b/library/templates/Intonation/View/TagAction.php @@ -68,7 +68,7 @@ class Intonation_View_TagAction extends ZendAfi_View_Helper_BaseHelper { $content, $attribs) : $this->_tag('a', - $content, + (string)$content, $attribs); } diff --git a/library/templates/MyBibApp/Assets/css/mybibapp.css b/library/templates/MyBibApp/Assets/css/mybibapp.css new file mode 100644 index 0000000000000000000000000000000000000000..582bf670006cf26ce9d3e18617ea41b63cfb2788 --- /dev/null +++ b/library/templates/MyBibApp/Assets/css/mybibapp.css @@ -0,0 +1,102 @@ +:root { + --mba-page-background: #dadce2; + --mba-title-background: #3b4564; + --mba-widget-background: #fff; + --mba-tab-background: #fff; + --mba-tab-selected-background: #fff; + --mba-button-background: #ffbd54; + + --mba-button-color: #000; + --mba-button-hover-color: #3b4564; + --mba-notice-color: #bd7c33; + --mba-ok-color: #17ed99; + --mba-widget-title-color: #fff; + --mba-widget-body-color: #3b4564; + --mba-link-color: #3b4564; + --mba-tab-color: #8f94a6; + --mba-tab-selected-color: #3b4564; + + --mba-button-border: #bd7c33; +} + +body { + background-color: var(--mba-page-background); +} + +.btn-primary, +.btn-primary:hover { + background-color: var(--mba-button-background); + color: var(--mba-button-color); + border-color: var(--mba-button-border); +} + + +.btn-primary:hover { + color: var(--mba-button-hover-color); +} + +.nav-tabs .nav-link { + border-radius: 0; + border: 0; + border-bottom: solid 4px var(--mba-tab-background); + color: var(--mba-tab-color); + background-color: var(--mba-tab-background); +} + +.nav-tabs .nav-link.active { + border-color: var(--mba-tab-selected-color); + color: var(--mba-tab-selected-color); + background-color: var(--mba-tab-selected-background); +} + +.badge-primary { + background-color: var(--mba-widget-background); + color: var(--mba-notice-color); +} + +.text-success { + color: var(--mba-ok-color) !important; +} + + +.mba_widget .card-header { + background-color: var(--mba-title-background); + color: var(--mba-widget-title-color); + text-align: center; +} + +.mba_widget .card-body, +.mba_widget .card-footer { + background-color: var(--mba-widget-background); + color: var(--mba-widget-body-color); +} + +.mba_dark_widget, +.mba_dark_widget .card-body { + background: var(--mba-title-background); + color: var(--mba-widget-title-color); +} + +a { + color: var(--mba-link-color); +} + +a.text-primary, +a.card-link { + color: var(--mba-link-color) !important; +} + +.mba_dark_widget a.text-primary { + color: var(--mba-widget-title-color) !important; +} + +.mba_logo_background .widget-body.card-body { + background: url(../images/logo.png) no-repeat right center; + background-size: 22%; +} + +.widget .card, +.widget .card-header, +.widget .card-footer { + border-radius: 0; +} \ No newline at end of file diff --git a/library/templates/MyBibApp/Assets/images/logo.png b/library/templates/MyBibApp/Assets/images/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..85e79e3f81dba227014e65d6c438d6cf470f1aea Binary files /dev/null and b/library/templates/MyBibApp/Assets/images/logo.png differ diff --git a/library/templates/MyBibApp/Library/FormCustomizer.php b/library/templates/MyBibApp/Library/FormCustomizer.php new file mode 100644 index 0000000000000000000000000000000000000000..6a91ea92598910d1934052a0a296eebcc8e95df9 --- /dev/null +++ b/library/templates/MyBibApp/Library/FormCustomizer.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 MyBibApp_Library_FormCustomizer extends Intonation_Library_FormCustomizer { + public function getTemplateForm($form) { + return (new MyBibApp_Library_FormCustomizer_Template($this->_template, $form))->getForm(); + } +} diff --git a/library/templates/MyBibApp/Library/FormCustomizer/Template.php b/library/templates/MyBibApp/Library/FormCustomizer/Template.php new file mode 100644 index 0000000000000000000000000000000000000000..ddb8b1924e71ee96ccb504d4aca34f999261c391 --- /dev/null +++ b/library/templates/MyBibApp/Library/FormCustomizer/Template.php @@ -0,0 +1,37 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 MyBibApp_Library_FormCustomizer_Template extends Intonation_Library_FormCustomizer_Template { + public function getForm() { + parent::getForm(); + + $this->_form + ->addElement('checkbox', + $this->_template->withNameSpace('mybibapp_css'), + ['label' => $this->_('mybibapp.css'), + 'order' => 3]); + + $this->_addToTemplateGroup(['mybibapp_css']); + + return $this; + } +} diff --git a/library/templates/MyBibApp/Library/ProfilePatcher.php b/library/templates/MyBibApp/Library/ProfilePatcher.php new file mode 100644 index 0000000000000000000000000000000000000000..8211bea717c930690e6ca03695e2db62060f56a9 --- /dev/null +++ b/library/templates/MyBibApp/Library/ProfilePatcher.php @@ -0,0 +1,89 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 MyBibApp_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher { + + protected function _upgradeWidgets() { + $this + ->_removeWidgets() + + ->_addWidget(Intonation_Library_Widget_Login_Definition::CODE, + Class_Profil::DIV_BANNIERE, + ['titre' => $this->_('Mes infos'), + 'boite' => ['mba_widget'], + $this->_template->withNameSpace('form_style') => 'inline', + $this->_template->withNameSpace('width_xsmall') => 12, + $this->_template->withNameSpace('show_header') => 1, + $this->_template->withNameSpace('show_content') => 1, + $this->_template->withNameSpace('show_footer') => 0]) + + ->_addWidget(Intonation_Library_Widget_Search_Definition::CODE, + Class_Profil::DIV_BANNIERE, + ['titre' => $this->_('Le catalogue'), + 'boite' => ['mba_widget'], + $this->_template->withNameSpace('form_style') => 'inline', + $this->_template->withNameSpace('width_xsmall') => 12, + $this->_template->withNameSpace('show_header') => 1, + $this->_template->withNameSpace('show_content') => 1, + $this->_template->withNameSpace('show_footer') => 0]) + + ->_addWidget(Intonation_Library_Widget_Breadcrumb_Definition::CODE, + Class_Profil::DIV_BANNIERE, + ['titre' => ' ', + 'boite' => ['mba_widget'], + $this->_template->withNameSpace('width_xsmall') => 12, + $this->_template->withNameSpace('show_header') => 0, + $this->_template->withNameSpace('show_content') => 0, + $this->_template->withNameSpace('show_footer') => 0]) + + ->_addWidget(Intonation_Library_Widget_Carousel_Library_Definition::CODE, + Class_Profil::DIV_MAIN, + ['titre' => $this->_('Horaires'), + 'boite' => ['mba_widget'], + 'rendering' => 'card-description', + 'layout' => 'list', + $this->_template->withNameSpace('width_xsmall') => 12, + $this->_template->withNameSpace('show_header') => 0, + $this->_template->withNameSpace('show_content') => 0, + $this->_template->withNameSpace('show_footer') => 0]) + + ->_addWidget(Intonation_Library_Widget_Carousel_Review_Definition::CODE, + Class_Profil::DIV_MAIN, + ['titre' => $this->_('Les dernières critiques'), + 'boite' => ['mba_widget'], + 'rendering' => 'card', + 'layout' => 'wall', + $this->_template->withNameSpace('width_xsmall') => 12, + $this->_template->withNameSpace('show_header') => 0, + $this->_template->withNameSpace('show_content') => 0, + $this->_template->withNameSpace('show_footer') => 0]) + + ->_addScrollTopWidget() + ->_addScrollDownWidget() + ->_addAdminWidget() + ->_addCreditWidget() + ->_addAccessibilityWidget() + ->_addNotificationWidget(); + + return $this; + } +} \ No newline at end of file diff --git a/library/templates/MyBibApp/Library/Settings.php b/library/templates/MyBibApp/Library/Settings.php new file mode 100644 index 0000000000000000000000000000000000000000..5ffb0555791d4ec7c54be1e19a2f4c8044419c61 --- /dev/null +++ b/library/templates/MyBibApp/Library/Settings.php @@ -0,0 +1,37 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 MyBibApp_Library_Settings extends Intonation_Library_Settings { + protected function _getDefaultSettings() { + $settings = parent::_getDefaultSettings(); + $settings[$this->_template->withNameSpace('mybibapp_css')] = 1; + + $custom_css_classes = $settings[$this->_template->withNameSpace('custom_css_class')]; + + $custom_css_classes [] = 'mba_widget'; + $custom_css_classes [] = 'mba_dark_widget'; + $custom_css_classes [] = 'mba_logo_background'; + + $settings[$this->_template->withNameSpace('custom_css_class')] = $custom_css_classes; + return $settings; + } +} diff --git a/library/templates/MyBibApp/Template.php b/library/templates/MyBibApp/Template.php new file mode 100644 index 0000000000000000000000000000000000000000..0cc0286366d2686a67cb0f168cfb4fcfd39eb5ad --- /dev/null +++ b/library/templates/MyBibApp/Template.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 MyBibApp_Template extends Intonation_Template { + const ID = 'MYBIBAPP'; + + public function __construct() { + $this->setId(static::ID) + ->setTitle($this->_('MyBibApp')) + ->setSettings(new MyBibApp_Library_Settings($this)) + ->setPatcher(new MyBibApp_Library_ProfilePatcher($this)); + } + + + public function getProfile() { + if ($this->_profile) + return $this->_profile; + + $this->tryOn(Class_Profil::getPortail()); + return $this->_profile = Class_Profil::getCurrentProfil(); + } + + + public function renderOpac($view) { + return (new MyBibApp_View_Opac($this, $view))->render(); + } + + + public function renderSubModal($view) { + return (new MyBibApp_View_SubModal($this, $view))->render(); + } + + + public function customTemplateForm($form) { + $helper = new MyBibApp_Library_FormCustomizer($this); + return $helper->getTemplateForm($form); + } +} diff --git a/library/templates/MyBibApp/View/Opac.php b/library/templates/MyBibApp/View/Opac.php new file mode 100644 index 0000000000000000000000000000000000000000..215d36df956de1c24f2c315b16d92f7b164e2bda --- /dev/null +++ b/library/templates/MyBibApp/View/Opac.php @@ -0,0 +1,29 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 MyBibApp_View_Opac extends Intonation_View_Opac { + protected function _headContent() { + Class_ScriptLoader::getInstance() + ->addStyleSheet(Class_Url::absolute('/library/templates/MyBibApp/Assets/css/mybibapp.css')); + return parent::_headContent(); + } +} diff --git a/library/templates/MyBibApp/View/SubModal.php b/library/templates/MyBibApp/View/SubModal.php new file mode 100644 index 0000000000000000000000000000000000000000..91f41befceae92d3d9e0dea1f4b07f64edc31822 --- /dev/null +++ b/library/templates/MyBibApp/View/SubModal.php @@ -0,0 +1,29 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 MyBibApp_View_SubModal extends Intonation_View_SubModal { + protected function _headContent() { + Class_ScriptLoader::getInstance() + ->addStyleSheet(Class_Url::absolute('/library/templates/MyBibApp/Assets/css/mybibapp.css')); + return parent::_headContent(); + } +} diff --git a/tests/application/modules/admin/controllers/CmsControllerTest.php b/tests/application/modules/admin/controllers/CmsControllerTest.php index fb918f2b0789744fd04b1bc8f84bc0ccbd7dce9b..164790a64f9c38cc9b0e5c10e458ab625b04de7a 100644 --- a/tests/application/modules/admin/controllers/CmsControllerTest.php +++ b/tests/application/modules/admin/controllers/CmsControllerTest.php @@ -926,6 +926,14 @@ class CmsControllerArticleConcertEditActionPostTest extends CmsControllerWithPer ->with('./images/bonlieu.jpg') ->answers(true) + ->whenCalled('fileExists') + ->with(BASE_URL.'/images/concert.jpg') + ->answers(false) + + ->whenCalled('fileExists') + ->with('./images/concert.jpg') + ->answers(true) + ->beStrict()); Class_WebService_Vignette::setFileSystem($filesystem); @@ -941,10 +949,28 @@ class CmsControllerArticleConcertEditActionPostTest extends CmsControllerWithPer ->beStrict(); + $image_from_summary = $this->mock() + ->whenCalled('thumbnailImage') + ->with(500, 500, true, false) + ->answers(null) + + ->whenCalled('writeImage') + ->with(PATH_TEMP . 'vignettes_titre/ERIKTRUFFAZLADYLANDQUARTETENCONCERT-4-TOM----8.jpg') + ->answers(null) + + ->beStrict(); + + $image_factory = $this->mock() + ->whenCalled('newImage') ->with('./images/bonlieu.jpg') - ->answers($image); + ->answers($image) + + ->whenCalled('newImage') + ->with('./images/concert.jpg') + ->answers($image_from_summary); + Class_Notice_Thumbnail_ProviderAbstract::setDefaultImageFactory($image_factory); diff --git a/tests/scenarios/Templates/MyBibAppTemplateTest.php b/tests/scenarios/Templates/MyBibAppTemplateTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e7aa89ff49056407eb15345b17ec5efaba3ccc81 --- /dev/null +++ b/tests/scenarios/Templates/MyBibAppTemplateTest.php @@ -0,0 +1,237 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 + */ + + +abstract class MyBibAppTemplateTestCase extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + Class_Systeme_ModulesAccueil::reset(); + Class_AdminVar::set('TEMPLATING', 1); + } + + + public function tearDown() { + parent::tearDown(); + Class_Systeme_ModulesAccueil::reset(); + } +} + + + + +class MyBibAppTemplateAdminTemplateIndexDispatchTest extends MyBibAppTemplateTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/template/index'); + } + + + /** @test */ + public function editMyBibAppUrlShouldBeDisplay() { + $this->assertXPath('//table//a[contains(@href,"/admin/template/edit/template/MYBIBAPP")]'); + } +} + + + +class MyBibAppTemplateProfilePatcherTest extends MyBibAppTemplateTestCase { + + public function setUp() { + parent::setUp(); + $profile = $this->fixture('Class_Profil', + ['id' => 23]); + + (new MyBibApp_Template)->tryOn($profile); + (new Class_Profil_Promoter())->promote($profile); + $this->dispatch('/opac/index/index'); + } + + + public function widgetsClasses() { + return [ + ['login'], + ['accessibility'], + ['rech_simple'], + ['admin_tools'], + ['scroll'], + ['ariane'], + ['library'], + ['critiques'], + ['credits'] + ]; + } + + + /** + * @dataProvider widgetsClasses + * @test */ + public function indexShouldContainsWidgets($widget_class) { + $this->assertXPath(sprintf('//div[contains(@class, "widget")][contains(@class, "%s")]', + $widget_class)); + } +} + + + +class MyBibAppTemplateOpacIndexWithUserAgentAndTemplateDisabledTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + $_SERVER['HTTP_USER_AGENT'] = 'MyBibApp/1.0.3 (Android)'; + Class_Profil::find(2)->beCurrentProfil(); + } + + + /** @test */ + public function withoutTemplatingShouldNotCreateMyBibAppProfile() { + Class_AdminVar::set('TEMPLATING', 0); + $this->dispatch('/opac/index/index'); + $this->assertEquals(2, Class_Profil::getCurrentProfil()->getId()); + } + + + /** @test */ + public function withoutTemplatingAndMyBibAppShouldNotCreateMyBibAppProfile() { + Class_AdminVar::set('TEMPLATING', 0); + Class_AdminVar::set('MYBIBAPP_TEMPLATE', 1); + $this->dispatch('/opac/index/index'); + $this->assertEquals(2, Class_Profil::getCurrentProfil()->getId()); + } + + + /** @test */ + public function withTemplatingAndNotMyBibAppShouldNotCreateMyBibAppProfile() { + Class_AdminVar::set('TEMPLATING', 1); + Class_AdminVar::set('MYBIBAPP_TEMPLATE', 0); + $this->dispatch('/opac/index/index'); + $this->assertEquals(2, Class_Profil::getCurrentProfil()->getId()); + } +} + + + + +class MyBibAppTemplateOpacIndexWithUserAgentTest extends MyBibAppTemplateTestCase { + public function setUp() { + parent::setUp(); + + $_SERVER['HTTP_USER_AGENT'] = 'MyBibApp/1.0.3 (Android)'; + + Class_AdminVar::set('MYBIBAPP_TEMPLATE', 1); + + Class_Profil::find(2)->beCurrentProfil(); + + $this->dispatch('/opac/index/index'); + } + + + public function tearDown() { + unset($_SERVER['HTTP_USER_AGENT']); + parent::tearDown(); + } + + + /** @test */ + public function pageTitleShouldBeTestCharteMyBibApp() { + $this->assertXPathContentContains('//head/title', 'Test charte : "MyBibApp"'); + } + + + /** @test */ + public function pageShouldLoadMyBibAppCss() { + $this->assertXPath('//head/link[contains(@href, "/templates/MyBibApp/Assets/css/mybibapp.css")]'); + } + + + /** @test */ + public function pageShouldBeHtml5Valid() { + $this->assertHTML5(); + } + + + /** @test */ + public function pageShouldBeAccessible() { + $this->assertAccessible($this->_response->getBody()); + } +} + + + +class MyBibAppTemplateEditTemplateTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + Class_AdminVar::set('TEMPLATING', 1); + + $settings = $this->fixture('Class_Template_Settings', + ['id' => 456, + 'template' => 'MYBIBAPP']); + + $this->dispatch('/admin/template/edit/template/mybibapp'); + } + + + /** @test */ + public function checkboxMyBibAppCssShouldBeChecked() { + $this->assertXPath('//form//input[@type="checkbox"][@name="MybibappMybibappCss"][@checked]'); + } + + + /** @test */ + public function customCssShouldContainsClassMbaWidget() { + $this->assertContains('"mba_widget"', $this->_response->getBody()); + } +} + + + +class MyBibAppTemplateOauthWithUserAgentTest extends MyBibAppTemplateTestCase { + public function setUp() { + parent::setUp(); + + $_SERVER['HTTP_USER_AGENT'] = 'MyBibApp/1.0.3 (Android)'; + + Class_AdminVar::set('MYBIBAPP_TEMPLATE', 1); + + Class_Profil::find(2)->beCurrentProfil(); + + $this->dispatch('/opac/auth/oauth/response_type/code/id_profil/1/client_id/MyBibApp?redirect_uri=www.mon-bokeh.org'); + } + + + public function tearDown() { + unset($_SERVER['HTTP_USER_AGENT']); + parent::tearDown(); + } + + + /** @test */ + public function pageShouldLoadMyBibAppCss() { + $this->assertXPath('//head/link[contains(@href, "/templates/MyBibApp/Assets/css/mybibapp.css")]'); + } +} \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index c47b908fa19bf7e6663dfea24a0a74950bf0e9bb..fca84372e9a108bb27107d894420015b2716e609 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -96,7 +96,7 @@ class TemplatesControllerTryIntonationTest extends TemplatesEnabledTestCase { /** @test */ public function porfil3shouldContainsTemplateKeyInComments() { - $this->assertEquals('1de7e1a28d1343ea74e681df4069a974', Class_Profil::find(3)->getCommentaire()); + $this->assertEquals('eb0da18cfce1c2efaaa1d1ec97c86b10', Class_Profil::find(3)->getCommentaire()); }