Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhj committed Jun 3, 2019
2 parents 5a505d6 + c386cda commit 5549dd5
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
8 changes: 4 additions & 4 deletions classes/GridClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function getGridCols() {
foreach($GLOBALS['EUF_GRID_SETTING']['cols'] as $option) {
foreach ($GLOBALS['EUF_GRID_SETTING']['viewports'] as $viewport) {
foreach($GLOBALS['EUF_GRID_SETTING']['columns'] as $column) {
$arrColumns[$option.$GLOBALS['EUF_GRID_SETTING']['devider'].$viewport][] = $option.$GLOBALS['EUF_GRID_SETTING']['devider'].$viewport.$GLOBALS['EUF_GRID_SETTING']['devider'].$column;
$arrColumns[$option.$viewport][] = $option.$viewport.$column;
}
}
}
Expand All @@ -42,7 +42,7 @@ public function getGridOptions() {
foreach($GLOBALS['EUF_GRID_SETTING']['offset'] as $option) {
foreach ($GLOBALS['EUF_GRID_SETTING']['viewports'] as $viewport) {
foreach($GLOBALS['EUF_GRID_SETTING']['offset_cols'] as $column) {
$arrOptions[$option.$GLOBALS['EUF_GRID_SETTING']['devider'].$viewport][] = $option.$GLOBALS['EUF_GRID_SETTING']['devider'].$viewport.$GLOBALS['EUF_GRID_SETTING']['devider'].$column;
$arrOptions[$option.$viewport][] = $option.$viewport.$column;
}
}
}
Expand All @@ -52,7 +52,7 @@ public function getGridOptions() {
if($GLOBALS['EUF_GRID_SETTING']['pulls']) {
foreach($GLOBALS['EUF_GRID_SETTING']['pulls'] as $option) {
foreach ($GLOBALS['EUF_GRID_SETTING']['viewports'] as $viewport) {
$arrOptions[$option][] = $option.$GLOBALS['EUF_GRID_SETTING']['devider'].$viewport;
$arrOptions[$option][] = $option.$viewport;
}
}
}
Expand All @@ -61,7 +61,7 @@ public function getGridOptions() {
if($GLOBALS['EUF_GRID_SETTING']['resets']) {
foreach($GLOBALS['EUF_GRID_SETTING']['resets'] as $option) {
foreach ($GLOBALS['EUF_GRID_SETTING']['viewports'] as $viewport) {
$arrOptions[$option][] = $option.$GLOBALS['EUF_GRID_SETTING']['devider'].$viewport;
$arrOptions[$option][] = $option.$viewport;
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions classes/GridHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ public function addGridClassesToForms($objWidget, $strForm, $arrForm)
// Klassen anfügen
if ($objWidget->type === 'fieldset' || $objWidget->type==='submit') {
$objWidget->class = $strClasses;
}
elseif ($objWidget->type==='submit' && version_compare(VERSION, '4.0', '<=')) {
$objWidget->class = $strClasses;
}
else {
$objWidget->prefix .= " ".$strClasses;
Expand Down
46 changes: 46 additions & 0 deletions classes/tl_content_extended.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,50 @@ public function addCteType($arrRow)
return $return;
}

public function onsubmitCallback(\DataContainer $dc)
{
if (!in_array($dc->activeRecord->type, array('rowStart', 'colStart'))) {
return;
}

if ('auto' !== \Contao\Input::post('SUBMIT_TYPE') && $this->siblingStopElmentIsMissing(
$dc->activeRecord->pid,
$dc->activeRecord->ptable,
$dc->activeRecord->sorting,
substr($dc->activeRecord->type, 0, 3)
)) {
$data = $dc->activeRecord->row();
unset($data['id']);
$data['type'] = str_replace('Start', 'End', $dc->activeRecord->type);
$data['sorting'] += 1;

$newElement = new \Contao\ContentModel();
$newElement->setRow($data);
$newElement->save();
}
}

private function siblingStopElmentIsMissing($pid, $ptable, $sorting, $rowOrCol)
{
if (!in_array($rowOrCol, array('row', 'col'))) {
throw new InvalidArgumentException('Argument $rowOrCol must be either "row" or "col"');
}
$statement = \Contao\Database::getInstance()
->prepare(
'SELECT * FROM tl_content WHERE pid=? AND ptable=? AND sorting>? AND type IN("' . $rowOrCol . 'Start", "'
. $rowOrCol . 'End") ORDER BY sorting'
)
->limit(1)
->execute($pid, $ptable, $sorting);

if (false === $row = $statement->fetchAssoc()) {
return true;
}

if ($rowOrCol . 'End' !== $row['type']) {
return true;
}

return false;
}
}
6 changes: 3 additions & 3 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@
* EuF Grid standard configuration
*/
$GLOBALS['EUF_GRID_SETTING'] = array (
'columns' => array ('1','2','3','4','5','6','7','8','9','10','11','12'),
'viewports' => array ('xs','sm','md','lg','xl'),
'columns' => array ('','-1','-2','-3','-4','-5','-6','-7','-8','-9','-10','-11','-12'),
'viewports' => array ('','-xs','-sm','-md','-lg','-xl'),
'devider' => '-',

'row' => 'row',
'cols' => array ('col'),
'offset' => array ('offset'),
'offset_cols' => array ('0', '1','2','3','4','5','6','7','8','9','10','11'),
'offset_cols' => array ('-0','-1','-2','-3','-4','-5','-6','-7','-8','-9','-10','-11'),
'pulls' => array ('pull-left', 'pull-right'),
'resets' => array ('clear'),
'options' => array ('') // additional custom classes
Expand Down
2 changes: 2 additions & 0 deletions dca/tl_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
$GLOBALS['TL_DCA']['tl_content']['list']['sorting']['child_record_callback'] = array('tl_content_extended', 'addCteType');

$GLOBALS['TL_DCA']['tl_content']['config']['onsubmit_callback'][] = array('tl_content_extended', 'onsubmitCallback');


/*
* Palettes
Expand Down

0 comments on commit 5549dd5

Please sign in to comment.