Skip to content

Commit

Permalink
Merge branch 'hotfix/1.3.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
abrain committed Nov 15, 2017
2 parents 6e3a0aa + 212e7fa commit 7b1df93
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 59 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ php:
- '7.1'

env:
- WP_VERSION=4.4.10 WP_MULTISITE=0
- WP_VERSION=4.5.9 WP_MULTISITE=0
- WP_VERSION=4.6.6 WP_MULTISITE=0
- WP_VERSION=4.7.5 WP_MULTISITE=0
- WP_VERSION=4.8.1 WP_MULTISITE=0
- WP_VERSION=4.4.12 WP_MULTISITE=0
- WP_VERSION=4.5.11 WP_MULTISITE=0
- WP_VERSION=4.6.8 WP_MULTISITE=0
- WP_VERSION=4.7.7 WP_MULTISITE=0
- WP_VERSION=4.8.3 WP_MULTISITE=0
- WP_VERSION=nightly WP_MULTISITE=0

matrix:
Expand Down
26 changes: 19 additions & 7 deletions src/Frontend/AnnotationIconBar.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
namespace abrain\Einsatzverwaltung\Frontend;

use abrain\Einsatzverwaltung\Core;
use abrain\Einsatzverwaltung\Model\IncidentReport;
use abrain\Einsatzverwaltung\Model\ReportAnnotation;
use abrain\Einsatzverwaltung\ReportAnnotationRepository;
Expand All @@ -16,18 +15,31 @@ class AnnotationIconBar
const DEFAULT_COLOR_OFF = '#bbb';

/**
* @var Core
* Hält die einzige Instanz dieser Klasse (Singleton)
*
* @var AnnotationIconBar
*/
private $core;
private static $instance;

/**
* AnnotationIconBar constructor.
*/
private function __construct()
{
//
}

/**
* Gibt die global einzigartige Instanz dieser Klasse zurück
*
* @param Core $core
* @return AnnotationIconBar
*/
public function __construct(Core $core)
public static function getInstance()
{
$this->core = $core;
if (null === self::$instance) {
self::$instance = new AnnotationIconBar();
}
return self::$instance;
}

/**
Expand All @@ -42,7 +54,7 @@ public function __construct(Core $core)
*/
public function render($report, $annotationIds = array())
{
$annotationRepository = $this->core->getAnnotationRepository();
$annotationRepository = ReportAnnotationRepository::getInstance();
$string = '';
$annotations = array();

Expand Down
2 changes: 1 addition & 1 deletion src/Frontend/ReportList.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private function constructList($reports, $args)

if (in_array('annotationImages', $this->columns) || in_array('annotationSpecial', $this->columns)) {
require_once dirname(__FILE__) . '/AnnotationIconBar.php';
$this->annotationIconBar = new AnnotationIconBar($this->core);
$this->annotationIconBar = AnnotationIconBar::getInstance();
}

// Berichte abarbeiten
Expand Down
23 changes: 22 additions & 1 deletion src/ReportAnnotationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,37 @@
*/
class ReportAnnotationRepository
{
/**
* Hält die einzige Instanz dieser Klasse (Singleton)
*
* @var ReportAnnotationRepository
*/
private static $instance;

private $annotations;

/**
* ReportAnnotationRepository constructor.
*/
public function __construct()
private function __construct()
{
$this->annotations = array();
}

/**
* Gibt die global einzigartige Instanz dieser Klasse zurück
*
* @return ReportAnnotationRepository
*/
public static function getInstance()
{
if (null === self::$instance) {
self::$instance = new ReportAnnotationRepository();
}

return self::$instance;
}

/**
* @param ReportAnnotation $annotation
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Util/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct($options, $utilities, $core)
require_once dirname(__FILE__) . '/../Frontend/AnnotationIconBar.php';
$this->options = $options;
$this->utilities = $utilities;
$this->annotationIconBar = new AnnotationIconBar($core);
$this->annotationIconBar = AnnotationIconBar::getInstance();
}


Expand Down
4 changes: 1 addition & 3 deletions src/Widgets/RecentIncidents.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
namespace abrain\Einsatzverwaltung\Widgets;

use abrain\Einsatzverwaltung\Core;
use abrain\Einsatzverwaltung\Frontend\AnnotationIconBar;
use abrain\Einsatzverwaltung\Model\IncidentReport;
use abrain\Einsatzverwaltung\Options;
Expand Down Expand Up @@ -99,8 +98,7 @@ public function widget($args, $instance)
$letzteEinsaetze .= '<li class="einsatzbericht">';

if (true === $showAnnotations) {
$core = Core::getInstance();
$annotationIconBar = new AnnotationIconBar($core);
$annotationIconBar = AnnotationIconBar::getInstance();
$letzteEinsaetze .= '<div class="annotation-icon-bar">' . $annotationIconBar->render($report) . '</div>';
}

Expand Down
2 changes: 1 addition & 1 deletion src/einsatzverwaltung-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public function filterColumnContentEinsatz($column, $postId)
case 'einsatzverwaltung_annotations':
if (empty($this->annotationIconBar)) {
require_once dirname(__FILE__) . '/Frontend/AnnotationIconBar.php';
$this->annotationIconBar = new AnnotationIconBar($this->core);
$this->annotationIconBar = AnnotationIconBar::getInstance();
}
echo $this->annotationIconBar->render($report);
break;
Expand Down
23 changes: 5 additions & 18 deletions src/einsatzverwaltung-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
class Core
{
const VERSION = '1.3.2';
const VERSION = '1.3.3';
const DB_VERSION = 20;

/**
Expand Down Expand Up @@ -241,11 +241,6 @@ class Core
)
);

/**
* @var ReportAnnotationRepository
*/
private $annotationRepository;

/**
* @var Admin
*/
Expand Down Expand Up @@ -394,24 +389,24 @@ private function registerTypes()
register_taxonomy('alarmierungsart', 'einsatz', $this->argsAlarmierungsart);

// Vermerke registrieren
$this->annotationRepository = new ReportAnnotationRepository();
$this->annotationRepository->addAnnotation(new ReportAnnotation(
$annotationRepository = ReportAnnotationRepository::getInstance();
$annotationRepository->addAnnotation(new ReportAnnotation(
'images',
'Bilder im Bericht',
'einsatz_hasimages',
'camera',
'Einsatzbericht enthält Bilder',
'Einsatzbericht enthält keine Bilder'
));
$this->annotationRepository->addAnnotation(new ReportAnnotation(
$annotationRepository->addAnnotation(new ReportAnnotation(
'special',
'Besonderer Einsatz',
'einsatz_special',
'star',
'Besonderer Einsatz',
'Kein besonderer Einsatz'
));
$this->annotationRepository->addAnnotation(new ReportAnnotation(
$annotationRepository->addAnnotation(new ReportAnnotation(
'falseAlarm',
'Fehlalarm',
'einsatz_fehlalarm',
Expand Down Expand Up @@ -584,14 +579,6 @@ public function getUpdater()
return new Update($this, $this->options, $this->utilities, $this->data);
}

/**
* @return ReportAnnotationRepository
*/
public function getAnnotationRepository()
{
return $this->annotationRepository;
}

/**
* @return Admin
*/
Expand Down
10 changes: 7 additions & 3 deletions src/einsatzverwaltung-utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,17 @@ public function getDurationString($minutes, $abbreviated = false)
}

if ($minutes < 60) {
$dauerstring = $minutes . ' ' . ($abbreviated ? 'min' : _n('Minute', 'Minuten', $minutes));
$dauerstring = sprintf(
'%d %s',
$minutes,
($abbreviated ? 'min' : _n('minute', 'minutes', $minutes, 'einsatzverwaltung'))
);
} else {
$hours = intval($minutes / 60);
$remainingMinutes = $minutes % 60;
$dauerstring = $hours . ' ' . ($abbreviated ? 'h' : _n('Stunde', 'Stunden', $hours));
$dauerstring = $hours . ' ' . ($abbreviated ? 'h' : _n('hour', 'hours', $hours, 'einsatzverwaltung'));
if ($remainingMinutes > 0) {
$unit = $abbreviated ? 'min' : _n('Minute', 'Minuten', $remainingMinutes);
$unit = $abbreviated ? 'min' : _n('minute', 'minutes', $remainingMinutes, 'einsatzverwaltung');
$dauerstring .= sprintf(' %d %s', $remainingMinutes, $unit);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/einsatzverwaltung.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Einsatzverwaltung
Plugin URI: https://einsatzverwaltung.abrain.de
Description: Verwaltung und Darstellung von Einsatzberichten der Feuerwehr und anderer Hilfsorganisationen
Version: 1.3.2
Version: 1.3.3
Author: Andreas Brain
Author URI: https://www.abrain.de
License: GPLv2
Expand Down
9 changes: 7 additions & 2 deletions src/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ Contributors: abrain
Donate link: https://einsatzverwaltung.abrain.de/unterstuetzen/
Tags: Feuerwehr, Hilfsorganisation, Öffentlichkeitsarbeit
Requires at least: 4.4.0
Tested up to: 4.8
Stable tag: 1.3.2
Tested up to: 4.9
Requires PHP: 5.3
Stable tag: 1.3.3
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -71,6 +72,10 @@ Nein, mehr gibt es [hier](https://einsatzverwaltung.abrain.de/faq/).

== Changelog ==

= 1.3.3 =
* Kompatibilit&auml;tsproblem mit "Page Builder by SiteOrigin" behoben
* Getestet mit WordPress 4.9

= 1.3.2 =
* Widgets: Die Symbole f&uuml;r die Vermerke k&ouml;nnen nun angezeigt werden
* Die Farbe f&uuml;r inaktive Vermerke kann nun eingestellt werden
Expand Down
22 changes: 6 additions & 16 deletions tests/ReportAnnotationRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,13 @@

class ReportAnnotationRepositoryTest extends \WP_UnitTestCase
{
/**
* @var ReportAnnotationRepository
*/
private $repository;

function setUp()
{
parent::setUp();
$this->repository = new ReportAnnotationRepository();
}

public function testCreateReportAnnotation()
{
self::assertCount(0, $this->repository->getAnnotations());
$this->repository->addAnnotation(new ReportAnnotation('dings', 'Dings', '', 'camera', 'aktiv', 'inaktiv'));
self::assertCount(1, $this->repository->getAnnotations());
self::assertArrayHasKey('dings', $this->repository->getAnnotations());
self::assertContains('dings', $this->repository->getAnnotationIdentifiers());
$repository = ReportAnnotationRepository::getInstance();
self::assertCount(3, $repository->getAnnotations());
$repository->addAnnotation(new ReportAnnotation('dings', 'Dings', '', 'camera', 'aktiv', 'inaktiv'));
self::assertCount(4, $repository->getAnnotations());
self::assertArrayHasKey('dings', $repository->getAnnotations());
self::assertContains('dings', $repository->getAnnotationIdentifiers());
}
}

0 comments on commit 7b1df93

Please sign in to comment.