diff --git a/docs/example/geolocation_div.php b/docs/example/geolocation_div.php
index b657f51..0fbaafa 100644
--- a/docs/example/geolocation_div.php
+++ b/docs/example/geolocation_div.php
@@ -1,64 +1,76 @@
.
+ *
+ * Es finden nur formale Prüfungen statt. Fehlende Werte werden nicht durch Defaults ersetzt.
+ * Hier wird aus Eingangsdaten HTML gebaut, mehr nicht.
+ *
+ *
+ */
-Es finden nur formale Prüfungen statt. Fehlende Werte werden nicht durch Defaults ersetzt.
-Hier wird aus Eingangsdaten HTML gebaut, mehr nicht.
+namespace Geolocation;
+
+/**
+ * @var \rex_fragment $this
+ */
-
-*/
$classes = [];
$attributes = [];
// dataset muss ein Array sein
-if( isset($this->dataset) && is_array($this->dataset) ) {
+if (isset($this->dataset) && \is_array($this->dataset)) {
$attributes['dataset'] = json_encode($this->dataset);
}
// mapset muss ein Array sein
-if( isset($this->mapset) && is_array($this->mapset) ) {
+if (isset($this->mapset) && \is_array($this->mapset)) {
$attributes['mapset'] = json_encode($this->mapset);
}
// map (Kartenoptionen) muss ein Array sein
-if( isset($this->map) && is_array($this->map) ) {
+if (isset($this->map) && \is_array($this->map)) {
$attributes['map'] = json_encode($this->map);
}
// Klassen hinzufügen (string oder array)
-if( isset($this->class) ) {
+if (isset($this->class)) {
$class = $this->class;
- if( is_string($class) && $class) $class = explode(' ',$class);
- if( is_array($class) && $class ) $classes = array_merge($classes,$class);
+ if (\is_string($class)) {
+ $class = explode(' ', $class);
+ }
+ if (\is_array($class)) {
+ $classes = array_merge($classes, $class);
+ }
}
-if( $classes ) {
+$classes = array_filter($classes, 'trim');
+if (0 < \count($classes)) {
$attributes['class'] = array_unique($classes);
}
// Schript-Code für Events einfügen
-if( isset($this->events) && is_array($this->events) && count($this->events) ) {
+if (isset($this->events) && \is_array($this->events) && 0 < \count($this->events)) {
$code = '';
- $id = 'rm'.md5( microtime() );
- foreach( $this->events as $k=>$v ) {
+ $id = 'rm'.md5(microtime());
+ foreach ($this->events as $k => $v) {
$exit = 'if( !e.detail.container.hasAttribute(\''.$id.'\') ) return;';
$code .= 'document.addEventListener(\'geolocation.'.$k.'\', function(e){'.$exit.'console.log(e);'.$v.'});';
}
- if( $code ) {
+ if ('' < $code) {
echo '';
$attributes[$id] = 1;
}
}
// sonstige Attribute hinzufügen (class,dataset,mapset,map ignorieren)
-if( isset($this->attributes) && is_array($this->attributes) && count($this->attributes) ) {
+if (isset($this->attributes) && \is_array($this->attributes) && 0 < \count($this->attributes)) {
$attributes = array_merge(
$attributes,
- array_diff_key($this->attributes,['mapset'=>null,'dataset'=>null,'map'=>null,'class'=>null])
+ array_diff_key($this->attributes, ['mapset' => null, 'dataset' => null, 'map' => null, 'class' => null])
);
}
// HTML-Tag generieren
-$id = 'rm-' . md5(time());
+$id = 'rm-' . md5(microtime());
?>