Commit 32c72445 authored by Ghislain Loas's avatar Ghislain Loas

Merge branch 'dev#99489_magasin_de_themes_bases_sur_bootstrap' into 'master'

Dev#99489 magasin de themes bases sur bootstrap

See merge request !3333
parents dfc23c13 6111e529
Pipeline #8989 passed with stage
in 43 minutes and 15 seconds
......@@ -1156,8 +1156,9 @@ class AbonneController extends ZendAfi_Controller_Action {
unset($data['id_items']);
$this->_user->setSettings(Class_User_Settings::serializeSettings($data));
$this->_user->save();
$this->_helper->notify($this->_('Favoris sauvegardés'));
return $this->_redirectClose($this->_getReferer());
Class_User_Settings::clearCache();
$this->_helper->notify($this->_('Configuration sauvegardée'));
return $this->_redirectToReferer();
}
$this->view->titre = $this->view->_('Gérer mes favoris');
......@@ -1867,4 +1868,11 @@ class AbonneController extends ZendAfi_Controller_Action {
$record->updateFacetsFromExemplaires();
}
}
public function clearHistoryAction() {
(new Class_SearchHistory())->clear();
$this->_helper->notify($this->_('Votre historique de recherche a été supprimé.'), ['status' => 'success']);
return $this->_redirectClose($this->_getReferer());
}
}
\ No newline at end of file
......@@ -237,6 +237,7 @@ class AuthController extends ZendAfi_Controller_Action {
$this->view->options = ['data' => array_merge(
$preferences,
['redirect_url' => $this->_getParam('redirect_uri'),
'clear_action' => true,
'id_notice' => 0])];
$this->getHelper('ViewRenderer')->setLayoutScript('subModal.phtml');
......
<?php
echo $this->tag('h1', $this->titre);
echo $this->Widget_Login(new Class_Entity(array_merge(['FormOptions' => $this->options])));
echo $this->Widget_Login(new Class_Entity(['FormOptions' => $this->options,
'Preferences' => $this->options['data']]));
......@@ -74,7 +74,7 @@ class Telephone_AuthController extends AuthController {
protected function _loginCommon() {
$form = $this->_getFormLogin();
$form = $this->_getFormLogin()->setAction($this->view->url());
if ($this->_request->isPost()) {
if (!($error = $this->_authenticate())) {
$this->_redirect($redirectUrl);
......@@ -96,7 +96,6 @@ class Telephone_AuthController extends AuthController {
Class_Profil::getPortail()->getModuleAccueilPreferencesByType('LOGIN'));
$form = new ZendAfi_Form_Mobile_Login();
$form->setAction($this->view->url());
$form->getElement('username')
->setAttrib('placeholder', $settings['identifiant_exemple'])
......
......@@ -229,7 +229,9 @@ class AvisNoticeLoader extends Storm_Model_Loader {
$grouped = [];
foreach ($reviews_by_records as $key => $value)
$grouped [$key] = new Class_ReviewsByRecord($value);
$grouped [$key] = ((new Class_ReviewsByRecord)
->setRecord($value['Record'])
->setReviews($value['Reviews']));
return $grouped;
}
......@@ -525,7 +527,7 @@ class Class_AvisNotice extends Storm_Model_Abstract {
public function getHumanDate() {
return Class_Date::humanDate($this->getDateAvis(), 'd MMMM yyyy HH:mm');
return strftime($this->_('%d %B %Y'), strtotime($this->getDateAvis()));
}
......
......@@ -154,7 +154,8 @@ class BibLoader extends Storm_Model_Loader {
public function byIdLabels($librairies) {
$labels = [];
foreach ($librairies as $library)
$labels[$library->getId()] = $library->getLibelle();
if ($library)
$labels[$library->getId()] = $library->getLibelle();
return $labels;
}
......
......@@ -26,7 +26,9 @@ class Class_DigitalResource_Config extends Class_Entity {
HARVEST = 'HARVEST',
SSO = 'SSO';
protected $_name;
protected $_name,
$_digital_resource,
$_admin_var_cache = [];
use Trait_Translator, Trait_PermissionTargetable, Trait_TimeSource;
......@@ -105,7 +107,10 @@ class Class_DigitalResource_Config extends Class_Entity {
public function getAdminVar($id) {
return $this->getDigitalResource()->getAdminVar($id);
if (isset($this->_admin_var_cache[$id]))
return $this->_admin_var_cache[$id];
return $this->_admin_var_cache[$id] = $this->getDigitalResource()->getAdminVar($id);
}
......@@ -397,4 +402,15 @@ class Class_DigitalResource_Config extends Class_Entity {
'Libelle' => $this->_name]),
Class_CodifThesaurus::findFixed('DigitalResources'));
}
public function getDigitalResource() {
return $this->_digital_resource;
}
public function setDigitalResource($resource) {
$this->_digital_resource = $resource;
return $this;
}
}
\ No newline at end of file
......@@ -260,8 +260,7 @@ class Class_Notice extends Storm_Model_Abstract {
public function getLocalAvis() {
if (!isset($this->_local_avis))
$this->_local_avis = Class_AvisNotice::findAllBy(['clef_oeuvre' => $this->getClefOeuvre(),
'source_actor_id' => null]);
$this->_local_avis = Class_AvisNotice::findAllBy(['clef_oeuvre' => $this->getClefOeuvre()]);
return $this->_local_avis;
}
......
......@@ -189,7 +189,6 @@ class Class_Profil extends Storm_Model_Abstract {
// cache des attributs pour raison de performances
protected $_has_parent_profil = null;
protected $_cfg_site_array;
protected $_should_forward_attributes = [];
protected $_skin;
......@@ -204,6 +203,15 @@ class Class_Profil extends Storm_Model_Abstract {
*/
protected $_translator;
protected
$_cfg_site_array_cache,
$_default_values_cache = [],
$_default_cfg_menus_cache,
$_default_cfg_notice_cache,
$_default_cfg_accueil_cache,
$_raw_cfg_cache = [],
$_loaded_modules_cache = [];
/**
* @return Class_Profil
......@@ -958,7 +966,13 @@ class Class_Profil extends Storm_Model_Abstract {
* @return array
*/
public function getDefaultCfgMenus() {
return $this->_unserialize(self::getDefaultValue('cfg_menus'));
if ($this->_default_cfg_menus_cache)
return $this->_default_cfg_menus_cache;
if ($data = $this->_unserialize(self::getDefaultValue('cfg_menus')))
$this->_default_cfg_menus_cache = $data;
return $data;
}
......@@ -966,12 +980,24 @@ class Class_Profil extends Storm_Model_Abstract {
* @return array
*/
public function getDefaultCfgNotice() {
return $this->_unserialize(self::getDefaultValue('cfg_notice'));
if ($this->_default_cfg_notice_cache)
return $this->_default_cfg_notice_cache;
if ($data = $this->_unserialize(self::getDefaultValue('cfg_notice')))
$this->_default_cfg_notice_cache = $data;
return $data;
}
public function getDefaultCfgAccueil() {
return $this->_unserialize(self::getDefaultValue('cfg_accueil'));
if ($this->_default_cfg_accueil_cache)
return $this->_default_cfg_accueil_cache;
if ($data = $this->_unserialize(self::getDefaultValue('cfg_accueil')))
$this->_default_cfg_accueil_cache = $data;
return $data;
}
......@@ -981,6 +1007,9 @@ class Class_Profil extends Storm_Model_Abstract {
*/
public function _getRawCfgAsArrayNamed($name) {
$name = (string)$name;
if (isset($this->_raw_cfg_cache[$name]))
return $this->_raw_cfg_cache[$name];
$cfg = $this->_unserialize($this->{'getCfg' . $name}());
if (empty($cfg) && method_exists($this, 'getDefaultCfg' . $name))
......@@ -993,7 +1022,10 @@ class Class_Profil extends Storm_Model_Abstract {
if(('Accueil' == $name ) && (!array_key_exists('page_css', $cfg) || (!array_key_exists('use_parent_css', $cfg)) && (method_exists($this, 'getDefaultCfg' . $name))))
$cfg=array_merge($this->{'getDefaultCfg' . $name}(), $cfg);
return $cfg;
if (empty($cfg))
return $cfg;
return $this->_raw_cfg_cache[$name] = $cfg;
}
......@@ -1020,20 +1052,20 @@ class Class_Profil extends Storm_Model_Abstract {
* @return array
*/
public function getCfgSiteAsArray() {
if (isset($this->_cfg_site_array))
return $this->_cfg_site_array;
if (isset($this->_cfg_site_array_cache))
return $this->_cfg_site_array_cache;
$params = $this->_getCfgAsArrayNamed('Site');
if (!is_array($params))
return [];
$valids = static::getCfgSiteKeys();
$this->_cfg_site_array = [];
$this->_cfg_site_array_cache = [];
foreach($params as $k => $v)
if (in_array($k, $valids))
$this->_cfg_site_array[$k] = $v;
$this->_cfg_site_array_cache[$k] = $v;
return $this->_cfg_site_array;
return $this->_cfg_site_array_cache;
}
......@@ -1131,6 +1163,8 @@ class Class_Profil extends Storm_Model_Abstract {
else
$cfg = $string_or_array;
$this->clearInstanceCache();
return $this->_set($cfg_name, $cfg);
}
......@@ -1177,7 +1211,6 @@ class Class_Profil extends Storm_Model_Abstract {
*/
public function setCfgSite($string_or_array) {
$this->_setCfgNamed('cfg_site', $string_or_array);
$this->_cfg_site_array = null;
return $this;
}
......@@ -1258,8 +1291,11 @@ class Class_Profil extends Storm_Model_Abstract {
* @return mixed
*/
public function getDefaultValue($param) {
if (isset($this->_default_values_cache[$param]))
return $this->_default_values_cache[$param];
$default_values = self::getDefaultValues();
return $default_values[$param];
return $this->_default_values_cache[$param] = $default_values[$param];
}
......@@ -1569,13 +1605,29 @@ class Class_Profil extends Storm_Model_Abstract {
? $cfg_accueil['modules']
: [];
if (!$this->_loaded_modules_cache)
$this->_loaded_modules_cache = $this->_getLoadedModuleFrom($modules);
foreach($this->_loaded_modules_cache as $id => $module)
if (array_key_exists('division', $module) and $module['division'] == $division)
$boites[$id] = $module;
return $boites;
}
protected function _getLoadedModuleFrom($modules) {
$profile_id = $this->getId();
$loaded_modules = [];
foreach ($modules as $id => $module) {
if (!$module)
$module = [];
$module = array_merge(['type_module' => null,
'preferences' => [],
'profile_id' => $this->getId()],
'profile_id' => $profile_id],
$module);
$module_accueil = Class_Systeme_ModulesAccueil::moduleBycode($module['type_module']);
......@@ -1586,11 +1638,10 @@ class Class_Profil extends Storm_Model_Abstract {
$module['preferences'] = array_merge($module_accueil->getDefaultValues(),
$module['preferences']);
if (array_key_exists('division', $module) and $module['division'] == $division)
$boites[$id] = $module;
$loaded_modules [$id] = $module;
}
return $boites;
return $loaded_modules;
}
......@@ -2408,4 +2459,16 @@ class Class_Profil extends Storm_Model_Abstract {
public function isMyselfMyOwnLoginPage() {
return $this->getLoginPage() == $this->getId();
}
public function clearInstanceCache() {
$this->_cfg_site_array_cache = null;
$this->_default_values_cache = [];
$this->_default_cfg_menus_cache = [];
$this->_default_cfg_notice_cache = [];
$this->_default_cfg_accueil_cache = [];
$this->_raw_cfg_cache = [];
$this->_loaded_modules_cache = [];
return $this;
}
}
......@@ -20,7 +20,33 @@
*/
class Class_ReviewsByRecord extends Class_Entity {
class Class_ReviewsByRecord {
protected
$_record,
$_reviews;
public function setRecord($record) {
$this->_record = $record;
return $this;
}
public function getRecord() {
return $this->_record;
}
public function setReviews($reviews) {
$this->_reviews = $reviews;
return $this;
}
public function getReviews() {
return $this->_reviews;
}
public function applyOrder($order, $reviews_by_records) {
......
......@@ -25,7 +25,15 @@ abstract class Class_Systeme_Widget_Abstract extends Class_Entity {
Trait_Translator,
Trait_Versionable;
protected $_errors = [];
protected
$_errors = [],
$_resources_definition,
$_resources_provider,
$_id,
$_title,
$_profile,
$_profile_id,
$_local_settings;
public function load() {
......@@ -118,6 +126,17 @@ abstract class Class_Systeme_Widget_Abstract extends Class_Entity {
}
public function getResourcesDefinition() {
return $this->_resources_definition;
}
public function setResourcesDefinition($definition) {
$this->_resources_definition = $definition;
return $this;
}
protected function _transmute($attributes) {
if(empty($attributes))
return null;
......@@ -245,4 +264,70 @@ abstract class Class_Systeme_Widget_Abstract extends Class_Entity {
public function getErrors() {
return $this->_errors;
}
public function getResourcesProvider() {
return $this->_resources_provider;
}
public function setResourcesProvider($provider) {
$this->_resources_provider = $provider;
return $this;
}
public function getId() {
return $this->_id;
}
public function setId($id) {
$this->_id = $id;
return $this;
}
public function getProfileId() {
return $this->_profile_id;
}
public function setProfileId($profile_id) {
$this->_profile_id = $profile_id;
return $this;
}
public function getProfile() {
return $this->_profile;
}
public function setProfile($profile) {
$this->_profile = $profile;
return $this;
}
public function getLocalSettings() {
return $this->_local_settings;
}
public function setLocalSettings($settings) {
$this->_local_settings = $settings;
return $this;
}
public function getTitle() {
return $this->_title;
}
public function setTitle($title) {
$this->_title = $title;
return $this;
}
}
......@@ -29,9 +29,9 @@ class Class_Systeme_Widget_Widget extends Class_Systeme_Widget_Abstract {
protected function _findLeaf($id) {
if ($cfg = $this->getProfile()->getLocalModuleAccueilConfig($id))
return $cfg;
return [];
return ($cfg = $this->getProfile()->getLocalModuleAccueilConfig($id))
? $cfg
: [];
}
......
......@@ -21,11 +21,14 @@
class Class_Template_Settings extends Storm_Model_Abstract {
protected
$_table_name = 'template_settings',
$_default_attribute_values = ['template' => '',
'settings' => ''],
$_hydrating_mapping;
$_settings_instance_cache,
$_getter_call_cache = [],
$_hydrating_mapping_cache;
public function __call($name, $params) {
......@@ -40,13 +43,21 @@ class Class_Template_Settings extends Storm_Model_Abstract {
if (preg_match('/(get)(\w+)/', $name, $matches)
&& false === strpos($name, ucfirst(strtolower(Class_Template::current()->getId()))))
return call_user_func([$settings, 'get' . Class_Template::current()->withNameSpace(Storm_Inflector::underscorize($matches[2]))], isset($params[0]) ? $params[0] : null);
return $this->_cacheGetterCall($settings, $matches[2], isset($params[0]) ? $params[0] : null);
return call_user_func([$settings, $name], isset($params[0]) ? $params[0] : null);
}
}
protected function _cacheGetterCall($settings, $function_name, $param) {
if (isset($this->_getter_call_cache[$function_name]))
return $this->_getter_call_cache[$function_name];
return $this->_getter_call_cache[$function_name] = call_user_func([$settings, 'get' . Class_Template::current()->withNameSpace(Storm_Inflector::underscorize($function_name))], $param);
}
public function getLibelle() {
return $this->getTemplateInstance()->getTitle();
}
......@@ -68,6 +79,9 @@ class Class_Template_Settings extends Storm_Model_Abstract {
unset($attributes['template']);
}
if(isset($attributes['id']))
unset($attributes['id']);
$local_data ['settings'] = $this->_updateSettings($attributes);
return parent::updateAttributes($local_data);
}
......@@ -89,23 +103,39 @@ class Class_Template_Settings extends Storm_Model_Abstract {
public function getSettingsInstance() {
if ($this->_settings_instance_cache)
return $this->_settings_instance_cache;
$settings = ($settings = unserialize($this->getSettings()))
? $settings
: [];
return new Class_Entity($settings);
if (empty($settings))
return new Class_Entity($settings);
return $this->_settings_instance_cache = new Class_Entity($settings);
}
public function getHydratingMapping() {
if ($this->_hydrating_mapping)
return $this->_hydrating_mapping;
if ($this->_hydrating_mapping_cache)
return $this->_hydrating_mapping_cache;
$settings = $this->getSettingsInstance();
return $this->_hydrating_mapping = $settings->getHydratingMapping();
return $this->_hydrating_mapping_cache = $settings->getHydratingMapping();
}
public function updateSettings() {
return $this;
}
public function clearCache() {
$this->_settings_instance_cache = null;
$this->_getter_call_cache = [];
$this->_hydrating_mapping_cache = null;
return $this;
}
}
\ No newline at end of file
......@@ -35,9 +35,23 @@ class Class_User_Settings {
protected $_user, $_user_settings;