Skip to content

Commit 03be4df

Browse files
committed
Version 1.0.1, change namespace , Fix vulnerabilities and maintenance issues
1 parent 2c93142 commit 03be4df

69 files changed

Lines changed: 1423 additions & 407 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Changelog
2+
3+
All notable changes to this module will be documented in this file.
4+
5+
## [1.0.1] - 2026-03-20
6+
7+
### Fixed
8+
- **Coding standards:** Replaced all loose comparisons (`==`, `!=`) with strict equivalents (`===`, `!==`) in `IndexController.php`.
9+
- **Coding standards:** Added missing parentheses on `new ViewModel` instantiations.
10+
- **Bug fix:** Fixed potential negative array index in `getAutoColor()` caused by `crc32()` returning negative values on 32-bit systems; added `abs()` wrapper.
11+
- **Security:** Added validation (regex allowlist) for `popup_props` query parameter in `getFeaturePopupContentAction()` to prevent injection via untrusted property terms.
12+
- **Error handling:** Narrowed all `catch (\Throwable)` blocks to `catch (\Exception)` to avoid silently catching fatal errors.
13+
- **Error handling:** Added `$this->logger()->warn()` / `->debug()` calls to all catch blocks — no more silently swallowed exceptions.
14+
15+
### Changed
16+
- **Namespace:** Renamed root namespace from `Mapping` to `MappingExtensions` across all PHP files to avoid conflicts with the official Mapping module.
17+
- **Code quality:** Extracted duplicated geography-to-array conversion into new `buildFeatureArray()` helper method.
18+
- **Code quality:** Extracted duplicated JSON response pattern into new `buildFeaturesJsonResponse()` helper method.
19+
- **Code quality:** Extracted linked-properties parsing into new `parseLinkedProperties()` helper method.
20+
- **Code quality:** Merged duplicate `searchOne('properties')` API calls in `addLegendForItem()` into a single call.
21+
- **Code quality:** Renamed `getFeatureActionforJourneyItems()` to `getFeatureActionForJourneyItems()` for consistent camelCase.
22+
23+
### Added
24+
- Class-level and method-level docblocks on all public and private methods in `IndexController.php`.
25+
26+
## [1.0.0] - Initial release
27+
28+
- Initial release of the Mapping Extensions module.

Module.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
2-
namespace Mapping;
2+
namespace MappingExtensions;
33

44
use Composer\Semver\Comparator;
55
use Doctrine\ORM\Events;
6-
use Mapping\Db\Event\Listener\DetachOrphanMappings;
6+
use MappingExtensions\Db\Event\Listener\DetachOrphanMappings;
77
use Omeka\Api\Exception as ApiException;
88
use Omeka\Api\Request;
9-
use Mapping\Api\Representation\MappingRepresentation;
10-
use Mapping\Entity\MappingFeature;
11-
use Mapping\Form\Element\CopyCoordinates;
12-
use Mapping\Form\Element\UpdateFeatures;
9+
use MappingExtensions\Api\Representation\MappingRepresentation;
10+
use MappingExtensions\Entity\MappingFeature;
11+
use MappingExtensions\Form\Element\CopyCoordinates;
12+
use MappingExtensions\Form\Element\UpdateFeatures;
1313
use Omeka\Module\AbstractModule;
1414
use Omeka\Permissions\Acl;
1515
use Laminas\EventManager\Event;
@@ -79,13 +79,13 @@ public function onBootstrap(MvcEvent $event)
7979
// Set the corresponding visibility rules on Mapping resources.
8080
$em = $this->getServiceLocator()->get('Omeka\EntityManager');
8181
$filter = $em->getFilters()->getFilter('resource_visibility');
82-
$filter->addRelatedEntity('Mapping\Entity\Mapping', 'item_id');
83-
$filter->addRelatedEntity('Mapping\Entity\MappingFeature', 'item_id');
82+
$filter->addRelatedEntity('MappingExtensions\Entity\Mapping', 'item_id');
83+
$filter->addRelatedEntity('MappingExtensions\Entity\MappingFeature', 'item_id');
8484

8585
$acl = $this->getServiceLocator()->get('Omeka\Acl');
8686
$acl->allow(
8787
null,
88-
'Mapping\Controller\Site\Index'
88+
'MappingExtensions\Controller\Site\Index'
8989
);
9090
$acl->allow(
9191
[Acl::ROLE_AUTHOR,
@@ -94,19 +94,19 @@ public function onBootstrap(MvcEvent $event)
9494
Acl::ROLE_REVIEWER,
9595
Acl::ROLE_SITE_ADMIN,
9696
],
97-
['Mapping\Api\Adapter\MappingFeatureAdapter',
98-
'Mapping\Api\Adapter\MappingAdapter',
99-
'Mapping\Entity\MappingFeature',
100-
'Mapping\Entity\Mapping',
97+
['MappingExtensions\Api\Adapter\MappingFeatureAdapter',
98+
'MappingExtensions\Api\Adapter\MappingAdapter',
99+
'MappingExtensions\Entity\MappingFeature',
100+
'MappingExtensions\Entity\Mapping',
101101
]
102102
);
103103

104104
$acl->allow(
105105
null,
106-
['Mapping\Api\Adapter\MappingFeatureAdapter',
107-
'Mapping\Api\Adapter\MappingAdapter',
108-
'Mapping\Entity\MappingFeature',
109-
'Mapping\Entity\Mapping',
106+
['MappingExtensions\Api\Adapter\MappingFeatureAdapter',
107+
'MappingExtensions\Api\Adapter\MappingAdapter',
108+
'MappingExtensions\Entity\MappingFeature',
109+
'MappingExtensions\Entity\Mapping',
110110
],
111111
['show', 'browse', 'read', 'search']
112112
);
@@ -280,7 +280,7 @@ public function attachListeners(SharedEventManagerInterface $sharedEventManager)
280280
);
281281
// Add the mapping fields to advanced search pages.
282282
$sharedEventManager->attach(
283-
'Mapping\Controller\Site\Index',
283+
'MappingExtensions\Controller\Site\Index',
284284
'view.advanced_search',
285285
[$this, 'filterMapBrowseAdvancedSearch']
286286
);
@@ -747,12 +747,12 @@ public function handleApiSearchQuery(Event $event)
747747
$mappingFeatureAlias = $itemAdapter->createAlias();
748748
if ($query['has_features']) {
749749
$qb->innerJoin(
750-
'Mapping\Entity\MappingFeature', $mappingFeatureAlias,
750+
'MappingExtensions\Entity\MappingFeature', $mappingFeatureAlias,
751751
'WITH', "$mappingFeatureAlias.item = omeka_root.id"
752752
);
753753
} else {
754754
$qb->leftJoin(
755-
'Mapping\Entity\MappingFeature', $mappingFeatureAlias,
755+
'MappingExtensions\Entity\MappingFeature', $mappingFeatureAlias,
756756
'WITH', "$mappingFeatureAlias.item = omeka_root.id"
757757
);
758758
$qb->andWhere($qb->expr()->isNull($mappingFeatureAlias));
@@ -862,7 +862,7 @@ public function handleMapping(Event $event)
862862
// Create mapping
863863
$subRequest = new \Omeka\Api\Request('create', 'mappings');
864864
$subRequest->setContent($mappingData);
865-
$mapping = new \Mapping\Entity\Mapping;
865+
$mapping = new \MappingExtensions\Entity\Mapping;
866866
$mapping->setItem($event->getParam('entity'));
867867
$mappingsAdapter->hydrateEntity($subRequest, $mapping, new \Omeka\Stdlib\ErrorStore);
868868
$mappingsAdapter->getEntityManager()->persist($mapping);
@@ -890,7 +890,7 @@ public function handleFeatures(Event $event)
890890

891891
$existingFeatures = [];
892892
if ($item->getId()) {
893-
$dql = 'SELECT mf FROM Mapping\Entity\MappingFeature mf INDEX BY mf.id WHERE mf.item = ?1';
893+
$dql = 'SELECT mf FROM MappingExtensions\Entity\MappingFeature mf INDEX BY mf.id WHERE mf.item = ?1';
894894
$query = $entityManager->createQuery($dql)->setParameter(1, $item->getId());
895895
$existingFeatures = $query->getResult();
896896
}
@@ -911,7 +911,7 @@ public function handleFeatures(Event $event)
911911
} else {
912912
$subRequest = new \Omeka\Api\Request('create', 'mapping_features');
913913
$subRequest->setContent($featureData);
914-
$feature = new \Mapping\Entity\MappingFeature;
914+
$feature = new \MappingExtensions\Entity\MappingFeature;
915915
$feature->setItem($item);
916916
$featuresAdapter->hydrateEntity($subRequest, $feature, new \Omeka\Stdlib\ErrorStore);
917917
$entityManager->persist($feature);
@@ -1000,7 +1000,7 @@ public function deleteFeatures(Event $event)
10001000
$services = $this->getServiceLocator();
10011001
$entityManager = $services->get('Omeka\EntityManager');
10021002

1003-
$dql = 'DELETE FROM Mapping\Entity\MappingFeature m WHERE m.item = :item_id';
1003+
$dql = 'DELETE FROM MappingExtensions\Entity\MappingFeature m WHERE m.item = :item_id';
10041004
$entityManager->createQuery($dql)
10051005
->setParameter('item_id', $item->getId())
10061006
->execute();
@@ -1042,7 +1042,7 @@ public function copyCoordinates(Event $event)
10421042
FROM Omeka\Entity\Media m
10431043
WHERE m.item = :item_id';
10441044
$dqlFeature = "SELECT f
1045-
FROM Mapping\Entity\MappingFeature f
1045+
FROM MappingExtensions\Entity\MappingFeature f
10461046
WHERE f.item = :item_id
10471047
AND ST_GeometryType(f.geography) = 'POINT'
10481048
AND ST_Intersects(ST_Buffer(ST_GeomFromText(:buffer_center_point), 0.00001), f.geography) = 1";
@@ -1199,7 +1199,7 @@ public function updateFeatures(Event $event)
11991199
$entityManager = $services->get('Omeka\EntityManager');
12001200

12011201
$dql = 'SELECT m
1202-
FROM Mapping\Entity\MappingFeature m
1202+
FROM MappingExtensions\Entity\MappingFeature m
12031203
WHERE m.item = :item_id';
12041204
$features = $entityManager->createQuery($dql)
12051205
->setParameter('item_id', $item->getId())

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ please ignore it. This is a known issue and will be resolved in future releases.
2424
- Download a ZIP package from one of the
2525
[releases](https://github.com/Systemik-Solutions/OmekaS-MappingExtensions/releases).
2626
- Extract the ZIP into the modules directory of your Omeka S installation.
27+
- Rename the folder to 'MappingExtensions'.
2728
- In the Omeka S admin panel, go to Modules and click Install next to “Mapping Extensions”.
2829

2930
For more details, refer to the [Omeka S module installation guide](https://omeka.org/s/docs/user-manual/modules/).

asset/js/MappingModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const MappingModule = {
4343

4444
let rowsHtml = "";
4545
clusterMarkers.forEach((marker, idx) => {
46-
const title = marker.feature.geometry.properties.title || "No title";
46+
const title = marker.feature.geometry.properties ? marker.feature.geometry.properties.title : "No title";
4747
rowsHtml += `
4848
<tr>
4949
<td><a href="#" class="cluster-jump" data-marker-index="${idx}">${title}</a></td>

config/module.config.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Mapping;
2+
namespace MappingExtensions;
33

44
use Osii\Service\ResourceMapper\ResourceMapperFactory;
55

@@ -22,7 +22,7 @@
2222
],
2323
'functions' => [
2424
'numeric' => [
25-
'ST_Buffer' => 'Mapping\Spatial\ORM\Query\AST\Functions\StBuffer',
25+
'ST_Buffer' => 'MappingExtensions\Spatial\ORM\Query\AST\Functions\StBuffer',
2626
'ST_Intersects' => 'LongitudeOne\Spatial\ORM\Query\AST\Functions\Standard\StIntersects',
2727
'ST_GeomFromText' => 'LongitudeOne\Spatial\ORM\Query\AST\Functions\Standard\StGeomFromText',
2828
'ST_GeometryType' => 'LongitudeOne\Spatial\ORM\Query\AST\Functions\Standard\StGeometryType',
@@ -51,9 +51,9 @@
5151
],
5252
'form_elements' => [
5353
'factories' => [
54-
'Mapping\Form\Fieldset\TimelineFieldset' => Service\Form\Fieldset\TimelineFieldsetFactory::class,
55-
'Mapping\Form\Element\CopyCoordinates' => Service\Form\Element\CopyCoordinatesFactory::class,
56-
'Mapping\Form\Element\UpdateFeatures' => Service\Form\Element\UpdateFeaturesFactory::class,
54+
'MappingExtensions\Form\Fieldset\TimelineFieldset' => Service\Form\Fieldset\TimelineFieldsetFactory::class,
55+
'MappingExtensions\Form\Element\CopyCoordinates' => Service\Form\Element\CopyCoordinatesFactory::class,
56+
'MappingExtensions\Form\Element\UpdateFeatures' => Service\Form\Element\UpdateFeaturesFactory::class,
5757
],
5858
],
5959
'csv_import' => [
@@ -84,8 +84,8 @@
8484
],
8585
'controllers' => [
8686
'invokables' => [
87-
'Mapping\Controller\Admin\Index' => Controller\Admin\IndexController::class,
88-
'Mapping\Controller\Site\Index' => Controller\Site\IndexController::class,
87+
'MappingExtensions\Controller\Admin\Index' => Controller\Admin\IndexController::class,
88+
'MappingExtensions\Controller\Site\Index' => Controller\Site\IndexController::class,
8989
],
9090
],
9191
'collecting_media_types' => [
@@ -102,7 +102,7 @@
102102
'options' => [
103103
'route' => '/mapping/:controller[/:action]',
104104
'defaults' => [
105-
'__NAMESPACE__' => 'Mapping\Controller\Admin',
105+
'__NAMESPACE__' => 'MappingExtensions\Controller\Admin',
106106
'controller' => 'index',
107107
'action' => 'index',
108108
],
@@ -121,7 +121,7 @@
121121
'options' => [
122122
'route' => '/mapping/:controller[/:action]',
123123
'defaults' => [
124-
'__NAMESPACE__' => 'Mapping\Controller\Site',
124+
'__NAMESPACE__' => 'MappingExtensions\Controller\Site',
125125
'controller' => 'index',
126126
'action' => 'index',
127127
],
@@ -157,12 +157,12 @@
157157
],
158158
'static_site_export' => [
159159
'vendor_packages' => [
160-
'omeka-mapping' => sprintf('%s/modules/Mapping/src/StaticSiteExport/omeka-mapping', OMEKA_PATH),
161-
'leaflet' => sprintf('%s/modules/Mapping/src/StaticSiteExport/leaflet', OMEKA_PATH),
162-
'leaflet.markercluster' => sprintf('%s/modules/Mapping/src/StaticSiteExport/leaflet.markercluster', OMEKA_PATH),
160+
'omeka-mapping' => sprintf('%s/modules/MappingExtensions/src/StaticSiteExport/omeka-mapping', OMEKA_PATH),
161+
'leaflet' => sprintf('%s/modules/MappingExtensions/src/StaticSiteExport/leaflet', OMEKA_PATH),
162+
'leaflet.markercluster' => sprintf('%s/modules/MappingExtensions/src/StaticSiteExport/leaflet.markercluster', OMEKA_PATH),
163163
],
164164
'shortcodes' => [
165-
'omeka-mapping-features' => sprintf('%s/modules/Mapping/src/StaticSiteExport/omeka-mapping-features.html', OMEKA_PATH),
165+
'omeka-mapping-features' => sprintf('%s/modules/MappingExtensions/src/StaticSiteExport/omeka-mapping-features.html', OMEKA_PATH),
166166
],
167167
'block_layouts' => [
168168
'invokables' => [

config/module.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[info]
2-
version = "1.0.0"
2+
version = "1.0.1"
33
omeka_version_constraint = "^4.1.1"
44
name = "Mapping Extensions"
55
description = "A module that extends the functionality of the official Mapping module."

data/doctrine-proxies/__CG__MappingEntityMapping.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
namespace DoctrineProxies\__CG__\Mapping\Entity;
3+
namespace DoctrineProxies\__CG__\MappingExtensions\Entity;
44

55

66
/**
77
* DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
88
*/
9-
class Mapping extends \Mapping\Entity\Mapping implements \Doctrine\ORM\Proxy\Proxy
9+
class Mapping extends \MappingExtensions\Entity\Mapping implements \Doctrine\ORM\Proxy\Proxy
1010
{
1111
/**
1212
* @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with

data/doctrine-proxies/__CG__MappingEntityMappingFeature.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
namespace DoctrineProxies\__CG__\Mapping\Entity;
3+
namespace DoctrineProxies\__CG__\MappingExtensions\Entity;
44

55

66
/**
77
* DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
88
*/
9-
class MappingFeature extends \Mapping\Entity\MappingFeature implements \Doctrine\ORM\Proxy\Proxy
9+
class MappingFeature extends \MappingExtensions\Entity\MappingFeature implements \Doctrine\ORM\Proxy\Proxy
1010
{
1111
/**
1212
* @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with

data/doctrine-proxies/__CG__MappingEntityMappingMarker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
namespace DoctrineProxies\__CG__\Mapping\Entity;
3+
namespace DoctrineProxies\__CG__\MappingExtensions\Entity;
44

55

66
/**
77
* DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
88
*/
9-
class MappingMarker extends \Mapping\Entity\MappingMarker implements \Doctrine\ORM\Proxy\Proxy
9+
class MappingMarker extends \MappingExtensions\Entity\MappingMarker implements \Doctrine\ORM\Proxy\Proxy
1010
{
1111
/**
1212
* @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with

src/Api/Adapter/MappingAdapter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Mapping\Api\Adapter;
2+
namespace MappingExtensions\Api\Adapter;
33

44
use Doctrine\ORM\QueryBuilder;
55
use Omeka\Api\Adapter\AbstractEntityAdapter;
@@ -16,12 +16,12 @@ public function getResourceName()
1616

1717
public function getRepresentationClass()
1818
{
19-
return 'Mapping\Api\Representation\MappingRepresentation';
19+
return 'MappingExtensions\Api\Representation\MappingRepresentation';
2020
}
2121

2222
public function getEntityClass()
2323
{
24-
return 'Mapping\Entity\Mapping';
24+
return 'MappingExtensions\Entity\Mapping';
2525
}
2626

2727
public function hydrate(Request $request, EntityInterface $entity,

0 commit comments

Comments
 (0)