Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow recursive dca picker in the same table #906

Merged
merged 4 commits into from
Jul 4, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Resources/contao/classes/DataContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -874,14 +874,21 @@ protected function generateGlobalButtons()
*/
protected function initPicker()
{
if (\Input::get('target') == '' || \Input::get('act') == 'select' || \Input::get('act') == 'paste')
{
return false;
}

list($this->strPickerTable, $this->strPickerField, $this->intPickerId) = explode('.', \Input::get('target'), 3);
\Input::setGet('target', null);

$menuBuilder = \System::getContainer()->get('contao.menu.picker_menu_builder');

if (!$menuBuilder->supportsTable($this->strTable))
if (!$menuBuilder->supportsTable($this->strTable) || empty($this->strPickerTable) || empty($this->strPickerField) || empty($this->intPickerId))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should run those checks before we initialize the menu builder, shouldn't we?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, changed in 4665cd5

{
return false;
}

list($this->strPickerTable, $this->strPickerField, $this->intPickerId) = explode('.', \Input::get('target'), 3);
$this->intPickerId = (int) $this->intPickerId;

\Controller::loadDataContainer($this->strPickerTable);
Expand Down
10 changes: 1 addition & 9 deletions src/Resources/contao/drivers/DC_Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,7 @@ public function __construct($strTable)
}

// Initialize the picker
if (isset($_GET['target']) && \Input::get('act') != 'select' && \Input::get('act') != 'paste')
{
list($table) = explode('.', \Input::get('target'), 2);

if ($this->strTable != $table)
{
$this->initPicker();
}
}
$this->initPicker();

// Get all filemounts (root folders)
if (is_array($GLOBALS['TL_DCA'][$strTable]['list']['sorting']['root']))
Expand Down
10 changes: 1 addition & 9 deletions src/Resources/contao/drivers/DC_Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,7 @@ public function __construct($strTable, $arrModule=array())
}

// Initialize the picker
if (isset($_GET['target']) && \Input::get('act') != 'select' && \Input::get('act') != 'paste')
{
list($table) = explode('.', \Input::get('target'), 2);

if ($this->strTable != $table)
{
$this->initPicker();
}
}
$this->initPicker();

// Get the IDs of all root records (tree view)
if ($this->treeView)
Expand Down