Skip to content

Commit

Permalink
Merge pull request #19 from akrys/master
Browse files Browse the repository at this point in the history
Finale Änderungen v2.0
  • Loading branch information
akrys authored Aug 9, 2020
2 parents 81bba56 + e66e483 commit e020313
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 44 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Namens einzufügen, sofern beim Upload keine Kategorie definiert wurde.
![Screenshot](https://raw.githubusercontent.com/FriendsOfREDAXO/mediapool_exif/master/assets/screenshot.png)


## Beta-Features (Version 1.1)
## Speicherung der Rohdaten

Es werden alle EXIF-Daten in der Spalte ```rex_media.exif``` gespeichert, so dass man leichten Zugriff erhält.
Ab Version 2.0 werden alle EXIF-Daten in der Spalte ```rex_media.exif``` gespeichert, so dass man leichten Zugriff erhält.

Im Prinzip sind die Daten über folgenden Code erreichbar:

Expand Down Expand Up @@ -80,7 +80,7 @@ if(!$vendor) {
}
```

Das hier ist nicht das Standard-Vorgehen, da es u.U. schwierig werden kann, wenn man die Unterscheidung zwischen ```false``` und ```false``` machen muss. In speziellen Fällen kann man es noch mit ```null``` (```\FriendsOfRedaxo\addon\MediapoolExif\Exif::MODE_RETURN_NULL```) statt ```false```(```\FriendsOfRedaxo\addon\MediapoolExif\Exif::MODE_RETURN_FALSE```) zu versuchen.
Das hier ist nicht das Standard-Vorgehen, da es u.U. schwierig werden kann, wenn man die Unterscheidung zwischen ```false``` und ```false``` machen muss. In speziellen Fällen kann man es mit ```null``` (```\FriendsOfRedaxo\addon\MediapoolExif\Exif::MODE_RETURN_NULL```) statt ```false```(```\FriendsOfRedaxo\addon\MediapoolExif\Exif::MODE_RETURN_FALSE```) versuchen.
Am Besten aber, man bleibt einfach bei Exceptions. Es ist und bleibt das Eindeutigste.

### Formatierung
Expand Down Expand Up @@ -203,7 +203,7 @@ select exif,
exif->"$.ExposureTime" exposure,
exif->"$.ISOSpeedRatings" iso
from rex_media;
-- where exif->"$.Make" = 'Apple'
-- where exif->"$.Make" = 'Apple'
```

Äquivalent in MariaDB:
Expand Down
10 changes: 6 additions & 4 deletions boot.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

rex_fragment::addDirectory(realpath(__DIR__));
use FriendsOfRedaxo\addon\MediapoolExif\MediapoolExif;

rex_fragment::addDirectory(realpath(__DIR__));

rex_extension::register('MEDIA_ADDED', ['rex_mediapool_exif', 'processUploadedMedia'], rex_extension::LATE );
rex_extension::register('MEDIA_UPDATED', ['rex_mediapool_exif', 'processUploadedMedia'], rex_extension::LATE );
rex_extension::register('MEDIA_DETAIL_SIDEBAR', ['rex_mediapool_exif', 'mediapoolDetailOutput']);
$class = MediapoolExif::class;
rex_extension::register('MEDIA_ADDED', [$class, 'processUploadedMedia'], rex_extension::LATE);
rex_extension::register('MEDIA_UPDATED', [$class, 'processUploadedMedia'], rex_extension::LATE);
rex_extension::register('MEDIA_DETAIL_SIDEBAR', [$class, 'mediapoolDetailOutput']);
10 changes: 6 additions & 4 deletions lib/Cli/Read.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
namespace FriendsOfRedaxo\addon\MediapoolExif\Cli;

use FriendsOfRedaxo\addon\MediapoolExif\Exif;
use FriendsOfRedaxo\addon\MediapoolExif\MediapoolExif;
use rex_console_command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand Down Expand Up @@ -48,13 +50,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
$updateAll = $input->getOption('all');
$updateSilent = $input->getOption('silent');

$mode = \FriendsOfRedaxo\addon\MediapoolExif\Exif::GETMEDIA_MODE_NULL_ONLY;
$mode = Exif::GETMEDIA_MODE_NULL_ONLY;
if ($updateAll) {
if ($updateSilent || $io->confirm('You are going to update all files. Are you sure?', false)) {
$mode = \FriendsOfRedaxo\addon\MediapoolExif\Exif::GETMEDIA_MODE_ALL;
$mode = Exif::GETMEDIA_MODE_ALL;
}
}
$files = \FriendsOfRedaxo\addon\MediapoolExif\Exif::getMediaToRead($mode);
$files = Exif::getMediaToRead($mode);

$numEntries = count($files);
$io->writeln($numEntries.' entries to read');
Expand All @@ -64,7 +66,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$counter++;
$io->writeln('Process file '.$counter.' of '.$numEntries.': '.$file['filename']);

\rex_mediapool_exif::readExifFromFile($file['filename']);
MediapoolExif::readExifFromFile($file['filename']);
}

$io->success('done');
Expand Down
5 changes: 3 additions & 2 deletions lib/Exception/InvalidFormatExcption.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace FriendsOfRedaxo\addon\MediapoolExif\Exception;

use Exception;
use Throwable;

/**
* Description of InvalidFormatExcption
Expand All @@ -30,9 +31,9 @@ class InvalidFormatExcption
* @param string $format
* @param string $message
* @param int $code
* @param \Throwable $previous
* @param Throwable $previous
*/
public function __construct(string $format, string $message = "", int $code = 0, \Throwable $previous = NULL)
public function __construct(string $format, string $message = "", int $code = 0, Throwable $previous = NULL)
{
$this->format = $format;
if ($message === '') {
Expand Down
9 changes: 6 additions & 3 deletions lib/Exception/NotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
*/
namespace FriendsOfRedaxo\addon\MediapoolExif\Exception;

use Exception;
use Throwable;

/**
* Description of NotFoundException
*
* @author akrys
*/
class NotFoundException
extends \Exception
extends Exception
{
/**
*
Expand All @@ -28,9 +31,9 @@ class NotFoundException
* @param string $index
* @param string $message
* @param int $code
* @param \Throwable $previous
* @param Throwable $previous
*/
public function __construct(string $index, string $message = "", int $code = 0, \Throwable $previous = NULL)
public function __construct(string $index, string $message = "", int $code = 0, Throwable $previous = NULL)
{
$this->index = $index;
parent::__construct($message, $code, $previous);
Expand Down
4 changes: 2 additions & 2 deletions lib/Exif.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
namespace FriendsOfRedaxo\addon\MediapoolExif;

use rex_media;
use FriendsOfRedaxo\addon\MediapoolExif\ExifData;

/**
* Description of Exif
Expand Down Expand Up @@ -45,7 +45,7 @@ public static function get(rex_media $media, $mode = self::MODE_THROW_EXCEPTION)
*/
public static function getMediaToRead($mode = self::GETMEDIA_MODE_NULL_ONLY): array
{
$rexSQL = \rex_sql::factory();
$rexSQL = rex_sql::factory();

switch ($mode) {
case self::GETMEDIA_MODE_ALL:
Expand Down
6 changes: 3 additions & 3 deletions lib/ExifData.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
namespace FriendsOfRedaxo\addon\MediapoolExif;

use FriendsOfRedaxo\addon\MediapoolExif\Exception\NotFoundException;
use FriendsOfRedaxo\addon\MediapoolExif\Exif;
use FriendsOfRedaxo\addon\MediapoolExif\Format\FormatInterface;
use rex_media;

/**
* Description of ExifData
Expand Down Expand Up @@ -106,7 +106,7 @@ public function format(string $type, string $format = null)
{
try {
return FormatInterface::get($this->exif, $type, $format)->format();
} catch (\Exception $e) {
} catch (Exception $e) {
return $this->handleExcption($e);
}
}
Expand All @@ -120,7 +120,7 @@ public function format(string $type, string $format = null)
* @return mixed
* @throws NotFoundException
*/
private function handleExcption(\Exception $exception)
private function handleExcption(Exception $exception)
{
$return = '';

Expand Down
2 changes: 1 addition & 1 deletion lib/Format/Camera.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
*/
namespace FriendsOfRedaxo\addon\MediapoolExif\Format;

use Exception;
use FriendsOfRedaxo\addon\MediapoolExif\Exception\InvalidFormatExcption;
use FriendsOfRedaxo\addon\MediapoolExif\Format\Camera\Aperture;
use FriendsOfRedaxo\addon\MediapoolExif\Format\Camera\Exposure;
use FriendsOfRedaxo\addon\MediapoolExif\Format\Camera\Iso;
use FriendsOfRedaxo\addon\MediapoolExif\Format\Camera\Length;
use FriendsOfRedaxo\addon\MediapoolExif\Format\FormatInterface;

/**
* Description of Camera
Expand Down
1 change: 1 addition & 0 deletions lib/Format/FormatInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace FriendsOfRedaxo\addon\MediapoolExif\Format;

use FriendsOfRedaxo\addon\MediapoolExif\Exception\InvalidFormatExcption;
use FriendsOfRedaxo\addon\MediapoolExif\Format\FormatInterface;

/**
* Description of FormatBase
Expand Down
16 changes: 6 additions & 10 deletions lib/Format/Geo.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<?php

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace FriendsOfRedaxo\addon\MediapoolExif\Format;

/**
* Datei für ...
* Datei für GEO
*
* @version 1.0 / 2020-06-12
* @author akrys
*/
namespace FriendsOfRedaxo\addon\MediapoolExif\Format;

use Exception;

/**
* Description of Geo
Expand All @@ -26,7 +22,7 @@ class Geo
/**
* Formatierung der Daten
* @return array
* @throws \Exception
* @throws Exception
*/
public function format()
{
Expand All @@ -35,7 +31,7 @@ public function format()
!isset($this->data['GPSLatitudeRef']) ||
!isset($this->data['GPSLongitude']) ||
!isset($this->data['GPSLongitudeRef'])) {
throw new \Exception('GPS not found');
throw new Exception('GPS not found');
}

$GPSLatitude = $this->data['GPSLatitude'];
Expand Down
Loading

0 comments on commit e020313

Please sign in to comment.