Skip to content
Snippets Groups Projects

Hotline#15779 fix newsletter with catalog

Merged Patrick Barroca requested to merge hotline#15779_fix_newsletter_with_catalog into hotline_6.50
Compare and
+ 131
123
Preferences
Compare changes
Files
+ 65
66
@@ -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
*/
//////////////////////////////////////////////////////////////////////////////////////
@@ -27,8 +27,7 @@ class NoticeLoader extends Storm_Model_Loader {
public function getNoticesFromPreferences($preferences) {
$catalogue = new Class_Catalogue();
$requetes = $catalogue->getRequetes($preferences);
$requetes = Class_Catalogue::getRequetes($preferences);
$notices = $this->findAll($requetes["req_liste"]);
// Tirage aleatoire
@@ -53,12 +52,12 @@ class NoticeLoader extends Storm_Model_Loader {
return (new Storm_Cache())
->useImplodeExplodeSerialization()
->memoize([$req,__CLASS__,__FUNCTION__],
->memoize([$req,__CLASS__,__FUNCTION__],
function() use ($req) {
return Zend_Registry::get('sql')->fetchAllByColumn($req);
});
}
public function selectIdsFromRequest($request) {
return "Select inner_table.id_notice from ( ".$request." ) inner_table";
@@ -70,17 +69,17 @@ class NoticeLoader extends Storm_Model_Loader {
$ids = $this->getNoticeIdsByRequeteRecherche($req);
if ($nb_par_page)
$ids = array_slice($ids,
($page_no-1) * $nb_par_page,
if ($nb_par_page)
$ids = array_slice($ids,
($page_no-1) * $nb_par_page,
$nb_par_page);
if (empty($ids))
return [];
return Class_Notice::getLoader()->findAllBy(['id_notice' => $ids,
'order' => 'FIELD(id_notice, '.implode(',', $ids).')']);
}
}
public function countBySQLSelect($req) {
@@ -119,7 +118,7 @@ class NoticeLoader extends Storm_Model_Loader {
if (!$clef_alpha = $frbr_link->extractKeyFromUrl($url))
return;
return Class_Notice::getNoticeByClefAlpha($clef_alpha);
return Class_Notice::getNoticeByClefAlpha($clef_alpha);
}
@@ -227,12 +226,12 @@ class Class_Notice extends Storm_Model_Abstract {
if ($id_site == $exemplaire->getIdBib())
$exemplaire_on_site []= $exemplaire;
}
return $exemplaire_on_site;
}
public function isEpub() {
if ($this->getAlbum()
if ($this->getAlbum()
&& $this->getAlbum()->isEpub())
return true;
return false;
@@ -271,7 +270,7 @@ class Class_Notice extends Storm_Model_Abstract {
* @return Class_Exemplaire
*/
public function getFirstExemplaire() {
return isset($this->_first_exemplaire)
return isset($this->_first_exemplaire)
? $this->_first_exemplaire
: $this->_first_exemplaire = Class_Exemplaire::findFirstBy(['id_notice' => $this->getId()]);
}
@@ -391,8 +390,8 @@ class Class_Notice extends Storm_Model_Abstract {
public function withUrlVignetteDo($closure) {
return $closure($this,
$this->hasVignette()?$this->_attributes['url_vignette']:'',
return $closure($this,
$this->hasVignette()?$this->_attributes['url_vignette']:'',
isset($this->_attributes['url_image']) ? $this->_attributes['url_image'] : '');
}
@@ -534,7 +533,7 @@ class Class_Notice extends Storm_Model_Abstract {
$data = $this->get_subfield("200", "b");
return $this->filtreTitre($data[0]);
}
// ----------------------------------------------------------------
// Renvoie la clef chapeau et le no de partie
// ----------------------------------------------------------------
@@ -628,7 +627,7 @@ class Class_Notice extends Storm_Model_Abstract {
$criteres_recherche = new Class_CriteresRecherche();
$criteres_recherche->setParams(['facette' => $facette]);
$moteur =Class_MoteurRecherche::getInstance();
$ret=$moteur->lancerRecherche($criteres_recherche);
return fetchAll($ret['req_liste'],10);
@@ -640,7 +639,7 @@ class Class_Notice extends Storm_Model_Abstract {
return [];
return $this->getLoader()->getAllNoticesByClefChapeau($this->getClefChapeau());
}
@@ -691,7 +690,7 @@ class Class_Notice extends Storm_Model_Abstract {
$mots = explode(" ", trim($champ));
foreach ($mots as $mot) {
$mot = $ix->getExpressionRecherche($mot);
if ($mot)
if ($mot)
$recherche .= ' ' . $mot;
}
}
@@ -763,7 +762,7 @@ class Class_Notice extends Storm_Model_Abstract {
// On cherche le chapeau et le n°
if ($data = $this->get_subfield("461", "t")) {
$chapeau = $this->filtreTitre($data[0]);
if ($chapeau)
if ($chapeau)
{
if ($titre == $chapeau) $titre = "";
$data=$this->get_subfield('461','v');
@@ -801,7 +800,7 @@ class Class_Notice extends Storm_Model_Abstract {
}
return $titre;
}
// ----------------------------------------------------------------
// Label docs sonores
// ----------------------------------------------------------------
@@ -836,13 +835,13 @@ class Class_Notice extends Storm_Model_Abstract {
return true;
return false;
}
public function getMorceaux() {
return Class_Notice_TracksReader::getTracksOf($this);
}
// ----------------------------------------------------------------
// Complément du titre (1er seulement)
// ----------------------------------------------------------------
@@ -852,7 +851,7 @@ class Class_Notice extends Storm_Model_Abstract {
$titre = $this->filtreTitre($titre[0]);
return trim($titre);
}
// ----------------------------------------------------------------
// ISSN
// ----------------------------------------------------------------
@@ -861,7 +860,7 @@ class Class_Notice extends Storm_Model_Abstract {
$issn = $this->get_subfield("011", "a");
return trim($issn[0]);
}
// ----------------------------------------------------------------
// Mention d'edition
// ----------------------------------------------------------------
@@ -919,19 +918,19 @@ class Class_Notice extends Storm_Model_Abstract {
$deb = substr($titre, 0, 6);
$titre = str_replace('?', '', $deb) . substr($titre, 6);
}
// filtrage caractères terminaux
$filtre = ["/", ";", ",", ":"];
foreach($filtre as $car) {
if (substr($titre,-1,1) == $car)
$titre = substr($titre, 0, strlen($titre)-1);
}
$titre = str_replace("#BR#",BR, $titre);
return trim($titre);
}
public function getAuteurPrincipal() {
if (!isset($this->_auteur_principal)) {
$this->_auteur_principal = '';
@@ -945,7 +944,7 @@ class Class_Notice extends Storm_Model_Abstract {
}
public function getFirstAuthor() {
if (!$auteurs = $this->getAuteursUnimarc(true))
if (!$auteurs = $this->getAuteursUnimarc(true))
return '';
return $auteurs[0];
}
@@ -977,7 +976,7 @@ class Class_Notice extends Storm_Model_Abstract {
// Si fonctions on constitue une nouvelle matrice détaillée
if ($getFonction and 0 < count($auteurs))
return $this->_getAuteursAvecFonctions($auteurs);
return $auteurs;
}
@@ -992,7 +991,7 @@ class Class_Notice extends Storm_Model_Abstract {
foreach ($data as $items) {
$auteur = $this->_getAuteurDansSousChamps($this->decoupe_bloc_champ($items));
$libelle = $auteur->nom . '|' . $auteur->prenom;
if ($this->_isAuteurDansZoneValide($libelle, $indexation)) {
return trim($auteur->prenom . ' ' . $auteur->nom);
}
@@ -1012,7 +1011,7 @@ class Class_Notice extends Storm_Model_Abstract {
$data = $this->get_subfield($zone);
foreach ($data as $items) {
$libelle = $this->_getAuteurDansZone($items, $avec_fonction);
if ($this->_isAuteurDansZoneValide($libelle, $indexation)) {
$auteurs[] = $libelle;
}
@@ -1025,7 +1024,7 @@ class Class_Notice extends Storm_Model_Abstract {
protected function getNatureDocs() {
return $this->get_subfield('200','b');
}
@@ -1040,7 +1039,7 @@ class Class_Notice extends Storm_Model_Abstract {
$libelle = $auteur->nom . '|' . $auteur->prenom;
if ($avec_fonction)
$libelle .= '|' . $auteur->fonction . '|' . $auteur->fonction_pergame;
return $libelle;
}
@@ -1084,7 +1083,7 @@ class Class_Notice extends Storm_Model_Abstract {
protected function _getAuteursAvecFonctions($auteurs) {
if (!is_array($auteurs) || empty($auteurs))
return [];
$ix = new Class_Indexation();
$result = [];
foreach ($auteurs as $auteur) {
@@ -1092,7 +1091,7 @@ class Class_Notice extends Storm_Model_Abstract {
if (!empty($avec_fonction))
$result[] = $avec_fonction;
}
return $result;
}
@@ -1121,7 +1120,7 @@ class Class_Notice extends Storm_Model_Abstract {
if ($auteur_fonction = Class_CodifAuteurFonction::find($fonction))
$fonction = $auteur_fonction->getLibelle();
}
$label = trim($prenom . ' ' . $nom) . (($fonction) ? ' (' . $fonction . ')': '');
return $this->getReboundFieldForFacet('A'.$codif_auteur->getId(),
$label);
@@ -1168,7 +1167,7 @@ class Class_Notice extends Storm_Model_Abstract {
public function getCollection($principale=false) {
if (!$data = $this->get_subfield(225, "a")) $data = $this->get_subfield(410, "t");
if (!$data = $this->get_subfield(225, "a")) $data = $this->get_subfield(410, "t");
if(!$data) $data = [];
if ($principale == true) {
@@ -1182,7 +1181,7 @@ class Class_Notice extends Storm_Model_Abstract {
public function getMatieres() {
if (isset($this->_matieres))
return $this->_matieres;
$matiere = array();
// Recup des zones matières dans les variables
@@ -1250,7 +1249,7 @@ class Class_Notice extends Storm_Model_Abstract {
$codes = $this->getLangueCodes();
if (0 == count($codes))
return array();
$langues = array();
foreach ($codes as $code) {
if ($langue = Class_CodifLangue::getLoader()->find($code))
@@ -1261,9 +1260,9 @@ class Class_Notice extends Storm_Model_Abstract {
public function getLangueCodes() {
if ($this->_langueCodes)
if ($this->_langueCodes)
return $this->_langueCodes;
$langues = array();
$data = $this->get_subfield(101);
foreach ($data as $items) {
@@ -1274,7 +1273,7 @@ class Class_Notice extends Storm_Model_Abstract {
$code = substr(strtolower($item['valeur']), 0, 3);
if ('und' == $code)
continue;
if ('fra' == $code)
if ('fra' == $code)
$code = 'fre';
$langues[] = $code;
}
@@ -1315,7 +1314,7 @@ class Class_Notice extends Storm_Model_Abstract {
$mot.=$item['valeur'];
}
}
if ($mot)
if ($mot)
$notes[] = trim($mot);
}
}
@@ -1361,13 +1360,13 @@ class Class_Notice extends Storm_Model_Abstract {
return $collations;
}
// ----------------------------------------------------------------
// Résumé
// ----------------------------------------------------------------
public function getResume() {
if (isset($this->_resume))
if (isset($this->_resume))
return $this->_resume;
if ($album = $this->getAlbum())
@@ -1378,9 +1377,9 @@ class Class_Notice extends Storm_Model_Abstract {
foreach ($data as $item)
if (strlen($item) > strlen($resume)) $resume = trim($item);
if ($resume && substr($resume, -1) != ".")
if ($resume && substr($resume, -1) != ".")
$resume.=".";
return $this->_resume = $resume;
}
@@ -1410,10 +1409,10 @@ class Class_Notice extends Storm_Model_Abstract {
}
if ($data['code']=='u')
$link = $data['valeur'];
if ($data['code']=='a')
$link = $data['valeur'];
}
}
$result[]=$link;
}
@@ -1428,7 +1427,7 @@ class Class_Notice extends Storm_Model_Abstract {
$target = Class_CosmoVar::get('url_site');
$trav = explode('/', $target);
$ctrl_target = array_pop($trav);
if (!trim($ctrl_target))
if (!trim($ctrl_target))
$ctrl_target = array_pop($trav);
// tableau des liens
@@ -1437,18 +1436,18 @@ class Class_Notice extends Storm_Model_Abstract {
if ($black_list) {
foreach ($black_list as $mot) {
if (stripos($item, $mot) !== false) {
$controle = false;
break;
$controle = false;
break;
}
}
}
if ($controle == true) {
if (substr(strtoupper($item), 0, 4) != 'HTTP')
if (substr(strtoupper($item), 0, 4) != 'HTTP')
$item = 'http://' . $item;
$target = (strpos($item, $ctrl_target) === false)
? 'target="_blank"' : '';
$target = (strpos($item, $ctrl_target) === false)
? 'target="_blank"' : '';
$lien[] = '<a href="' . trim($item) . '" ' . $target . ">" . trim($item) . '</a>';
}
@@ -1499,12 +1498,12 @@ class Class_Notice extends Storm_Model_Abstract {
$providers = array('Class_WebService_Fnac',
'Class_WebService_Babelio',
'Class_WebService_Premiere');
foreach ($providers as $provider_class) {
$provider = new $provider_class();
$avis = array_merge($avis, $provider->getResumes($this));
}
return $avis;
}
@@ -1552,7 +1551,7 @@ class Class_Notice extends Storm_Model_Abstract {
*/
public function toTabbedList() {
$sep=chr(9);
$enreg = Class_Codification::getInstance()->getLibelleFacette("T".$this->getTypeDoc()).$sep;
$enreg .= $this->getTitrePrincipal().$sep;
$enreg .= $this->getAuteurPrincipal().$sep;
@@ -1579,7 +1578,7 @@ class Class_Notice extends Storm_Model_Abstract {
}
public function renderOn($canvas) {
return $canvas->renderNotice($this);
return $canvas->renderNotice($this);
}
public function getFamilleId() {
@@ -1588,7 +1587,7 @@ class Class_Notice extends Storm_Model_Abstract {
return 0;
}
public function isNouveaute() {
return date('Y-m-d', self::getTimeSource()->time()) <= substr($this->getDateCreation(), 0, 10);
}
@@ -1597,15 +1596,15 @@ class Class_Notice extends Storm_Model_Abstract {
public function isInPanier() {
if(!$user=Class_Users::getIdentity())
return false;
return $user->isNoticeInMyPanier($this);
}
public function getPaniers() {
if(!$user=Class_Users::getIdentity())
return [];
return $user->getPaniersWhereICanFound($this);
}
@@ -1614,7 +1613,7 @@ class Class_Notice extends Storm_Model_Abstract {
$list_panier = $this->getPaniers();
if(($nb_paniers = count($list_panier)) < 1)
return '';
return $this->_plural($nb_paniers,
'',
'Dans le panier %s',