Skip to content
Snippets Groups Projects
Commit d3892500 authored by Laurent's avatar Laurent
Browse files

Cache annexes in cosmogramme

parent f9f7c40a
Branches
Tags
3 merge requests!529Hotline 6.56,!433Hotline 6.53,!431Hotline 6.53
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 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).
*
* AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
abstract class CodifCacheAbstract {
static $_instance;
protected $_cache = [];
public static function getInstance() {
if (!isset(static::$_instance))
static::$_instance = new self();
return static::$_instance;
}
public function find($code) {
if (!isset($this->_cache[$code]))
$this->_cache[$code] = $this->load($code);
return $this->_cache[$code];
}
abstract public function load($code);
}
class CodifAnnexeCache extends CodifCacheAbstract {
public function load($code) {
return Class_CodifAnnexe::findFirstBy(['code' => $code]);
}
}
?>
\ No newline at end of file
......@@ -25,6 +25,8 @@ require_once 'classe_dewey.php';
require_once 'classe_pcdm4.php';
require_once 'classe_indexation.php';
require_once 'classe_isbn.php';
require_once 'classe_codif_cache.php';
class notice_unimarc extends iso2709_record {
private $id_profil; // Id du profil de données pour le fichier chargé
......@@ -445,8 +447,8 @@ class notice_unimarc extends iso2709_record {
protected function isAnnexeInvisible($id) {
return ($enreg = fetchEnreg('select * from codif_annexe where code=\'' . $id . '\''))
&& $enreg['invisible'] == 1;
$annexe = CodifAnnexeCache::getInstance()->find($id);
return $annexe && !$annexe->isVisible();
}
......
......@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_CodifAnnexe extends Storm_Model_Abstract {
......@@ -38,6 +38,11 @@ class Class_CodifAnnexe extends Storm_Model_Abstract {
public function getMailIntBib() {
return $this->getIntBib()->getMail();
}
public function isVisible() {
return (1 != $this->getInvisible());
}
}
?>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment