Commit 2c6df4a8 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

wip on theme store

parents 2f310ad1 4323546e
Pipeline #9404 failed with stage
in 38 minutes and 7 seconds
06/02/2020 - v8.0.41
- ticket #105040 : Articles / Formulaires : Correction de la détection des robot pour des formulaires ayant des noms d'input contenant des espaces, des tirets bas et des crochets droits
- ticket #105091 : Performance : Correction de la perte de performance suite à la livraison des nouveaux groupes dynamiques
03/02/2020 - v8.0.40
- ticket #101015 : Articles / Formulaires : Amélioration de la détection des robots
......
- ticket #103980 : Administration / Domaines : l'écran de test/indexation affiche maintenant la liste des notices complète avec pagination et vignettes. Permet de générer les vignettes des notices.
\ No newline at end of file
......@@ -40,12 +40,16 @@ class Admin_CatalogueController extends ZendAfi_Controller_Action {
if (!$catalogue = Class_Catalogue::find((int)$this->_getParam("id_catalogue", 0)))
$this->_redirect("admin/catalogue/index");
$this->view->page = $this->_getParam('page', 1);
$this->view->nb_per_page = 20;
$ret = ['requete' => '',
'nb_notices' => 0,
'avec_vignettes' => 0,
'notices' => ''];
$this->getRequest()->setParam('render', null);
$ret = array_merge($ret, $catalogue->getTestCatalogue());
$ret = array_merge($ret,
$catalogue->getTestCatalogue($this->view->nb_per_page,
$this->view->page));
if ($catalogue->hasIndexer())
$catalogue->indexWithBaskets();
......
......@@ -541,12 +541,10 @@ class Admin_ModulesController extends ZendAfi_Controller_Action {
public function applyToAction() {
$module = new Class_Profil_ModuleDefinition($this->_getParam('type_module'),
$this->_getParam('action1'),
$this->_getParam('action2'));
$module = $this->_getProfileModuleDefinition();
$this->view->titre = $this->_('Étendre le paramétrage');
$this->view->form = $form = $module->getApplyToForm($this->view->url);
$this->view->form = $form = $module->getApplyToForm($this->view->url());
if ($this->_request->isPost()
&& $form->isValid($this->_request->getPost())) {
......@@ -556,4 +554,17 @@ class Admin_ModulesController extends ZendAfi_Controller_Action {
$this->render->renderScript('modules/_retour.phtml');
}
}
protected function _getProfileModuleDefinition() {
if (!$id = $this->_getParam('id'))
return new Class_Profil_ModuleDefinition($this->_getParam('type_module'),
$this->_getParam('action1'),
$this->_getParam('action2'));
$id = explode('_', $id);
return new Class_Profil_ModuleDefinition((isset($id[0]) ? $id[0] : ''),
(isset($id[1]) ? $id[1] : ''),
(isset($id[2]) ? $id[2] : ''));
}
}
\ No newline at end of file
......@@ -41,8 +41,7 @@ class Admin_SystemeController extends Zend_Controller_Action {
if ($this->_getParam('mode') != 'reset_no')
return $this;
Zend_Registry::get('sql')
->execute("update notices set url_vignette='',url_image='' where url_vignette='" . Class_WebService_Vignette::NO_DATA . "'");
Class_WebService_Vignette::resetNoDataThumbnails();
}
......@@ -89,16 +88,15 @@ class Admin_SystemeController extends Zend_Controller_Action {
public function makecacheimagesAction() {
if ($records_count = Class_Notice::countBy(['url_vignette' => ''])) {
$record = Class_Notice::findFirstBy(['url_vignette' => '']);
$record->fetchUrlLocalVignette();
}
$this->getHelper('ViewRenderer')->setNoRender();
$html = $records_count - 1;
$cache = new Class_Notice_Thumbnail_Cache();
$cache->build($this->getRequest());
if ($next_record = Class_Notice::findFirstBy(['url_vignette' => ''])) {
$html = $cache->getRecordCount();
if ($next_record = $cache->getNextRecord()) {
$html .= $this->view->tag('div',
$this->view->tag('a',
$next_record->getTitrePrincipal() . ' (' . $next_record->getAuteurPrincipal() . ')',
......@@ -107,7 +105,12 @@ class Admin_SystemeController extends Zend_Controller_Action {
null,
true),
'target' => '_blank']));
$html .= '<script>makeCacheImages("/admin/systeme/makecacheimages")</script>';
$html .= sprintf('<script>makeCacheImages(\'%s\')</script>',
$this->view->url($cache->getCallbackUrl($this->getRequest()),
null,
true));
}
$this->getResponse()->setBody($html);
......
......@@ -18,7 +18,14 @@
['alt' => $this->_('Paniers'),
'class' => 'ico',
'title' => $this->_('Paniers rattachés au domaine "%s"',
$this->catalogue->getLibelle())])),
$this->catalogue->getLibelle())]))
.
$this->tagPreview($this->url(['module' => 'opac',
'controller' => 'recherche',
'action' => 'simple',
'id_catalogue' => $this->catalogue->getId()],
null, true),
$this->_('Visualiser le domaine "%s" dans un nouvel onglet', $this->catalogue->getLibelle())),
['class' => 'header_actions']);
......@@ -30,23 +37,44 @@ if (!$this->notices)
else {
echo $this->ligneInfos($this->_('Notices trouvées'), $this->nb_notices);
echo $this->ligneInfos($this->_('Avec vignettes en cache'), $this->avec_vignettes);
echo $this->Admin_GenerateImageCache(
$this->url(['module' => 'admin',
'controller' => 'systeme',
'action' => 'makecacheimages',
'id_catalogue' => $this->catalogue->getId(),
'reset_no' => 1],
null,
true));
if (!$this->isPopup())
echo $this->button((new Class_Entity())
->setText($this->_('Modifier le domaine '))
->setAttribs(['title' => $this->_('Modifier le domaine : %s',
$this->catalogue->getLibelle())])
->setUrl($this->url(['action' => 'edit',
'id_catalogue' => $this->catalogue->getId()]))
->setImage($this->tagImg(Class_Admin_Skin::current()
->getIconUrl('buttons', 'configuration'))));
}
echo $this->pager($this->nb_notices,
$this->nb_per_page,
$this->page,
$this->url(['module' => 'admin',
'controller' => 'catalogue',
'action' => 'tester',
'id_catalogue' => $this->catalogue->getId()],
null,
true));
if ($this->notices) {
echo $this->listeNotices_Tableau($this->notices,
['liste_codes' => 'T;J;A;N']);
['liste_codes' => implode(';',
[Class_Codification::CODE_THUMBNAIL,
Class_TypeDoc::CODE_FACETTE,
Class_Codification::CODE_TITRE,
Class_CodifAuteur::CODE_FACETTE,
Class_Codification::CODE_ANNEE ]),
'open_links_in_new_tab' => '1']);
}
echo $this->tagNotice('Affichage des 20 premières notices uniquement.');
if (!$this->isPopup())
echo $this->button((new Class_Entity())
->setText($this->_('Modifier le domaine '))
->setAttribs(['title' => $this->_('Modifier le domaine : %s',
$this->catalogue->getLibelle())])
->setUrl($this->url(['action' => 'edit',
'id_catalogue' => $this->catalogue->getId()]))
->setImage($this->tagImg(Class_Admin_Skin::current()
->getIconUrl('buttons', 'configuration'))));
<script src="<?php echo URL_ADMIN_JS?>jquery-1.6.4.min"> </script>
<script src="<?php echo URL_ADMIN_JS?>cacheimages.js"> </script>
<?php
echo $this->tag('h2', $this->_('Base de données'));
......@@ -20,14 +17,4 @@ echo $this->button(
->setUrl($this->url(['mode' => 'reset_no']))
->setImage($this->tagImg(Class_Admin_Skin::current()->getIconUrl('buttons', 'generate'))));
echo $this->button(
(new Class_Entity())->setText($this->_('Constitution du cache'))
->setAttribs(['onclick' => 'makeCacheImages(); return false;'])
->setImage($this->tagImg(Class_Admin_Skin::current()->getIconUrl('actions', 'down'),
['style' => 'filter: invert();'])));
// Constitution du cache des images
echo BR.BR.'<div id="bloc_restantes" align="center" style="display:none">';
echo $this->tag('h2', $this->_('Constitution du cache en cours...'));
echo $this->tag('h3', $this->_('Notices à traiter: %s', '<span id="restantes"></span>'));
echo '</div>';
echo $this->Admin_GenerateImageCache();
......@@ -56,7 +56,14 @@ class FormulaireController extends ZendAfi_Controller_Action {
$article->getContenu(),
$all_inputs);
if (array_diff(array_keys($post), $all_inputs[1]))
$clean_input = array_map(function($input)
{
return str_replace(['.',' ','['],
'_',
$input);
},
$all_inputs[1]);
if (array_diff(array_keys($post), $clean_input))
return true;
return false;
......
......@@ -23,10 +23,8 @@
class Class_AdminVarLoader extends Storm_Model_Loader {
use Trait_Translator;
/** @var array */
protected
$all_vars,
$_all_vars_values;
protected static $_all_vars_values, $_all_vars;
protected $_inited = false;
......@@ -115,10 +113,10 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
public function knownVars() {
if (null !== $this->all_vars)
return $this->all_vars;
if (null !== static::$_all_vars)
return static::$_all_vars;
return $this->all_vars =
return static::$_all_vars =
[
'avis' => $this->_getCommentVars(),
'modo' => $this->_getModerationVars(),
......@@ -537,15 +535,15 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
public function allVarsValues() {
if (null !== $this->_all_vars_values)
return $this->_all_vars_values;
if (null !== static::$_all_vars_values)
return static::$_all_vars_values;
$values=[];
foreach ($this->knownVars() as $key => $value) {
$values = array_merge($values, $value);
}
return $this->_all_vars_values = $values;
return static::$_all_vars_values = $values;
}
......@@ -584,8 +582,9 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
/** @category testing */
public function resetAllVars() {
$this->all_vars = null;
$this->_all_vars_values = null;
static::$_all_vars = null;
static::$_all_vars_values = null;
return $this;
}
......
......@@ -243,6 +243,12 @@ class Class_Calendar {
}
public function setSize($size) {
$this->preferences['size'] = $size;
return $this;
}
public function getAdminSelectedCategories() {
if (isset($this->admin_selected_categories))
return $this->admin_selected_categories;
......
......@@ -345,10 +345,14 @@ class CatalogueLoader extends Storm_Model_Loader {
if ($catalogue && $catalogue->isEmpty())
return [];
if(isset($preferences['only_img']) && ($preferences['only_img'] == 1)
if(isset($preferences['only_img']) && ($preferences['only_img'] == Class_Catalogue::ONLY_IMG)
&& (($catalogue && Class_Catalogue::getLoader()->hasFilters($preferences['id_catalogue'])) || !$catalogue))
$conditions[] = "url_vignette > '' and url_vignette != '" . Class_WebService_Vignette::NO_DATA . "' ";
if (isset($preferences['only_img']) && ($preferences['only_img'] == Class_Catalogue::WITHOUT_IMG))
$conditions[] = "url_vignette=''";
$join = (isset($preferences['avec_avis']) && ($preferences['avec_avis'] == 1))
? ' INNER JOIN notices_avis ON notices.clef_oeuvre=notices_avis.clef_oeuvre '
: '';
......@@ -645,7 +649,10 @@ class CatalogueLoader extends Storm_Model_Loader {
class Class_Catalogue extends Storm_Model_Abstract {
use Trait_TreeNode, Trait_Translator, Trait_CustomFields, Trait_Facetable;
const CODE_FACETTE = 'Q';
const
CODE_FACETTE = 'Q',
ONLY_IMG = 1,
WITHOUT_IMG = 2;
protected
$_table_name = 'catalogue',
......@@ -827,9 +834,8 @@ class Class_Catalogue extends Storm_Model_Abstract {
}
public function getTestCatalogue() {
public function getTestCatalogue($nb_per_page = 20, $page = 1) {
$preferences = $this->toArray();
$preferences['nb_notices'] = 20;
$requetes = Class_Catalogue::getLoader()->getRequetes($preferences);
if(empty($requetes['req_liste']))
......@@ -839,9 +845,10 @@ class Class_Catalogue extends Storm_Model_Abstract {
$temps = time();
$ret["notices"] = Class_Notice::findAllByRequeteRecherche($requetes['req_ids'],
$preferences['nb_notices'],
1);
$nb_per_page,
$page);
$ret["temps_execution"] = time() - $temps;
$ret["nb_notices"] = fetchOne($requetes["req_comptage"]);
$req = $requetes["req_comptage"];
......
......@@ -42,10 +42,10 @@
* R: résumé
* S: section
* T: type de doc
* U:
* U: vignette/image
* V: disponibilité
* W: éditeur
* X:
* X: index dewey pcdm4
* Y: annexe
* Z: tag
* 5: données autorités
......@@ -68,7 +68,9 @@ class Class_Codification {
CODE_AVAILABILITY='V',
CODE_AUTHORITY_DATAS='5',
CODE_URL = '8',
CODE_NOUVEAUTE = '9';
CODE_NOUVEAUTE = '9',
CODE_INDEX_DEWEY_PCDM4 = 'X',
CODE_THUMBNAIL = 'U';
protected
......@@ -92,7 +94,7 @@ class Class_Codification {
return '';
switch($type) {
case "X":
case Class_Codification::CODE_INDEX_DEWEY_PCDM4:
$lib=[" ", $this->_('Livres et Vidéos'), $this->_('Musique')];
$l=Class_AdminVar::get("FACETTE_PCDM4_LIBELLE"); if(trim($l)) $lib[2]=$l;
$l=Class_AdminVar::get("FACETTE_DEWEY_LIBELLE"); if(trim($l)) $lib[1]=$l;
......@@ -147,6 +149,7 @@ class Class_Codification {
Class_Codification::CODE_NOUVEAUTE => [ $this->_("Nouveauté"), $this->_("Nouveauté")],
Class_Codification::CODE_PRIX => [ $this->_("Prix"), $this->_("Prix")],
Class_CodifEmplacement::CODE_FACETTE => [ $this->_('Emplacement'), $this->_('Emplacement')],
Class_Codification::CODE_THUMBNAIL => [ $this->_('Vignette'), $this->_('Vignette')],
Class_Codification::CODE_AUTHORITY_DATAS => [ $this->_('Autorité'), $this->_('Autorité')],];
$this->addThesauriToNomChamps();
......
......@@ -30,10 +30,33 @@ class Class_Journal_Type {
PREVIOUS_VALUE = 'previous_value',
NEW_VALUE = 'new_value';
protected static $_enabled = true;
protected $_journal;
/** @category testing */
public static function disable() {
static::$_enabled = false;
}
/** @category testing */
public static function enable() {
static::$_enabled = true;
}
/** @category testing */
protected static function _isEnabled() {
return static::$_enabled;
}
public static function save($model) {
if (!static::_isEnabled())
return;
$journal = Class_Journal::newInstance(['type' => static::MY_TYPE]);
if (!$journal->save())
return;
......
......@@ -51,18 +51,21 @@ class NoticeLoader extends Storm_Model_Loader {
}
public function getNoticeIdsByRequeteRecherche($req) {
public function getNoticeIdsByRequeteRecherche($req, $clear_cache = false) {
if (!$req)
return [];
$closure = function() use ($req) {
return Zend_Registry::get('sql')->fetchAllByColumn($req);
};
$cache = (new Storm_Cache())->useImplodeExplodeSerialization();
$cache_key = [$req, __CLASS__, __FUNCTION__];
return (new Storm_Cache())
->useImplodeExplodeSerialization()
->memoize([$req, __CLASS__, __FUNCTION__],
$closure);
if ($clear_cache)
$cache->remove($cache_key);
return $cache->memoize($cache_key,
function() use ($req)
{
return Zend_Registry::get('sql')->fetchAllByColumn($req);
});
}
......
<?php
/**
* Copyright (c) 2012-2020, 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_Notice_Thumbnail_Cache {
protected
$_remaining_records_count,
$_next_record;
public function build($request) {
$this->_next_record = null;
$this->_remaining_records_count = 0;
if ($request->getParam('reset_no'))
Class_WebService_Vignette::resetNoDataThumbnails();
return ($id_catalogue = $request->getParam('id_catalogue'))
? $this->_updateNextRecordForCatalogue($request)
: $this->_updateNextRecordForAll();
}
public function getCallbackUrl($request) {
return array_filter( ['module' => 'admin',
'controller' => 'systeme',
'action' => 'makecacheimages',
'id_catalogue' => $request->getParam('id_catalogue')] );
}
protected function _updateNextRecordForCatalogue($request) {
if (!$catalog = Class_Catalogue::find($request->getParam('id_catalogue')))
return $this;
$requetes = Class_Catalogue::getRequetes(['id_catalogue' => $catalog->getId(),
'only_img' => Class_Catalogue::WITHOUT_IMG]);
if (!$ids = Class_Notice::getNoticeIdsByRequeteRecherche($requetes['req_ids'], true))
return $this;
$this->_remaining_records_count = count($ids);
$this->_updateThumbnailForRecord(Class_Notice::find($ids[0]));
if ($this->_remaining_records_count > 0)
$this->_next_record = Class_Notice::find($ids[1]);
return $this;
}
protected function _updateNextRecordForAll() {
if (!$this->_remaining_records_count = Class_Notice::countBy(['url_vignette' => '']))
return $this;
$this->_updateThumbnailForRecord($this->_firstRecordWithoutThumbnail());
$this->_next_record = $this->_firstRecordWithoutThumbnail();
return $this;
}
protected function _updateThumbnailForRecord($record) {
$record->fetchUrlLocalVignette();
$this->_remaining_records_count --;
return $this;
}
public function getNextRecord() {
return $this->_next_record;
}
public function getRecordCount() {
return $this->_remaining_records_count;
}
public function isBuiltDone() {
return empty($this->_next_record);
}
protected function _firstRecordWithoutThumbnail() {
return Class_Notice::findFirstBy(['url_vignette' => '']);
}
}
<?php
/**
* Copyright (c) 2012, 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_Thumbs
{
var $config = array(
'album' => array(
"max_width" => 9999,
"max_height" => 9999,
"thumb_max_width" => 160,
"thumb_max_height" => 120
)