diff --git a/cosmogramme/php/integration/pseudo_notices.php b/cosmogramme/php/integration/pseudo_notices.php index ff84745ea0ec586e3bdb1b95ceb298edfb4ea470..e8d5a286c07db607c392dde8693d82204579ef84 100644 --- a/cosmogramme/php/integration/pseudo_notices.php +++ b/cosmogramme/php/integration/pseudo_notices.php @@ -37,11 +37,7 @@ function deletePseudoNotice($id_notice) { // ---------------------------------------------------------------- // CMS // ---------------------------------------------------------------- -if ($phase > 0.1 and $phase < 0.202) -{ - // init variables - if ($phase == 0.2) - { +if ($phase > 0.1 and $phase < 0.202) { unset($phase_data); $phase_data["nombre"] = 0; $phase_data["timeStart"] = time(); @@ -49,22 +45,8 @@ if ($phase > 0.1 and $phase < 0.202) setVariable("traitement_phase", "Pseudo-notices : CMS"); $log->ecrire("<h4>Traitement des pseudo-notices</h4>"); $log->ecrire(BR . BR . '<span class="violet">Notices CMS :</span>' . BR); - } - else print('<span class="violet">Notices CMS :</span>' . BR); - // suppression des notices et des exemplaires - $phase = 0.2001; - $items = fetchAll("select id_notice from notices where type_doc=8"); - if ($items) - { - foreach ($items as $item) - { - if (!$mode_cron and $chrono->tempsPasse() > 10) sauveContexte(); - $id_notice = $item["id_notice"]; - deletePseudoNotice($id_notice); - } - } - $phase = 0.2002; + $phase = 0.2002; } @@ -72,22 +54,37 @@ if ($phase > 0.1 and $phase < 0.202) // ---------------------------------------------------------------- // Articles CMS // ---------------------------------------------------------------- -if ($phase == 0.2002) -{ - if ($phase_data["nombre"] and !$mode_cron) print('<span class="violet">Notices CMS :</span>' . BR); - if (!$mode_cron and $chrono->tempsPasse() > 10) sauveContexte(); +if ($phase == 0.2002) { + if ($phase_data["nombre"] and !$mode_cron) + print('<span class="violet">Notices CMS :</span>' . BR); + + if (!$mode_cron and $chrono->tempsPasse() > 10) + sauveContexte(); + $chrono->start(); - $result = $sql->prepareListe("select * from cms_article where ID_ARTICLE >" . $phase_data["pointeur_reprise"] . " and INDEXATION=1 and STATUS NOT IN(1, 2, 4) order by ID_ARTICLE"); - if ($result) - { - while ($enreg = $sql->fetchNext($result)) - { - if (!$mode_cron and $chrono->tempsPasse() > 10) sauveContexte(); - $enreg["id_bib"] = $sql->fetchOne("select ID_SITE from cms_categorie where ID_CAT=" . $enreg["ID_CAT"]); + + while($articles = Class_Article::findAllBy(['where' => 'id_article >' . $phase_data["pointeur_reprise"], + 'order' => 'id_article', + 'limit' => 100 + ])) { + foreach($articles as $article) { + if (!$mode_cron and $chrono->tempsPasse() > 10) + sauveContexte(); + $phase_data["nombre"]++; - $ret = $notice->traitePseudoNotice(8, $enreg); - tracePseudoNotice($ret, $enreg); - $phase_data["pointeur_reprise"] = $enreg["ID_ARTICLE"]; + + $article->index(); + $record = $article->getNotice(); + $statut = $record + ? ['statut' => 1, + 'id_notice' => $record->getId(), + 'unimarc' => $record->getUnimarc(), + 'code_barres' => '', + 'facettes' => $record->getFacettes()] + : ['statut' => 0, 'id_notice' => 0]; + + tracePseudoNotice($ret, $statut); + $phase_data["pointeur_reprise"] = $article->getId(); } } traceRecapPseudoNotices($phase_data); @@ -231,7 +228,6 @@ if ($phase == 0.7) { $chrono->start(); while ( $albums = Class_Album::findAllBy(['where' => 'id > ' . $phase_data["pointeur_reprise"], - 'visible' => true, 'order' => 'id', 'limit' => 100]) ) { foreach($albums as $album) { @@ -240,17 +236,17 @@ if ($phase == 0.7) { $phase_data["nombre"]++; $album->index(); - $notice = $album->getNotice(); - $statut = $notice - ? ['statut' => 0, 'id_notice' => 0] - : ['statut' => 1, - 'id_notice' => $notice->getId(), - 'unimarc' => $notice->getUnimarc(), - 'code_barres' => $notice->getCodeBarres(), - 'facettes' => $notice->getFacettes()]; - - tracePseudoNotice($ret, $statut); - $phase_data["pointeur_reprise"] = $album->getId(); + $record = $album->getNotice(); + $statut = $record + ? ['statut' => 1, + 'id_notice' => $record->getId(), + 'unimarc' => $record->getUnimarc(), + 'code_barres' => '', + 'facettes' => $record->getFacettes()] + : ['statut' => 0, 'id_notice' => 0]; + + tracePseudoNotice($ret, $statut); + $phase_data["pointeur_reprise"] = $album->getId(); } }