1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,88 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+/** |
|
4 |
+ * News notification extension for Contao |
|
5 |
+ * |
|
6 |
+ * Copyright (c) 2016 Benjamin Roth |
|
7 |
+ * |
|
8 |
+ * @link http://www.esales-media.de |
|
9 |
+ * @license commercial |
|
10 |
+ */ |
|
11 |
+ |
|
12 |
+/** |
|
13 |
+ * Palettes |
|
14 |
+ */ |
|
15 |
+ |
|
16 |
+$GLOBALS['TL_DCA']['tl_news_archive']['palettes']['__selector__'][] = 'nc_enable'; |
|
17 |
+$GLOBALS['TL_DCA']['tl_news_archive']['palettes']['default'] = str_replace('{protected_legend:hide}','{nc_legend:hide},nc_enable;{protected_legend:hide}',$GLOBALS['TL_DCA']['tl_news_archive']['palettes']['default']); |
|
18 |
+ |
|
19 |
+/** |
|
20 |
+ * Subpalettes |
|
21 |
+ */ |
|
22 |
+ |
|
23 |
+$GLOBALS['TL_DCA']['tl_news_archive']['subpalettes']['nc_enable'] = 'nc_notification,nc_notification_groups'; |
|
24 |
+ |
|
25 |
+/** |
|
26 |
+ * Fields |
|
27 |
+ */ |
|
28 |
+ |
|
29 |
+$GLOBALS['TL_DCA']['tl_news_archive']['fields']['nc_enable'] = array |
|
30 |
+( |
|
31 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_news_archive']['nc_enable'], |
|
32 |
+ 'exclude' => true, |
|
33 |
+ 'inputType' => 'checkbox', |
|
34 |
+ 'eval' => array('tl_class'=>'w50 m12','submitOnChange'=>true), |
|
35 |
+ 'sql' => "char(1) NOT NULL default ''" |
|
36 |
+); |
|
37 |
+ |
|
38 |
+$GLOBALS['TL_DCA']['tl_news_archive']['fields']['nc_notification_groups'] = array |
|
39 |
+( |
|
40 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_news_archive']['nc_notification_groups'], |
|
41 |
+ 'exclude' => true, |
|
42 |
+ 'inputType' => 'checkbox', |
|
43 |
+ 'foreignKey' => 'tl_member_group.name', |
|
44 |
+ 'eval' => array('mandatory'=>true, 'multiple'=>true,'tl_class'=>'clr'), |
|
45 |
+ 'sql' => "blob NULL", |
|
46 |
+ 'relation' => array('type'=>'hasMany', 'load'=>'lazy') |
|
47 |
+); |
|
48 |
+ |
|
49 |
+$GLOBALS['TL_DCA']['tl_news_archive']['fields']['nc_notification'] = array |
|
50 |
+( |
|
51 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_news_archive']['nc_notification'], |
|
52 |
+ 'exclude' => true, |
|
53 |
+ 'inputType' => 'select', |
|
54 |
+ 'options_callback' => array('tl_news_archive_eSM_nc_news', 'getNotificationChoices'), |
|
55 |
+ 'eval' => array('mandatory'=>true,'includeBlankOption'=>true, 'chosen'=>true, 'tl_class'=>'w50'), |
|
56 |
+ 'sql' => "int(10) unsigned NOT NULL default '0'" |
|
57 |
+); |
|
58 |
+ |
|
59 |
+/** |
|
60 |
+ * Provide miscellaneous methods that are used by the data configuration array. |
|
61 |
+ * |
|
62 |
+ * @author Benjamin Roth <http://www.esales-media.de> |
|
63 |
+ */ |
|
64 |
+class tl_news_archive_eSM_nc_news extends \Backend |
|
65 |
+{ |
|
66 |
+ |
|
67 |
+ public function __construct() |
|
68 |
+ { |
|
69 |
+ parent::__construct(); |
|
70 |
+ } |
|
71 |
+ |
|
72 |
+ /** |
|
73 |
+ * Get notification choices |
|
74 |
+ * |
|
75 |
+ * @return array |
|
76 |
+ */ |
|
77 |
+ public function getNotificationChoices() |
|
78 |
+ { |
|
79 |
+ $arrChoices = array(); |
|
80 |
+ $objNotifications = \Database::getInstance()->execute("SELECT id,title FROM tl_nc_notification WHERE type='news_submitted' ORDER BY title"); |
|
81 |
+ |
|
82 |
+ while ($objNotifications->next()) { |
|
83 |
+ $arrChoices[$objNotifications->id] = $objNotifications->title; |
|
84 |
+ } |
|
85 |
+ |
|
86 |
+ return $arrChoices; |
|
87 |
+ } |
|
88 |
+} |
|
0 | 89 |
\ No newline at end of file |