I was wondering if there was any advice (or scripts) to help me migrate from media gallery for geeklog to gallery 2 or 3, i know i can batch import th photos but i was wondering abou the details the users have added to there photos?
Waaay late reply, but this is the first hit on google for 'migrate geeklog gallery to gallery2', so I thought I'd post the answer ;)
After starting this as a fairly manual process, then realising how much work it was going to be, I wrote a quick import script.. Basically firstly it exports all the images for each album into separate directories, so you can import them an album at a time into G2. Then after you've done that, it goes through all the files and sets the title/description/timestamp for each image file.. I didn't bother with comments, as my old gallery had them disabled..
Anyway, thought it'd help a bit
<?PHP
// settings
$db_gl_connectstring = 'mysql:host=hostname;dbname=mygldb'; // GL DB PDO connection string
$db_gl_username = 'gluser'; // GL DB Username
$db_gl_password = 'pass'; // GL DB Password.
$db_g2_connectstring = 'mysql:host=hostname;dbname=gallery2'; // Gallery2 DB PDO connection string
$db_g2_username = 'g2user'; // Gallery2 DB Username
$db_g2_password = 'pass'; // Gallery2 DB Password.
$gl_source = '/home/oldsite/mediagallery/mediaobjects/orig/';
$targetlocation = '/home/newsite/uploads/old_gl/'; // Directory to use as base for created directories..
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Geeklog mediagallery to Gallery2 convertor</title>
</head>
<h2>There are a number of steps:</h2>
<table><tr valign="top"><th>Step 1</th><td>Create your entire GL MG gallery structure within Gallery 2. Yes, I could have probably coded this up, but I'd already done it manually before I realised I was going to need to do some scripting, so I'm not building it myself ;) )</td></tr>
<tr valign="top"><th>Step 2</th><td>We iterate over the Geeklog MediaGallery albums, creating a folder for each album. We also copy each of the source files for this album, into this new folder. Script will display a table with Album ID (sub-folder name on filesystem), Gallery Name (for your reference), and number of files copied to location. <a href="<?=$_SERVER['PHP_SELF']?>?step=2">Run Step 2</a></td></tr>
<tr valign="top"><th>Step 3</th><td>Go back into gallery, open each album, and import the contents of the relevant folder from the filesystem into that gallery. yes, it'll take you some work :-p</td></tr>
<tr valign="top"><th>Step 4</th><td>We iterate over every media item in mediagallery (we assume we don't have duplicate filenames..), and then look for an identical filename in Gallery2 - if we get a match, we set the title, file date, and upload date, to what it was in mediagallery..<a href="<?=$_SERVER['PHP_SELF']?>?step=4">Run Step 4</a></td></tr>
</table>
<?PHP
if ($_REQUEST['step']==2) {
echo '<h3>Step 2</h3><table><tr><td>Album ID</td><Td>Album title</td><td>File Count</td></tr>';
$db = new PDO($db_gl_connectstring, $db_gl_username, $db_gl_password);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare("select album_id, album_title from gl_mg_albums");
$stmt->execute();
while (($row = $stmt->fetch(PDO::FETCH_ASSOC))) {
@mkdir($targetlocation.$row['album_id']);
echo "<tr><td>".$row['album_id'].'</td><td>'.$row['album_title']."</td><td>";
$stmt2 = $db->prepare("select m.media_filename, m.media_original_filename, m.media_mime_ext from gl_mg_media m left join gl_mg_media_albums a on a.media_id=m.media_id where a.album_id=".$row['album_id']);
$stmt2->execute();
$filecount=0;
while (($row2 = $stmt2->fetch(PDO::FETCH_ASSOC))) {
// copy the original file to the target directory..
copy($gl_source.substr($row2['media_filename'], 0, 1).'/'.$row2['media_filename'].'.'.$row2['media_mime_ext'], $targetlocation.'/'.$row['album_id'].'/'.$row2['media_original_filename']);
$filecount++;
}
echo "$filecount</td></tr>";
}
echo '</table>';
} else if ($_REQUEST['step']==4) {
echo '<h3>Step 4</h3>';
// Connect to GL
$gldb = new PDO($db_gl_connectstring, $db_gl_username, $db_gl_password);
$gldb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$g2db = new PDO($db_g2_connectstring, $db_g2_username, $db_g2_password);
$g2db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Select out *all* media items..
$stmt2 = $gldb->prepare("select media_original_filename, media_time, media_title, media_desc, media_upload_time from gl_mg_media m");
$stmt2->execute();
$g2stmt = $g2db->prepare("update g2_Item i left join g2_FileSystemEntity f on i.g_id=f.g_id set i.g_title=?, i.g_summary=?, i.g_originationTimestamp=? where upper(f.g_pathComponent)=?");
while (($row = $stmt2->fetch(PDO::FETCH_ASSOC))) {
echo $row['media_original_filename']."<br>\n";
flush();
$g2stmt->bindParam(1, $row['media_title']);
$g2stmt->bindParam(2, $row['media_desc']);
$g2stmt->bindParam(3, $row['media_time']);
$g2stmt->bindValue(4, strtoupper($row['media_original_filename']));
$g2stmt->execute();
}
}
?>
<body>
</body>
</html>
Hope that saves someone else some hassles
Cheers,
Damien
suprsidr
Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2010-10-26 13:18
I'm sorry I missed the original comment, I could have saved you the trouble as I'm the maintainer of the Geeklog<->Gallery2 bridge and could have easily done this.
Posts: 1
Waaay late reply, but this is the first hit on google for 'migrate geeklog gallery to gallery2', so I thought I'd post the answer ;)
After starting this as a fairly manual process, then realising how much work it was going to be, I wrote a quick import script.. Basically firstly it exports all the images for each album into separate directories, so you can import them an album at a time into G2. Then after you've done that, it goes through all the files and sets the title/description/timestamp for each image file.. I didn't bother with comments, as my old gallery had them disabled..
Anyway, thought it'd help a bit
Hope that saves someone else some hassles
Cheers,
Damien
Posts: 8339
I'm sorry I missed the original comment, I could have saved you the trouble as I'm the maintainer of the Geeklog<->Gallery2 bridge and could have easily done this.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2