Improved the table detection in the mapping of the extrusion class when building table/fields from mysql dump

This commit is contained in:
2018-06-15 15:31:23 +02:00
parent 3db9deb534
commit 0c7d7265dd
5 changed files with 31 additions and 16 deletions

View File

@ -1417,6 +1417,11 @@ class Interpretation extends Fields
$method[] = $this->_t(3) . "'password1' => \$password, // First password field";
$method[] = $this->_t(3) . "'password2' => \$password2, // Confirm password field";
$method[] = $this->_t(3) . "'block' => 0 );";
$method[] = $this->_t(2) . "// set groups if found";
$method[] = $this->_t(2) . "if (isset(\$new['groups']) && self::checkArray(\$new['groups']))";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "\$data['groups'] = \$new['groups'];";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "// register the new user";
$method[] = $this->_t(2) . "\$done = \$model->save(\$data);";
$method[] = $this->_t(2) . "// if user is updated";

View File

@ -101,7 +101,7 @@ class Mapping
{
// set the app to insure messages can be set
$this->app = JFactory::getApplication();
if (ComponentbuilderHelper::checkArray($data))
{
if (isset($data['buildcomp']) && 1 == $data['buildcomp'] && isset($data['buildcompsql']))
@ -155,7 +155,7 @@ class Mapping
);
return false;
}
/**
* The mapping function
* To Map the views and fields that are needed
@ -169,7 +169,8 @@ class Mapping
foreach ($queries as $query)
{
// only use create table queries
if (strpos($query, 'CREATE TABLE IF NOT EXISTS `') !== false)
if (strpos($query, 'CREATE TABLE IF NOT EXISTS') !== false ||
strpos($query, 'CREATE TABLE') !== false)
{
if ($tableName = $this->getTableName($query))
{
@ -205,15 +206,24 @@ class Mapping
}
return false;
}
/**
* Get the table name
*/
protected function getTableName(&$query)
{
$tableName = ComponentbuilderHelper::getBetween($query, '`#__', "`");
if (strpos($query, '`#__') !== false)
{
// get table name
$tableName = ComponentbuilderHelper::getBetween($query, '`#__', "`");
}
elseif (strpos($query, "'#__") !== false)
{
// get table name
$tableName = ComponentbuilderHelper::getBetween($query, "'#__", "'");
}
// if it still was not found
if (!ComponentbuilderHelper::checkString($tableName))
if (!isset($tableName) || !ComponentbuilderHelper::checkString($tableName))
{
// skip this query
return false;
@ -231,13 +241,13 @@ class Mapping
// skip this query
return false;
}
/**
* Get the field details
*/
protected function getFields(&$query)
{
$rows = array_map('trim', explode("\n", $query));
$rows = array_map('trim', explode(PHP_EOL, $query));
$fields = array();
foreach ($rows as $row)
{
@ -306,7 +316,7 @@ class Mapping
}
return false;
}
/**
* Get the field types
*/
@ -325,7 +335,7 @@ class Mapping
}
return false;
}
/**
* Get the field size
*/
@ -337,7 +347,7 @@ class Mapping
}
return '';
}
/**
* Get the field default
*/
@ -355,7 +365,7 @@ class Mapping
}
return '';
}
/**
* Get the field Null Value
*/
@ -373,7 +383,7 @@ class Mapping
}
return 'NULL';
}
/**
* Get the field key status
*/