-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
76 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,90 @@ | ||
<?php | ||
|
||
class cadastreDockableListener extends jEventListener | ||
class cadastreDockableListener extends jEventListener | ||
{ | ||
public function onmapDockable($event) | ||
{ | ||
public function onmapDockable($event) | ||
{ | ||
$isCadastreProject = false; | ||
$services = lizmap::getServices(); | ||
$parcelleId = null; | ||
if (version_compare($services->qgisServerVersion, '3.0', '<')) { | ||
if (preg_match('#^cadastre#i', $event->project)) { | ||
$isCadastreProject = true; | ||
} | ||
} else { | ||
$config = cadastreConfig::get($event->repository, $event->project); | ||
if ($config !== null) { | ||
$isCadastreProject = true; | ||
$parcelleId = $config->parcelle->id; | ||
} | ||
$isCadastreProject = false; | ||
$services = lizmap::getServices(); | ||
$parcelleId = null; | ||
if (version_compare($services->qgisServerVersion, '3.0', '<')) { | ||
if (preg_match('#^cadastre#i', $event->project)) { | ||
$isCadastreProject = true; | ||
} | ||
|
||
// Check profile | ||
$profile = 'cadastre'; | ||
if (!empty($parcelleId)) { | ||
$profile = cadastreProfile::getWithLayerId( | ||
$event->repository, | ||
$event->project, | ||
$parcelleId | ||
); | ||
} else { | ||
try { | ||
// try to get the specific search profile to do not rebuild it | ||
jProfiles::get('jdb', $profile, true); | ||
} catch (Exception $e) { | ||
$profile = null; | ||
} | ||
} else { | ||
$config = cadastreConfig::get($event->repository, $event->project); | ||
if ($config !== null) { | ||
$isCadastreProject = true; | ||
$parcelleId = $config->parcelle->id; | ||
} | ||
} | ||
|
||
if ($isCadastreProject | ||
and cadastreProfile::checkAccess($profile) | ||
) { | ||
// Check if database has MAJIC content or not | ||
$hasProprietaire = cadastreProfile::checkTableContent('proprietaire', $profile); | ||
$form_name = 'cadastre~search'; | ||
if (!$hasProprietaire) { | ||
$form_name = 'cadastre~search_no_majic'; | ||
} | ||
// Check profile | ||
$profile = 'cadastre'; | ||
if (!empty($parcelleId)) { | ||
$profile = cadastreProfile::getWithLayerId( | ||
$event->repository, | ||
$event->project, | ||
$parcelleId | ||
); | ||
} else { | ||
try { | ||
// try to get the specific search profile to do not rebuild it | ||
jProfiles::get('jdb', $profile, true); | ||
} catch (Exception $e) { | ||
$profile = null; | ||
} | ||
} | ||
|
||
// cadastre dock | ||
// Create search form | ||
$searchForm = jForms::create($form_name); | ||
$searchForm->setData('repository', $event->repository); | ||
$searchForm->setData('project', $event->project); | ||
$searchForm->setData('parcelleLayerId', $parcelleId); | ||
$hasMajic = '0'; | ||
if ($hasProprietaire | ||
&& (jAcl2::check('cadastre.acces.donnees.proprio') || jAcl2::check('cadastre.acces.donnees.proprio.simple'))) { | ||
$hasMajic = '1'; | ||
} | ||
$searchForm->setData('has_majic', $hasMajic); | ||
$assign = array( | ||
'form' => $searchForm, | ||
'has_majic' => $hasMajic, | ||
); | ||
$content = array('cadastre~cadastre_search', $assign); | ||
if ($isCadastreProject | ||
and cadastreProfile::checkAccess($profile) | ||
) { | ||
// Check if database has MAJIC content or not | ||
$hasProprietaire = cadastreProfile::checkTableContent('proprietaire', $profile); | ||
$form_name = 'cadastre~search'; | ||
if (!$hasProprietaire) { | ||
$form_name = 'cadastre~search_no_majic'; | ||
} | ||
|
||
$dock = new lizmapMapDockItem( | ||
'cadastre', | ||
jLocale::get('cadastre~search.dock.title'), | ||
$content, | ||
9, | ||
null, | ||
null | ||
); | ||
$event->add($dock); | ||
// cadastre dock | ||
// Create search form | ||
$searchForm = jForms::create($form_name); | ||
$searchForm->setData('repository', $event->repository); | ||
$searchForm->setData('project', $event->project); | ||
$searchForm->setData('parcelleLayerId', $parcelleId); | ||
$hasMajic = '0'; | ||
if ($hasProprietaire | ||
&& (jAcl2::check('cadastre.acces.donnees.proprio') || jAcl2::check('cadastre.acces.donnees.proprio.simple'))) { | ||
$hasMajic = '1'; | ||
} | ||
} | ||
$searchForm->setData('has_majic', $hasMajic); | ||
$assign = array( | ||
'form' => $searchForm, | ||
'has_majic' => $hasMajic, | ||
); | ||
$content = array('cadastre~cadastre_search', $assign); | ||
|
||
public function onmapMiniDockable($event) | ||
{ | ||
$dock = new lizmapMapDockItem( | ||
'cadastre', | ||
jLocale::get('cadastre~search.dock.title'), | ||
$content, | ||
9, | ||
null, | ||
null | ||
); | ||
$event->add($dock); | ||
} | ||
} | ||
|
||
public function onmapRightDockable($event) | ||
{ | ||
} | ||
public function onmapMiniDockable($event) | ||
{ | ||
} | ||
|
||
public function onmapBottomDockable($event) | ||
{ | ||
} | ||
public function onmapRightDockable($event) | ||
{ | ||
} | ||
|
||
public function onmapBottomDockable($event) | ||
{ | ||
} | ||
} |