Commit c5d10876 authored by continuum's avatar continuum

Resolve conflicts

Conflicts:
	.gitattributes
	.gitignore
	application/modules/admin/controllers/AlbumController.php
	application/modules/admin/controllers/HarvestController.php
	application/modules/admin/controllers/SystemeController.php
	cosmogramme/php/classes/classe_notice_avenio.php
	cosmogramme/php/classes/classe_notice_integration.php
	cosmogramme/php/classes/classe_unimarc.php
	cosmogramme/tests/php/classes/NoticeIntegrationTest.php
	library/Class/Album.php
	library/Class/FRBR/Link.php
	library/Class/Indexation.php
	library/Class/NatureDoc.php
	library/Class/Notice.php
	library/Class/Profil.php
	library/Class/WebService/BibNumerique/RessourceNumerique.php
	library/ZendAfi/Controller/Plugin/AdminAuth.php
	scripts/emacs/phafi-autoload.el
	tests/application/modules/admin/controllers/AdminAuthControllerTest.php
	tests/application/modules/admin/controllers/AlbumControllerTest.php
	tests/application/modules/admin/controllers/HarvestControllerTest.php
	tests/application/modules/opac/controllers/IndexControllerTest.php
	tests/library/Class/FRBR/LinkTest.php
	tests/library/Class/ProfilTest.php
parent 2908f1fd
This diff is collapsed.
......@@ -520,10 +520,11 @@ class Admin_AlbumController extends ZendAfi_Controller_Action {
$droits_precision : 'Domaine public';
$album->updateAttributes($values);
if ($album->save()
&& $album->receiveFile()
&& $album->receivePDF()) {
&& $album->receivePDF()
&& $album->index()) {
(new Storm_Cache())->clean();
$this->_helper->notify('Album sauvegardé');
$this->_redirect('admin/album/edit_album/id/' . $album->getId());
}
......
......@@ -20,23 +20,12 @@
*/
class Admin_HarvestController extends Zend_Controller_Action {
public function arteVodAction() {
if (!Class_AdminVar::isArteVodEnabled())
$this->_redirect('/admin/index');
$logger = new Zend_Log();
$logger->addWriter(new Zend_Log_Writer_Stream('php://output'));
ob_start();
$logger->info('Début du moissonnage');
$service = new Class_WebService_BibNumerique_ArteVOD();
$service->setLogger($logger);
$service->harvest('');
public function arteVodAction() {
$this->_withServiceDo(new Class_WebService_BibNumerique_ArteVOD(),
$this->view->_('Moissonnage ArteVOD'),
Class_AdminVar::isArteVodEnabled());
$logger->info('Fin du moissonnage');
$this->view->log = ob_get_clean();
}
......@@ -46,44 +35,16 @@ class Admin_HarvestController extends Zend_Controller_Action {
public function vodeclicAction() {
if (!Class_AdminVar::isVodeclicEnabled())
$this->_redirect('/admin/index');
$this->view->titre = $this->view->_('Moissonnage Vodeclic');
$logger = new Zend_Log();
$logger->addWriter(new Zend_Log_Writer_Stream('php://output'));
ob_start();
$logger->info('Début du moissonnage');
$service = new Class_WebService_BibNumerique_Vodeclic();
$service->setLogger($logger);
$service->harvest(['partenaire_id'=>Class_AdminVar::get('VODECLIC_ID'),
'key'=>Class_AdminVar::get('VODECLIC_KEY'),
'bib_id'=>Class_AdminVar::get('VODECLIC_BIB_ID')]);
$logger->info('Fin du moissonnage');
$this->view->log = ob_get_clean();
$this->_withServiceDo(new Class_WebService_BibNumerique_Vodeclic(),
$this->view->_('Moissonnage Vodeclic'),
Class_AdminVar::isVodeclicEnabled());
}
public function toutapprendreAction() {
if (!Class_AdminVar::isToutApprendreEnabled())
$this->_redirect('/admin/index');
$this->view->titre = $this->view->_('Moissonnage Tout Apprendre');
$logger = new Zend_Log();
$logger->addWriter(new Zend_Log_Writer_Stream('php://output'));
ob_start();
$logger->info('Début du moissonnage');
$service = new Class_WebService_BibNumerique_ToutApprendre();
$service->setLogger($logger);
$service->harvest();
$logger->info('Fin du moissonnage');
$this->view->log = ob_get_clean();
$this->_withServiceDo(new Class_WebService_BibNumerique_ToutApprendre(),
$this->view->_('Moissonnage Tout Apprendre'),
Class_AdminVar::isToutApprendreEnabled());
}
......@@ -95,29 +56,16 @@ class Admin_HarvestController extends Zend_Controller_Action {
$this->view->titre = $this->view->_('Moissonnage Tout Apprendre');
}
public function numilogAction() {
if (!Class_AdminVar::isNumilogEnabled())
$this->_redirect('/admin/index');
$logger = new Zend_Log();
$logger->addWriter(new Zend_Log_Writer_Stream('php://output'));
ob_start();
$logger->info('Début du moissonnage');
$service = new Class_WebService_BibNumerique_Numilog();
$service->setLogger($logger);
$service->harvest('');
$logger->info('Fin du moissonnage');
$this->view->log = ob_get_clean();
public function numilogAction() {
$this->_withServiceDo(new Class_WebService_BibNumerique_Numilog(),
$this->view->_('Moissonnage Numilog'),
Class_AdminVar::isNumilogEnabled());
}
public function numilogBrowseAction() {
$this->view->titre = $this->view->_('Moissonnage Numilog');
$this->view->titre = $this->view->_('Moissonnage Numilog');
}
......@@ -132,4 +80,26 @@ class Admin_HarvestController extends Zend_Controller_Action {
protected function _withServiceDo($service, $titre, $enabled) {
if (!$enabled) {
$this->_redirect('/admin/index');
return;
}
$this->view->titre = $titre;
$logger = new Zend_Log();
$logger->addWriter(new Zend_Log_Writer_Stream('php://output'));
ob_start();
$logger->info('Début du moissonnage');
$service->setLogger($logger);
$service->harvest();
(new Storm_Cache())->clean();
$logger->info('Fin du moissonnage');
$this->view->log = ob_get_clean();
}
}
......@@ -63,7 +63,14 @@ class Admin_SystemeController extends Zend_Controller_Action {
$this->view->nb_pas_reconnu=fetchOne("select count(*) from notices where url_vignette ='NO'");
// Calcul de l'espace occupé
$dir=opendir($path);
if (!file_exists($path))
mkdir($path);
if (!$dir=opendir($path)) {
$this->view->taille_cache = 0;
return;
}
while(false !== ($file = readdir($dir)))
{
$extension=substr($file,-4);
......
<?xml version="1.0" encoding="UTF-8"?>
<project name="opacce" default="build">
<target name="build"
depends="prepare,phpunit"/>
<target name="build-parallel"
depends="prepare,lint,tools-parallel,phpunit,phpcb"/>
<target name="tools-parallel"
description="Run tools in parallel">
<parallel threadCount="2">
<sequential>
<antcall target="pdepend"/>
<antcall target="phpmd-ci"/>
</sequential>
<antcall target="phpcpd"/>
<antcall target="phpcs-ci"/>
<antcall target="phploc"/>
<antcall target="phpdoc"/>
</parallel>
</target>
<target name="clean" description="Cleanup build artifacts">
<delete dir="${basedir}/build/api"/>
<delete dir="${basedir}/build/code-browser"/>
<delete dir="${basedir}/build/coverage"/>
<delete dir="${basedir}/build/logs"/>
<delete dir="${basedir}/build/pdepend"/>
</target>
<target name="prepare" depends="clean"
description="Prepare for build">
<mkdir dir="${basedir}/build/api"/>
<mkdir dir="${basedir}/build/code-browser"/>
<mkdir dir="${basedir}/build/coverage"/>
<mkdir dir="${basedir}/build/logs"/>
<mkdir dir="${basedir}/build/pdepend"/>
</target>
<target name="lint">
<apply executable="php" failonerror="true">
<arg value="-l" />
<fileset dir="${basedir}">
<include name="**/*.php" />
<modified />
</fileset>
<fileset dir="${basedir}/tests">
<include name="**/*.php" />
<modified />
</fileset>
</apply>
</target>
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="phploc">
<arg value="--log-csv" />
<arg value="${basedir}/build/logs/phploc.csv" />
<arg path="${basedir}" />
</exec>
</target>
<target name="pdepend"
description="Calculate software metrics using PHP_Depend">
<exec executable="pdepend">
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
<arg path="${basedir}" />
</exec>
</target>
<target name="phpmd"
description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="phpmd">
<arg path="${basedir}" />
<arg value="text" />
<arg value="${basedir}/build/phpmd.xml" />
</exec>
</target>
<target name="phpmd-ci"
description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
<exec executable="phpmd">
<arg path="${basedir}" />
<arg value="xml" />
<arg value="${basedir}/build/phpmd.xml" />
<arg value="--reportfile" />
<arg value="${basedir}/build/logs/pmd.xml" />
</exec>
</target>
<target name="phpcs"
description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="phpcs">
<arg value="--standard=${basedir}/build/phpcs.xml" />
<arg path="${basedir}" />
</exec>
</target>
<target name="phpcs-ci"
description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
<exec executable="phpcs" output="/dev/null">
<arg value="--report=checkstyle" />
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
<arg value="--standard=${basedir}/build/phpcs.xml" />
<arg path="${basedir}" />
</exec>
</target>
<target name="phpcpd" description="Find duplicate code using PHPCPD">
<exec executable="phpcpd">
<arg value="--log-pmd" />
<arg value="${basedir}/build/logs/pmd-cpd.xml" />
<arg path="${basedir}" />
</exec>
</target>
<target name="phpdoc"
description="Generate API documentation using PHPDocumentor">
<exec executable="phpdoc">
<arg value="--directory" />
<arg path="${basedir}" />
<arg value="--target" />
<arg path="${basedir}/build/api" />
</exec>
</target>
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec dir="${basedir}/tests" executable="phpunit" failonerror="true">
<arg line="--log-junit ${basedir}/build/logs/junit.xml" />
<arg line="--coverage-html ${basedir}/build/coverage" />
</exec>
</target>
<target name="phpcb"
description="Aggregate tool output with PHP_CodeBrowser">
<exec executable="phpcb">
<arg value="--log" />
<arg path="${basedir}/build/logs" />
<arg value="--source" />
<arg path="${basedir}" />
<arg value="--output" />
<arg path="${basedir}/build/code-browser" />
</exec>
</target>
</project>
......@@ -176,8 +176,7 @@ class notice_avenio
{
$elems=explode("(",$enreg);
$nom=$elems[0];
$prenom=trim($elems[1]);
$prenom=substr($prenom,0,(strlen($prenom)-1));
$prenom=substr(trim($elems[1],0,(strlen(trim($elems[1]))-1)));
$auteurs[]=$nom . "|" .$prenom;
}
return $auteurs;
......@@ -288,9 +287,9 @@ class notice_avenio
{
if(!trim($auteur)) continue;
$elems=explode("|",$auteur);
$data_auteur[0]=array('a',$elems[0]);
if($elems[1]>'') $data_auteur[1]=array('b',$elems[1]);
$notice_sgbd->add_field("700","01",$data_auteur);
$notice_sgbd->add_field("700","1 ","a".trim($elems[0]." ".trim($elems[1])));
}
}
$unimarc=$notice_sgbd->update();
......
......@@ -366,7 +366,8 @@ class notice_integration
if (!$enreg['id_bib'])
$enreg['id_bib'] = $sql->fetchOne('select min(id_bib) from int_bib');
$notice = Pseudo_Notice::newWith($type_doc, $enreg);
$notice = Class_Indexation_PseudoNotice::newWith($type_doc, $enreg);
if (!$notice->isValid() || !$notice->save())
return ['statut' => 0, 'id_notice' => 0];
......@@ -1311,6 +1312,7 @@ class notice_integration
}
}
<<<<<<< HEAD
class Pseudo_Notice {
const TYPE_CMS = 8;
......@@ -1735,4 +1737,6 @@ class Pseudo_Notice_Null extends Pseudo_Notice{
return false;
}
}
?>
\ No newline at end of file
......@@ -266,7 +266,9 @@ class notice_unimarc extends iso2709_record
$chapeau=$this->get_subfield("461","t");
$ret["clef_chapeau"]=$this->indexation->codeAlphaTitre($chapeau[0]);
$numero=$this->get_subfield("461","v");
if(!$numero) $numero=$this->get_subfield("200","h");
$ret["clef_numero"]=$this->indexation->alphaMaj($numero[0]);
}
if(!$ret["clef_chapeau"] or !$ret["clef_numero"]) return false;
......
......@@ -142,7 +142,8 @@ abstract class NoticeIntegrationSacramentariumTestCase extends NoticeIntegration
public function setUp() {
parent::setUp();
Codif_matiere::getInstance()->setCodif(['62115' => ['libelle' => 'Douzième siècle']]);
$this->fixture('Class_CodifMatiere', ['id' => 62115,
'libelle' => 'Douzième siècle']);
$sacramentarium = $this->fixture(
'Class_Album',
......
This diff is collapsed.
......@@ -148,7 +148,9 @@ class Class_FRBR_Link extends Storm_Model_Abstract {
return $this->$attribute;
try {
$key = $this->extractKeyFromUrl($this->{'get'. ucfirst($type)}());
} catch(Zend_Uri_Exception $e) {
return;
}
......@@ -177,16 +179,15 @@ class Class_FRBR_Link extends Storm_Model_Abstract {
* @param $url string
* @return string
*/
public function extractKeyFromUrl($url) {
if ('' == $url)
return '';
xdebug_break();
// simule un routage standard
$request = new Zend_Controller_Request_Http($url);
// $request->setBaseUrl(BASE_URL);
$router = new ZendAfi_Controller_Router_RewriteWithoutBaseUrl();
$router->route($request);
return $request->getParam('clef', '');
}
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -44,16 +44,30 @@ class NatureDocLoader {
}
public function find($id) {
$all = $this->findAll();
return isset($all[$id]) ? $all[$id] : null;
}
public function getLibelle($id) {
return ($instance = $this->find($id)) ? $instance->getLibelle() : '';
}
public function findAll() {
$instances = [];
$lines = explode("\r\n",
Class_CosmoVar::getLoader()->find('nature_docs')->getListe());
Class_CosmoVar::find('nature_docs')->getListe());
foreach($lines as $line) {
$colon_pos = strpos($line, ':');
$instances[] = (new Class_NatureDoc())->updateAttributes(['id' => substr($line, 0, $colon_pos),
'libelle' => substr($line, $colon_pos+1)]);
$id = substr($line, 0, $colon_pos);
$instances[$id] = (new Class_NatureDoc())->updateAttributes(['id' => $id,
'libelle' => substr($line, $colon_pos+1)]);
}
return $instances;
......
......@@ -132,7 +132,8 @@ class Class_Notice extends Storm_Model_Abstract {
/** @var Class_NoticeUnimarc */
protected $_notice_unimarc;
protected $_has_many = ['exemplaires' => ['model' => 'Class_Exemplaire',
'role' => 'notice']];
'role' => 'notice',
'dependents' => 'delete']];
protected
$_titre_principal,
......
This diff is collapsed.
......@@ -1391,6 +1391,7 @@ class Class_Profil extends Storm_Model_Abstract {
$pages = $this->getSubProfils();
foreach($pages as $page)
$clone->addSubProfil($page->copy()->setLibelle($page->getLibelle()));
return $clone;
}
......@@ -1442,6 +1443,7 @@ class Class_Profil extends Storm_Model_Abstract {
}
public function beforeSave() {
unset($this->_has_parent_profil);
$this->_should_forward_attributes = [];
......@@ -1764,5 +1766,7 @@ class Class_Profil extends Storm_Model_Abstract {
}
}
return false;
}
}
}
\ No newline at end of file
......@@ -251,11 +251,11 @@
$this->fillAlbum($album);
$this->fillAlbumTypeDoc($album);
$this->updateRessourceNumeriqueNotes($album);
//$this->importZones($album);
if ($album->save())
Class_WebService_BibNumerique_Vignette::getInstance()->updateAlbum($album);
return $album;
}
......
......@@ -50,6 +50,7 @@ class ZendAfi_Controller_Plugin_AdminAuth extends Zend_Controller_Plugin_Abstrac
Zend_Controller_Front::getInstance()
->getPlugin('Zend_Controller_Plugin_ErrorHandler')
->setErrorHandlerModule('admin');
if (!$user = Class_Users::getIdentity()) {
$controller = 'auth';
$action = 'login';
......@@ -57,8 +58,11 @@ class ZendAfi_Controller_Plugin_AdminAuth extends Zend_Controller_Plugin_Abstrac
$redirector_helper = new Zend_Controller_Action_Helper_Redirector();
$redirector_helper->setExit(false);
$redirector_helper->goToUrl('opac/');
$module = 'opac';
$controller = 'index';
$action = 'index';
}
} else {
} else {
// Entree dans opac on teste si le site a été désactivé
if (Class_AdminVar::get("SITE_OK") == "0" and $module == 'opac') {
$controller = 'index';
......@@ -79,7 +83,6 @@ class ZendAfi_Controller_Plugin_AdminAuth extends Zend_Controller_Plugin_Abstrac
protected function userCanAccessAdminPage($user) {
xdebug_break();
$acl = new ZendAfi_Acl_AdminControllerRoles();
$resource = $this->_request->getControllerName();
......
......@@ -42,10 +42,12 @@
(require 'magit)
;;(require 'magit-svn)
;;(add-hook 'magit-mode-hook 'turn-on-magit-svn)
(require 'js)
(defun phafi-js-mode()
(setq js-indent-level 2)
......
......@@ -86,6 +86,7 @@ class AdminAuthControllerNobodyLoggedTest extends Admin_AbstractControllerTestCa
class AdminAuthControllerWithRestrictedProfilTest extends AbstractControllerTestCase {
public function setup() {
parent::setUp();
......@@ -110,4 +111,5 @@ class AdminAuthControllerWithRestrictedProfilTest extends AbstractControllerTest
$this->assertRedirectTo('/opac/');
}
}
?>
\ No newline at end of file
......@@ -63,7 +63,10 @@ abstract class Admin_AlbumControllerTestCase extends Admin_AbstractControllerTes
->setLibelle('Patrimoine');
$patrimoine->save();
$this->fixture('Class_Album', ['id' => 43])
$this->fixture('Class_Album', ['id' => 43,
'notes' => 'a:3:{s:5:"305$a";s:12:"XIIe siècle";s:5:"200$b";s:9:"Parchemin";s:5:"316$a";s:12:"Reliure bois";}'])
->setTitre('Mes BD')
->setAuteur('Laurent')
->setTags('bd;dessin')
......@@ -82,7 +85,6 @@ abstract class Admin_AlbumControllerTestCase extends Admin_AbstractControllerTes
->setCategorie($favoris)
->save();
$this->fixture('Class_Album', ['id' => 44])
->setTitre('Bible Souvigny')
->beLivreNumerique()
......@@ -114,16 +116,13 @@ abstract class Admin_AlbumControllerTestCase extends Admin_AbstractControllerTes
class Admin_AlbumControllerIndexTest extends Admin_AlbumControllerTestCase {
public function setUp() {
parent::setUp();
$favoris=Class_AlbumCategorie::find(2);
$favoris = Class_AlbumCategorie::find(2);
$favoris->setSousCategories([Class_AlbumCategorie::find(6)])
->save();
$this->fixture('Class_Album', ['id' => 66,
'titre' => "L'orphelin",
'parent_id' => 0,
'cat_id' => 0]);
$this->dispatch('/admin/album', true);
}
......@@ -650,27 +649,25 @@ class Admin_AlbumControllerPostAlbumRenaissanceToPatrimoineTest extends Admin_Al
public function setUp() {
parent::setUp();
$data = ['titre' => 'Renaissance',
'sous_titre' => 'Ze Renaissance',
'description' => 'Oeuvres majeures sous François 1er',
'nature_doc' => '2;3'];
$this
->getRequest()
->setMethod('POST')
->setPost($data);
$_FILES['fichier'] = ['size' => 0,
'name' => '',
'tmp_name' => '',
'error' => 4];
$_FILES['pdf'] = ['size' => 0,
'name' => '',
'tmp_name' => '',
'error' => 4];
$this->postDispatch('/admin/album/add_album_to/id/38',
['titre' => 'Renaissance',
'sous_titre' => 'Ze Renaissance',
'description' => 'Oeuvres majeures sous François 1er',
'nature_doc' => '2;3',
'type_doc_id' => '102',
'genre' => '32;23']);
$_FILES['fichier'] = array('size' => 0,
'name' => '',
'tmp_name' => '',
'error' => 4);
$_FILES['pdf'] = array('size' => 0,
'name' => '',
'tmp_name' => '',
'error' => 4);
$this->dispatch('/admin/album/add_album_to/id/38', true);
$this->new_album = Class_Album::findFirstBy(['order'=>'id desc']);
$this->new_notice = $this->new_album->getNotice();
}
......@@ -694,7 +691,8 @@ class Admin_AlbumControllerPostAlbumRenaissanceToPatrimoineTest extends Admin_Al
/** @test */
public function shouldRedirectToEditAlbum() {
$this->assertRedirectTo('/admin/album/edit_album/id/'.$this->new_album->getId());
$this->assertRedirectTo('/admin/album/edit_album/id/'.$this->new_album->getId(),
implode(' :: ', $this->new_album->getErrors()));
}
......@@ -708,6 +706,23 @@ class Admin_AlbumControllerPostAlbumRenaissanceToPatrimoineTest extends Admin_Al
public function natureDocShouldBe2SemiColon3() {
$this->assertEquals('2;3', $this->new_album->getNatureDoc());
}
/** @test */
public function pseudoNoticeShouldBeIndexed() {
$this->assertNotNull($this->new_notice);
}
/** @test */
public function shouldHaveGenre32Facette() {
$this->assertContains('G32', explode(' ', $this->new_notice->getFacettes()));
}
/** @test */
public function shouldHaveGenre23Facette() {
$this->assertContains('G23', explode(' ', $this->new_notice->getFacettes()));
}
}
......@@ -1031,37 +1046,47 @@ class Admin_AlbumControllerEditAlbumMesRomans extends Admin_AlbumControllerTestC
class Admin_AlbumControllerPostEditAlbumMesBDTest extends Admin_AlbumControllerTestCase {