summaryrefslogtreecommitdiffstats
path: root/gl2drupal.php
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mekanisti.fi>2009-02-24 00:30:09 +0200
committerFilipp Lepalaan <filipp@mekanisti.fi>2009-02-24 00:30:09 +0200
commitf435e769b56d484b98e8e28706b2a97a7f05b776 (patch)
treed5d271d5710b34658e26ae91791d6508bf0965d8 /gl2drupal.php
parente7a3359321c9b705ce078b92aa7cace43ec9ed13 (diff)
downloadgl2drupal-f435e769b56d484b98e8e28706b2a97a7f05b776.tar.gz
gl2drupal-f435e769b56d484b98e8e28706b2a97a7f05b776.tar.bz2
gl2drupal-f435e769b56d484b98e8e28706b2a97a7f05b776.zip
flatpot
Diffstat (limited to 'gl2drupal.php')
-rwxr-xr-xgl2drupal.php28
1 files changed, 25 insertions, 3 deletions
diff --git a/gl2drupal.php b/gl2drupal.php
index 5d89c3c..e9b0b22 100755
--- a/gl2drupal.php
+++ b/gl2drupal.php
@@ -176,8 +176,30 @@ EOS;
$result = mysql_query($sql);
+
+/**
+ * Flatten a modified pre-order traversal structure
+ * into the Drupal form.
+ * @param
+ * @return (string) a "node's" full path in Drupal notation
+ */
+function flatpot($lft, $rht, $indent, $current = '')
+{
+ $sql = "SELECT lft, rht, indent
+ FROM gl_comments
+ WHERE lft < $lft AND rht > $rht
+ ORDER BY lft ASC";
+ $result = mysql_query($sql);
+ while ($row = mysql_fetch_assoc($result)) {
+ $path = $current .
+ $out .= flatpot($row['lft'], $row['rht'], $row['indent'], $path);
+ }
+ return $out;
+}
+
/**
* Convert GL "pre-order traversal" to Drupal "notation"
+ * http://www.sitepoint.com/article/hierarchical-data-database/2/
* Since we order by lft, we know that the next row always comes "after" the current one.
* We only have to determine if it's a child or a sibling, which we should get from the indent.
* 1 2 0 01/
@@ -187,8 +209,8 @@ $result = mysql_query($sql);
* 9 10 0 03/
*/
$sid = 0;
-while ($row = mysql_fetch_array($result)) {
-
+while ($row = mysql_fetch_array($result))
+{
// Process these by chunks of "stories"
if ($sid != $row['sid']) {
$sid = $row['sid'];
@@ -222,7 +244,7 @@ while ($row = mysql_fetch_array($result)) {
'{$row['ipaddress']}', {$row['date']}, 0, 1, '{$thread}',
'{$row['username']}', '{$row['email']}')";
- query($insert, "Inserting comment thread $thread");
+// query($insert, "Inserting comment thread $thread");
}