From be9060795df6fb88e80d704e102ff52d6210497b Mon Sep 17 00:00:00 2001 From: David Molineus Date: Mon, 5 Jan 2015 12:25:46 +0100 Subject: [PATCH] Ongoing development. --- module/assets/css/backend.css | 2 +- module/assets/img/control.png | Bin 0 -> 778 bytes module/assets/img/fol-placeholder.gif | Bin 0 -> 208 bytes module/assets/img/folPlus.gif | Bin 222 -> 0 bytes module/assets/img/geolocation_sight.png | Bin 0 -> 1400 bytes module/assets/img/geotag.png | Bin 0 -> 1499 bytes module/assets/img/sitemap_image.png | Bin 0 -> 1406 bytes module/assets/img/table_heatmap.png | Bin 0 -> 1472 bytes module/assets/img/tile.png | Bin 0 -> 686 bytes module/config/config.php | 37 ++++- module/dca/tl_leaflet_control.php | 151 ++++++++++++++++-- module/dca/tl_leaflet_layer.php | 19 ++- module/dca/tl_leaflet_map.php | 8 + src/Netzmacht/Contao/Leaflet/Dca/Control.php | 25 +++ src/Netzmacht/Contao/Leaflet/Dca/Layer.php | 51 ++++++ .../Contao/Leaflet/Mapper/AbstractMapper.php | 17 +- ...LayerMapper.php => AbstractTypeMapper.php} | 2 +- .../Mapper/Control/AbstractControlMapper.php | 32 ++++ .../Mapper/Control/LayersControlMapper.php | 30 ++++ .../Mapper/Control/ScaleControlMapper.php | 44 +++++ .../Mapper/Control/ZoomControlMapper.php | 48 ++++++ .../Mapper/Layer/ProviderLayerMapper.php | 4 +- .../Contao/Leaflet/Mapper/MapMapper.php | 13 ++ .../Contao/Leaflet/Model/ControlModel.php | 17 ++ .../Leaflet/Subscriber/EncoderSubscriber.php | 5 +- 25 files changed, 472 insertions(+), 33 deletions(-) create mode 100644 module/assets/img/control.png create mode 100644 module/assets/img/fol-placeholder.gif delete mode 100644 module/assets/img/folPlus.gif create mode 100644 module/assets/img/geolocation_sight.png create mode 100644 module/assets/img/geotag.png create mode 100644 module/assets/img/sitemap_image.png create mode 100644 module/assets/img/table_heatmap.png create mode 100644 module/assets/img/tile.png create mode 100644 src/Netzmacht/Contao/Leaflet/Dca/Control.php rename src/Netzmacht/Contao/Leaflet/Mapper/{AbstractLayerMapper.php => AbstractTypeMapper.php} (87%) create mode 100644 src/Netzmacht/Contao/Leaflet/Mapper/Control/AbstractControlMapper.php create mode 100644 src/Netzmacht/Contao/Leaflet/Mapper/Control/LayersControlMapper.php create mode 100644 src/Netzmacht/Contao/Leaflet/Mapper/Control/ScaleControlMapper.php create mode 100644 src/Netzmacht/Contao/Leaflet/Mapper/Control/ZoomControlMapper.php create mode 100644 src/Netzmacht/Contao/Leaflet/Model/ControlModel.php diff --git a/module/assets/css/backend.css b/module/assets/css/backend.css index 3e5bb71..187249c 100644 --- a/module/assets/css/backend.css +++ b/module/assets/css/backend.css @@ -1,6 +1,6 @@ .tl_listing_container.tree_view ul > li.tl_file { - background: url('./../img/folPlus.gif') no-repeat 6px 1px; + background: url('./../img/fol-placeholder.gif') no-repeat 6px 1px; } .tl_listing_container.tree_view > ul > li.tl_file { diff --git a/module/assets/img/control.png b/module/assets/img/control.png new file mode 100644 index 0000000000000000000000000000000000000000..f906ed6444a69bab70d1777fe1ee5ecee7a298d0 GIT binary patch literal 778 zcmV+l1NHogP)*GBuM{$Xoyb0+&fd zK~y-)t&>Yg)L|6Gf8Y0i%&T#nqSCA=wd@I5P!vT$_MmbjgtoFpL_zzApjASvz#xiT z6fGnpYEz_zP!t84MuS*liDMd!<)T}!1A z>WwkWb2+W`h^5ro$7lC8{FPwqxd#gZj$Oa4Y+=puighfCS~E?fNx1p+9nEhBo{vpr zYunEs>dV#aT;O-C`Xk#*YmV$JmOHP8)s!9ly+J`Tk)XC>m6R4lwqI-QZYVn0RQ35v z^%#H!u)D6Ma_fqMx?}rROY_@tb@~1qB0fb~Q54sL%XeR}cFjt)eo0uenQZZo$?V7I zmg@8_Zr@R7uE6MD|9oo7- zvLtNC3s^KhdQBp2@uV|Oe$a=WmR)ie$`J^lm0{P0B8m$_96PX{a6r)>PjmY4MqUm4 zBob7pS;I2~N=za?4s$~mT7ejah+tdbXlU&kBI4KN2Vgh_o@a0{GDDCW?!S2JSr3JI zil7Tw1C{~|RBu^8+uK1ZH_j*GKyybwqeBB%C%^P$XB#SS$C=w*O`SuM5;0A&5s8gv zq%S2hI3;queMmeJY3Ui2gLU@@g5^~uxxt*>(khT2>r1-ji7B^mfB9mTg)PDkgfuK& zIETg;ac(~BjCZ|kJ*9ddwWpHf^5-wu!Q#!U*HzTiE?%|agl*d)nQrimF~jlR8*TR* zu397AvDD9G`mfLAk1mQT$1MT;GA*}KDkEMtKKbp_7ydVX0lh^DRRX8KK>z>%07*qo IM6N<$f{Hs`;s5{u literal 0 HcmV?d00001 diff --git a/module/assets/img/fol-placeholder.gif b/module/assets/img/fol-placeholder.gif new file mode 100644 index 0000000000000000000000000000000000000000..9ee6972e456c7ee4581550ccf927a5baa4a5b5d2 GIT binary patch literal 208 zcmZ?wbhEHb6k-r!Xc1#LeE7`Kqvy__zkcDujZ2qqUcY|t#*O>8Zautp>&e}_kM7=m z_V(@P4m8Wrj$J~Sw@QJiwv?Q+Wk2kpL0 l&WRyG5>Z0ecTKq_HPKz=Qief|dbp2U^3C@@YBX6GtO478Zautp>&e}_kM7=m z_V(@P4Lc-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxKsVXI%uvD1M9IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr4|esh*)icxGNo zet9uiy|1s8XI^nhVqS8pr;Du;&;-5A%oHm}6AMRULl<*%Ge;*wLsugULo-VYGgAX+ zXGaTTb5~QCUYGpj(%jU%5}4i;gkB4rdO=Acw*Y9fOKMSOS!#+~QGTuh*vnR#xZPrk z(>$o&6x?nx!>Lyv=oo!a#3DsBObD2IKumbD1#;jCKQ#}S+KYh6dZMgw5d#C`8&4O< zkcwMNg3szRJBrModG}Y&N@h;Mg{~b(wy#xC68zs#Fm1=m9TPt2hwR|g>zm`DqEsj# zetfEylgDL#7oE;U)0V1UtG<1A)wSaXz3Z&^e}DG(-nl(97p__*77gu$iiafT%j)76*)8)y*&t0B( zz2kR$H)r8xt}7v-=7z`S^dvutt-WvYvC?|U>(#1X1Wzbl>no1x*{FEs2)BUK@{Lxh zJ|BP89v1k(AlD2#d>uW34aUb7ZP$AN`VB?;{j~72%@|Rs+?&-!o zF|Tb3d>5N;+_=us_uZ7|3H@rnc(;DlwA}q$Zq-_b?_a0?og%C)a9f@8Zrhy31cyI* zAJs&pdfXOox|)@1m_GaX{y9uJ&QBijv;O=U{9sqygBT&r`NDge7gi zY0b^u?dD^nufi37|DKEIt~nps|J>I2_s#I-G*%6^h)H#N%z6x7r?UU_*K!yztlNJs UTKxLi*Pyb{)78&qol`;+0F*cfkpKVy literal 0 HcmV?d00001 diff --git a/module/assets/img/geotag.png b/module/assets/img/geotag.png new file mode 100644 index 0000000000000000000000000000000000000000..8de98527ee484590c09713d68175224a52a8f46c GIT binary patch literal 1499 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+n3Xa^B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxKsVXI%uvD1M9IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bS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5A%oHnU19Mk%BMVnkOH*@0LsugUV@Fp@3v(A! z3pZ0kHw#CYUYGpj(%jU%5}4i;gkCqCdO=Acw*Y9fOKMSOS!#+~QGTuh*vnR#xZUE6 z(>$o&6x?oc!Kqgt=oo!a#3DsBObD2IKumbD1#;jCKQ#}S+KYh6+N0&c90mr)Po6H0 zAr-fJg1x<^14aJ5n|rY}se`}cuEz$BwI$D;G(%Q$o5voRs#mMiRqw#9C%W-&NvyMO z6l-S9g3@4l7p1ic-49NQrz8em)G+-hT3S?G{m!L*hU67y`R_&hiuYB|_{{6SdU zjt|GP$)3y;n0gF_cO6@9C6)c^a`w_G7mQg$ikEMfdp&hxh#<3xmAadgodwHzAC;F+ z_lF9$=rbfIi#<(Vs$m_`vSGRv_l1}f3l}ShfB5&Cc}|LQ;0Kvc8<~7gJ6-(dzUR+J zo^`7WzxcgV_?;m#$Jm|mwt2_=<4t!@ug_v#y;O~NkL#lJmr@@$dkFOR1Ua=HO5Y!U z?_U0=6L*?SuZ#az-@0BR_4690txlSktLwJ!%U$gwzC*b7Z}Ut2TNkd|E944KDC`sV zd^XJ~z-xwbVb#pne;&j-mwx4Cku<7^JM_*5W&d}Hq z6@K`J^sk8~b4)$YlX`Q{K$P||F$1#ojXM*^WXLRG37y-LC6$=ef`T#+x~MK ZFmTR$?sSCbuOz5M^mO%eS?83{1OP7-2bTZ< literal 0 HcmV?d00001 diff --git a/module/assets/img/table_heatmap.png b/module/assets/img/table_heatmap.png new file mode 100644 index 0000000000000000000000000000000000000000..f5b1782fee48c36ca0b8ac47db8e9aa557592eb1 GIT binary patch literal 1472 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+n3Xa^B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(A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#y=p0!HS^b&9w1?Sagmr(M9?L%j6bk zp`yW60{a8dco6a`(#*>gwV@-}s-5Z3D88WTgnGHb)Ad!8VO1J>7b1&T?;tZeplq8| zevHKNaTRKvyfirK&2IY2zm)LxlPV*84jI49TFnsYmOiq{1}2|$^ENi3#0By9v8utc zs7UC5JA|ju!AgBUO&w`=xjbrY?_qwtg~x6}7&!uMtvdzE<9hpiq;x#E<)Pk$Q|y3c zh%Esp8;d9JhW&ZFV&-KT UHd?uuFaQ7m07*qoM6N<$f*>S1x&QzG literal 0 HcmV?d00001 diff --git a/module/config/config.php b/module/config/config.php index 70a1ef2..c01540a 100644 --- a/module/config/config.php +++ b/module/config/config.php @@ -4,7 +4,7 @@ * Backend module. */ $GLOBALS['BE_MOD']['content']['leaflet'] = array( - 'tables' => array('tl_leaflet_map', 'tl_leaflet_layer'), + 'tables' => array('tl_leaflet_map', 'tl_leaflet_layer', 'tl_leaflet_control'), 'icon' => 'system/modules/leaflet/assets/img/leaflet.png', 'stylesheet' => 'system/modules/leaflet/assets/css/backend.css', ); @@ -18,8 +18,9 @@ $GLOBALS['TL_CTE']['includes']['leaflet'] = 'Netzmacht\Contao\Leaflet\LeafletMap /* * Models. */ -$GLOBALS['TL_MODELS']['tl_leaflet_map'] = 'Netzmacht\Contao\Leaflet\Model\MapModel'; -$GLOBALS['TL_MODELS']['tl_leaflet_layer'] = 'Netzmacht\Contao\Leaflet\Model\LayerModel'; +$GLOBALS['TL_MODELS']['tl_leaflet_map'] = 'Netzmacht\Contao\Leaflet\Model\MapModel'; +$GLOBALS['TL_MODELS']['tl_leaflet_layer'] = 'Netzmacht\Contao\Leaflet\Model\LayerModel'; +$GLOBALS['TL_MODELS']['tl_leaflet_control'] = 'Netzmacht\Contao\Leaflet\Model\ControlModel'; /* @@ -30,6 +31,10 @@ $GLOBALS['TL_MODELS']['tl_leaflet_layer'] = 'Netzmacht\Contao\Leaflet\Model\Laye $GLOBALS['LEAFLET_MAPPERS'] = array(); $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\MapMapper'; $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\ProviderLayerMapper'; +$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\ZoomControlMapper'; +$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\ScaleControlMapper'; +$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\LayersControlMapper'; + /* * Leaflet encoders. @@ -50,12 +55,34 @@ $GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\RasterEncoder'; $GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\VectorEncoder'; $GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\Contao\Leaflet\Subscriber\EncoderSubscriber'; -$GLOBALS['LEAFLET_LAYERS'][] = 'provider'; + +/* + * Leaflet layer types. + * + * The type is used for the database driven definitions. + */ +$GLOBALS['LEAFLET_LAYERS'] = array(); +$GLOBALS['LEAFLET_LAYERS']['default'] = array('children' => true); +$GLOBALS['LEAFLET_LAYERS']['provider'] = array('children' => false); +$GLOBALS['LEAFLET_LAYERS']['group'] = array('children' => true, 'geojson' => true); + + +/* + * leaflet controls. + * + * Supported leaflet control types. Register your type for the database driven definition here. + */ +$GLOBALS['LEAFLET_CONTROLS'] = array(); +$GLOBALS['LEAFLET_CONTROLS'][] = 'zoom'; +$GLOBALS['LEAFLET_CONTROLS'][] = 'layers'; +$GLOBALS['LEAFLET_CONTROLS'][] = 'scale'; +$GLOBALS['LEAFLET_CONTROLS'][] = 'attribution'; + /* * Leaflet tile layer providers. */ -require_once __DIR__ . '/leaflet_providers.php'; +require_once TL_ROOT . '/system/modules/leaflet/config/leaflet_providers.php'; /* * Leaflet assets. diff --git a/module/dca/tl_leaflet_control.php b/module/dca/tl_leaflet_control.php index 158d86a..89abd47 100644 --- a/module/dca/tl_leaflet_control.php +++ b/module/dca/tl_leaflet_control.php @@ -5,6 +5,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array 'config' => array( 'dataContainer' => 'Table', 'enableVersioning' => true, + 'ptable' => 'tl_leaflet_map', 'sql' => array ( 'keys' => array @@ -19,14 +20,16 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array ( 'sorting' => array ( - 'mode' => 1, - 'fields' => array('title'), - 'flag' => 1 + 'mode' => 4, + 'fields' => array('sorting'), + 'headerFields' => array('title'), + 'flag' => 1, + 'child_record_callback' => array('Netzmacht\Contao\Leaflet\Dca\Control', 'generateRow'), ), 'label' => array ( 'fields' => array('title'), - 'format' => '%s' + 'format' => '%s', ), 'global_operations' => array ( @@ -68,18 +71,24 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array ) ), + 'palettes' => array( + '__selector__' => array('type') + ), + 'metapalettes' => array( 'default' => array( - 'name' => array('title', 'type', 'position'), + 'name' => array('title', 'alias', 'type', 'position'), + 'config' => array(), + 'active' => array('active') ), 'zoom extends default' => array( - 'zoom' => array('zoomInText', 'zoomOutText', 'zoomInTitle', 'zoomOutTitle'), + 'config' => array('zoomInText', 'zoomOutText', 'zoomInTitle', 'zoomOutTitle'), ), 'layers extends default' => array( - 'layers' => array('collapsed', 'autoZIndex') + 'config' => array('layers', 'collapsed', 'autoZIndex') ), 'scale extends default' => array( - 'scale' => array('maxWidth', 'scale', 'updateWhenIdle') + 'config' => array('maxWidth', 'metric', 'imperial', 'updateWhenIdle') ) ), @@ -89,33 +98,72 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array ( 'sql' => "int(10) unsigned NOT NULL auto_increment" ), + 'pid' => array + ( + 'sql' => "int(10) unsigned NOT NULL default '0'" + ), 'tstamp' => array ( 'sql' => "int(10) unsigned NOT NULL default '0'" ), + 'sorting' => array + ( + 'sql' => "int(10) unsigned NOT NULL default '0'" + ), 'title' => array ( 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['title'], 'exclude' => true, 'inputType' => 'text', - 'eval' => array('mandatory' => true, 'maxlength' => 255), + 'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''" ), + 'alias' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['alias'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), + 'sql' => "varchar(255) NOT NULL default ''" + ), + 'type' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['type'], + 'exclude' => true, + 'inputType' => 'select', + 'eval' => array( + 'mandatory' => true, + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'submitOnChange' => true, + 'chosen' => true, + ), + 'options' => $GLOBALS['LEAFLET_CONTROLS'], + 'sql' => "varchar(32) NOT NULL default ''" + ), 'position' => array ( 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['position'], 'exclude' => true, 'inputType' => 'select', 'options' => array('topleft', 'topright', 'bottomleft', 'bottomright'), - 'eval' => array('mandatory' => true, 'maxlength' => 255), + 'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''" ), + 'active' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['active'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => array('tl_class' => 'w50'), + 'sql' => "char(1) NOT NULL default ''" + ), 'zoomInText' => array ( 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInText'], 'exclude' => true, 'inputType' => 'text', - 'eval' => array('mandatory' => true, 'maxlength' => 255), + 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''" ), 'zoomOutText' => array @@ -123,7 +171,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInText'], 'exclude' => true, 'inputType' => 'text', - 'eval' => array('mandatory' => true, 'maxlength' => 255), + 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''" ), 'zoomInTitle' => array @@ -131,7 +179,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInText'], 'exclude' => true, 'inputType' => 'text', - 'eval' => array('mandatory' => true, 'maxlength' => 255), + 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''" ), 'zoomOutTitle' => array @@ -139,7 +187,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInText'], 'exclude' => true, 'inputType' => 'text', - 'eval' => array('mandatory' => true, 'maxlength' => 255), + 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''" ), 'collapsed' => array @@ -148,7 +196,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array 'exclude' => true, 'inputType' => 'checkbox', 'default' => '1', - 'eval' => array(), + 'eval' => array('tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''" ), 'autoZIndex' => array @@ -157,7 +205,78 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array 'exclude' => true, 'inputType' => 'checkbox', 'default' => '1', - 'eval' => array(), + 'eval' => array('tl_class' => 'w50'), + 'sql' => "char(1) NOT NULL default ''" + ), + 'layers' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['layers'], + 'exclude' => true, + 'inputType' => 'multiColumnWizard', + 'eval' => array + ( + 'tl_class' => 'clr', + 'columnFields' => array + ( + 'layer' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['layer'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\Control', 'getLayers'), + 'eval' => array( + 'style' => 'width: 200px', + 'chosen' => true, + 'includeBlankOption' => true + ), + ), + 'mode' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['layer'], + 'exclude' => true, + 'inputType' => 'select', + 'options' => array('base', 'overlay'), + 'eval' => array( + 'style' => 'width: 200px' + ), + ), + ) + ), + 'sql' => "mediumblob NULL" + ), + 'maxWidth' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['maxWidth'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => 100, + 'eval' => array('tl_class' => 'w50', 'rgxp' => 'digit'), + 'sql' => "int(5) NOT NULL default '100'" + ), + 'metric' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['metric'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => '1', + 'eval' => array('tl_class' => 'w50 clr'), + 'sql' => "char(1) NOT NULL default '1'" + ), + 'imperial' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['imperial'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => '1', + 'eval' => array('tl_class' => 'w50'), + 'sql' => "char(1) NOT NULL default '1'" + ), + 'updateWhenIdle' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['updateWhenIdle'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => array('tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''" ), ), diff --git a/module/dca/tl_leaflet_layer.php b/module/dca/tl_leaflet_layer.php index 21ea9ae..8a2d861 100644 --- a/module/dca/tl_leaflet_layer.php +++ b/module/dca/tl_leaflet_layer.php @@ -20,7 +20,8 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = array 'mode' => 5, 'fields' => array('title'), 'flag' => 1, - 'icon' => 'system/modules/leaflet/assets/img/layers.png' + 'icon' => 'system/modules/leaflet/assets/img/layers.png', + 'paste_button_callback' => array('Netzmacht\Contao\Leaflet\Dca\Layer', 'getPasteButtons'), ), 'label' => array ( @@ -29,6 +30,13 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = array ), 'global_operations' => array ( + 'map' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['map'], + 'href' => 'table=tl_leaflet_map', + 'icon' => 'system/modules/leaflet/assets/img/leaflet.png', + 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="m"' + ), 'all' => array ( 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], @@ -51,6 +59,13 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = array 'href' => 'act=copy', 'icon' => 'copy.gif' ), + 'cut' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['cut'], + 'href' => 'act=paste&mode=cut', + 'icon' => 'cut.gif', + 'attributes' => 'onclick="Backend.getScrollOffset()"', + ), 'delete' => array ( 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['delete'], @@ -129,7 +144,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = array 'submitOnChange' => true, 'chosen' => true, ), - 'options' => &$GLOBALS['LEAFLET_LAYERS'], + 'options' => array_keys($GLOBALS['LEAFLET_LAYERS']), 'sql' => "varchar(32) NOT NULL default ''" ), 'tile_provider' => array( diff --git a/module/dca/tl_leaflet_map.php b/module/dca/tl_leaflet_map.php index 64511fb..99a87fe 100644 --- a/module/dca/tl_leaflet_map.php +++ b/module/dca/tl_leaflet_map.php @@ -5,6 +5,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array 'config' => array( 'dataContainer' => 'Table', 'enableVersioning' => true, + 'ctable' => array('tl_leaflet_control'), 'sql' => array ( 'keys' => array @@ -52,6 +53,13 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array 'href' => 'act=edit', 'icon' => 'header.gif' ), + 'controls' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['controls'], + 'href' => 'table=tl_leaflet_control', + 'icon' => 'system/modules/leaflet/assets/img/control.png', + 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"' + ), 'copy' => array ( 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['copy'], diff --git a/src/Netzmacht/Contao/Leaflet/Dca/Control.php b/src/Netzmacht/Contao/Leaflet/Dca/Control.php new file mode 100644 index 0000000..eebe592 --- /dev/null +++ b/src/Netzmacht/Contao/Leaflet/Dca/Control.php @@ -0,0 +1,25 @@ + + * @copyright 2015 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + +namespace Netzmacht\Contao\Leaflet\Dca; + + +class Control +{ + public function generateRow($row) + { + return sprintf( + '%s [%s]', + $row['title'], + $row['type'] + ); + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Dca/Layer.php b/src/Netzmacht/Contao/Leaflet/Dca/Layer.php index a7047dd..44037c2 100644 --- a/src/Netzmacht/Contao/Leaflet/Dca/Layer.php +++ b/src/Netzmacht/Contao/Leaflet/Dca/Layer.php @@ -14,6 +14,12 @@ namespace Netzmacht\Contao\Leaflet\Dca; class Layer { + private $layers; + + public function __construct() + { + $this->layers = &$GLOBALS['LEAFLET_LAYERS']; + } public function getVariants($dataContainer) { if ($dataContainer->activeRecord @@ -25,4 +31,49 @@ class Layer return array(); } + + // Call paste_button_callback (&$dc, $row, $table, $cr, $childs, $previous, $next) + public function getPasteButtons($dataContainer, $row, $table, $whatever, $children) + { + $pasteAfterUrl = \Controller::addToUrl( + 'act='.$children['mode'].'&mode=1&pid='.$row['id'] + .(!is_array($children['id']) ? '&id='.$children['id'] : '') + ); + + $buffer = sprintf( + '%s ', + $pasteAfterUrl, + specialchars(sprintf($GLOBALS['TL_LANG'][$table]['pasteafter'][1], $row['id'])), + \Image::getHtml( + 'pasteafter.gif', + sprintf($GLOBALS['TL_LANG'][$table]['pasteafter'][1], $row['id']) + ) + ); + + if (!empty($this->layers[$row['type']]['children'])) { + $pasteIntoUrl = \Controller::addToUrl( + sprintf( + 'act=%s&mode=2&pid=%s%s', + $children['mode'], + $row['id'], + !is_array($children['id']) ? '&id='.$children['id'] : '' + ) + ); + + $buffer .= sprintf( + '%s ', + $pasteIntoUrl, + specialchars(sprintf($GLOBALS['TL_LANG'][$table]['pasteinto'][1], $row['id'])), + \Image::getHtml( + 'pasteinto.gif', + sprintf($GLOBALS['TL_LANG'][$table]['pasteinto'][1], $row['id']) + ) + ); + + } elseif ($row['id'] > 0) { + $buffer .= \Image::getHtml('pasteinto_.gif'); + } + + return $buffer; + } } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/AbstractMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/AbstractMapper.php index 0713928..ca4f484 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/AbstractMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/AbstractMapper.php @@ -20,6 +20,9 @@ use Netzmacht\LeafletPHP\Definition; */ abstract class AbstractMapper implements Mapper { + const VALUE_NOT_EMPTY = '__value_not_empty__'; + const VALUE_EMPTY = '__value_empty__'; + /** * Class of the model being build. * @@ -109,8 +112,10 @@ abstract class AbstractMapper implements Mapper * * @return $this */ - public function addConditionalOption($column, $option, $mapping = null, $value = '1') + public function addConditionalOption($column, $option = null, $mapping = null, $value = self::VALUE_NOT_EMPTY) { + $option = $option ?: $column; + if (!isset($this->conditional[$column][$value][$option])) { $this->conditional[$column][$value][$option] = $this->getMapping($option, $mapping); } @@ -127,7 +132,7 @@ abstract class AbstractMapper implements Mapper * * @return $this */ - public function addConditionalOptions($column, array $options, $value = '1') + public function addConditionalOptions($column, array $options, $value = self::VALUE_NOT_EMPTY) { foreach ($options as $key => $option) { if (is_numeric($key)) { @@ -214,7 +219,7 @@ abstract class AbstractMapper implements Mapper protected function buildConstructArguments(\Model $model, DefinitionMapper $mapper) { return array( - $model->alias ?: $model->id + $model->alias ?: (str_replace('tl_leaflet_', '', $model->getTable()) . '_' . $model->id) ); } @@ -243,7 +248,11 @@ abstract class AbstractMapper implements Mapper { foreach ($this->conditional as $column => $conditions) { foreach ($conditions as $value => $options) { - if ($model->$column == $value) { + if ($value === static::VALUE_EMPTY && empty($model->$column)) { + $this->applyOptions($options, $definition, $model); + } elseif ($value === static::VALUE_NOT_EMPTY && !empty($model->$column)) { + $this->applyOptions($options, $definition, $model); + } elseif ($model->$column == $value) { $this->applyOptions($options, $definition, $model); } } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/AbstractLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/AbstractTypeMapper.php similarity index 87% rename from src/Netzmacht/Contao/Leaflet/Mapper/AbstractLayerMapper.php rename to src/Netzmacht/Contao/Leaflet/Mapper/AbstractTypeMapper.php index 875c587..8a16af6 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/AbstractLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/AbstractTypeMapper.php @@ -12,7 +12,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper; -abstract class AbstractLayerMapper extends AbstractMapper +abstract class AbstractTypeMapper extends AbstractMapper { protected static $type; diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/AbstractControlMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Control/AbstractControlMapper.php new file mode 100644 index 0000000..74779fb --- /dev/null +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Control/AbstractControlMapper.php @@ -0,0 +1,32 @@ + + * @copyright 2015 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + +namespace Netzmacht\Contao\Leaflet\Mapper\Control; + +use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; + +class AbstractControlMapper extends AbstractTypeMapper +{ + /** + * Class of the model being build. + * + * @var string + */ + protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\ControlModel'; + + /** + * {@inheritdoc} + */ + protected function initialize() + { + $this->addOption('position'); + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/LayersControlMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Control/LayersControlMapper.php new file mode 100644 index 0000000..a641b1e --- /dev/null +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Control/LayersControlMapper.php @@ -0,0 +1,30 @@ + + * @copyright 2015 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + +namespace Netzmacht\Contao\Leaflet\Mapper\Control; + + +class LayersControlMapper extends AbstractControlMapper +{ + /** + * Class of the definition being created. + * + * @var string + */ + protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Layers'; + + /** + * Layer type. + * + * @var string + */ + protected static $type = 'layers'; +} diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/ScaleControlMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Control/ScaleControlMapper.php new file mode 100644 index 0000000..aa7e4ff --- /dev/null +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Control/ScaleControlMapper.php @@ -0,0 +1,44 @@ + + * @copyright 2015 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + +namespace Netzmacht\Contao\Leaflet\Mapper\Control; + +/** + * Class ScaleControlMapper maps the database item of the type "scale" to the scale control. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Control + */ +class ScaleControlMapper extends AbstractControlMapper +{ + /** + * Class of the definition being created. + * + * @var string + */ + protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Scale'; + + /** + * Layer type. + * + * @var string + */ + protected static $type = 'scale'; + + /** + * {@inheritdoc} + */ + protected function initialize() + { + parent::initialize(); + + $this->addOptions('maxWidth', 'metric', 'imperial', 'updateWhenIdle'); + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/ZoomControlMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Control/ZoomControlMapper.php new file mode 100644 index 0000000..e510ece --- /dev/null +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Control/ZoomControlMapper.php @@ -0,0 +1,48 @@ + + * @copyright 2015 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + +namespace Netzmacht\Contao\Leaflet\Mapper\Control; + +/** + * Class ZoomControlMapper maps the zoom database definition to the zoom control. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Control + */ +class ZoomControlMapper extends AbstractControlMapper +{ + /** + * Class of the definition being created. + * + * @var string + */ + protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Zoom'; + + /** + * Layer type. + * + * @var string + */ + protected static $type = 'zoom'; + + /** + * {@inheritdoc} + */ + protected function initialize() + { + parent::initialize(); + + $this + ->addConditionalOption('zoomInText') + ->addConditionalOption('zoomOutText') + ->addConditionalOption('zoomInTitle') + ->addConditionalOption('zoomOutTitle'); + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php index 6636b52..f605f39 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php @@ -12,11 +12,11 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer; -use Netzmacht\Contao\Leaflet\Mapper\AbstractLayerMapper; +use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\LeafletPHP\Definition; -class ProviderLayerMapper extends AbstractLayerMapper +class ProviderLayerMapper extends AbstractTypeMapper { /** * Class of the model being build. diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php index 521589e..67e10d8 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php @@ -11,6 +11,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper; +use Netzmacht\Contao\Leaflet\Model\ControlModel; use Netzmacht\Contao\Leaflet\Model\LayerModel; use Netzmacht\Contao\Leaflet\Model\MapModel; use Netzmacht\LeafletPHP\Definition; @@ -93,6 +94,18 @@ class MapMapper extends AbstractMapper */ private function buildControls(Map $map, MapModel$model, DefinitionMapper $mapper) { + $collection = ControlModel::findBy( + array('pid=?', 'active=1'), + array($model->id), + array('order' => 'sorting') + ); + + if ($collection) { + foreach ($collection as $control) { + $control = $mapper->handle($control); + $map->addControl($control); + } + } } /** diff --git a/src/Netzmacht/Contao/Leaflet/Model/ControlModel.php b/src/Netzmacht/Contao/Leaflet/Model/ControlModel.php new file mode 100644 index 0000000..54d5469 --- /dev/null +++ b/src/Netzmacht/Contao/Leaflet/Model/ControlModel.php @@ -0,0 +1,17 @@ + + * @copyright 2015 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + +namespace Netzmacht\Contao\Leaflet\Model; + +class ControlModel extends \Model +{ + protected static $strTable = 'tl_leaflet_control'; +} diff --git a/src/Netzmacht/Contao/Leaflet/Subscriber/EncoderSubscriber.php b/src/Netzmacht/Contao/Leaflet/Subscriber/EncoderSubscriber.php index fbf4a3e..8998e89 100644 --- a/src/Netzmacht/Contao/Leaflet/Subscriber/EncoderSubscriber.php +++ b/src/Netzmacht/Contao/Leaflet/Subscriber/EncoderSubscriber.php @@ -47,8 +47,9 @@ class EncoderSubscriber implements EventSubscriberInterface if ($object instanceof Map) { $attribution = <<netzmacht creative' +map.map.attributionControl.setPrefix( + 'Leaflet | ' + + 'netzmacht creative' ); HTML; $event->getOutput()->addLine($attribution);