From 05ea58cd23c046b5e2d32adcab73fd31d596da02 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Briese Date: Mon, 24 Oct 2016 00:16:21 +0200 Subject: [PATCH 1/7] =?UTF-8?q?Einsatzorte=20k=C3=B6nnen=20mittels=20Googl?= =?UTF-8?q?e=20Maps=20API=20dargestellt=20werden.=20In=20den=20Einstellung?= =?UTF-8?q?en=20kann=20dies=20(de)aktiviert=20werden.=20Zus=C3=A4tzliches?= =?UTF-8?q?=20Feld=20mit=20Koordinate,=20welche=20via=20Button=20bestimmt?= =?UTF-8?q?=20wird.=20Im=20Admin=20kann=20der=20Marker=20verschoben=20werd?= =?UTF-8?q?en.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Model/IncidentReport.php | 13 ++++ src/einsatzverwaltung-admin.php | 97 +++++++++++++++++++++++++++++- src/einsatzverwaltung-core.php | 22 ++++++- src/einsatzverwaltung-data.php | 6 +- src/einsatzverwaltung-frontend.php | 53 +++++++++++++++- src/einsatzverwaltung-options.php | 30 +++++++++ src/einsatzverwaltung-settings.php | 44 ++++++++++++++ 7 files changed, 256 insertions(+), 9 deletions(-) diff --git a/src/Model/IncidentReport.php b/src/Model/IncidentReport.php index f76d27cc..60ce4701 100644 --- a/src/Model/IncidentReport.php +++ b/src/Model/IncidentReport.php @@ -75,6 +75,9 @@ public static function getMetaFields() 'einsatz_einsatzort' => array( 'label' => 'Einsatzort' ), + 'einsatz_location' => array( + 'label' => 'Goolemaps Position' + ), 'einsatz_einsatzleiter' => array( 'label' => 'Einsatzleiter' ), @@ -194,6 +197,16 @@ public function getLocation() return $this->getPostMeta('einsatz_einsatzort'); } + /** + * Gibt den eingetragenen Einsatzort als googlemaps koordinate zurück + * + * @return string + */ + public function getGmapsLocation() + { + return $this->getPostMeta('einsatz_location'); + } + /** * Gibt die Einsatznummer zurück * diff --git a/src/einsatzverwaltung-admin.php b/src/einsatzverwaltung-admin.php index b1012ffa..59592ef6 100644 --- a/src/einsatzverwaltung-admin.php +++ b/src/einsatzverwaltung-admin.php @@ -14,6 +14,11 @@ class Admin */ private $core; + /** + * @var Options + */ + private $options; + /** * @var Utilities */ @@ -23,11 +28,13 @@ class Admin * Constructor * * @param Core $core + * @param Options $options * @param Utilities $utilities */ - public function __construct($core, $utilities) + public function __construct($core, $options, $utilities) { $this->core = $core; + $this->options = $options; $this->utilities = $utilities; $this->addHooks(); } @@ -124,6 +131,8 @@ public function enqueueEditScripts($hook) array(), Core::VERSION ); + + wp_enqueue_script( 'einsatzvw_GoogleMap' ); } /** @@ -167,10 +176,11 @@ public function displayMetaBoxEinsatzdetails($post) $einsatzort = $report->getLocation(); $einsatzleiter = $report->getIncidentCommander(); $mannschaftsstaerke = $report->getWorkforce(); + $gmapslocation = $report->getGmapsLocation(); $names = Data::getEinsatzleiterNamen(); echo ''; - echo ''; + echo '
'; $this->echoInputText( 'Einsatznummer', @@ -202,6 +212,11 @@ public function displayMetaBoxEinsatzdetails($post) esc_attr($einsatzort) ); + if($this->options->isGMapActivate()) + { + $this->echoGMap($gmapslocation); + } + $this->echoInputText( 'Einsatzleiter', 'einsatzverwaltung_einsatzleiter', @@ -236,6 +251,84 @@ private function echoInputText($label, $name, $value, $placeholder = '', $size = echo '/>'; } + /** + * Generiert eine Googlemaps Karte zur bestimmung der Koordinate + */ + private function echoGMap($location) + { + if($location != "") + { + $latLon = explode(",",$location); + } + else + { + $latLon = array("",""); + } + $DeflatLon = explode(",",$this->options->getGMapDefaultPos()); + + echo ''; + echo ''; + echo ''; + } + /** * Gibt eine Checkbox für die Metabox aus * diff --git a/src/einsatzverwaltung-core.php b/src/einsatzverwaltung-core.php index d75fdca6..8bc99d0f 100644 --- a/src/einsatzverwaltung-core.php +++ b/src/einsatzverwaltung-core.php @@ -234,12 +234,12 @@ class Core * @var Data */ private $data; - + /** * @var Options */ private $options; - + /** * @var Utilities */ @@ -261,7 +261,7 @@ public function __construct() $this->options = new Options($this->utilities); $this->utilities->setDependencies($this->options); - new Admin($this, $this->utilities); + new Admin($this, $this->options, $this->utilities); $this->data = new Data($this, $this->utilities, $this->options); new Frontend($this, $this->options, $this->utilities); new Settings($this, $this->options, $this->utilities, $this->data); @@ -323,6 +323,7 @@ public function onDeactivation() public function onInit() { $this->registerTypes(); + $this->registerScripts(); $this->addRewriteRules(); if ($this->options->isFlushRewriteRules()) { flush_rewrite_rules(); @@ -354,6 +355,21 @@ private function registerTypes() register_taxonomy('alarmierungsart', 'einsatz', $this->argsAlarmierungsart); } + /** + * Registriert externe Scripts + */ + private function registerScripts() + { + if( $this->options->isGMapActivate() ) { + /* Google Maps */ + $protocal = is_ssl() ? 'https://' : 'http://'; + $url = add_query_arg( array( + 'key' => $this->options->getGMapAPI(), + ), "{$protocal}maps.googleapis.com/maps/api/js"); + wp_register_script( 'einsatzvw_GoogleMap', $url ); + } + } + private function addRewriteRules() { global $wp_rewrite; diff --git a/src/einsatzverwaltung-data.php b/src/einsatzverwaltung-data.php index 4ad755a0..446c2878 100644 --- a/src/einsatzverwaltung-data.php +++ b/src/einsatzverwaltung-data.php @@ -201,6 +201,9 @@ public function savePostdata($postId, $post) // Einsatzort validieren $einsatzort = sanitize_text_field($_POST['einsatzverwaltung_einsatzort']); + // Einsatzposition validieren + $location = sanitize_text_field($_POST['einsatzverwaltung_location']); + // Einsatzleiter validieren $einsatzleiter = sanitize_text_field($_POST['einsatzverwaltung_einsatzleiter']); @@ -214,6 +217,7 @@ public function savePostdata($postId, $post) // Metadaten schreiben update_post_meta($postId, 'einsatz_einsatzende', $einsatzende); update_post_meta($postId, 'einsatz_einsatzort', $einsatzort); + update_post_meta($postId, 'einsatz_location', $location); update_post_meta($postId, 'einsatz_einsatzleiter', $einsatzleiter); update_post_meta($postId, 'einsatz_mannschaft', $mannschaftsstaerke); update_post_meta($postId, 'einsatz_fehlalarm', $fehlalarm); @@ -283,7 +287,7 @@ public function onPublish($postId, $post) $this->utilities->removePostFromCategory($postId, $category); } } - + // Zwischenspeicher wird nur in der Entwurfsphase benötigt delete_post_meta($postId, '_einsatz_timeofalerting'); } diff --git a/src/einsatzverwaltung-frontend.php b/src/einsatzverwaltung-frontend.php index ce4fce18..8f6af021 100644 --- a/src/einsatzverwaltung-frontend.php +++ b/src/einsatzverwaltung-frontend.php @@ -21,7 +21,7 @@ class Frontend * @var Options */ private $options; - + /** * @var Utilities */ @@ -69,6 +69,7 @@ public function enqueueStyleAndScripts() Core::VERSION ); wp_add_inline_style('einsatzverwaltung-frontend', ReportList::getDynamicCss()); + wp_enqueue_script( 'einsatzvw_GoogleMap' ); } /** @@ -151,6 +152,52 @@ public function getEinsatzberichtHeader($post, $mayContainLinks = true, $showArc return ""; } + /** + * Erzeugt eine Google Map des Einsatzortes + * + * @return string Code zum Erzeugen der Google-Map mit Markierten einsatzort + */ + public function getEinsatzberichtMap($post) + { + $report = new IncidentReport($post); + $location = $report->getGmapsLocation(); + if($this->options->isGMapActivate() && $location) + { + $latLon = explode(",",$location); + $mapstring = ""; + //$mapstring .= ""; + $mapstring .= ""; + $mapstring .= "
"; + $mapstring .= "
"; + $mapstring .= "
"; + $mapstring .= "
"; + + return "

$mapstring

"; + } + } /** * Erzeugt eine Zeile für die Einsatzdetails @@ -193,7 +240,7 @@ public function renderContent($content) $header = $this->getEinsatzberichtHeader($post, true, true); $content = $this->prepareContent($content); - return $header . '
' . $content; + return $header . $this->getEinsatzberichtMap($post) . '
' . $content; } @@ -319,7 +366,7 @@ public function addReportsToQuery($query) } else { $postTypes = array('post'); } - + // Einsatzberichte nur zusammen mit Beiträgen abfragen if (!in_array('post', $postTypes)) { return; diff --git a/src/einsatzverwaltung-options.php b/src/einsatzverwaltung-options.php index e702bcdb..e9e3257b 100644 --- a/src/einsatzverwaltung-options.php +++ b/src/einsatzverwaltung-options.php @@ -27,6 +27,9 @@ class Options 'einsatzvw_flush_rewrite_rules' => false, 'einsatzvw_category' => false, 'einsatzvw_loop_only_special' => false, + 'einsatzvw_gmap' => false, + 'einsatzvw_gmap_api' => '', + 'einsatzvw_gmap_default_pos' => '53.523463,9.482329', ); /** @@ -151,6 +154,33 @@ public function getExcerptTypeFeed() return $this->utilities->sanitizeExcerptType($option); } + /** + * @return string + */ + public function getGMapAPI() + { + $option = $this->getOption('einsatzvw_gmap_api'); + return $option; + } + + /** + * @return string + */ + public function getGMapDefaultPos() + { + $option = $this->getOption('einsatzvw_gmap_default_pos'); + return $option; + } + + /** + * @return bool + */ + public function isGMapActivate() + { + $option = $this->getOption('einsatzvw_gmap'); + return $this->toBoolean($option); + } + /** * Gibt die Basis für die URL zu Einsatzberichten zurück * diff --git a/src/einsatzverwaltung-settings.php b/src/einsatzverwaltung-settings.php index c565b5f6..53b38b32 100644 --- a/src/einsatzverwaltung-settings.php +++ b/src/einsatzverwaltung-settings.php @@ -182,6 +182,19 @@ public function registerSettings() 'einsatzvw_list_ext_link', array($this->utilities, 'sanitizeCheckbox') ); + register_setting( + 'einsatzvw_settings', + 'einsatzvw_gmap', + array($this->utilities, 'sanitizeCheckbox') + ); + register_setting( + 'einsatzvw_settings', + 'einsatzvw_gmap_api' + ); + register_setting( + 'einsatzvw_settings', + 'einsatzvw_gmap_default_pos' + ); register_setting( 'einsatzvw_settings', 'einsatzvw_list_zebra', @@ -308,6 +321,13 @@ private function addSettingsFields() self::EVW_SETTINGS_SLUG, 'einsatzvw_settings_einsatzberichte' ); + add_settings_field( + 'einsatzvw_settings_gmap', + 'Google Maps', + array($this, 'echoSettingsGmap'), + self::EVW_SETTINGS_SLUG, + 'einsatzvw_settings_einsatzberichte' + ); add_settings_field( 'einsatzvw_settings_columns', 'Spalten der Einsatzliste', @@ -529,6 +549,30 @@ public function echoSettingsExcerpt() echo '

Bitte auch die Einstellung zum Umfang der Einträge im Feed (Einstellungen > Lesen) beachten!
Im Feed werden bei den Einsatzdetails aus technischen Gründen keine Links zu gefilterten Einsatzlisten angezeigt.

'; } + /** + * Gibt die Einstellmöglichkeiten für den Auszug aus + */ + public function echoSettingsGmap() + { + $this->echoSettingsCheckbox( + 'einsatzvw_gmap', + 'Googel Maps aktivieren', + $this->options->isGMapActivate() + ); + echo '

Googel Maps JavaScript API-Key: '; + $this->echoSettingsInput( + 'einsatzvw_gmap_api', + 'Wie generiere ich einen API-Key', + $this->options->getGMapAPI() + ); + echo '

Standartposition der Karte: '; + $this->echoSettingsInput( + 'einsatzvw_gmap_default_pos', + 'Als Lat,Lon: 53.523463,9.482329', + $this->options->getGMapDefaultPos() + ); + } + /** * From b53409e9250b5a1973df517174de74e02b8303ee Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Briese Date: Mon, 24 Oct 2016 12:14:31 +0200 Subject: [PATCH 2/7] =?UTF-8?q?Fehlende=20Felder=20in=20den=20Tests=20erg?= =?UTF-8?q?=C3=A4nzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Admin/ReportEditTest.php | 3 +++ tests/ReportFactory.php | 1 + 2 files changed, 4 insertions(+) diff --git a/tests/Admin/ReportEditTest.php b/tests/Admin/ReportEditTest.php index c08f90b4..4b6e6c73 100644 --- a/tests/Admin/ReportEditTest.php +++ b/tests/Admin/ReportEditTest.php @@ -52,6 +52,7 @@ public function testTimeOfAlertingSurvivesDraftState() 'einsatzverwaltung_einsatzort' => '', 'einsatzverwaltung_einsatzleiter' => '', 'einsatzverwaltung_mannschaft' => '', + 'einsatzverwaltung_location' => '', ); wp_update_post(array( 'ID' => $post->ID, @@ -101,6 +102,7 @@ public function testTimeOfAlertingSurvivesReviewAndPublish() 'einsatzverwaltung_einsatzort' => '', 'einsatzverwaltung_einsatzleiter' => '', 'einsatzverwaltung_mannschaft' => '', + 'einsatzverwaltung_location' => '', ); wp_update_post(array( 'ID' => $post->ID, @@ -125,6 +127,7 @@ public function testTimeOfAlertingSurvivesReviewAndPublish() 'einsatzverwaltung_einsatzort' => '', 'einsatzverwaltung_einsatzleiter' => '', 'einsatzverwaltung_mannschaft' => '', + 'einsatzverwaltung_location' => '', ); wp_update_post(array( 'ID' => $post->ID, diff --git a/tests/ReportFactory.php b/tests/ReportFactory.php index 7605ea07..0b259062 100644 --- a/tests/ReportFactory.php +++ b/tests/ReportFactory.php @@ -14,6 +14,7 @@ class ReportFactory extends WP_UnitTest_Factory_For_Post 'einsatz_einsatzende' => '', 'einsatz_einsatzleiter' => '', 'einsatz_einsatzort' => '', + 'einsatz_location' => '', 'einsatz_fehlalarm' => 0, 'einsatz_mannschaft' => '', 'einsatz_special' => 0, From 1eae76f161761e2ac15d99b1a040b0ffa49d54bd Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Briese Date: Wed, 26 Oct 2016 11:43:47 +0200 Subject: [PATCH 3/7] =?UTF-8?q?GoogleMaps=20integration:=20Refactoring:=20?= =?UTF-8?q?JavaScript=20so=20weit=20es=20geht=20aus=20dem=20PHP=20Source?= =?UTF-8?q?=20entfernt=20und=20in=20js/einsatzverwaltung-gmaps.js=20ausgel?= =?UTF-8?q?agert.=20[einsatzliste]=20um=20Parameter=20googlemaps=3Dja/nein?= =?UTF-8?q?=20erweitert,=20um=20am=20Seitenanfang=20eine=20Karte=20mit=20a?= =?UTF-8?q?llen=20Eins=C3=A4tzen=20anzuzeigen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Frontend/ReportList.php | 36 +++++++++++++++ src/einsatzverwaltung-admin.php | 65 +++++----------------------- src/einsatzverwaltung-frontend.php | 47 +++++++++----------- src/einsatzverwaltung-shortcodes.php | 2 + src/js/einsatzverwaltung-gmaps.js | 63 +++++++++++++++++++++++++++ 5 files changed, 132 insertions(+), 81 deletions(-) create mode 100644 src/js/einsatzverwaltung-gmaps.js diff --git a/src/Frontend/ReportList.php b/src/Frontend/ReportList.php index 262bf071..bbea4b00 100644 --- a/src/Frontend/ReportList.php +++ b/src/Frontend/ReportList.php @@ -107,6 +107,13 @@ class ReportList */ private $splitMonths; + /** + * Gibt an, ob eine Google-Map mit den Einsätzen angezeigt wird + * + * @var bool + */ + private $showMap; + /** * In diesem String wird der HTML-Code für die Liste aufgebaut * @@ -151,6 +158,7 @@ private function constructList($reports, $args) // Argumente auswerten $defaults = array( 'splitMonths' => false, + 'showMap' => false, 'columns' => array(), 'linkToVehicles' => $this->options->getBoolOption('einsatzvw_list_fahrzeuge_link'), 'linkToAddForces' => $this->options->getBoolOption('einsatzvw_list_ext_link'), @@ -159,11 +167,13 @@ private function constructList($reports, $args) 'showHeading' => true, 'compact' => false, ); + $parsedArgs = wp_parse_args($args, $defaults); // Variablen setzen $this->compact = (bool) $parsedArgs['compact']; $this->splitMonths = (bool) $parsedArgs['splitMonths'] && !$this->compact; + $this->showMap = (bool) $parsedArgs['showMap'] && !$this->compact; $this->columns = $this->utilities->sanitizeColumnsArray($parsedArgs['columns']); $this->numberOfColumns = count($this->columns); $this->linkToVehicles = (true === $parsedArgs['linkToVehicles']); @@ -185,6 +195,21 @@ private function constructList($reports, $args) $this->beginTable(false); $this->insertTableHeader(); } + + if( $this->options->isGMapActivate() != "" && $this->showMap) { + $latLon = explode(",", $this->options->getGMapDefaultPos() ); + $mapstring = ""; + $mapstring .= "

"; + $mapstring .= "
"; + $mapstring .= "
"; + $mapstring .= "
"; + $mapstring .= ""; + + echo "$mapstring"; + } + /** @var IncidentReport $report */ foreach ($reports as $report) { $timeOfAlerting = $report->getTimeOfAlerting(); @@ -265,6 +290,7 @@ private function beginTable($year) if ($this->showHeading && $year !== false) { $this->string .= '

Einsätze '.$year.'

'; } + $this->string .= '
'; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
'; + echo '
'; + echo '
'; } @@ -320,7 +346,17 @@ private function insertRow($report) } $this->string .= ''; } + if( $this->options->isGMapActivate() && $this->showMap && $report->getGmapsLocation() != "") { + $latLon = explode(",", $report->getGmapsLocation()); + $timeOfAlerting = $report->getTimeOfAlerting(); + $infoContent = '

' . get_the_title($report->getPostId()) . '

' . $timeOfAlerting->format('d.m.Y H:i') . '

' . $report->getLocation() . '

'; + $marker = ''; + $this->string .= $marker; + } $this->string .= ''; + } /** diff --git a/src/einsatzverwaltung-admin.php b/src/einsatzverwaltung-admin.php index 59592ef6..d82596c6 100644 --- a/src/einsatzverwaltung-admin.php +++ b/src/einsatzverwaltung-admin.php @@ -132,7 +132,14 @@ public function enqueueEditScripts($hook) Core::VERSION ); - wp_enqueue_script( 'einsatzvw_GoogleMap' ); + if($this->options->isGMapActivate()) + { + wp_enqueue_script( 'einsatzvw_GoogleMap' ); + wp_enqueue_script( + 'einsatzverwaltung-gmap', + $this->core->scriptUrl . 'einsatzverwaltung-gmaps.js' + ); + } } /** @@ -262,70 +269,20 @@ private function echoGMap($location) } else { - $latLon = array("",""); + $latLon = explode(",",$this->options->getGMapDefaultPos()); } - $DeflatLon = explode(",",$this->options->getGMapDefaultPos()); echo ''; echo ''; echo ''; } diff --git a/src/einsatzverwaltung-frontend.php b/src/einsatzverwaltung-frontend.php index 8f6af021..49774f48 100644 --- a/src/einsatzverwaltung-frontend.php +++ b/src/einsatzverwaltung-frontend.php @@ -69,7 +69,15 @@ public function enqueueStyleAndScripts() Core::VERSION ); wp_add_inline_style('einsatzverwaltung-frontend', ReportList::getDynamicCss()); - wp_enqueue_script( 'einsatzvw_GoogleMap' ); + + if($this->options->isGMapActivate()) + { + wp_enqueue_script( 'einsatzvw_GoogleMap' ); + wp_enqueue_script( + 'einsatzverwaltung-gmap', + $this->core->scriptUrl . 'einsatzverwaltung-gmaps.js' + ); + } } /** @@ -164,36 +172,16 @@ public function getEinsatzberichtMap($post) if($this->options->isGMapActivate() && $location) { $latLon = explode(",",$location); + $mapstring = ""; - //$mapstring .= ""; - $mapstring .= ""; $mapstring .= "
"; $mapstring .= "
"; $mapstring .= "
"; $mapstring .= "
"; + $mapstring .= ""; return "

$mapstring

"; } @@ -239,8 +227,13 @@ public function renderContent($content) $header = $this->getEinsatzberichtHeader($post, true, true); $content = $this->prepareContent($content); + $map = ""; + if($this->options->isGMapActivate()) + { + $map = $this->getEinsatzberichtMap($post); + } - return $header . $this->getEinsatzberichtMap($post) . '
' . $content; + return $header . $map . '
' . $content; } diff --git a/src/einsatzverwaltung-shortcodes.php b/src/einsatzverwaltung-shortcodes.php index 77e82985..8ab1af3c 100644 --- a/src/einsatzverwaltung-shortcodes.php +++ b/src/einsatzverwaltung-shortcodes.php @@ -60,6 +60,7 @@ public function einsatzliste($atts) 'jahr' => $currentYear, 'sort' => 'ab', 'monatetrennen' => 'nein', + 'googlemaps' => 'nein', 'link' => 'title', 'limit' => -1, 'options' => '' @@ -102,6 +103,7 @@ public function einsatzliste($atts) $reports, array( 'splitMonths' => ($shortcodeParams['monatetrennen'] == 'ja'), + 'showMap' => ($shortcodeParams['googlemaps'] == 'ja'), 'columns' => $this->options->getEinsatzlisteEnabledColumns(), 'columnsWithLink' => $columnsWithLink, 'linkEmptyReports' => $linkEmptyReports, diff --git a/src/js/einsatzverwaltung-gmaps.js b/src/js/einsatzverwaltung-gmaps.js new file mode 100644 index 00000000..57caf2fa --- /dev/null +++ b/src/js/einsatzverwaltung-gmaps.js @@ -0,0 +1,63 @@ +var map; +var marker + +function initializeMap(lat, lon, zoom) { + if(!zoom) { + zoom = 13; + } + var latLon = new google.maps.LatLng(lat, lon); + var mapOptions = { + zoom: zoom, + center: latLon + }; + map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); +} + +function setAdminMarker( position, locationField ) { + if (marker && marker.setPosition) { + // if the marker already exists, move it (set its position) + marker.setPosition(position); + } else { + marker = new google.maps.Marker({ + map: map, + position: position, + draggable: true, + scaleControl:true + }); + } + map.setCenter(marker.getPosition()); + document.getElementById(locationField).value=marker.getPosition().toUrlValue(); + marker.addListener("drag", function(){ + document.getElementById(locationField).value=marker.getPosition().toUrlValue(); + }); +} + +function geocodeAddress( address, locationField ) { + var geocoder = new google.maps.Geocoder(); + geocoder.geocode({"address": address}, function(results, status) { + if (status === google.maps.GeocoderStatus.OK) { + var location = results[0].geometry.location; + setAdminMarker( location, locationField ); + map.setZoom(16); + } else { + alert("Konnte Position nicht ermitteln: " + status); + } + }); +} + +function addMarker( lat, lon , infoContent, showContent ) { + var latLon = new google.maps.LatLng(lat, lon); + var newMarker = new google.maps.Marker({ + map: map, + position: latLon, + }); + var infowindow = new google.maps.InfoWindow({ + content: infoContent + }); + newMarker.addListener('click', function() { + infowindow.open(map, newMarker); + }); + if(showContent) { + infowindow.open(map, newMarker); + } +} From 9e871c2f070a40075cd693e7010bac948a4c27cf Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Briese Date: Mon, 29 May 2017 16:25:45 +0200 Subject: [PATCH 4/7] =?UTF-8?q?Aufr=C3=A4umen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...einsatzverwaltung-options_BACKUP_44663.php | 338 ------------------ src/einsatzverwaltung-options_BASE_44663.php | 296 --------------- src/einsatzverwaltung-options_LOCAL_44663.php | 326 ----------------- ...einsatzverwaltung-options_REMOTE_44663.php | 305 ---------------- 4 files changed, 1265 deletions(-) delete mode 100644 src/einsatzverwaltung-options_BACKUP_44663.php delete mode 100644 src/einsatzverwaltung-options_BASE_44663.php delete mode 100644 src/einsatzverwaltung-options_LOCAL_44663.php delete mode 100644 src/einsatzverwaltung-options_REMOTE_44663.php diff --git a/src/einsatzverwaltung-options_BACKUP_44663.php b/src/einsatzverwaltung-options_BACKUP_44663.php deleted file mode 100644 index a4f1adad..00000000 --- a/src/einsatzverwaltung-options_BACKUP_44663.php +++ /dev/null @@ -1,338 +0,0 @@ - 'number,date,time,title', - 'einsatzvw_einsatznummer_stellen' => 3, - 'einsatzvw_show_einsatzart_archive' => false, - 'einsatzvw_show_exteinsatzmittel_archive' => false, - 'einsatzvw_show_fahrzeug_archive' => false, - 'einsatzvw_open_ext_in_new' => false, - 'einsatzvw_excerpt_type' => 'default', - 'einsatzvw_excerpt_type_feed' => 'default', - 'einsatzvw_show_einsatzberichte_mainloop' => false, - 'einsatzvw_einsatz_hideemptydetails' => true, - 'einsatzvw_einsatznummer_lfdvorne' => false, - 'date_format' => 'd.m.Y', - 'time_format' => 'H:i', - 'einsatzvw_list_art_hierarchy' => false, - 'einsatzvw_list_ext_link' => false, - 'einsatzvw_list_fahrzeuge_link' => false, - 'einsatzvw_rewrite_slug' => 'einsatzberichte', - 'einsatzvw_flush_rewrite_rules' => false, - 'einsatzvw_category' => false, - 'einsatzvw_loop_only_special' => false, -<<<<<<< HEAD - 'einsatzvw_gmap' => false, - 'einsatzvw_gmap_api' => '', - 'einsatzvw_gmap_default_pos' => '53.523463,9.482329', -======= - 'einsatzverwaltung_incidentnumbers_auto' => false, ->>>>>>> f48eba8482fea0509a601b2c8dac20436d83333e - ); - - /** - * @var Utilities - */ - private $utilities; - - /** - * Options constructor. - * - * @param Utilities $utilities - */ - public function __construct($utilities) - { - $this->utilities = $utilities; - } - - /** - * Ruft die benannte Option aus der Datenbank ab - * - * @param string $key Schlüssel der Option - * - * @return mixed - */ - public function getOption($key) - { - if (array_key_exists($key, $this->defaults)) { - return get_option($key, $this->defaults[$key]); - } - - // Fehlenden Standardwert beklagen, außer es handelt sich um eine Rechteeinstellung - if (strpos($key, 'einsatzvw_cap_roles_') !== 0) { - error_log(sprintf('Kein Standardwert für %s gefunden!', $key)); - } - - return get_option($key, false); - } - - /** - * @param string $key Schlüssel der Option - * - * @return bool - */ - public function getBoolOption($key) - { - $option = $this->getOption($key); - return $this->toBoolean($option); - } - - public function getDefaultColumns() - { - return $this->defaults['einsatzvw_list_columns']; - } - - public function getDefaultEinsatznummerStellen() - { - return $this->defaults['einsatzvw_einsatznummer_stellen']; - } - - public function getDefaultExcerptType() - { - return $this->defaults['einsatzvw_excerpt_type']; - } - - /** - * Gibt das Datumsformat von WordPress zurück - */ - public function getDateFormat() - { - return $this->getOption('date_format'); - } - - /** - * Gibt die Kategorie zurück, in der neben Beiträgen auch Einsatzberichte angezeigt werden sollen - * - * @since 1.0.0 - * - * @return int Die ID der Kategorie oder -1, wenn nicht gesetzt - */ - public function getEinsatzberichteCategory() - { - $categoryId = $this->getOption('einsatzvw_category'); - return (false === $categoryId ? -1 : intval($categoryId)); - } - - /** - * Gibt die aktiven Spalten für die Einsatzliste zurück - * - * @return array Spalten-IDs der aktiven Spalten, geprüft auf Existenz. Bei Problemen die Standardspalten. - */ - public function getEinsatzlisteEnabledColumns() - { - $enabledColumns = $this->getOption('einsatzvw_list_columns'); - $enabledColumns = $this->utilities->sanitizeColumns($enabledColumns); - return explode(',', $enabledColumns); - } - - /** - * @return int - */ - public function getEinsatznummerStellen() - { - $option = $this->getOption('einsatzvw_einsatznummer_stellen'); - return $this->utilities->sanitizeEinsatznummerStellen($option); - } - - /** - * @return string - */ - public function getExcerptType() - { - $option = $this->getOption('einsatzvw_excerpt_type'); - return $this->utilities->sanitizeExcerptType($option); - } - - /** - * @return string - */ - public function getExcerptTypeFeed() - { - $option = $this->getOption('einsatzvw_excerpt_type_feed'); - return $this->utilities->sanitizeExcerptType($option); - } - - /** - * @return string - */ - public function getGMapAPI() - { - $option = $this->getOption('einsatzvw_gmap_api'); - return $option; - } - - /** - * @return string - */ - public function getGMapDefaultPos() - { - $option = $this->getOption('einsatzvw_gmap_default_pos'); - return $option; - } - - /** - * @return bool - */ - public function isGMapActivate() - { - $option = $this->getOption('einsatzvw_gmap'); - return $this->toBoolean($option); - } - - /** - * Gibt die Basis für die URL zu Einsatzberichten zurück - * - * @since 1.0.0 - * - * @return string - */ - public function getRewriteSlug() - { - $option = $this->getOption('einsatzvw_rewrite_slug'); - return sanitize_title($option, $this->defaults['einsatzvw_rewrite_slug']); - } - - /** - * @return mixed - */ - public function getTimeFormat() - { - return $this->getOption('time_format'); - } - - /** - * @return bool - */ - public function isAutoIncidentNumbers() - { - return $this->getBoolOption('einsatzverwaltung_incidentnumbers_auto'); - } - - /** - * @return bool - */ - public function isEinsatznummerLfdVorne() - { - $option = $this->getOption('einsatzvw_einsatznummer_lfdvorne'); - return $this->toBoolean($option); - } - - /** - * @since 1.0.0 - * - * @return bool - */ - public function isFlushRewriteRules() - { - return $this->getBoolOption('einsatzvw_flush_rewrite_rules'); - } - - /** - * Gibt die Option einsatzvw_einsatz_hideemptydetails als bool zurück - * - * @return bool - */ - public function isHideEmptyDetails() - { - $option = $this->getOption('einsatzvw_einsatz_hideemptydetails'); - return $this->toBoolean($option); - } - - /** - * Gibt zurück, ob nur als besonders markierte Einsatzberichte zwischen normalen WordPress-Beiträgen angezeigt - * werden sollen - * - * @return bool - */ - public function isOnlySpecialInLoop() - { - return $this->getBoolOption('einsatzvw_loop_only_special'); - } - - - /** - * @return bool - */ - public function isOpenExtEinsatzmittelNewWindow() - { - $option = $this->getOption('einsatzvw_open_ext_in_new'); - return $this->toBoolean($option); - } - - /** - * @param $roleSlug - * - * @return bool - */ - public function isRoleAllowedToEdit($roleSlug) - { - if ($roleSlug === 'administrator') { - return true; - } - - $option = $this->getOption('einsatzvw_cap_roles_' . $roleSlug); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowEinsatzartArchive() - { - $option = $this->getOption('einsatzvw_show_einsatzart_archive'); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowReportsInLoop() - { - $option = $this->getOption('einsatzvw_show_einsatzberichte_mainloop'); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowExtEinsatzmittelArchive() - { - $option = $this->getOption('einsatzvw_show_exteinsatzmittel_archive'); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowFahrzeugArchive() - { - $option = $this->getOption('einsatzvw_show_fahrzeug_archive'); - return $this->toBoolean($option); - } - - /** - * @since 1.0.0 - * - * @param bool $value - */ - public function setFlushRewriteRules($value) - { - update_option('einsatzvw_flush_rewrite_rules', $value ? 1 : 0); - } - - /** - * @param $value - * - * @return bool - */ - private function toBoolean($value) - { - return in_array($value, array(1, true, '1', 'yes', 'on'), true); - } -} diff --git a/src/einsatzverwaltung-options_BASE_44663.php b/src/einsatzverwaltung-options_BASE_44663.php deleted file mode 100644 index e702bcdb..00000000 --- a/src/einsatzverwaltung-options_BASE_44663.php +++ /dev/null @@ -1,296 +0,0 @@ - 'number,date,time,title', - 'einsatzvw_einsatznummer_stellen' => 3, - 'einsatzvw_show_einsatzart_archive' => false, - 'einsatzvw_show_exteinsatzmittel_archive' => false, - 'einsatzvw_show_fahrzeug_archive' => false, - 'einsatzvw_open_ext_in_new' => false, - 'einsatzvw_excerpt_type' => 'default', - 'einsatzvw_excerpt_type_feed' => 'default', - 'einsatzvw_show_einsatzberichte_mainloop' => false, - 'einsatzvw_einsatz_hideemptydetails' => true, - 'einsatzvw_einsatznummer_lfdvorne' => false, - 'date_format' => 'd.m.Y', - 'time_format' => 'H:i', - 'einsatzvw_list_art_hierarchy' => false, - 'einsatzvw_list_ext_link' => false, - 'einsatzvw_list_fahrzeuge_link' => false, - 'einsatzvw_rewrite_slug' => 'einsatzberichte', - 'einsatzvw_flush_rewrite_rules' => false, - 'einsatzvw_category' => false, - 'einsatzvw_loop_only_special' => false, - ); - - /** - * @var Utilities - */ - private $utilities; - - /** - * Options constructor. - * - * @param Utilities $utilities - */ - public function __construct($utilities) - { - $this->utilities = $utilities; - } - - /** - * Ruft die benannte Option aus der Datenbank ab - * - * @param string $key Schlüssel der Option - * - * @return mixed - */ - public function getOption($key) - { - if (array_key_exists($key, $this->defaults)) { - return get_option($key, $this->defaults[$key]); - } - - // Fehlenden Standardwert beklagen, außer es handelt sich um eine Rechteeinstellung - if (strpos($key, 'einsatzvw_cap_roles_') !== 0) { - error_log(sprintf('Kein Standardwert für %s gefunden!', $key)); - } - - return get_option($key, false); - } - - /** - * @param string $key Schlüssel der Option - * - * @return bool - */ - public function getBoolOption($key) - { - $option = $this->getOption($key); - return $this->toBoolean($option); - } - - public function getDefaultColumns() - { - return $this->defaults['einsatzvw_list_columns']; - } - - public function getDefaultEinsatznummerStellen() - { - return $this->defaults['einsatzvw_einsatznummer_stellen']; - } - - public function getDefaultExcerptType() - { - return $this->defaults['einsatzvw_excerpt_type']; - } - - /** - * Gibt das Datumsformat von WordPress zurück - */ - public function getDateFormat() - { - return $this->getOption('date_format'); - } - - /** - * Gibt die Kategorie zurück, in der neben Beiträgen auch Einsatzberichte angezeigt werden sollen - * - * @since 1.0.0 - * - * @return int Die ID der Kategorie oder -1, wenn nicht gesetzt - */ - public function getEinsatzberichteCategory() - { - $categoryId = $this->getOption('einsatzvw_category'); - return (false === $categoryId ? -1 : intval($categoryId)); - } - - /** - * Gibt die aktiven Spalten für die Einsatzliste zurück - * - * @return array Spalten-IDs der aktiven Spalten, geprüft auf Existenz. Bei Problemen die Standardspalten. - */ - public function getEinsatzlisteEnabledColumns() - { - $enabledColumns = $this->getOption('einsatzvw_list_columns'); - $enabledColumns = $this->utilities->sanitizeColumns($enabledColumns); - return explode(',', $enabledColumns); - } - - /** - * @return int - */ - public function getEinsatznummerStellen() - { - $option = $this->getOption('einsatzvw_einsatznummer_stellen'); - return $this->utilities->sanitizeEinsatznummerStellen($option); - } - - /** - * @return string - */ - public function getExcerptType() - { - $option = $this->getOption('einsatzvw_excerpt_type'); - return $this->utilities->sanitizeExcerptType($option); - } - - /** - * @return string - */ - public function getExcerptTypeFeed() - { - $option = $this->getOption('einsatzvw_excerpt_type_feed'); - return $this->utilities->sanitizeExcerptType($option); - } - - /** - * Gibt die Basis für die URL zu Einsatzberichten zurück - * - * @since 1.0.0 - * - * @return string - */ - public function getRewriteSlug() - { - $option = $this->getOption('einsatzvw_rewrite_slug'); - return sanitize_title($option, $this->defaults['einsatzvw_rewrite_slug']); - } - - /** - * @return mixed - */ - public function getTimeFormat() - { - return $this->getOption('time_format'); - } - - /** - * @return bool - */ - public function isEinsatznummerLfdVorne() - { - $option = $this->getOption('einsatzvw_einsatznummer_lfdvorne'); - return $this->toBoolean($option); - } - - /** - * @since 1.0.0 - * - * @return bool - */ - public function isFlushRewriteRules() - { - return $this->getBoolOption('einsatzvw_flush_rewrite_rules'); - } - - /** - * Gibt die Option einsatzvw_einsatz_hideemptydetails als bool zurück - * - * @return bool - */ - public function isHideEmptyDetails() - { - $option = $this->getOption('einsatzvw_einsatz_hideemptydetails'); - return $this->toBoolean($option); - } - - /** - * Gibt zurück, ob nur als besonders markierte Einsatzberichte zwischen normalen WordPress-Beiträgen angezeigt - * werden sollen - * - * @return bool - */ - public function isOnlySpecialInLoop() - { - return $this->getBoolOption('einsatzvw_loop_only_special'); - } - - - /** - * @return bool - */ - public function isOpenExtEinsatzmittelNewWindow() - { - $option = $this->getOption('einsatzvw_open_ext_in_new'); - return $this->toBoolean($option); - } - - /** - * @param $roleSlug - * - * @return bool - */ - public function isRoleAllowedToEdit($roleSlug) - { - if ($roleSlug === 'administrator') { - return true; - } - - $option = $this->getOption('einsatzvw_cap_roles_' . $roleSlug); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowEinsatzartArchive() - { - $option = $this->getOption('einsatzvw_show_einsatzart_archive'); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowReportsInLoop() - { - $option = $this->getOption('einsatzvw_show_einsatzberichte_mainloop'); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowExtEinsatzmittelArchive() - { - $option = $this->getOption('einsatzvw_show_exteinsatzmittel_archive'); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowFahrzeugArchive() - { - $option = $this->getOption('einsatzvw_show_fahrzeug_archive'); - return $this->toBoolean($option); - } - - /** - * @since 1.0.0 - * - * @param bool $value - */ - public function setFlushRewriteRules($value) - { - update_option('einsatzvw_flush_rewrite_rules', $value ? 1 : 0); - } - - /** - * @param $value - * - * @return bool - */ - private function toBoolean($value) - { - return in_array($value, array(1, true, '1', 'yes', 'on'), true); - } -} diff --git a/src/einsatzverwaltung-options_LOCAL_44663.php b/src/einsatzverwaltung-options_LOCAL_44663.php deleted file mode 100644 index e9e3257b..00000000 --- a/src/einsatzverwaltung-options_LOCAL_44663.php +++ /dev/null @@ -1,326 +0,0 @@ - 'number,date,time,title', - 'einsatzvw_einsatznummer_stellen' => 3, - 'einsatzvw_show_einsatzart_archive' => false, - 'einsatzvw_show_exteinsatzmittel_archive' => false, - 'einsatzvw_show_fahrzeug_archive' => false, - 'einsatzvw_open_ext_in_new' => false, - 'einsatzvw_excerpt_type' => 'default', - 'einsatzvw_excerpt_type_feed' => 'default', - 'einsatzvw_show_einsatzberichte_mainloop' => false, - 'einsatzvw_einsatz_hideemptydetails' => true, - 'einsatzvw_einsatznummer_lfdvorne' => false, - 'date_format' => 'd.m.Y', - 'time_format' => 'H:i', - 'einsatzvw_list_art_hierarchy' => false, - 'einsatzvw_list_ext_link' => false, - 'einsatzvw_list_fahrzeuge_link' => false, - 'einsatzvw_rewrite_slug' => 'einsatzberichte', - 'einsatzvw_flush_rewrite_rules' => false, - 'einsatzvw_category' => false, - 'einsatzvw_loop_only_special' => false, - 'einsatzvw_gmap' => false, - 'einsatzvw_gmap_api' => '', - 'einsatzvw_gmap_default_pos' => '53.523463,9.482329', - ); - - /** - * @var Utilities - */ - private $utilities; - - /** - * Options constructor. - * - * @param Utilities $utilities - */ - public function __construct($utilities) - { - $this->utilities = $utilities; - } - - /** - * Ruft die benannte Option aus der Datenbank ab - * - * @param string $key Schlüssel der Option - * - * @return mixed - */ - public function getOption($key) - { - if (array_key_exists($key, $this->defaults)) { - return get_option($key, $this->defaults[$key]); - } - - // Fehlenden Standardwert beklagen, außer es handelt sich um eine Rechteeinstellung - if (strpos($key, 'einsatzvw_cap_roles_') !== 0) { - error_log(sprintf('Kein Standardwert für %s gefunden!', $key)); - } - - return get_option($key, false); - } - - /** - * @param string $key Schlüssel der Option - * - * @return bool - */ - public function getBoolOption($key) - { - $option = $this->getOption($key); - return $this->toBoolean($option); - } - - public function getDefaultColumns() - { - return $this->defaults['einsatzvw_list_columns']; - } - - public function getDefaultEinsatznummerStellen() - { - return $this->defaults['einsatzvw_einsatznummer_stellen']; - } - - public function getDefaultExcerptType() - { - return $this->defaults['einsatzvw_excerpt_type']; - } - - /** - * Gibt das Datumsformat von WordPress zurück - */ - public function getDateFormat() - { - return $this->getOption('date_format'); - } - - /** - * Gibt die Kategorie zurück, in der neben Beiträgen auch Einsatzberichte angezeigt werden sollen - * - * @since 1.0.0 - * - * @return int Die ID der Kategorie oder -1, wenn nicht gesetzt - */ - public function getEinsatzberichteCategory() - { - $categoryId = $this->getOption('einsatzvw_category'); - return (false === $categoryId ? -1 : intval($categoryId)); - } - - /** - * Gibt die aktiven Spalten für die Einsatzliste zurück - * - * @return array Spalten-IDs der aktiven Spalten, geprüft auf Existenz. Bei Problemen die Standardspalten. - */ - public function getEinsatzlisteEnabledColumns() - { - $enabledColumns = $this->getOption('einsatzvw_list_columns'); - $enabledColumns = $this->utilities->sanitizeColumns($enabledColumns); - return explode(',', $enabledColumns); - } - - /** - * @return int - */ - public function getEinsatznummerStellen() - { - $option = $this->getOption('einsatzvw_einsatznummer_stellen'); - return $this->utilities->sanitizeEinsatznummerStellen($option); - } - - /** - * @return string - */ - public function getExcerptType() - { - $option = $this->getOption('einsatzvw_excerpt_type'); - return $this->utilities->sanitizeExcerptType($option); - } - - /** - * @return string - */ - public function getExcerptTypeFeed() - { - $option = $this->getOption('einsatzvw_excerpt_type_feed'); - return $this->utilities->sanitizeExcerptType($option); - } - - /** - * @return string - */ - public function getGMapAPI() - { - $option = $this->getOption('einsatzvw_gmap_api'); - return $option; - } - - /** - * @return string - */ - public function getGMapDefaultPos() - { - $option = $this->getOption('einsatzvw_gmap_default_pos'); - return $option; - } - - /** - * @return bool - */ - public function isGMapActivate() - { - $option = $this->getOption('einsatzvw_gmap'); - return $this->toBoolean($option); - } - - /** - * Gibt die Basis für die URL zu Einsatzberichten zurück - * - * @since 1.0.0 - * - * @return string - */ - public function getRewriteSlug() - { - $option = $this->getOption('einsatzvw_rewrite_slug'); - return sanitize_title($option, $this->defaults['einsatzvw_rewrite_slug']); - } - - /** - * @return mixed - */ - public function getTimeFormat() - { - return $this->getOption('time_format'); - } - - /** - * @return bool - */ - public function isEinsatznummerLfdVorne() - { - $option = $this->getOption('einsatzvw_einsatznummer_lfdvorne'); - return $this->toBoolean($option); - } - - /** - * @since 1.0.0 - * - * @return bool - */ - public function isFlushRewriteRules() - { - return $this->getBoolOption('einsatzvw_flush_rewrite_rules'); - } - - /** - * Gibt die Option einsatzvw_einsatz_hideemptydetails als bool zurück - * - * @return bool - */ - public function isHideEmptyDetails() - { - $option = $this->getOption('einsatzvw_einsatz_hideemptydetails'); - return $this->toBoolean($option); - } - - /** - * Gibt zurück, ob nur als besonders markierte Einsatzberichte zwischen normalen WordPress-Beiträgen angezeigt - * werden sollen - * - * @return bool - */ - public function isOnlySpecialInLoop() - { - return $this->getBoolOption('einsatzvw_loop_only_special'); - } - - - /** - * @return bool - */ - public function isOpenExtEinsatzmittelNewWindow() - { - $option = $this->getOption('einsatzvw_open_ext_in_new'); - return $this->toBoolean($option); - } - - /** - * @param $roleSlug - * - * @return bool - */ - public function isRoleAllowedToEdit($roleSlug) - { - if ($roleSlug === 'administrator') { - return true; - } - - $option = $this->getOption('einsatzvw_cap_roles_' . $roleSlug); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowEinsatzartArchive() - { - $option = $this->getOption('einsatzvw_show_einsatzart_archive'); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowReportsInLoop() - { - $option = $this->getOption('einsatzvw_show_einsatzberichte_mainloop'); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowExtEinsatzmittelArchive() - { - $option = $this->getOption('einsatzvw_show_exteinsatzmittel_archive'); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowFahrzeugArchive() - { - $option = $this->getOption('einsatzvw_show_fahrzeug_archive'); - return $this->toBoolean($option); - } - - /** - * @since 1.0.0 - * - * @param bool $value - */ - public function setFlushRewriteRules($value) - { - update_option('einsatzvw_flush_rewrite_rules', $value ? 1 : 0); - } - - /** - * @param $value - * - * @return bool - */ - private function toBoolean($value) - { - return in_array($value, array(1, true, '1', 'yes', 'on'), true); - } -} diff --git a/src/einsatzverwaltung-options_REMOTE_44663.php b/src/einsatzverwaltung-options_REMOTE_44663.php deleted file mode 100644 index 46de0ec3..00000000 --- a/src/einsatzverwaltung-options_REMOTE_44663.php +++ /dev/null @@ -1,305 +0,0 @@ - 'number,date,time,title', - 'einsatzvw_einsatznummer_stellen' => 3, - 'einsatzvw_show_einsatzart_archive' => false, - 'einsatzvw_show_exteinsatzmittel_archive' => false, - 'einsatzvw_show_fahrzeug_archive' => false, - 'einsatzvw_open_ext_in_new' => false, - 'einsatzvw_excerpt_type' => 'default', - 'einsatzvw_excerpt_type_feed' => 'default', - 'einsatzvw_show_einsatzberichte_mainloop' => false, - 'einsatzvw_einsatz_hideemptydetails' => true, - 'einsatzvw_einsatznummer_lfdvorne' => false, - 'date_format' => 'd.m.Y', - 'time_format' => 'H:i', - 'einsatzvw_list_art_hierarchy' => false, - 'einsatzvw_list_ext_link' => false, - 'einsatzvw_list_fahrzeuge_link' => false, - 'einsatzvw_rewrite_slug' => 'einsatzberichte', - 'einsatzvw_flush_rewrite_rules' => false, - 'einsatzvw_category' => false, - 'einsatzvw_loop_only_special' => false, - 'einsatzverwaltung_incidentnumbers_auto' => false, - ); - - /** - * @var Utilities - */ - private $utilities; - - /** - * Options constructor. - * - * @param Utilities $utilities - */ - public function __construct($utilities) - { - $this->utilities = $utilities; - } - - /** - * Ruft die benannte Option aus der Datenbank ab - * - * @param string $key Schlüssel der Option - * - * @return mixed - */ - public function getOption($key) - { - if (array_key_exists($key, $this->defaults)) { - return get_option($key, $this->defaults[$key]); - } - - // Fehlenden Standardwert beklagen, außer es handelt sich um eine Rechteeinstellung - if (strpos($key, 'einsatzvw_cap_roles_') !== 0) { - error_log(sprintf('Kein Standardwert für %s gefunden!', $key)); - } - - return get_option($key, false); - } - - /** - * @param string $key Schlüssel der Option - * - * @return bool - */ - public function getBoolOption($key) - { - $option = $this->getOption($key); - return $this->toBoolean($option); - } - - public function getDefaultColumns() - { - return $this->defaults['einsatzvw_list_columns']; - } - - public function getDefaultEinsatznummerStellen() - { - return $this->defaults['einsatzvw_einsatznummer_stellen']; - } - - public function getDefaultExcerptType() - { - return $this->defaults['einsatzvw_excerpt_type']; - } - - /** - * Gibt das Datumsformat von WordPress zurück - */ - public function getDateFormat() - { - return $this->getOption('date_format'); - } - - /** - * Gibt die Kategorie zurück, in der neben Beiträgen auch Einsatzberichte angezeigt werden sollen - * - * @since 1.0.0 - * - * @return int Die ID der Kategorie oder -1, wenn nicht gesetzt - */ - public function getEinsatzberichteCategory() - { - $categoryId = $this->getOption('einsatzvw_category'); - return (false === $categoryId ? -1 : intval($categoryId)); - } - - /** - * Gibt die aktiven Spalten für die Einsatzliste zurück - * - * @return array Spalten-IDs der aktiven Spalten, geprüft auf Existenz. Bei Problemen die Standardspalten. - */ - public function getEinsatzlisteEnabledColumns() - { - $enabledColumns = $this->getOption('einsatzvw_list_columns'); - $enabledColumns = $this->utilities->sanitizeColumns($enabledColumns); - return explode(',', $enabledColumns); - } - - /** - * @return int - */ - public function getEinsatznummerStellen() - { - $option = $this->getOption('einsatzvw_einsatznummer_stellen'); - return $this->utilities->sanitizeEinsatznummerStellen($option); - } - - /** - * @return string - */ - public function getExcerptType() - { - $option = $this->getOption('einsatzvw_excerpt_type'); - return $this->utilities->sanitizeExcerptType($option); - } - - /** - * @return string - */ - public function getExcerptTypeFeed() - { - $option = $this->getOption('einsatzvw_excerpt_type_feed'); - return $this->utilities->sanitizeExcerptType($option); - } - - /** - * Gibt die Basis für die URL zu Einsatzberichten zurück - * - * @since 1.0.0 - * - * @return string - */ - public function getRewriteSlug() - { - $option = $this->getOption('einsatzvw_rewrite_slug'); - return sanitize_title($option, $this->defaults['einsatzvw_rewrite_slug']); - } - - /** - * @return mixed - */ - public function getTimeFormat() - { - return $this->getOption('time_format'); - } - - /** - * @return bool - */ - public function isAutoIncidentNumbers() - { - return $this->getBoolOption('einsatzverwaltung_incidentnumbers_auto'); - } - - /** - * @return bool - */ - public function isEinsatznummerLfdVorne() - { - $option = $this->getOption('einsatzvw_einsatznummer_lfdvorne'); - return $this->toBoolean($option); - } - - /** - * @since 1.0.0 - * - * @return bool - */ - public function isFlushRewriteRules() - { - return $this->getBoolOption('einsatzvw_flush_rewrite_rules'); - } - - /** - * Gibt die Option einsatzvw_einsatz_hideemptydetails als bool zurück - * - * @return bool - */ - public function isHideEmptyDetails() - { - $option = $this->getOption('einsatzvw_einsatz_hideemptydetails'); - return $this->toBoolean($option); - } - - /** - * Gibt zurück, ob nur als besonders markierte Einsatzberichte zwischen normalen WordPress-Beiträgen angezeigt - * werden sollen - * - * @return bool - */ - public function isOnlySpecialInLoop() - { - return $this->getBoolOption('einsatzvw_loop_only_special'); - } - - - /** - * @return bool - */ - public function isOpenExtEinsatzmittelNewWindow() - { - $option = $this->getOption('einsatzvw_open_ext_in_new'); - return $this->toBoolean($option); - } - - /** - * @param $roleSlug - * - * @return bool - */ - public function isRoleAllowedToEdit($roleSlug) - { - if ($roleSlug === 'administrator') { - return true; - } - - $option = $this->getOption('einsatzvw_cap_roles_' . $roleSlug); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowEinsatzartArchive() - { - $option = $this->getOption('einsatzvw_show_einsatzart_archive'); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowReportsInLoop() - { - $option = $this->getOption('einsatzvw_show_einsatzberichte_mainloop'); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowExtEinsatzmittelArchive() - { - $option = $this->getOption('einsatzvw_show_exteinsatzmittel_archive'); - return $this->toBoolean($option); - } - - /** - * @return bool - */ - public function isShowFahrzeugArchive() - { - $option = $this->getOption('einsatzvw_show_fahrzeug_archive'); - return $this->toBoolean($option); - } - - /** - * @since 1.0.0 - * - * @param bool $value - */ - public function setFlushRewriteRules($value) - { - update_option('einsatzvw_flush_rewrite_rules', $value ? 1 : 0); - } - - /** - * @param $value - * - * @return bool - */ - private function toBoolean($value) - { - return in_array($value, array(1, true, '1', 'yes', 'on'), true); - } -} From a4129e13e58ca26500b4640e05ca2ef81e7b1b48 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Briese Date: Fri, 6 Oct 2017 14:22:35 +0200 Subject: [PATCH 5/7] Einige Probleme nach merge (Fehlende Zeilen) behoben und Anregungen von sebastianroming implementiert --- src/Frontend/ReportList.php | 2 +- src/Model/IncidentReport.php | 2 +- src/einsatzverwaltung-admin.php | 2 +- src/einsatzverwaltung-core.php | 16 +++++++++++ src/einsatzverwaltung-settings.php | 46 ++++++++++++++++++++++++++++++ 5 files changed, 65 insertions(+), 3 deletions(-) diff --git a/src/Frontend/ReportList.php b/src/Frontend/ReportList.php index 551fcf7f..e239e84d 100644 --- a/src/Frontend/ReportList.php +++ b/src/Frontend/ReportList.php @@ -206,7 +206,7 @@ private function constructList($reports, $args) $this->insertTableHeader(); } - if( $this->options->isGMapActivate() != "" && $this->showMap) { + if( $this->options->isGMapActivate() && $this->showMap) { $latLon = explode(",", $this->options->getGMapDefaultPos() ); $mapstring = ""; $mapstring .= "
"; diff --git a/src/Model/IncidentReport.php b/src/Model/IncidentReport.php index 2b3a3177..36a506ac 100644 --- a/src/Model/IncidentReport.php +++ b/src/Model/IncidentReport.php @@ -76,7 +76,7 @@ public static function getMetaFields() 'label' => 'Einsatzort' ), 'einsatz_location' => array( - 'label' => 'Goolemaps Position' + 'label' => 'Google Maps Position' ), 'einsatz_einsatzleiter' => array( 'label' => 'Einsatzleiter' diff --git a/src/einsatzverwaltung-admin.php b/src/einsatzverwaltung-admin.php index 3911281d..7f30a2d7 100644 --- a/src/einsatzverwaltung-admin.php +++ b/src/einsatzverwaltung-admin.php @@ -281,7 +281,7 @@ private function echoInputText($label, $name, $value, $placeholder = '', $size = */ private function echoGMap($location) { - if($location != "") + if(!empty($location )) { $latLon = explode(",",$location); } diff --git a/src/einsatzverwaltung-core.php b/src/einsatzverwaltung-core.php index 32104028..56e5ac7c 100644 --- a/src/einsatzverwaltung-core.php +++ b/src/einsatzverwaltung-core.php @@ -361,6 +361,7 @@ public function onDeactivation() public function onInit() { $this->registerTypes(); + $this->registerScripts(); $this->addRewriteRules(); if ($this->options->isFlushRewriteRules()) { flush_rewrite_rules(); @@ -416,6 +417,21 @@ private function registerTypes() )); } + /** + * Registriert externe Scripts + */ + private function registerScripts() + { + if( $this->options->isGMapActivate() ) { + /* Google Maps */ + $protocal = is_ssl() ? 'https://' : 'http://'; + $url = add_query_arg( array( + 'key' => $this->options->getGMapAPI(), + ), "{$protocal}maps.googleapis.com/maps/api/js"); + wp_register_script( 'einsatzvw_GoogleMap', $url ); + } + } + private function addRewriteRules() { global $wp_rewrite; diff --git a/src/einsatzverwaltung-settings.php b/src/einsatzverwaltung-settings.php index 2e09ec7e..bb5c64d8 100644 --- a/src/einsatzverwaltung-settings.php +++ b/src/einsatzverwaltung-settings.php @@ -192,6 +192,19 @@ public function registerSettings() 'einsatzvw_list_ext_link', array($this->utilities, 'sanitizeCheckbox') ); + register_setting( + 'einsatzvw_settings', + 'einsatzvw_gmap', + array($this->utilities, 'sanitizeCheckbox') + ); + register_setting( + 'einsatzvw_settings', + 'einsatzvw_gmap_api' + ); + register_setting( + 'einsatzvw_settings', + 'einsatzvw_gmap_default_pos' + ); register_setting( 'einsatzvw_settings', 'einsatzvw_list_annotations_color_off', @@ -338,6 +351,13 @@ private function addSettingsFields() self::EVW_SETTINGS_SLUG, 'einsatzvw_settings_einsatzberichte' ); + add_settings_field( + 'einsatzvw_settings_gmap', + 'Google Maps', + array($this, 'echoSettingsGmap'), + self::EVW_SETTINGS_SLUG, + 'einsatzvw_settings_einsatzberichte' + ); add_settings_field( 'einsatzvw_settings_columns', 'Spalten der Einsatzliste', @@ -575,6 +595,32 @@ public function echoSettingsExcerpt() } + /** + * Gibt die Einstellmöglichkeiten für Google-Maps aus + */ + public function echoSettingsGmap() + { + $this->echoSettingsCheckbox( + 'einsatzvw_gmap', + 'Googel Maps aktivieren', + $this->options->isGMapActivate() + ); + echo '

Googel Maps JavaScript API-Key: '; + $this->echoSettingsInput( + 'einsatzvw_gmap_api', + 'Wie generiere ich einen API-Key', + $this->options->getGMapAPI() + ); + echo '

Standartposition der Karte: '; + $this->echoSettingsInput( + 'einsatzvw_gmap_default_pos', + 'Als Lat,Lon: 53.523463,9.482329', + $this->options->getGMapDefaultPos() + ); + } + + + /** * */ From dce28819b6bca6013aadfa3fc23d9923e56401ab Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Briese Date: Fri, 6 Oct 2017 14:52:11 +0200 Subject: [PATCH 6/7] Code Climate improvements --- src/Frontend/ReportList.php | 42 ++++++++++++++++-------------- src/einsatzverwaltung-admin.php | 37 +++++++++++++------------- src/einsatzverwaltung-core.php | 10 +++---- src/einsatzverwaltung-frontend.php | 29 ++++++++++----------- src/einsatzverwaltung-settings.php | 4 +-- 5 files changed, 62 insertions(+), 60 deletions(-) diff --git a/src/Frontend/ReportList.php b/src/Frontend/ReportList.php index e239e84d..2e4fa005 100644 --- a/src/Frontend/ReportList.php +++ b/src/Frontend/ReportList.php @@ -206,16 +206,19 @@ private function constructList($reports, $args) $this->insertTableHeader(); } - if( $this->options->isGMapActivate() && $this->showMap) { - $latLon = explode(",", $this->options->getGMapDefaultPos() ); - $mapstring = ""; - $mapstring .= "

"; - $mapstring .= "
"; - $mapstring .= "
"; - $mapstring .= "
"; - $mapstring .= ""; + if ($this->options->isGMapActivate() && $this->showMap) { + $latLon = explode(",", $this->options->getGMapDefaultPos()); + $mapstring = ""; + $mapstring .= "
"; + $mapstring .= "
"; + $mapstring .= "
"; + $mapstring .= "
"; + $mapstring .= ""; echo "$mapstring"; } @@ -356,17 +359,18 @@ private function insertRow($report) } $this->string .= ''; } - if( $this->options->isGMapActivate() && $this->showMap && $report->getGmapsLocation() != "") { - $latLon = explode(",", $report->getGmapsLocation()); - $timeOfAlerting = $report->getTimeOfAlerting(); - $infoContent = '

' . get_the_title($report->getPostId()) . '

' . $timeOfAlerting->format('d.m.Y H:i') . '

' . $report->getLocation() . '

'; - $marker = ''; - $this->string .= $marker; + if ($this->options->isGMapActivate() && $this->showMap && $report->getGmapsLocation() != "") { + $latLon = explode(",", $report->getGmapsLocation()); + $timeOfAlerting = $report->getTimeOfAlerting(); + $infoContent = '

' . get_the_title($report->getPostId()) . '

'; + $infoContent .= $timeOfAlerting->format('d.m.Y H:i') . '

'; + $infoContent .= $report->getLocation() . '

'; + $marker = ''; + $this->string .= $marker; } $this->string .= ''; - } /** diff --git a/src/einsatzverwaltung-admin.php b/src/einsatzverwaltung-admin.php index 7f30a2d7..ade2a0de 100644 --- a/src/einsatzverwaltung-admin.php +++ b/src/einsatzverwaltung-admin.php @@ -139,13 +139,12 @@ public function enqueueEditScripts($hook) Core::VERSION ); - if($this->options->isGMapActivate()) - { - wp_enqueue_script( 'einsatzvw_GoogleMap' ); - wp_enqueue_script( - 'einsatzverwaltung-gmap', - $this->core->scriptUrl . 'einsatzverwaltung-gmaps.js' - ); + if ($this->options->isGMapActivate()) { + wp_enqueue_script('einsatzvw_GoogleMap'); + wp_enqueue_script( + 'einsatzverwaltung-gmap', + $this->core->scriptUrl . 'einsatzverwaltung-gmaps.js' + ); } } @@ -237,8 +236,7 @@ public function displayMetaBoxEinsatzdetails($post) esc_attr($einsatzort) ); - if($this->options->isGMapActivate()) - { + if ($this->options->isGMapActivate()) { $this->echoGMap($gmapslocation); } @@ -281,26 +279,27 @@ private function echoInputText($label, $name, $value, $placeholder = '', $size = */ private function echoGMap($location) { - if(!empty($location )) - { - $latLon = explode(",",$location); - } - else - { - $latLon = explode(",",$this->options->getGMapDefaultPos()); + if (!empty($location )) { + $latLon = explode(",", $location); + } else { + $latLon = explode(",", $this->options->getGMapDefaultPos()); } echo '
'; echo ''; echo ''; } diff --git a/src/einsatzverwaltung-core.php b/src/einsatzverwaltung-core.php index 56e5ac7c..2cc837db 100644 --- a/src/einsatzverwaltung-core.php +++ b/src/einsatzverwaltung-core.php @@ -361,7 +361,7 @@ public function onDeactivation() public function onInit() { $this->registerTypes(); - $this->registerScripts(); + $this->registerScripts(); $this->addRewriteRules(); if ($this->options->isFlushRewriteRules()) { flush_rewrite_rules(); @@ -422,15 +422,15 @@ private function registerTypes() */ private function registerScripts() { - if( $this->options->isGMapActivate() ) { + if ($this->options->isGMapActivate()) { /* Google Maps */ $protocal = is_ssl() ? 'https://' : 'http://'; - $url = add_query_arg( array( + $url = add_query_arg(array( 'key' => $this->options->getGMapAPI(), ), "{$protocal}maps.googleapis.com/maps/api/js"); - wp_register_script( 'einsatzvw_GoogleMap', $url ); + wp_register_script('einsatzvw_GoogleMap', $url); } - } + } private function addRewriteRules() { diff --git a/src/einsatzverwaltung-frontend.php b/src/einsatzverwaltung-frontend.php index 5d19ac8e..b9a537ef 100644 --- a/src/einsatzverwaltung-frontend.php +++ b/src/einsatzverwaltung-frontend.php @@ -77,13 +77,12 @@ public function enqueueStyleAndScripts() ); wp_add_inline_style('einsatzverwaltung-frontend', ReportList::getDynamicCss()); - if($this->options->isGMapActivate()) - { - wp_enqueue_script( 'einsatzvw_GoogleMap' ); - wp_enqueue_script( - 'einsatzverwaltung-gmap', - $this->core->scriptUrl . 'einsatzverwaltung-gmaps.js' - ); + if ($this->options->isGMapActivate()) { + wp_enqueue_script('einsatzvw_GoogleMap'); + wp_enqueue_script( + 'einsatzverwaltung-gmap', + $this->core->scriptUrl . 'einsatzverwaltung-gmaps.js' + ); } } @@ -175,17 +174,18 @@ public function getEinsatzberichtMap($post) { $report = new IncidentReport($post); $location = $report->getGmapsLocation(); - if($this->options->isGMapActivate() && $location) - { - $latLon = explode(",",$location); + if ($this->options->isGMapActivate() && $location) { + $latLon = explode(",", $location); - $mapstring = ""; + $mapstring = ""; $mapstring .= "
"; $mapstring .= "
"; $mapstring .= "
"; $mapstring .= "
"; $mapstring .= ""; @@ -234,9 +234,8 @@ public function renderContent($content) $header = $this->getEinsatzberichtHeader($post, true, true); $content = $this->prepareContent($content); $map = ""; - if($this->options->isGMapActivate()) - { - $map = $this->getEinsatzberichtMap($post); + if ($this->options->isGMapActivate()) { + $map = $this->getEinsatzberichtMap($post); } return $header . $map . '
' . $content; diff --git a/src/einsatzverwaltung-settings.php b/src/einsatzverwaltung-settings.php index bb5c64d8..1ac24a93 100644 --- a/src/einsatzverwaltung-settings.php +++ b/src/einsatzverwaltung-settings.php @@ -204,7 +204,7 @@ public function registerSettings() register_setting( 'einsatzvw_settings', 'einsatzvw_gmap_default_pos' - ); + ); register_setting( 'einsatzvw_settings', 'einsatzvw_list_annotations_color_off', @@ -357,7 +357,7 @@ private function addSettingsFields() array($this, 'echoSettingsGmap'), self::EVW_SETTINGS_SLUG, 'einsatzvw_settings_einsatzberichte' - ); + ); add_settings_field( 'einsatzvw_settings_columns', 'Spalten der Einsatzliste', From 1933af4d8547ef045468792ab580499cc23573ae Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Briese Date: Sat, 7 Oct 2017 17:13:57 +0200 Subject: [PATCH 7/7] Typo in den Settings Googel --> Google --- src/einsatzverwaltung-settings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/einsatzverwaltung-settings.php b/src/einsatzverwaltung-settings.php index 1ac24a93..f55f2485 100644 --- a/src/einsatzverwaltung-settings.php +++ b/src/einsatzverwaltung-settings.php @@ -602,10 +602,10 @@ public function echoSettingsGmap() { $this->echoSettingsCheckbox( 'einsatzvw_gmap', - 'Googel Maps aktivieren', + 'Google Maps aktivieren', $this->options->isGMapActivate() ); - echo '

Googel Maps JavaScript API-Key: '; + echo '

Google Maps JavaScript API-Key: '; $this->echoSettingsInput( 'einsatzvw_gmap_api', 'Wie generiere ich einen API-Key',

'; echo ''; echo ''; echo ''; - echo ''; + echo ''; echo '
'; echo '
'; echo '
'; echo ''; echo ''; - echo ''; - echo ''; + echo ''; + echo ''; echo '
'; echo '
'; echo '