Skip to content
Snippets Groups Projects
Commit 3b6df8b1 authored by efalcy's avatar efalcy Committed by Patrick Barroca
Browse files

hotline #16604 : fix base dir in frbr

parent 58b68b8e
Branches
Tags
3 merge requests!896Master,!795Wip test newopac3,!766Wip test newopac3
......@@ -98,7 +98,17 @@ class Class_CmsUrlTransformer {
return preg_replace($regs, '$1$7', $content, -1, $replace_count);
}
public static function removeHostFromUrl($hostname,$basedir, $content, &$replace_count = null) {
public static function removeBaseDir($hostname,$basedir, $content, &$replace_count = null) {
$regs = static::checkHostFromUrl($hostname,$basedir);
$result = preg_replace($regs, '$1$4', $content, -1, $replace_count);
return $result;
}
public static function checkHostFromUrl($hostname,$basedir) {
$hosts = ['web.afi-sa.net',
'opac3.pergame.net',
'www.'.$basedir,
......@@ -109,7 +119,12 @@ class Class_CmsUrlTransformer {
foreach($hosts as $host) {
$regs []= '/^((http:\/\/)?' . $host. ')?(\/'.$basedir.')?([\/?][^"\']*)/i';
}
return $regs;
}
public static function removeHostFromUrl($hostname,$basedir, $content, &$replace_count = null) {
$regs = static::checkHostFromUrl($hostname,$basedir);
$result = preg_replace($regs, '$4', $content, -1, $replace_count);
if (strpos($result,"?") === 0 )
$result="/".$result;
......
......@@ -27,8 +27,8 @@ foreach ($profils as $profil) {
}
foreach (Class_FRBR_Link::findAll() as $frbr) {
$frbr->setSource(Class_CmsUrlTransformer::removeHost($hostname,$basedir, $frbr->getSource()));
$frbr->setTarget(Class_CmsUrlTransformer::removeHost($hostname,$basedir, $frbr->getTarget()));
$frbr->setSource(Class_CmsUrlTransformer::removeBaseDir($hostname,$basedir, $frbr->getSource()));
$frbr->setTarget(Class_CmsUrlTransformer::removeBaseDir($hostname,$basedir, $frbr->getTarget()));
$frbr->save();
}
......
......@@ -97,7 +97,11 @@ class CmsUrlTransformerTest extends AbstractControllerTestCase {
$this->assertEquals('/?id_profil=1',$this->profil_jeunesse->getCfgAccueilAsArray()['modules'][2]['preferences']['lien_connexion']);
}
/** @test */
public function testremoveBaseDir() {
$this->assertEquals("http://ma-mediatheque.fr/recherche/viewnotice/expressionRecherche/dragon/tri/*/clef/DRAGONJAUNEETLEDRAGONBLEULE-CONTECOREEN-LOUISC--PPICQUIER-2012-1/id/1805295",
Class_CmsUrlTransformer::removeBaseDir('ma-mediatheque.fr', 'casa','http://ma-mediatheque.fr/casa/recherche/viewnotice/expressionRecherche/dragon/tri/*/clef/DRAGONJAUNEETLEDRAGONBLEULE-CONTECOREEN-LOUISC--PPICQUIER-2012-1/id/1805295'));
}
/* @test */
public function testProfilCfgSite() {
$this->profil_jeunesse->setCfgSite(Class_CmsUrlTransformer::removeHostFromArray("ma-mediatheque.net","afi-opac3", $this->profil_jeunesse->getCfgSiteAsArray(), $countSite));
......
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