vendor/numero2/contao-storelocator/src/Resources/contao/dca/tl_module.php line 197

Open in your IDE?
  1. <?php
  2. /**
  3.  * StoreLocator Bundle for Contao Open Source CMS
  4.  *
  5.  * @author    Benny Born <benny.born@numero2.de>
  6.  * @author    Michael Bösherz <michael.boesherz@numero2.de>
  7.  * @license   LGPL-3.0-or-later
  8.  * @copyright Copyright (c) 2024, numero2 - Agentur für digitales Marketing GbR
  9.  */
  10. use Contao\Config;
  11. use Contao\CoreBundle\DataContainer\PaletteManipulator;
  12. use numero2\StoreLocator\DCAHelper\Module;
  13. use numero2\StoreLocator\DCAHelper\Stores;
  14. use numero2\StoreLocator\StoreLocatorBackend;
  15. use numero2\TagsBundle\TagsBundle;
  16. /**
  17.  * Add config to tl_module
  18.  */
  19. $GLOBALS['TL_DCA']['tl_module']['config']['onload_callback'][] = [StoreLocatorBackend::class, 'showNoProviderAvailable'];
  20. $GLOBALS['TL_DCA']['tl_module']['config']['onload_callback'][] = [Module::class, 'hideProviderDependentField'];
  21. /**
  22.  * Add palettes to tl_module
  23.  */
  24. $GLOBALS['TL_DCA']['tl_module']['palettes']['storelocator_search'] = '{title_legend},name,headline,type;{config_legend},storelocator_provider,jumpTo,storelocator_enable_autocomplete,storelocator_search_categories;{template_legend:hide},customTpl;{expert_legend:hide},guests,cssID,space';
  25. $GLOBALS['TL_DCA']['tl_module']['palettes']['storelocator_list'] = '{title_legend},name,headline,type;{config_legend},storelocator_list_categories,storelocator_list_limit,storelocator_list_sort_field,storelocator_list_sort_direction,storelocator_limit_distance,storelocator_always_show_results,storelocator_use_filter,jumpTo;{sl_map_legend},storelocator_show_map;{source_legend},imgSize;{template_legend:hide},customTpl;{expert_legend:hide},guests,cssID,space';
  26. $GLOBALS['TL_DCA']['tl_module']['palettes']['storelocator_filter'] = '{title_legend},name,headline,type;{config_legend},jumpTo,storelocator_search_in,storelocator_sortable;{template_legend:hide},customTpl;{expert_legend:hide},guests,cssID,space';
  27. $GLOBALS['TL_DCA']['tl_module']['palettes']['storelocator_details'] = '{title_legend},name,type;{config_legend},storelocator_provider;{source_legend},imgSize;{template_legend:hide},customTpl;{expert_legend:hide},guests,cssID,space';
  28. $GLOBALS['TL_DCA']['tl_module']['palettes']['storelocator_static_map'] = '{title_legend},name,headline,type;{config_legend},jumpTo,storelocator_center,storelocator_zoom,storelocator_search_categories,storelocator_limit_marker_static;{template_legend:hide},customTpl,storelocator_maptype,storelocator_size,storelocator_scale,storelocator_format;{expert_legend:hide},guests,cssID,space';
  29. $GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'storelocator_limit_distance';
  30. $GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'storelocator_enable_autocomplete';
  31. $GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'storelocator_always_show_results';
  32. $GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'storelocator_show_map';
  33. $GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'storelocator_load_results_on_pan';
  34. $GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'storelocator_use_filter';
  35. $GLOBALS['TL_DCA']['tl_module']['subpalettes']['storelocator_limit_distance'] = 'storelocator_max_distance';
  36. $GLOBALS['TL_DCA']['tl_module']['subpalettes']['storelocator_use_filter'] = 'storelocator_mod_filter';
  37. $GLOBALS['TL_DCA']['tl_module']['subpalettes']['storelocator_enable_autocomplete'] = 'storelocator_autocomplete_country';
  38. $GLOBALS['TL_DCA']['tl_module']['subpalettes']['storelocator_always_show_results'] = 'storelocator_default_country';
  39. $GLOBALS['TL_DCA']['tl_module']['subpalettes']['storelocator_show_map'] = 'storelocator_provider';
  40. $GLOBALS['TL_DCA']['tl_module']['subpalettes']['storelocator_provider-google-maps'] = 'storelocator_provider,storelocator_markerclusterer,storelocator_map_interaction,storelocator_list_interaction,storelocator_map_pin,storelocator_load_results_on_pan';
  41. $GLOBALS['TL_DCA']['tl_module']['subpalettes']['storelocator_load_results_on_pan'] = 'storelocator_limit_marker';
  42. /**
  43.  * Add fields to tl_module
  44.  */
  45. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_provider'] = [
  46.     'inputType'           => 'select'
  47. ,   'options_callback'    => [Module::class, 'getJavascriptProviders']
  48. ,   'reference'           => &$GLOBALS['TL_LANG']['tl_module']['storelocator_providers']
  49. ,   'eval'                => ['includeBlankOption'=>true'submitOnChange'=>true'tl_class'=>'w50']
  50. ,   'sql'                 => "varchar(32) NOT NULL default ''"
  51. ];
  52. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_enable_autocomplete'] = [
  53.     'inputType'           => 'checkbox'
  54. ,   'eval'                => ['submitOnChange'=>true'tl_class'=>'w50']
  55. ,   'sql'                 => "char(1) NOT NULL default ''"
  56. ];
  57. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_autocomplete_country'] = [
  58.     'inputType'           => 'select'
  59. ,   'options_callback'    => [Stores::class, 'getCountries']
  60. ,   'default'             => 'de'
  61. ,   'eval'                => ['maxlength'=>2'tl_class'=>'w50''chosen'=>true'includeBlankOption'=>true]
  62. ,   'sql'                 => "varchar(2) NOT NULL default ''"
  63. ];
  64. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_default_country'] = [
  65.     'inputType'           => 'select'
  66. ,   'options_callback'    => [Stores::class, 'getCountries']
  67. ,   'default'             => 'de'
  68. ,   'eval'                => ['includeBlankOption'=>true'maxlength'=>2'tl_class'=>'w50''chosen'=>true]
  69. ,   'sql'                 => "varchar(2) NOT NULL default ''"
  70. ];
  71. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_search_categories'] = [
  72.     'exclude'             => true
  73. ,   'inputType'           => 'checkbox'
  74. ,   'options_callback'    => [Module::class, 'getCategories']
  75. ,   'eval'                => ['mandatory'=>true'multiple'=>true'tl_class'=>'clr w50']
  76. ,   'sql'                 => "text NULL"
  77. ];
  78. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_list_categories'] = [
  79.     'exclude'             => true
  80. ,   'inputType'           => 'checkbox'
  81. ,   'options_callback'    => [Module::class, 'getCategories']
  82. ,   'eval'                => ['mandatory'=>true'multiple'=>true]
  83. ,   'sql'                 => "text NULL"
  84. ];
  85. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_list_limit'] = [
  86.     'default'             => '10'
  87. ,   'exclude'             => true
  88. ,   'inputType'           => 'text'
  89. ,   'eval'                => ['rgxp'=>'digit''tl_class'=>'w50''mandatory'=>true]
  90. ,   'sql'                 => "varchar(255) NOT NULL default ''"
  91. ];
  92. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_list_sort_field'] = [
  93.     'inputType'           => 'select'
  94. ,   'options_callback'    => [Module::class, 'getSortableFields']
  95. ,   'exclude'             => true
  96. ,   'eval'                => ['tl_class'=>'clr w50''chosen'=>true'includeBlankOption'=>true]
  97. ,   'sql'                 => "varchar(255) NOT NULL default ''"
  98. ];
  99. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_list_sort_direction'] = [
  100.     'inputType'           => 'select'
  101. ,   'options'             => ['ascending''descending']
  102. ,   'reference'           => &$GLOBALS['TL_LANG']['MSC']
  103. ,   'exclude'             => true
  104. ,   'eval'                => ['tl_class'=>'w50']
  105. ,   'sql'                 => "varchar(10) NOT NULL default ''"
  106. ];
  107. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_limit_distance'] = [
  108.     'inputType'           => 'checkbox'
  109. ,   'default'             => false
  110. ,   'eval'                => ['tl_class'=>'w50 clr''submitOnChange'=>true]
  111. ,   'sql'                 => "char(1) NOT NULL default ''"
  112. ];
  113. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_max_distance'] = [
  114.     'default'             => '10'
  115. ,   'exclude'             => true
  116. ,   'inputType'           => 'text'
  117. ,   'eval'                => ['rgxp'=>'digit''tl_class'=>'w50''mandatory'=>true]
  118. ,   'sql'                 => "int(5) unsigned NOT NULL default '0'"
  119. ];
  120. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_always_show_results'] = [
  121.     'inputType'           => 'checkbox'
  122. ,   'default'             => true
  123. ,   'eval'                => ['tl_class'=>'clr w50''submitOnChange'=>true]
  124. ,   'sql'                 => "char(1) NOT NULL default '1'"
  125. ];
  126. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_show_map'] = [
  127.     'inputType'           => 'checkbox'
  128. ,   'default'             => true
  129. ,   'eval'                => ['tl_class'=>'w50''submitOnChange'=>true]
  130. ,   'sql'                 => "char(1) NOT NULL default '1'"
  131. ];
  132. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_markerclusterer'] = [
  133.     'inputType'           => 'checkbox'
  134. ,   'eval'                => ['tl_class'=>'w50 cbx']
  135. ,   'sql'                 => "char(1) NOT NULL default ''"
  136. ];
  137. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_load_results_on_pan'] = [
  138.     'inputType'           => 'checkbox'
  139. ,   'default'             => true
  140. ,   'eval'                => ['tl_class'=>'w50 cbx m12''submitOnChange'=>true]
  141. ,   'sql'                 => "char(1) NOT NULL default '1'"
  142. ];
  143. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_limit_marker'] = [
  144.     'inputType'           => 'text'
  145. ,   'default'             => '100'
  146. ,   'exclude'             => true
  147. ,   'eval'                => ['rgxp'=>'digit''tl_class'=>'w50''mandatory'=>true]
  148. ,   'sql'                 => "int(5) unsigned NOT NULL default '0'"
  149. ];
  150. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_map_interaction'] = [
  151.     'default'             => 'nothing'
  152. ,   'exclude'             => true
  153. ,   'inputType'           => 'select'
  154. ,   'options_callback'    => [StoreLocatorBackend::class, 'getMapInteractions']
  155. ,   'eval'                => ['tl_class'=>'w50 clr']
  156. ,   'sql'                 => "varchar(64) NOT NULL default ''"
  157. ];
  158. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_list_interaction'] = [
  159.     'default'             => 'nothing'
  160. ,   'exclude'             => true
  161. ,   'inputType'           => 'select'
  162. ,   'options_callback'    => [StoreLocatorBackend::class, 'getListInteractions']
  163. ,   'eval'                => ['tl_class'=>'w50']
  164. ,   'sql'                 => "varchar(64) NOT NULL default ''"
  165. ];
  166. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_map_pin'] = [
  167.     'inputType'           => 'fileTree'
  168. ,   'eval'                => ['filesOnly'=>true'extensions'=>Config::get('validImageTypes'), 'fieldType'=>'radio''tl_class'=>'clr']
  169. ,   'sql'                 => "binary(16) NULL"
  170. ];
  171. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_search_in'] = [
  172.     'inputType'           => 'checkboxWizard'
  173. ,   'options'             => ['name''email''url''phone''fax''description''postal''city']
  174. ,   'options_callback'    => [Module::class, 'getStoreFields']
  175. ,   'eval'                => ['multiple'=>true'tl_class'=>'clr w50 heightAuto']
  176. ,   'sql'                 => "blob NULL"
  177. ];
  178. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_sortable'] = [
  179.     'inputType'           => 'checkboxWizard'
  180. ,   'options'             => ['name''email''url''phone''fax''description''postal''city']
  181. ,   'options_callback'    => [Module::class, 'getStoreFields']
  182. ,   'eval'                => ['multiple'=>true'tl_class'=>'w50 heightAuto']
  183. ,   'sql'                 => "blob NULL"
  184. ];
  185. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_use_filter'] = [
  186.     'inputType'           => 'checkbox'
  187. ,   'eval'                => ['tl_class'=>'clr w50''submitOnChange'=>true]
  188. ,   'sql'                 => "char(1) NOT NULL default ''"
  189. ];
  190. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_mod_filter'] = [
  191.     'inputType'           => 'select'
  192. ,   'exclude'             => true
  193. ,   'options_callback'    => [Module::class, 'getFilterModules']
  194. ,   'eval'                => ['mandatory'=>true'tl_class'=>'w50 wizard']
  195. ,   'wizard'              => [[Module::class, 'editModule']]
  196. ,   'sql'                 => "int(10) NOT NULL default '0'"
  197. ];
  198. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_center'] = [
  199.     'inputType'           => 'text'
  200. ,   'exclude'             => true
  201. ,   'eval'                => ['maxlength'=>32'tl_class'=>'w50']
  202. ,   'sql'                 => "varchar(32) NOT NULL default ''"
  203. ];
  204. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_zoom'] = [
  205.     'inputType'           => 'text'
  206. ,   'exclude'             => true
  207. ,   'eval'                => ['rgxp'=>'digit''maxlength'=>2'tl_class'=>'w50']
  208. ,   'sql'                 => "varchar(2) NOT NULL default ''"
  209. ];
  210. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_limit_marker_static'] = [
  211.     'inputType'           => 'text'
  212. ,   'exclude'             => true
  213. ,   'eval'                => ['mandatory'=>true'rgxp'=>'digit''tl_class'=>'w50']
  214. ,   'sql'                 => "varchar(3) NOT NULL default ''"
  215. ];
  216. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_maptype'] = [
  217.     'inputType'           => 'select'
  218. ,   'default'             => 'roadmap'
  219. ,   'exclude'             => true
  220. ,   'options_callback'    => [Module::class, 'getMapType']
  221. ,   'eval'                => ['mandatory'=>true'tl_class'=>'w50 clr']
  222. ,   'sql'                 => "varchar(16) NOT NULL default ''"
  223. ];
  224. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_size'] = [
  225.     'inputType'           => 'text'
  226. ,   'exclude'             => true
  227. ,   'eval'                => ['mandatory'=>true'multiple'=>true'size'=>2'rgxp'=>'natural''nospace'=>true'tl_class'=>'w50']
  228. ,   'sql'                 => "varchar(64) NOT NULL default ''"
  229. ];
  230. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_format'] = [
  231.     'inputType'           => 'select'
  232. ,   'default'             => 'jpg'
  233. ,   'exclude'             => true
  234. ,   'options_callback'    => [Module::class, 'getMapFormat']
  235. ,   'eval'                => ['mandatory'=>true'tl_class'=>'w50']
  236. ,   'sql'                 => "varchar(16) NOT NULL default ''"
  237. ];
  238. $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_scale'] = [
  239.     'inputType'           => 'select'
  240. ,   'default'             => '1'
  241. ,   'exclude'             => true
  242. ,   'options_callback'    => [Module::class, 'getMapScale']
  243. ,   'eval'                => ['mandatory'=>true'tl_class'=>'w50']
  244. ,   'sql'                 => "varchar(16) NOT NULL default ''"
  245. ];
  246. if( !array_key_exists('tl_class'$GLOBALS['TL_DCA']['tl_module']['fields']['jumpTo']['eval']) ) {
  247.     $GLOBALS['TL_DCA']['tl_module']['fields']['jumpTo']['eval']['tl_class'] = 'clr';
  248. } else {
  249.     $GLOBALS['TL_DCA']['tl_module']['fields']['jumpTo']['eval']['tl_class'] .= ' clr';
  250. }
  251. if( class_exists(TagsBundle::class) ) {
  252.     PaletteManipulator::create()
  253.         ->addField('storelocator_use_tags''config_legend''append')
  254.         ->applyToPalette('storelocator_filter''tl_module')
  255.     ;
  256.     $GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'storelocator_use_tags';
  257.     $GLOBALS['TL_DCA']['tl_module']['subpalettes']['storelocator_use_tags'] = 'storelocator_list_categories';
  258.     $GLOBALS['TL_DCA']['tl_module']['fields']['storelocator_use_tags'] = [
  259.         'inputType'           => 'checkbox'
  260.     ,   'eval'                => ['submitOnChange'=>true'tl_class'=>'w50 cbx m12']
  261.     ,   'sql'                 => "char(1) NOT NULL default ''"
  262.     ];
  263. }