? l10n
Index: extractor.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/l10n_community/Attic/extractor.inc,v
retrieving revision 1.1.2.13.2.2
diff -u -p -r1.1.2.13.2.2 extractor.inc
--- extractor.inc	15 Oct 2008 00:09:30 -0000	1.1.2.13.2.2
+++ extractor.inc	7 Mar 2009 18:42:52 -0000
@@ -127,7 +127,7 @@ function l10n_community_parse_package($p
 function l10n_community_save_file($revision = NULL, $file = NULL) {
   static $rid = 0;
   static $files = array();
-  
+
   if (!isset($file)) {
     // We get the release number for the files.
     $rid = $revision;
@@ -146,7 +146,8 @@ function l10n_community_save_file($revis
     }
     else {
       // New file in this release.
-      db_query("INSERT INTO {l10n_community_file} (rid, location, revision) VALUES(%d, '%s', '%s')", $rid, $file, $revision);
+      $pid = db_result(db_query("SELECT pid FROM {l10n_community_release} WHERE rid = %d", $rid));
+      db_query("INSERT INTO {l10n_community_file} (rid, pid, location, revision) VALUES(%d, %d, '%s', '%s')", $rid, $pid, $file, $revision);
       $fid = db_result(db_query("SELECT fid FROM {l10n_community_file} WHERE rid = %d and location = '%s'", $rid, $file));
     }
     $files[$file] = $fid;
@@ -174,7 +175,7 @@ function l10n_community_save_file($revis
  */
 function l10n_community_save_string($value = NULL, $file = NULL, $line = 0, $string_type = 2 /*POTX_STRING_RUNTIME*/) {
   static $files = array();
-  
+
   // Strip all slashes from string.
   $value = stripcslashes($value);
   
@@ -195,7 +196,8 @@ function l10n_community_save_string($val
     }
     if (!db_result(db_query("SELECT fid FROM {l10n_community_line} WHERE fid = %d AND sid = %d AND lineno = %d AND type = %d", $files[$file], $sid, $line, $string_type))) {
       // Location does not exist with this string.
-      db_query("INSERT INTO {l10n_community_line} (fid, sid, lineno, type) VALUES (%d, %d, %d, %d)", $files[$file], $sid, $line, $string_type);
+      $row = db_fetch_object(db_query("SELECT rid, pid FROM {l10n_community_file} WHERE fid = %d", $files[$file]));
+      db_query("INSERT INTO {l10n_community_line} (fid, sid, lineno, type, rid, pid) VALUES (%d, %d, %d, %d, %d, %d)", $files[$file], $sid, $line, $string_type, $row->rid, $row->pid);
     }
   }
 }
Index: l10n_community.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/l10n_community/Attic/l10n_community.install,v
retrieving revision 1.1.2.11.2.7
diff -u -p -r1.1.2.11.2.7 l10n_community.install
--- l10n_community.install	26 Oct 2008 20:56:42 -0000	1.1.2.11.2.7
+++ l10n_community.install	7 Mar 2009 18:42:53 -0000
@@ -170,6 +170,12 @@ function l10n_community_schema() {
         'not null' => FALSE,
         'disp-width' => '11'
       ),
+      'pid' => array(
+        'description' => $t('Reference to the {l10n_community_project}.pid of the parent project.'),
+        'type' => 'int',
+        'not null' => FALSE,
+        'disp-width' => '11'
+      ),
       'location' => array(
         'description' => $t('Path to the file within the release package.'),
         'type' => 'varchar',
@@ -198,6 +204,18 @@ function l10n_community_schema() {
         'not null' => FALSE,
         'disp-width' => '11'
       ),
+      'pid' => array(
+        'description' => $t('Reference to the {l10n_community_project}.pid of the parent project.'),
+        'type' => 'int',
+        'not null' => FALSE,
+        'disp-width' => '11'
+      ),
+      'rid' => array(
+        'description' => $t('Reference to the {l10n_community_release}.rid of the parent release.'),
+        'type' => 'int',
+        'not null' => FALSE,
+        'disp-width' => '11'
+      ),
       'lineno' => array(
         'description' => $t('Number of line where the string occurance was found.'),
         'type' => 'int',
@@ -504,3 +522,35 @@ function l10n_community_update_6004() {
   db_add_index($ret, 'l10n_community_translation', 'sid_language_suggestion', array('sid', 'language', 'is_suggestion'));
   return $ret;
 }
+
+/**
+ * Denormalize data in order to improve performance: Push project ID to file table.
+ */
+function l10n_community_update_6005() {
+  $ret = array();
+
+  db_add_field($ret, 'l10n_community_file', 'pid', array('type' => 'int', 'not null' => FALSE, 'disp-width' => 11));
+
+  $q = db_query("SELECT f.fid, r.pid FROM {l10n_community_release} r, {l10n_community_file} f WHERE r.rid = f.rid");
+  while ($row = db_fetch_object($q)) {
+    db_query("UPDATE {l10n_community_file} SET pid = %d WHERE fid = %d", $row->pid, $row->fid);
+  }
+  return $ret;
+}
+
+/**
+ * Denormalize data in order to improve performance: Push project and release ID to line table.
+ */
+function l10n_community_update_6006() {
+  $ret = array();
+
+  db_add_field($ret, 'l10n_community_line', 'pid', array('type' => 'int', 'not null' => FALSE, 'disp-width' => 11));
+  db_add_field($ret, 'l10n_community_line', 'rid', array('type' => 'int', 'not null' => FALSE, 'disp-width' => 11));
+
+  $q = db_query("SELECT l.lineno, l.fid, l.sid, l.type, f.rid, f.pid FROM {l10n_community_line} l, {l10n_community_file} f WHERE f.fid = l.fid");
+  while ($row = db_fetch_object($q)) {
+    db_query("UPDATE {l10n_community_line} SET pid = %d, rid = %d WHERE fid = %d AND lineno = %d AND type = %d AND sid = %d", $row->pid, $row->rid, $row->fid, $row->lineno, $row->type, $row->sid);
+  }
+  return $ret;
+}
+
Index: translate.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/l10n_community/Attic/translate.inc,v
retrieving revision 1.1.2.7.2.7
diff -u -p -r1.1.2.7.2.7 translate.inc
--- translate.inc	30 Dec 2008 16:57:39 -0000	1.1.2.7.2.7
+++ translate.inc	7 Mar 2009 18:42:54 -0000
@@ -591,8 +591,8 @@ function l10n_community_get_strings($lan
   }
   else {
     // Project based filtering and language based filtering built in.
-    $sql = "SELECT DISTINCT s.sid, s.value, t.tid, t.language, t.translation, t.uid_entered, t.uid_approved, t.time_entered, t.time_approved, t.has_suggestion, t.is_suggestion, t.is_active FROM {l10n_community_release} r INNER JOIN {l10n_community_file} f ON r.rid = f.rid INNER JOIN {l10n_community_line} l ON f.fid = l.fid INNER JOIN {l10n_community_string} s ON l.sid = s.sid LEFT JOIN {l10n_community_translation} t ON s.sid = t.sid AND t.language = '%s' AND t.is_active = 1 AND t.is_suggestion = 0 WHERE r.pid = %d";
-    $sql_count = "SELECT COUNT(DISTINCT(s.sid)) FROM {l10n_community_release} r INNER JOIN {l10n_community_file} f ON r.rid = f.rid INNER JOIN {l10n_community_line} l ON f.fid = l.fid INNER JOIN {l10n_community_string} s ON l.sid = s.sid LEFT JOIN {l10n_community_translation} t ON s.sid = t.sid AND t.language = '%s' AND t.is_active = 1 AND t.is_suggestion = 0 WHERE r.pid = %d";
+    $sql = "SELECT DISTINCT s.sid, s.value, t.tid, t.language, t.translation, t.uid_entered, t.uid_approved, t.time_entered, t.time_approved, t.has_suggestion, t.is_suggestion, t.is_active FROM {l10n_community_line} l INNER JOIN {l10n_community_string} s ON l.sid = s.sid LEFT JOIN {l10n_community_translation} t ON s.sid = t.sid AND t.language = '%s' AND t.is_active = 1 AND t.is_suggestion = 0 WHERE l.pid = %d";
+    $sql_count = "SELECT COUNT(DISTINCT(s.sid)) FROM {l10n_community_line} l INNER JOIN {l10n_community_string} s ON l.sid = s.sid LEFT JOIN {l10n_community_translation} t ON s.sid = t.sid AND t.language = '%s' AND t.is_active = 1 AND t.is_suggestion = 0 WHERE l.pid = %d";
     $sql_args = array($langcode, $project->pid);
   }
 
@@ -609,7 +609,7 @@ function l10n_community_get_strings($lan
     // Release restriction.
     $sql_args[] = $release;
     $sql_args[] = $release;
-    $release_sql = ' AND r.rid = %d';
+    $release_sql = ' AND l.rid = %d';
     $sql .= $release_sql;
     $sql_count .= $release_sql;
   }
