Work on migration script
This commit is contained in:
parent
406c333849
commit
65fbc24b36
@ -59,6 +59,7 @@ ErrorPartialFile=File not received completely by server.
|
||||
ErrorNoTmpDir=Temporary directy %s does not exists.
|
||||
ErrorUploadBlockedByAddon=Upload blocked by a PHP/Apache plugin.
|
||||
ErrorFileSizeTooLarge=File size is too large.
|
||||
ErrorFieldTooLong=Field %s is too long.
|
||||
ErrorSizeTooLongForIntType=Size too long for int type (%s digits maximum)
|
||||
ErrorSizeTooLongForVarcharType=Size too long for string type (%s chars maximum)
|
||||
ErrorNoValueForSelectType=Please fill value for select list
|
||||
|
||||
43
scripts/website/migrate_news_joomla2dolibarr.php
Normal file → Executable file
43
scripts/website/migrate_news_joomla2dolibarr.php
Normal file → Executable file
@ -37,10 +37,53 @@ define('EVEN_IF_ONLY_LOGIN_ALLOWED', 1); // Set this define to 0 if you want to
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (empty($argv[3]) || ! in_array($argv[1], array('test','confirm'))) {
|
||||
print "Usage: $script_file (test|confirm) website login:pass@serverjoomla/tableprefix/databasejoomla\n";
|
||||
print "\n";
|
||||
print "Load joomla news and create them into Dolibarr database (if they don't alreay exist).\n";
|
||||
exit(- 1);
|
||||
}
|
||||
|
||||
$mode = $argv[1];
|
||||
$website = $argv[2];
|
||||
$joomlaserverinfo = $argv[3];
|
||||
|
||||
require $path . "../../htdocs/master.inc.php";
|
||||
|
||||
$langs->load('main');
|
||||
|
||||
$joomlaserverinfoarray = preg_split('/(:|@|\/)/', $joomlaserverinfo);
|
||||
$joomlalogin = $joomlaserverinfoarray[0];
|
||||
$joomlapass = $joomlaserverinfoarray[1];
|
||||
$joomlahost = $joomlaserverinfoarray[2];
|
||||
$joomlaprefix = $joomlaserverinfoarray[3];
|
||||
$joomladatabase = $joomlaserverinfoarray[4];
|
||||
$joomlaport = 3306;
|
||||
|
||||
|
||||
$dbjoomla=getDoliDBInstance('mysqli', $joomlahost, $joomlalogin, $joomlapass, $joomladatabase, $joomlaport);
|
||||
if ($dbjoomla->error)
|
||||
{
|
||||
dol_print_error($dbjoomla,"host=".$joomlahost.", port=".$joomlaport.", user=".$joomlalogin.", databasename=".$joomladatabase.", ".$dbjoomla->error);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
$sql = 'SELECT id, title, alias, created, introtext, `fulltext` FROM '.$joomlaprefix.'_content WHERE 1 = 1';
|
||||
$resql = $dbjoomla->query($sql);
|
||||
|
||||
if (! $resql) {
|
||||
dol_print_error($dbjoomla);
|
||||
exit;
|
||||
}
|
||||
|
||||
while ($obj = $dbjoomla->fetch_object($resql)) {
|
||||
if ($obj) {
|
||||
$id = $obj->id;
|
||||
$title = $obj->title;
|
||||
$alias = $obj->alias;
|
||||
$description = dol_string_nohtmltag($obj->introtext);
|
||||
$hmtltext = $obj->fulltext;
|
||||
}
|
||||
}
|
||||
|
||||
exit($error);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user