| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,315 +0,0 @@ |
| 1 |
-<?php |
|
| 2 |
- |
|
| 3 |
-/** |
|
| 4 |
- * TeamList for Contao |
|
| 5 |
- * |
|
| 6 |
- * Copyright (c) 2016 Benjamin Roth |
|
| 7 |
- * |
|
| 8 |
- * @license LGPL-3.0+ |
|
| 9 |
- */ |
|
| 10 |
- |
|
| 11 |
-/** |
|
| 12 |
- * Table tl_eSM_team |
|
| 13 |
- */ |
|
| 14 |
- |
|
| 15 |
-use Contao\DC_Table; |
|
| 16 |
-use Contao\DataContainer; |
|
| 17 |
- |
|
| 18 |
-$GLOBALS['TL_DCA']['tl_eSM_team'] = array |
|
| 19 |
-( |
|
| 20 |
- |
|
| 21 |
- // Config |
|
| 22 |
- 'config' => array |
|
| 23 |
- ( |
|
| 24 |
- 'dataContainer' => DC_Table::class, |
|
| 25 |
- 'ptable' => 'tl_eSM_team_group', |
|
| 26 |
- 'enableVersioning' => true, |
|
| 27 |
- 'sql' => array |
|
| 28 |
- ( |
|
| 29 |
- 'keys' => array |
|
| 30 |
- ( |
|
| 31 |
- 'id' => 'primary', |
|
| 32 |
- 'pid' => 'index', |
|
| 33 |
- 'pid,published' => 'index' |
|
| 34 |
- ) |
|
| 35 |
- ) |
|
| 36 |
- ), |
|
| 37 |
- |
|
| 38 |
- // List |
|
| 39 |
- 'list' => array |
|
| 40 |
- ( |
|
| 41 |
- 'sorting' => array |
|
| 42 |
- ( |
|
| 43 |
- |
|
| 44 |
- 'mode' => DataContainer::MODE_PARENT, |
|
| 45 |
- 'fields' => array('division', 'lastname'),
|
|
| 46 |
- 'headerFields' => array('title'),
|
|
| 47 |
- 'panelLayout' => 'filter,search;sort,limit', |
|
| 48 |
-// 'child_record_callback' => array('tl_eSM_team', 'listMembers')
|
|
| 49 |
- ), |
|
| 50 |
- 'label' => array |
|
| 51 |
- ( |
|
| 52 |
- |
|
| 53 |
- ), |
|
| 54 |
- 'global_operations' => array |
|
| 55 |
- ( |
|
| 56 |
- 'all' => array |
|
| 57 |
- ( |
|
| 58 |
- 'href' => 'act=select', |
|
| 59 |
- 'class' => 'header_edit_all', |
|
| 60 |
- 'attributes' => 'onclick="Backend.getScrollOffset()" accesskey="e"' |
|
| 61 |
- ) |
|
| 62 |
- ), |
|
| 63 |
- 'operations' => array |
|
| 64 |
- ( |
|
| 65 |
- 'edit' => array |
|
| 66 |
- ( |
|
| 67 |
- 'href' => 'act=edit', |
|
| 68 |
- 'icon' => 'edit.svg' |
|
| 69 |
- ), |
|
| 70 |
- 'copy' => array |
|
| 71 |
- ( |
|
| 72 |
- 'href' => 'act=paste&mode=copy', |
|
| 73 |
- 'attributes' => 'onclick="Backend.getScrollOffset()"', |
|
| 74 |
- 'icon' => 'copy.svg' |
|
| 75 |
- ), |
|
| 76 |
- 'cut' => array |
|
| 77 |
- ( |
|
| 78 |
- 'href' => 'act=paste&mode=cut', |
|
| 79 |
- 'icon' => 'cut.svg', |
|
| 80 |
- 'attributes' => 'onclick="Backend.getScrollOffset()"' |
|
| 81 |
- ), |
|
| 82 |
- 'delete' => array |
|
| 83 |
- ( |
|
| 84 |
- 'href' => 'act=delete', |
|
| 85 |
- 'icon' => 'delete.svg', |
|
| 86 |
- 'attributes' => 'onclick="if(!confirm(\'' . ($GLOBALS['TL_LANG']['MSC']['deleteConfirm'] ?? null) . '\'))return false;Backend.getScrollOffset()"' |
|
| 87 |
- ), |
|
| 88 |
- 'toggle' => array |
|
| 89 |
- ( |
|
| 90 |
- 'href' => 'act=toggle&field=invisible', |
|
| 91 |
- 'icon' => 'visible.svg', |
|
| 92 |
-// 'button_callback' => array('tl_eSM_team', 'toggleIcon')
|
|
| 93 |
- ), |
|
| 94 |
- 'show' => array |
|
| 95 |
- ( |
|
| 96 |
- 'href' => 'act=show', |
|
| 97 |
- 'icon' => 'show.svg' |
|
| 98 |
- ) |
|
| 99 |
- ) |
|
| 100 |
- ), |
|
| 101 |
- |
|
| 102 |
- // Palettes |
|
| 103 |
- 'palettes' => array |
|
| 104 |
- ( |
|
| 105 |
- 'default' => '{person_legend},firstname,lastname,comment;{company_legend},position,division;{picture_legend},singleSRC;{publish_legend:hide},published'
|
|
| 106 |
- ), |
|
| 107 |
- |
|
| 108 |
- // Subpalettes |
|
| 109 |
- 'subpalettes' => array |
|
| 110 |
- ( |
|
| 111 |
- ), |
|
| 112 |
- |
|
| 113 |
- // Fields |
|
| 114 |
- 'fields' => array |
|
| 115 |
- ( |
|
| 116 |
- 'id' => array |
|
| 117 |
- ( |
|
| 118 |
- 'sql' => "int(10) unsigned NOT NULL auto_increment" |
|
| 119 |
- ), |
|
| 120 |
- 'pid' => array |
|
| 121 |
- ( |
|
| 122 |
- 'foreignKey' => 'tl_faq_category.title', |
|
| 123 |
- 'sql' => "int(10) unsigned NOT NULL default '0'", |
|
| 124 |
- 'relation' => array('type'=>'belongsTo', 'load'=>'eager')
|
|
| 125 |
- ), |
|
| 126 |
- 'tstamp' => array |
|
| 127 |
- ( |
|
| 128 |
- 'sql' => "int(10) unsigned NOT NULL default '0'" |
|
| 129 |
- ), |
|
| 130 |
- 'firstname' => array |
|
| 131 |
- ( |
|
| 132 |
- 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['firstname'], |
|
| 133 |
- 'exclude' => true, |
|
| 134 |
- 'search' => true, |
|
| 135 |
- 'inputType' => 'text', |
|
| 136 |
- 'eval' => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
|
|
| 137 |
- 'sql' => "varchar(128) NOT NULL default ''" |
|
| 138 |
- ), |
|
| 139 |
- 'lastname' => array |
|
| 140 |
- ( |
|
| 141 |
- 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['lastname'], |
|
| 142 |
- 'exclude' => true, |
|
| 143 |
- 'search' => true, |
|
| 144 |
- 'inputType' => 'text', |
|
| 145 |
- 'eval' => array('mandatory'=>false, 'maxlength'=>128, 'tl_class'=>'w50'),
|
|
| 146 |
- 'sql' => "varchar(128) NOT NULL default ''" |
|
| 147 |
- ), |
|
| 148 |
- 'position' => array |
|
| 149 |
- ( |
|
| 150 |
- 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['position'], |
|
| 151 |
- 'exclude' => true, |
|
| 152 |
- 'search' => true, |
|
| 153 |
- 'inputType' => 'text', |
|
| 154 |
- 'eval' => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
|
|
| 155 |
- 'sql' => "varchar(128) NOT NULL default ''" |
|
| 156 |
- ), |
|
| 157 |
- 'comment' => array |
|
| 158 |
- ( |
|
| 159 |
- 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['comment'], |
|
| 160 |
- 'exclude' => true, |
|
| 161 |
- 'inputType' => 'textarea', |
|
| 162 |
- 'eval' => array('mandatory'=>false, 'maxlength'=>128, 'tl_class'=>'clr'),
|
|
| 163 |
- 'sql' => "varchar(128) NOT NULL default ''" |
|
| 164 |
- ), |
|
| 165 |
- 'division' => array |
|
| 166 |
- ( |
|
| 167 |
- 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['division'], |
|
| 168 |
- 'exclude' => true, |
|
| 169 |
- 'filter' => true, |
|
| 170 |
- 'inputType' => 'select', |
|
| 171 |
- 'options' => $GLOBALS['eSM_team']['divisions'], |
|
| 172 |
- 'reference' => &$GLOBALS['TL_LANG']['REF']['divisions'], |
|
| 173 |
- 'eval' => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
|
|
| 174 |
- 'sql' => "varchar(128) NOT NULL default ''" |
|
| 175 |
- ), |
|
| 176 |
- 'singleSRC' => array |
|
| 177 |
- ( |
|
| 178 |
- 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['singleSRC'], |
|
| 179 |
- 'exclude' => true, |
|
| 180 |
- 'inputType' => 'fileTree', |
|
| 181 |
- 'eval' => array('filesOnly'=>true, 'extensions'=>Config::get('validImageTypes'), 'fieldType'=>'radio', 'mandatory'=>true),
|
|
| 182 |
- 'sql' => "binary(16) NULL" |
|
| 183 |
- ), |
|
| 184 |
- 'published' => array |
|
| 185 |
- ( |
|
| 186 |
- 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['published'], |
|
| 187 |
- 'exclude' => true, |
|
| 188 |
- 'filter' => true, |
|
| 189 |
- 'inputType' => 'checkbox', |
|
| 190 |
- 'default' => '1', |
|
| 191 |
- 'eval' => array('doNotCopy'=>true),
|
|
| 192 |
- 'sql' => "char(1) NOT NULL default ''" |
|
| 193 |
- ), |
|
| 194 |
- ) |
|
| 195 |
-); |
|
| 196 |
- |
|
| 197 |
-/** |
|
| 198 |
- * Provide miscellaneous methods that are used by the data configuration array. |
|
| 199 |
- */ |
|
| 200 |
-class tl_eSM_team extends Backend |
|
| 201 |
-{
|
|
| 202 |
- |
|
| 203 |
- /** |
|
| 204 |
- * Import the back end user object |
|
| 205 |
- */ |
|
| 206 |
- public function __construct() |
|
| 207 |
- {
|
|
| 208 |
- parent::__construct(); |
|
| 209 |
- $this->import('BackendUser', 'User');
|
|
| 210 |
- } |
|
| 211 |
- |
|
| 212 |
- /** |
|
| 213 |
- * Add the type of input field |
|
| 214 |
- * |
|
| 215 |
- * @param array $arrRow |
|
| 216 |
- * |
|
| 217 |
- * @return string |
|
| 218 |
- */ |
|
| 219 |
- public function listMembers($arrRow) |
|
| 220 |
- {
|
|
| 221 |
- return ' |
|
| 222 |
-<div style="float: left; width: 35%;">' . $arrRow['firstname'] . ' ' . $arrRow['lastname'] . '</div> |
|
| 223 |
-<div style="font-size: .625rem; color: #c6c6c6;"><strong>[' . $arrRow['position'] . ']</strong></div>' . "\n"; |
|
| 224 |
- } |
|
| 225 |
- |
|
| 226 |
- /** |
|
| 227 |
- * Return the "toggle visibility" button |
|
| 228 |
- * |
|
| 229 |
- * @param array $row |
|
| 230 |
- * @param string $href |
|
| 231 |
- * @param string $label |
|
| 232 |
- * @param string $title |
|
| 233 |
- * @param string $icon |
|
| 234 |
- * @param string $attributes |
|
| 235 |
- * |
|
| 236 |
- * @return string |
|
| 237 |
- */ |
|
| 238 |
- public function toggleIcon($row, $href, $label, $title, $icon, $attributes) |
|
| 239 |
- {
|
|
| 240 |
- if (strlen(Input::get('tid')))
|
|
| 241 |
- {
|
|
| 242 |
- $this->toggleVisibility(Input::get('tid'), (Input::get('state') == 1), (@func_get_arg(12) ?: null));
|
|
| 243 |
- $this->redirect($this->getReferer()); |
|
| 244 |
- } |
|
| 245 |
- |
|
| 246 |
- // Check permissions AFTER checking the tid, so hacking attempts are logged |
|
| 247 |
- if (!$this->User->hasAccess('tl_eSM_team::published', 'alexf'))
|
|
| 248 |
- {
|
|
| 249 |
- return ''; |
|
| 250 |
- } |
|
| 251 |
- |
|
| 252 |
- $href .= '&tid='.$row['id'].'&state='.($row['published'] ? '' : 1); |
|
| 253 |
- |
|
| 254 |
- if (!$row['published']) |
|
| 255 |
- {
|
|
| 256 |
- $icon = 'invisible.gif'; |
|
| 257 |
- } |
|
| 258 |
- |
|
| 259 |
- return '<a href="'.$this->addToUrl($href).'" title="'.specialchars($title).'"'.$attributes.'>'.Image::getHtml($icon, $label, 'data-state="' . ($row['published'] ? 1 : 0) . '"').'</a> '; |
|
| 260 |
- } |
|
| 261 |
- |
|
| 262 |
- |
|
| 263 |
- /** |
|
| 264 |
- * Disable/enable a user group |
|
| 265 |
- * |
|
| 266 |
- * @param integer $intId |
|
| 267 |
- * @param boolean $blnVisible |
|
| 268 |
- * @param DataContainer $dc |
|
| 269 |
- */ |
|
| 270 |
- public function toggleVisibility($intId, $blnVisible, DataContainer $dc=null) |
|
| 271 |
- {
|
|
| 272 |
- // Set the ID and action |
|
| 273 |
- Input::setGet('id', $intId);
|
|
| 274 |
- Input::setGet('act', 'toggle');
|
|
| 275 |
- |
|
| 276 |
- if ($dc) |
|
| 277 |
- {
|
|
| 278 |
- $dc->id = $intId; // see #8043 |
|
| 279 |
- } |
|
| 280 |
- |
|
| 281 |
- // Check the field access |
|
| 282 |
- if (!$this->User->hasAccess('tl_eSM_team::published', 'alexf'))
|
|
| 283 |
- {
|
|
| 284 |
- $this->log('Not enough permissions to publish/unpublish teammember ID "'.$intId.'"', __METHOD__, TL_ERROR);
|
|
| 285 |
- $this->redirect('contao/main.php?act=error');
|
|
| 286 |
- } |
|
| 287 |
- |
|
| 288 |
- $objVersions = new Versions('tl_eSM_team', $intId);
|
|
| 289 |
- $objVersions->initialize(); |
|
| 290 |
- |
|
| 291 |
- // Trigger the save_callback |
|
| 292 |
- if (is_array($GLOBALS['TL_DCA']['tl_news']['fields']['published']['save_callback'])) |
|
| 293 |
- {
|
|
| 294 |
- foreach ($GLOBALS['TL_DCA']['tl_news']['fields']['published']['save_callback'] as $callback) |
|
| 295 |
- {
|
|
| 296 |
- if (is_array($callback)) |
|
| 297 |
- {
|
|
| 298 |
- $this->import($callback[0]); |
|
| 299 |
- $blnVisible = $this->{$callback[0]}->{$callback[1]}($blnVisible, ($dc ?: $this));
|
|
| 300 |
- } |
|
| 301 |
- elseif (is_callable($callback)) |
|
| 302 |
- {
|
|
| 303 |
- $blnVisible = $callback($blnVisible, ($dc ?: $this)); |
|
| 304 |
- } |
|
| 305 |
- } |
|
| 306 |
- } |
|
| 307 |
- |
|
| 308 |
- // Update the database |
|
| 309 |
- $this->Database->prepare("UPDATE tl_eSM_team SET tstamp=". time() .", published='" . ($blnVisible ? '1' : '') . "' WHERE id=?")
|
|
| 310 |
- ->execute($intId); |
|
| 311 |
- |
|
| 312 |
- $objVersions->create(); |
|
| 313 |
- $this->log('A new version of record "tl_eSM_team.id='.$intId.'" has been created'.$this->getParentEntries('tl_eSM_team', $intId), __METHOD__, TL_GENERAL);
|
|
| 314 |
- } |
|
| 315 |
-} |
|
| 316 | 0 |
\ No newline at end of file |
| ... | ... |
@@ -45,7 +45,7 @@ $GLOBALS['TL_DCA']['tl_eSM_team'] = array |
| 45 | 45 |
'fields' => array('division', 'lastname'),
|
| 46 | 46 |
'headerFields' => array('title'),
|
| 47 | 47 |
'panelLayout' => 'filter,search;sort,limit', |
| 48 |
- 'child_record_callback' => array('tl_eSM_team', 'listMembers')
|
|
| 48 |
+// 'child_record_callback' => array('tl_eSM_team', 'listMembers')
|
|
| 49 | 49 |
), |
| 50 | 50 |
'label' => array |
| 51 | 51 |
( |
| ... | ... |
@@ -83,7 +83,7 @@ $GLOBALS['TL_DCA']['tl_eSM_team'] = array |
| 83 | 83 |
( |
| 84 | 84 |
'href' => 'act=delete', |
| 85 | 85 |
'icon' => 'delete.svg', |
| 86 |
- 'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"' |
|
| 86 |
+ 'attributes' => 'onclick="if(!confirm(\'' . ($GLOBALS['TL_LANG']['MSC']['deleteConfirm'] ?? null) . '\'))return false;Backend.getScrollOffset()"' |
|
| 87 | 87 |
), |
| 88 | 88 |
'toggle' => array |
| 89 | 89 |
( |
| ... | ... |
@@ -12,13 +12,16 @@ |
| 12 | 12 |
* Table tl_eSM_team |
| 13 | 13 |
*/ |
| 14 | 14 |
|
| 15 |
+use Contao\DC_Table; |
|
| 16 |
+use Contao\DataContainer; |
|
| 17 |
+ |
|
| 15 | 18 |
$GLOBALS['TL_DCA']['tl_eSM_team'] = array |
| 16 | 19 |
( |
| 17 | 20 |
|
| 18 | 21 |
// Config |
| 19 | 22 |
'config' => array |
| 20 | 23 |
( |
| 21 |
- 'dataContainer' => 'Table', |
|
| 24 |
+ 'dataContainer' => DC_Table::class, |
|
| 22 | 25 |
'ptable' => 'tl_eSM_team_group', |
| 23 | 26 |
'enableVersioning' => true, |
| 24 | 27 |
'sql' => array |
| ... | ... |
@@ -38,17 +41,20 @@ $GLOBALS['TL_DCA']['tl_eSM_team'] = array |
| 38 | 41 |
'sorting' => array |
| 39 | 42 |
( |
| 40 | 43 |
|
| 41 |
- 'mode' => 4, |
|
| 44 |
+ 'mode' => DataContainer::MODE_PARENT, |
|
| 42 | 45 |
'fields' => array('division', 'lastname'),
|
| 43 | 46 |
'headerFields' => array('title'),
|
| 44 | 47 |
'panelLayout' => 'filter,search;sort,limit', |
| 45 | 48 |
'child_record_callback' => array('tl_eSM_team', 'listMembers')
|
| 46 |
- ), |
|
| 49 |
+ ), |
|
| 50 |
+ 'label' => array |
|
| 51 |
+ ( |
|
| 52 |
+ |
|
| 53 |
+ ), |
|
| 47 | 54 |
'global_operations' => array |
| 48 | 55 |
( |
| 49 | 56 |
'all' => array |
| 50 | 57 |
( |
| 51 |
- 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], |
|
| 52 | 58 |
'href' => 'act=select', |
| 53 | 59 |
'class' => 'header_edit_all', |
| 54 | 60 |
'attributes' => 'onclick="Backend.getScrollOffset()" accesskey="e"' |
| ... | ... |
@@ -58,43 +64,45 @@ $GLOBALS['TL_DCA']['tl_eSM_team'] = array |
| 58 | 64 |
( |
| 59 | 65 |
'edit' => array |
| 60 | 66 |
( |
| 61 |
- 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['edit'], |
|
| 62 | 67 |
'href' => 'act=edit', |
| 63 |
- 'icon' => 'edit.gif' |
|
| 68 |
+ 'icon' => 'edit.svg' |
|
| 64 | 69 |
), |
| 65 | 70 |
'copy' => array |
| 66 | 71 |
( |
| 67 |
- 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['copy'], |
|
| 68 |
- 'href' => 'act=copy', |
|
| 69 |
- 'icon' => 'copy.gif' |
|
| 72 |
+ 'href' => 'act=paste&mode=copy', |
|
| 73 |
+ 'attributes' => 'onclick="Backend.getScrollOffset()"', |
|
| 74 |
+ 'icon' => 'copy.svg' |
|
| 70 | 75 |
), |
| 76 |
+ 'cut' => array |
|
| 77 |
+ ( |
|
| 78 |
+ 'href' => 'act=paste&mode=cut', |
|
| 79 |
+ 'icon' => 'cut.svg', |
|
| 80 |
+ 'attributes' => 'onclick="Backend.getScrollOffset()"' |
|
| 81 |
+ ), |
|
| 71 | 82 |
'delete' => array |
| 72 | 83 |
( |
| 73 |
- 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['delete'], |
|
| 74 | 84 |
'href' => 'act=delete', |
| 75 |
- 'icon' => 'delete.gif', |
|
| 76 |
- 'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['tl_eSM_team']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"' |
|
| 85 |
+ 'icon' => 'delete.svg', |
|
| 86 |
+ 'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"' |
|
| 77 | 87 |
), |
| 78 | 88 |
'toggle' => array |
| 79 | 89 |
( |
| 80 |
- 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['toggle'], |
|
| 81 |
- 'icon' => 'visible.gif', |
|
| 82 |
- 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', |
|
| 83 |
- 'button_callback' => array('tl_eSM_team', 'toggleIcon')
|
|
| 90 |
+ 'href' => 'act=toggle&field=invisible', |
|
| 91 |
+ 'icon' => 'visible.svg', |
|
| 92 |
+// 'button_callback' => array('tl_eSM_team', 'toggleIcon')
|
|
| 84 | 93 |
), |
| 85 |
- 'show' => array |
|
| 86 |
- ( |
|
| 87 |
- 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['show'], |
|
| 88 |
- 'href' => 'act=show', |
|
| 89 |
- 'icon' => 'show.gif' |
|
| 90 |
- ) |
|
| 94 |
+ 'show' => array |
|
| 95 |
+ ( |
|
| 96 |
+ 'href' => 'act=show', |
|
| 97 |
+ 'icon' => 'show.svg' |
|
| 98 |
+ ) |
|
| 91 | 99 |
) |
| 92 | 100 |
), |
| 93 | 101 |
|
| 94 | 102 |
// Palettes |
| 95 | 103 |
'palettes' => array |
| 96 | 104 |
( |
| 97 |
- 'default' => '{person_legend},firstname,lastname;{company_legend},position,division;{picture_legend},singleSRC;{publish_legend:hide},published'
|
|
| 105 |
+ 'default' => '{person_legend},firstname,lastname,comment;{company_legend},position,division;{picture_legend},singleSRC;{publish_legend:hide},published'
|
|
| 98 | 106 |
), |
| 99 | 107 |
|
| 100 | 108 |
// Subpalettes |
| ... | ... |
@@ -146,6 +154,14 @@ $GLOBALS['TL_DCA']['tl_eSM_team'] = array |
| 146 | 154 |
'eval' => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
|
| 147 | 155 |
'sql' => "varchar(128) NOT NULL default ''" |
| 148 | 156 |
), |
| 157 |
+ 'comment' => array |
|
| 158 |
+ ( |
|
| 159 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['comment'], |
|
| 160 |
+ 'exclude' => true, |
|
| 161 |
+ 'inputType' => 'textarea', |
|
| 162 |
+ 'eval' => array('mandatory'=>false, 'maxlength'=>128, 'tl_class'=>'clr'),
|
|
| 163 |
+ 'sql' => "varchar(128) NOT NULL default ''" |
|
| 164 |
+ ), |
|
| 149 | 165 |
'division' => array |
| 150 | 166 |
( |
| 151 | 167 |
'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['division'], |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,299 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+/** |
|
| 4 |
+ * TeamList for Contao |
|
| 5 |
+ * |
|
| 6 |
+ * Copyright (c) 2016 Benjamin Roth |
|
| 7 |
+ * |
|
| 8 |
+ * @license LGPL-3.0+ |
|
| 9 |
+ */ |
|
| 10 |
+ |
|
| 11 |
+/** |
|
| 12 |
+ * Table tl_eSM_team |
|
| 13 |
+ */ |
|
| 14 |
+ |
|
| 15 |
+$GLOBALS['TL_DCA']['tl_eSM_team'] = array |
|
| 16 |
+( |
|
| 17 |
+ |
|
| 18 |
+ // Config |
|
| 19 |
+ 'config' => array |
|
| 20 |
+ ( |
|
| 21 |
+ 'dataContainer' => 'Table', |
|
| 22 |
+ 'ptable' => 'tl_eSM_team_group', |
|
| 23 |
+ 'enableVersioning' => true, |
|
| 24 |
+ 'sql' => array |
|
| 25 |
+ ( |
|
| 26 |
+ 'keys' => array |
|
| 27 |
+ ( |
|
| 28 |
+ 'id' => 'primary', |
|
| 29 |
+ 'pid' => 'index', |
|
| 30 |
+ 'pid,published' => 'index' |
|
| 31 |
+ ) |
|
| 32 |
+ ) |
|
| 33 |
+ ), |
|
| 34 |
+ |
|
| 35 |
+ // List |
|
| 36 |
+ 'list' => array |
|
| 37 |
+ ( |
|
| 38 |
+ 'sorting' => array |
|
| 39 |
+ ( |
|
| 40 |
+ |
|
| 41 |
+ 'mode' => 4, |
|
| 42 |
+ 'fields' => array('division', 'lastname'),
|
|
| 43 |
+ 'headerFields' => array('title'),
|
|
| 44 |
+ 'panelLayout' => 'filter,search;sort,limit', |
|
| 45 |
+ 'child_record_callback' => array('tl_eSM_team', 'listMembers')
|
|
| 46 |
+ ), |
|
| 47 |
+ 'global_operations' => array |
|
| 48 |
+ ( |
|
| 49 |
+ 'all' => array |
|
| 50 |
+ ( |
|
| 51 |
+ 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], |
|
| 52 |
+ 'href' => 'act=select', |
|
| 53 |
+ 'class' => 'header_edit_all', |
|
| 54 |
+ 'attributes' => 'onclick="Backend.getScrollOffset()" accesskey="e"' |
|
| 55 |
+ ) |
|
| 56 |
+ ), |
|
| 57 |
+ 'operations' => array |
|
| 58 |
+ ( |
|
| 59 |
+ 'edit' => array |
|
| 60 |
+ ( |
|
| 61 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['edit'], |
|
| 62 |
+ 'href' => 'act=edit', |
|
| 63 |
+ 'icon' => 'edit.gif' |
|
| 64 |
+ ), |
|
| 65 |
+ 'copy' => array |
|
| 66 |
+ ( |
|
| 67 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['copy'], |
|
| 68 |
+ 'href' => 'act=copy', |
|
| 69 |
+ 'icon' => 'copy.gif' |
|
| 70 |
+ ), |
|
| 71 |
+ 'delete' => array |
|
| 72 |
+ ( |
|
| 73 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['delete'], |
|
| 74 |
+ 'href' => 'act=delete', |
|
| 75 |
+ 'icon' => 'delete.gif', |
|
| 76 |
+ 'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['tl_eSM_team']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"' |
|
| 77 |
+ ), |
|
| 78 |
+ 'toggle' => array |
|
| 79 |
+ ( |
|
| 80 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['toggle'], |
|
| 81 |
+ 'icon' => 'visible.gif', |
|
| 82 |
+ 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', |
|
| 83 |
+ 'button_callback' => array('tl_eSM_team', 'toggleIcon')
|
|
| 84 |
+ ), |
|
| 85 |
+ 'show' => array |
|
| 86 |
+ ( |
|
| 87 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['show'], |
|
| 88 |
+ 'href' => 'act=show', |
|
| 89 |
+ 'icon' => 'show.gif' |
|
| 90 |
+ ) |
|
| 91 |
+ ) |
|
| 92 |
+ ), |
|
| 93 |
+ |
|
| 94 |
+ // Palettes |
|
| 95 |
+ 'palettes' => array |
|
| 96 |
+ ( |
|
| 97 |
+ 'default' => '{person_legend},firstname,lastname;{company_legend},position,division;{picture_legend},singleSRC;{publish_legend:hide},published'
|
|
| 98 |
+ ), |
|
| 99 |
+ |
|
| 100 |
+ // Subpalettes |
|
| 101 |
+ 'subpalettes' => array |
|
| 102 |
+ ( |
|
| 103 |
+ ), |
|
| 104 |
+ |
|
| 105 |
+ // Fields |
|
| 106 |
+ 'fields' => array |
|
| 107 |
+ ( |
|
| 108 |
+ 'id' => array |
|
| 109 |
+ ( |
|
| 110 |
+ 'sql' => "int(10) unsigned NOT NULL auto_increment" |
|
| 111 |
+ ), |
|
| 112 |
+ 'pid' => array |
|
| 113 |
+ ( |
|
| 114 |
+ 'foreignKey' => 'tl_faq_category.title', |
|
| 115 |
+ 'sql' => "int(10) unsigned NOT NULL default '0'", |
|
| 116 |
+ 'relation' => array('type'=>'belongsTo', 'load'=>'eager')
|
|
| 117 |
+ ), |
|
| 118 |
+ 'tstamp' => array |
|
| 119 |
+ ( |
|
| 120 |
+ 'sql' => "int(10) unsigned NOT NULL default '0'" |
|
| 121 |
+ ), |
|
| 122 |
+ 'firstname' => array |
|
| 123 |
+ ( |
|
| 124 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['firstname'], |
|
| 125 |
+ 'exclude' => true, |
|
| 126 |
+ 'search' => true, |
|
| 127 |
+ 'inputType' => 'text', |
|
| 128 |
+ 'eval' => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
|
|
| 129 |
+ 'sql' => "varchar(128) NOT NULL default ''" |
|
| 130 |
+ ), |
|
| 131 |
+ 'lastname' => array |
|
| 132 |
+ ( |
|
| 133 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['lastname'], |
|
| 134 |
+ 'exclude' => true, |
|
| 135 |
+ 'search' => true, |
|
| 136 |
+ 'inputType' => 'text', |
|
| 137 |
+ 'eval' => array('mandatory'=>false, 'maxlength'=>128, 'tl_class'=>'w50'),
|
|
| 138 |
+ 'sql' => "varchar(128) NOT NULL default ''" |
|
| 139 |
+ ), |
|
| 140 |
+ 'position' => array |
|
| 141 |
+ ( |
|
| 142 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['position'], |
|
| 143 |
+ 'exclude' => true, |
|
| 144 |
+ 'search' => true, |
|
| 145 |
+ 'inputType' => 'text', |
|
| 146 |
+ 'eval' => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
|
|
| 147 |
+ 'sql' => "varchar(128) NOT NULL default ''" |
|
| 148 |
+ ), |
|
| 149 |
+ 'division' => array |
|
| 150 |
+ ( |
|
| 151 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['division'], |
|
| 152 |
+ 'exclude' => true, |
|
| 153 |
+ 'filter' => true, |
|
| 154 |
+ 'inputType' => 'select', |
|
| 155 |
+ 'options' => $GLOBALS['eSM_team']['divisions'], |
|
| 156 |
+ 'reference' => &$GLOBALS['TL_LANG']['REF']['divisions'], |
|
| 157 |
+ 'eval' => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
|
|
| 158 |
+ 'sql' => "varchar(128) NOT NULL default ''" |
|
| 159 |
+ ), |
|
| 160 |
+ 'singleSRC' => array |
|
| 161 |
+ ( |
|
| 162 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['singleSRC'], |
|
| 163 |
+ 'exclude' => true, |
|
| 164 |
+ 'inputType' => 'fileTree', |
|
| 165 |
+ 'eval' => array('filesOnly'=>true, 'extensions'=>Config::get('validImageTypes'), 'fieldType'=>'radio', 'mandatory'=>true),
|
|
| 166 |
+ 'sql' => "binary(16) NULL" |
|
| 167 |
+ ), |
|
| 168 |
+ 'published' => array |
|
| 169 |
+ ( |
|
| 170 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_eSM_team']['published'], |
|
| 171 |
+ 'exclude' => true, |
|
| 172 |
+ 'filter' => true, |
|
| 173 |
+ 'inputType' => 'checkbox', |
|
| 174 |
+ 'default' => '1', |
|
| 175 |
+ 'eval' => array('doNotCopy'=>true),
|
|
| 176 |
+ 'sql' => "char(1) NOT NULL default ''" |
|
| 177 |
+ ), |
|
| 178 |
+ ) |
|
| 179 |
+); |
|
| 180 |
+ |
|
| 181 |
+/** |
|
| 182 |
+ * Provide miscellaneous methods that are used by the data configuration array. |
|
| 183 |
+ */ |
|
| 184 |
+class tl_eSM_team extends Backend |
|
| 185 |
+{
|
|
| 186 |
+ |
|
| 187 |
+ /** |
|
| 188 |
+ * Import the back end user object |
|
| 189 |
+ */ |
|
| 190 |
+ public function __construct() |
|
| 191 |
+ {
|
|
| 192 |
+ parent::__construct(); |
|
| 193 |
+ $this->import('BackendUser', 'User');
|
|
| 194 |
+ } |
|
| 195 |
+ |
|
| 196 |
+ /** |
|
| 197 |
+ * Add the type of input field |
|
| 198 |
+ * |
|
| 199 |
+ * @param array $arrRow |
|
| 200 |
+ * |
|
| 201 |
+ * @return string |
|
| 202 |
+ */ |
|
| 203 |
+ public function listMembers($arrRow) |
|
| 204 |
+ {
|
|
| 205 |
+ return ' |
|
| 206 |
+<div style="float: left; width: 35%;">' . $arrRow['firstname'] . ' ' . $arrRow['lastname'] . '</div> |
|
| 207 |
+<div style="font-size: .625rem; color: #c6c6c6;"><strong>[' . $arrRow['position'] . ']</strong></div>' . "\n"; |
|
| 208 |
+ } |
|
| 209 |
+ |
|
| 210 |
+ /** |
|
| 211 |
+ * Return the "toggle visibility" button |
|
| 212 |
+ * |
|
| 213 |
+ * @param array $row |
|
| 214 |
+ * @param string $href |
|
| 215 |
+ * @param string $label |
|
| 216 |
+ * @param string $title |
|
| 217 |
+ * @param string $icon |
|
| 218 |
+ * @param string $attributes |
|
| 219 |
+ * |
|
| 220 |
+ * @return string |
|
| 221 |
+ */ |
|
| 222 |
+ public function toggleIcon($row, $href, $label, $title, $icon, $attributes) |
|
| 223 |
+ {
|
|
| 224 |
+ if (strlen(Input::get('tid')))
|
|
| 225 |
+ {
|
|
| 226 |
+ $this->toggleVisibility(Input::get('tid'), (Input::get('state') == 1), (@func_get_arg(12) ?: null));
|
|
| 227 |
+ $this->redirect($this->getReferer()); |
|
| 228 |
+ } |
|
| 229 |
+ |
|
| 230 |
+ // Check permissions AFTER checking the tid, so hacking attempts are logged |
|
| 231 |
+ if (!$this->User->hasAccess('tl_eSM_team::published', 'alexf'))
|
|
| 232 |
+ {
|
|
| 233 |
+ return ''; |
|
| 234 |
+ } |
|
| 235 |
+ |
|
| 236 |
+ $href .= '&tid='.$row['id'].'&state='.($row['published'] ? '' : 1); |
|
| 237 |
+ |
|
| 238 |
+ if (!$row['published']) |
|
| 239 |
+ {
|
|
| 240 |
+ $icon = 'invisible.gif'; |
|
| 241 |
+ } |
|
| 242 |
+ |
|
| 243 |
+ return '<a href="'.$this->addToUrl($href).'" title="'.specialchars($title).'"'.$attributes.'>'.Image::getHtml($icon, $label, 'data-state="' . ($row['published'] ? 1 : 0) . '"').'</a> '; |
|
| 244 |
+ } |
|
| 245 |
+ |
|
| 246 |
+ |
|
| 247 |
+ /** |
|
| 248 |
+ * Disable/enable a user group |
|
| 249 |
+ * |
|
| 250 |
+ * @param integer $intId |
|
| 251 |
+ * @param boolean $blnVisible |
|
| 252 |
+ * @param DataContainer $dc |
|
| 253 |
+ */ |
|
| 254 |
+ public function toggleVisibility($intId, $blnVisible, DataContainer $dc=null) |
|
| 255 |
+ {
|
|
| 256 |
+ // Set the ID and action |
|
| 257 |
+ Input::setGet('id', $intId);
|
|
| 258 |
+ Input::setGet('act', 'toggle');
|
|
| 259 |
+ |
|
| 260 |
+ if ($dc) |
|
| 261 |
+ {
|
|
| 262 |
+ $dc->id = $intId; // see #8043 |
|
| 263 |
+ } |
|
| 264 |
+ |
|
| 265 |
+ // Check the field access |
|
| 266 |
+ if (!$this->User->hasAccess('tl_eSM_team::published', 'alexf'))
|
|
| 267 |
+ {
|
|
| 268 |
+ $this->log('Not enough permissions to publish/unpublish teammember ID "'.$intId.'"', __METHOD__, TL_ERROR);
|
|
| 269 |
+ $this->redirect('contao/main.php?act=error');
|
|
| 270 |
+ } |
|
| 271 |
+ |
|
| 272 |
+ $objVersions = new Versions('tl_eSM_team', $intId);
|
|
| 273 |
+ $objVersions->initialize(); |
|
| 274 |
+ |
|
| 275 |
+ // Trigger the save_callback |
|
| 276 |
+ if (is_array($GLOBALS['TL_DCA']['tl_news']['fields']['published']['save_callback'])) |
|
| 277 |
+ {
|
|
| 278 |
+ foreach ($GLOBALS['TL_DCA']['tl_news']['fields']['published']['save_callback'] as $callback) |
|
| 279 |
+ {
|
|
| 280 |
+ if (is_array($callback)) |
|
| 281 |
+ {
|
|
| 282 |
+ $this->import($callback[0]); |
|
| 283 |
+ $blnVisible = $this->{$callback[0]}->{$callback[1]}($blnVisible, ($dc ?: $this));
|
|
| 284 |
+ } |
|
| 285 |
+ elseif (is_callable($callback)) |
|
| 286 |
+ {
|
|
| 287 |
+ $blnVisible = $callback($blnVisible, ($dc ?: $this)); |
|
| 288 |
+ } |
|
| 289 |
+ } |
|
| 290 |
+ } |
|
| 291 |
+ |
|
| 292 |
+ // Update the database |
|
| 293 |
+ $this->Database->prepare("UPDATE tl_eSM_team SET tstamp=". time() .", published='" . ($blnVisible ? '1' : '') . "' WHERE id=?")
|
|
| 294 |
+ ->execute($intId); |
|
| 295 |
+ |
|
| 296 |
+ $objVersions->create(); |
|
| 297 |
+ $this->log('A new version of record "tl_eSM_team.id='.$intId.'" has been created'.$this->getParentEntries('tl_eSM_team', $intId), __METHOD__, TL_GENERAL);
|
|
| 298 |
+ } |
|
| 299 |
+} |
|
| 0 | 300 |
\ No newline at end of file |