Skip to content

Commit

Permalink
Merge branch 'release/1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
abrain committed Jun 29, 2018
2 parents 612e6de + 0125496 commit 3a4663a
Show file tree
Hide file tree
Showing 84 changed files with 7,963 additions and 3,015 deletions.
25 changes: 14 additions & 11 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
engines:
version: "2"
plugins:
phpcodesniffer:
enabled: true
config:
file_extensions: "php"
standard: "PSR1,PSR2"
phpmd:
enabled: true
config:
standard: "PSR1,PSR2"
file_extensions:
- php
rulesets: "phpmd.xml"
csslint:
enabled: true
eslint:
enabled: true
csslint:
duplication:
enabled: true
fixme:
enabled: true
ratings:
paths:
- src/**/*.php
- src/**/*.js
- src/**/*.css
- tests/**/*.php
exclude_paths:
- src/font-awesome/**/*
exclude_patterns:
- src/font-awesome/
- vendor/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ build
setupLocalTest.sh
vendor
composer.lock
.DS_Store
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
- WP_VERSION=4.6.11 WP_MULTISITE=0
- WP_VERSION=4.7.10 WP_MULTISITE=0
- WP_VERSION=4.8.6 WP_MULTISITE=0
- WP_VERSION=4.9.5 WP_MULTISITE=0
- WP_VERSION=4.9.6 WP_MULTISITE=0
- WP_VERSION=nightly WP_MULTISITE=0

matrix:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Einsatzverwaltung
## Plugin zur Verwaltung von Feuerwehreinsätzen

[![Build Status](https://travis-ci.org/abrain/einsatzverwaltung.svg)](https://travis-ci.org/abrain/einsatzverwaltung) [![Code Climate](https://codeclimate.com/github/abrain/einsatzverwaltung/badges/gpa.svg)](https://codeclimate.com/github/abrain/einsatzverwaltung) [![Test Coverage](https://codeclimate.com/github/abrain/einsatzverwaltung/badges/coverage.svg)](https://codeclimate.com/github/abrain/einsatzverwaltung/coverage)
[![Build Status](https://travis-ci.org/abrain/einsatzverwaltung.svg)](https://travis-ci.org/abrain/einsatzverwaltung) [![Maintainability](https://api.codeclimate.com/v1/badges/e977859ca4c209053b79/maintainability)](https://codeclimate.com/github/abrain/einsatzverwaltung/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/e977859ca4c209053b79/test_coverage)](https://codeclimate.com/github/abrain/einsatzverwaltung/test_coverage)

Dieses Plugin fügt WordPress eine neue Beitragsart "Einsatzbericht" hinzu. Diese Einsatzberichte werden wie gewöhnliche WordPress-Beiträge erstellt, es können aber zusätzliche Informationen wie Alarmzeit, Art des Einsatzes, eingesetzte Fahrzeuge und vieles mehr angegeben werden. Zudem stellt das Plugin verschiedene Möglichkeiten zur Darstellung der Einsatzberichte zur Verfügung.

Expand All @@ -23,7 +23,7 @@ Der PHP-Code wird gemäß dem Coding Style Guide [PSR-2](http://www.php

### Mindestvoraussetzungen
* PHP: 5.3.0
* WordPress: 4.4
* WordPress: 4.6

Auch wenn PHP 5.3 vorausgesetzt und derzeit noch als Minimum erhalten wird, werden die automatisierten Tests nur mit den [aktuellen PHP-Versionen](https://secure.php.net/supported-versions.php) durchgeführt.

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"require-dev": {
"codeclimate/php-test-reporter": "dev-master",
"phpunit/phpunit": "5.7.*"
"phpunit/phpunit": "5.7.*",
"bartlett/php-compatinfo": "^5.0"
}
}
56 changes: 56 additions & 0 deletions src/CustomFields/ColorPicker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
namespace abrain\Einsatzverwaltung\CustomFields;

/**
* Represents an additional color picker of a taxonomy
* @package abrain\Einsatzverwaltung\CustomFields
*/
class ColorPicker extends CustomField
{
/**
* @inheritDoc
*/
public function __construct($key, $label, $description, $defaultValue = '')
{
parent::__construct($key, $label, $description, $defaultValue);
}

/**
* @inheritdoc
*/
public function getAddTermInput()
{
return sprintf(
'<input id="tag-%1$s" type="text" value="" name="%1$s" class="einsatzverwaltung-color-picker" />',
esc_attr($this->key)
);
}

/**
* @inheritdoc
*/
public function getEditTermInput($tag)
{
return sprintf(
'<input name="%1$s" id="%1$s" type="text" value="%2$s" class="einsatzverwaltung-color-picker" />',
esc_attr($this->key),
esc_attr($this->getValue($tag->term_id))
);
}

/**
* @inheritdoc
*/
public function getColumnContent($termId)
{
$value = $this->getValue($termId);
if (empty($value)) {
return '';
}

return sprintf(
'<div style="width: 20px; height: 20px; border: 1px solid black; background-color: %s">&nbsp;</div>',
esc_attr($value)
);
}
}
85 changes: 85 additions & 0 deletions src/CustomFields/CustomField.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
namespace abrain\Einsatzverwaltung\CustomFields;

/**
* Base class for additional fields of taxonomies
* @package abrain\Einsatzverwaltung\CustomFields
*/
abstract class CustomField
{
public $key;
public $label;
public $description;
public $defaultValue;

/**
* CustomField constructor.
* @param string $key
* @param string $label
* @param string $description
* @param mixed $defaultValue
*/
public function __construct($key, $label, $description, $defaultValue = false)
{
$this->key = $key;
$this->label = $label;
$this->description = $description;
$this->defaultValue = $defaultValue;
}

/**
* @return string The markup for the form field shown when adding a new term.
*/
public function getAddTermMarkup()
{
return sprintf(
'<div class="form-field"><label for="tag-%1$s">%2$s</label>%4$s<p>%3$s</p></div>',
esc_attr($this->key),
esc_html($this->label),
esc_html($this->description),
$this->getAddTermInput()
);
}

/**
* @param object $tag Current taxonomy term object.
* @return string The markup for the form field shown when editing an existing term.
*/
public function getEditTermMarkup($tag)
{
return sprintf(
'<tr class="form-field"><th scope="row"><label for="%1$s">%2$s</label></th><td>%4$s<p class="description">%3$s</p></td></tr>',
esc_attr($this->key),
esc_html($this->label),
esc_html($this->description),
$this->getEditTermInput($tag)
);
}

/**
* @param int $termId
* @return mixed
*/
public function getValue($termId)
{
$termMeta = get_term_meta($termId, $this->key, true);
return (false === $termMeta ? $this->defaultValue : $termMeta);
}

/**
* @return string The markup for the input shown when adding a new term.
*/
abstract public function getAddTermInput();

/**
* @param int $termId
* @return string
*/
abstract public function getColumnContent($termId);

/**
* @param object $tag Current taxonomy term object.
* @return string The markup for the input shown when editing an existing term.
*/
abstract public function getEditTermInput($tag);
}
49 changes: 49 additions & 0 deletions src/CustomFields/NumberInput.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
namespace abrain\Einsatzverwaltung\CustomFields;

/**
* Represents an additional number input of a taxonomy
* @package abrain\Einsatzverwaltung\CustomFields
*/
class NumberInput extends CustomField
{
/**
* @inheritDoc
*/
public function __construct($key, $label, $description, $defaultValue = 0)
{
parent::__construct($key, $label, $description, $defaultValue);
}

/**
* @inheritdoc
*/
public function getAddTermInput()
{
return sprintf(
'<input id="tag-%1$s" type="number" min="0" value="%2$d" name="%1$s">',
esc_attr($this->key),
esc_attr($this->defaultValue)
);
}

/**
* @inheritdoc
*/
public function getEditTermInput($tag)
{
return sprintf(
'<input id="tag-%1$s" type="number" min="0" value="%2$d" name="%1$s">',
esc_attr($this->key),
esc_attr($this->getValue($tag->term_id))
);
}

/**
* @inheritdoc
*/
public function getColumnContent($termId)
{
return esc_html($this->getValue($termId));
}
}
Loading

0 comments on commit 3a4663a

Please sign in to comment.