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

First try to have content_types working with additional connections #1812

Merged
merged 2 commits into from
Mar 9, 2017
Merged
Changes from all 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
17 changes: 10 additions & 7 deletions administrator/components/com_fabrik/models/contenttypeexport.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ public function create($formModel)
// We don't want to export the main table, as a new one is created when importing the content type
$this->listModel = $formModel->getListModel();
$mainTable = $this->listModel->getTable()->get('db_table_name');
$mainTableConnection = $this->listModel->getTable()->get('connection_id');
$contentType = $this->doc->createElement('contenttype');
$tables = FabrikContentTypHelper::iniTableXML($this->doc, $mainTable);

Expand All @@ -234,7 +235,7 @@ public function create($formModel)
$elements[] = $elementModel->getElement()->getProperties();
}

$contentType->appendChild($this->createFabrikGroupXML($groupData, $elements, $tables, $mainTable));
$contentType->appendChild($this->createFabrikGroupXML($groupData, $elements, $tables, $mainTable, $mainTableConnection));
}

$contentType->appendChild($tables);
Expand Down Expand Up @@ -280,7 +281,7 @@ private function version()
*
* @return DOMElement
*/
private function createFabrikGroupXML($data, $elements, $tables, $mainTable = '')
private function createFabrikGroupXML($data, $elements, $tables, $mainTable = '', $mainTableConnection=1)
{
$tableParams = array('table_join', 'join_from_table');

Expand All @@ -295,7 +296,7 @@ private function createFabrikGroupXML($data, $elements, $tables, $mainTable = ''
{
if ($join->get($tableParam) !== $mainTable)
{
$this->createTableXML($tables, $join->get($tableParam));
$this->createTableXML($tables, $join->get($tableParam), $mainTableConnection);
}
}

Expand Down Expand Up @@ -334,7 +335,7 @@ private function createFabrikElementXML($data, $tables, $mainTable)

if ($params->get('join_db_name') !== $mainTable)
{
$this->createTableXML($tables, $params->get('join_db_name'));
$this->createTableXML($tables, $params->get('join_db_name'),$params->get('join_conn_id'));
}
};

Expand All @@ -361,7 +362,7 @@ private function createFabrikElementXML($data, $tables, $mainTable)
*
* @throws Exception
*/
private function createTableXML(&$tables, $tableName)
private function createTableXML(&$tables, $tableName,$tableConnId = 1)
{
if (in_array($tableName, self::$exportedTables))
{
Expand All @@ -371,15 +372,17 @@ private function createTableXML(&$tables, $tableName)
self::$exportedTables[] = $tableName;
//$exporter = $this->db->getExporter();

$tabDbo= FabrikWorker::getDbo(false, $tableConnId);

// Until the J! exporters are fixed, we only handle Mysqli (with out extended class)
if (!($this->db instanceof JDatabaseDriverMysqli))
if (!($tabDbo instanceof JDatabaseDriverMysqli))
{
throw new Exception('Sorry, we currently only support the Mysqli database driver for export');
}

$exporter = new JDatabaseExporterMysqli2;
$exporter->setDbo($this->db);

$exporter->setDbo($tabDbo);
$exporter->from($tableName);
$tableDoc = new DOMDocument();
$xml = (string) $exporter;
Expand Down