-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix upload problems resolves #51 * 🤖 Rector and PHPCS fixes * update test workflow
- Loading branch information
Showing
6 changed files
with
34 additions
and
27 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
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
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,7 +1,7 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright (c) 2011-2020 Mark C. Prins <[email protected]> | ||
* Copyright (c) 2011-2024 Mark C. Prins <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -325,18 +325,18 @@ private function printHTML(array $searchresults, bool $showMedia = true): void | |
*/ | ||
final public function handleMediaUploaded(Event $event): void | ||
{ | ||
// data[0] temporary file name (read from $_FILES) | ||
// data[1] file name of the file being uploaded | ||
// data[2] future directory id of the file being uploaded | ||
// data[3] the mime type of the file being uploaded | ||
// data[4] true if the uploaded file exists already | ||
// data[5] (since 2011-02-06) the PHP function used to move the file to the correct location | ||
//data[0] path/to/new/media.file (normally read from $_FILES, potentially could come from elsewhere) | ||
//data[1] file name of the file being uploaded | ||
//data[2] future directory id of the file being uploaded | ||
//data[3] the mime type of the file being uploaded | ||
//data[4] true if the uploaded file exists already | ||
//data[5] (since 2011-02-06) the PHP function used to move the file to the correct location | ||
|
||
Logger::debug("handleMediaUploaded::event data", $event->data); | ||
|
||
// check the list of mimetypes | ||
// if it's a supported type call appropriate index function | ||
if (substr_compare($event->data [3], 'image/jpeg', 0)) { | ||
if (str_contains($event->data [3], 'image/jpeg')) { | ||
$indexer = plugin_load('helper', 'spatialhelper_index'); | ||
if ($indexer !== null) { | ||
$indexer->indexImage($event->data [2]); | ||
|
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
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,7 +1,7 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright (c) 2011-2023 Mark C. Prins <[email protected]> | ||
* Copyright (c) 2011-2024 Mark C. Prins <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -86,10 +86,10 @@ final public function generateSpatialIndex(): bool | |
} | ||
// media | ||
$media = []; | ||
search($media, $conf ['mediadir'], 'search_media', []); | ||
search($media, $conf['mediadir'], 'search_media', []); | ||
foreach ($media as $medium) { | ||
if ($medium ['isimg']) { | ||
$this->indexImage($medium); | ||
if ($medium['isimg']) { | ||
$this->indexImage($medium['id']); | ||
} | ||
} | ||
return true; | ||
|
@@ -200,33 +200,34 @@ private function saveIndex(): bool | |
/** | ||
* Add an index entry for this file having EXIF / IPTC data. | ||
* | ||
* @param $img | ||
* a Dokuwiki image | ||
* @return bool true when image was succesfully added to the index. | ||
* @param $imgId | ||
* a Dokuwiki image id | ||
* @return bool true when image was successfully added to the index. | ||
* @throws Exception | ||
* @see http://www.php.net/manual/en/function.iptcparse.php | ||
* @see http://php.net/manual/en/function.exif-read-data.php | ||
* | ||
*/ | ||
final public function indexImage(array $img): bool | ||
final public function indexImage(string $imgId): bool | ||
{ | ||
// test for supported files (jpeg only) | ||
if ( | ||
(!str_ends_with($img ['file'], '.jpg')) && | ||
(!str_ends_with($img ['file'], '.jpeg')) | ||
(!str_ends_with(strtolower($imgId), '.jpg')) && | ||
(!str_ends_with(strtolower($imgId), '.jpeg')) | ||
) { | ||
Logger::debug("indexImage:: " . $imgId . " is not a supported image file."); | ||
return false; | ||
} | ||
|
||
$geometry = $this->getCoordsFromExif($img ['id']); | ||
$geometry = $this->getCoordsFromExif($imgId); | ||
if (!$geometry) { | ||
return false; | ||
} | ||
$geohash = $geometry->out('geohash'); | ||
// TODO truncate the geohash to something reasonable, otherwise they are | ||
// useless as an indexing mechanism eg. u1h73weckdrmskdqec3c9 is far too | ||
// precise, limit at ~9 as most GPS are not submeter accurate | ||
return $this->addToIndex($geohash, 'media__' . $img ['id']); | ||
// useless as an indexing mechanism eg. u1h73weckdrmskdqec3c9 is far too | ||
// precise, limit at ~9 as most GPS are not submeter accurate | ||
return $this->addToIndex($geohash, 'media__' . $imgId); | ||
} | ||
|
||
/** | ||
|
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,7 +1,7 @@ | ||
base spatialhelper | ||
author Mark C. Prins | ||
email [email protected] | ||
date 2023-12-22 | ||
date 2024-04-08 | ||
name Spatial Helper plugin for DokuWiki | ||
desc Provides spatial indexing and spatial search facilities. | ||
url https://www.dokuwiki.org/plugin:spatialhelper |