Skip to content

Commit d08dd9d

Browse files
committed
Synchronizing some fields, which are responsible for visibillity, from the start tag to the end tag (see #30)
1 parent f3e9f2c commit d08dd9d

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

contao/config/config.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@
1414
*
1515
* Config
1616
*/
17-
$GLOBALS['TL_HTML5'] = array(
17+
$GLOBALS['TL_HTML5']['tags'] = array(
1818
'tl_content' => array('article', 'aside', 'div', 'footer', 'header', 'section')
1919
);
2020

21+
$GLOBALS['TL_HTML5']['copyFields'] = array(
22+
'tl_content' => array('protected', 'groups', 'guests', 'start', 'stop')
23+
);
24+
2125
/**
2226
* Content Element
2327
*/

src/Backend/Callbacks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,6 @@ public static function addColorizeJs($objRow, $strBuffer, $objElement)
185185
*/
186186
public function getHtml5Tags(\DataContainer $dc) {
187187

188-
return $GLOBALS['TL_HTML5'][$dc->table];
188+
return $GLOBALS['TL_HTML5']['tags'][$dc->table];
189189
}
190190
}

src/Backend/TagUtils.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ public function createOrUpdateCorresppondingTag(Result $item)
7676
'sh5_pid' => $item->id,
7777
'sh5_type' => $item->sh5_type
7878
);
79+
80+
if ($item->type == 'sHtml5Start') {
81+
$data = array_merge($data, $this->getUpdateData($item));
82+
}
83+
7984
$this->updateTag($cTags->id, $data);
8085

8186
$blnDelete = true;
@@ -204,4 +209,21 @@ public function updateTag($id, $data)
204209
->execute($id);
205210
}
206211

212+
/**
213+
* Collects all fields which should have the same values foro start and end
214+
* tag, e.g. the show to guest only flag. See #30
215+
*
216+
* @param Result $item
217+
* @return array an array with the data of the copy fields
218+
*/
219+
protected function getUpdateData(Result $item){
220+
$copyFields = array();
221+
222+
foreach ($GLOBALS['TL_HTML5']['copyFields'][$this->table] as $field) {
223+
$copyFields[$field] = $item->$field;
224+
}
225+
226+
return $copyFields;
227+
}
228+
207229
}

0 commit comments

Comments
 (0)