Index: potx.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/potx/Attic/potx.info,v
retrieving revision 1.1.2.3.2.2.2.1
diff -u -p -r1.1.2.3.2.2.2.1 potx.info
--- potx.info	2 Apr 2009 11:05:29 -0000	1.1.2.3.2.2.2.1
+++ potx.info	9 Dec 2009 11:42:38 -0000
@@ -2,5 +2,6 @@
 name = Translation template extractor
 description = Provides a web interface and an API to extract translatable text from the sources of installed components.
 dependencies[] = locale
+dependencies[] = update
 core = 6.x
 package = Multilanguage
Index: potx.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/potx/Attic/potx.module,v
retrieving revision 1.1.2.12.2.2.2.10.4.2
diff -u -p -r1.1.2.12.2.2.2.10.4.2 potx.module
--- potx.module	24 Aug 2009 07:33:08 -0000	1.1.2.12.2.2.2.10.4.2
+++ potx.module	9 Dec 2009 11:42:39 -0000
@@ -37,37 +37,69 @@ function potx_menu() {
 }
 
 /**
+ * Implementation of hook_update_projects_alter().
+ */
+function potx_update_projects_alter(&$projects) {
+  module_load_include('inc', 'update', 'update.compare');
+  $modules = _potx_filter_disabled(module_rebuild_cache());
+  _update_process_info_list($projects, $modules, 'disabled-module');
+  $themes = _potx_filter_disabled(system_theme_data());
+  _update_process_info_list($projects, $themes, 'disabled-theme');
+}
+
+/**
  * Component selection interface.
  */
 function potx_select_form() {
 
   $form = array();
-  $components = _potx_component_list();
-  _potx_component_selector($form, $components);
+  /*$components = _potx_component_list();
+  _potx_component_selector($form, $components);*/
+
+  // Use update information to present a nicer overview. We then have nice
+  // project data about modules and themes which are enabled.
+  module_load_include('inc', 'update', 'update.compare');
+  $update_information = update_get_available();
+  $projects = update_get_projects();
+
+  $radios = array();
+  foreach ($projects as $key => $project) {
+    // @todo: rework this markup based on a nicer UI.
+    $title = (isset($update_information[$key]['title']) ? $update_information[$key]['title'] : $project['name']);
+    $radios[$key] = '<strong>'. $title .'</strong> <br /><small>'. t('(includes %list)', array('%list' => join(', ', $project['includes']))) .'</small>';
+  }
+  $form['project'] = array(
+    '#title' => t('Project to extract from'),
+    '#type' => 'radios',
+    '#default_value' => 'drupal',
+    '#options' => $radios,
+    '#description' => t('Pick a project to extract files from. All submodules / subthemes residing under the project in the directory tree will be included in the extraction.'),
+  );
 
   // Generate translation file for a specific language if possible.
   $languages = language_list();
   if (count($languages) > 1 || !isset($languages['en'])) {
     // We have more languages, or the single language we have is not English.
-    $options = array('n/a' => t('Language independent template'));
+    $form['type'] = array(
+      '#type' => 'radios',
+      '#title' => t('Type'),
+      '#options' => array(0 => t('Include both English originals and translations'), 1 => t('Just export English originals')),
+      '#default_value' => 0,
+    );
+
+    $options = array('n/a' => t('Language independent'));
     foreach ($languages as $langcode => $language) {
       // Skip English, as we should not have translations for this language.
       if ($langcode == 'en') {
         continue;
       }
-      $options[$langcode] = t('Template file for !langname translations', array('!langname' => t($language->name)));
+      $options[$langcode] = t($language->name);
     }
     $form['langcode'] = array(
-      '#type' => 'radios',
-      '#title' => t('Template language'),
+      '#type' => count($options) > 5 ? 'select' : 'radios',
+      '#title' => t('Language'),
       '#default_value' => 'n/a',
       '#options' => $options,
-      '#description' => t('Export a language independent or language dependent (plural forms, language team name, etc.) template.'),
-    );
-    $form['translations'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Include translations'),
-      '#description' => t('Include translations of strings in the file generated. Not applicable for language independent templates.')
     );
   }
 
@@ -297,6 +329,54 @@ function _potx_component_list() {
 }
 
 /**
+ * Implementation of hook_system_info_alter().
+ */
+function potx_system_info_alter(&$info, $file) {
+  static $names = array();
+
+  if (empty($info['project'])) {
+    if (isset($names[$file->filename])) {
+      $info['project'] = $names[$file->filename];
+      return;
+    }
+
+    if (module_exists('cvs_deploy') && ($project = cvs_deploy_get_project_name($file))) {
+      // Make sure cvs_deploy has a chance to run before our code.
+      $names[$file->filename] = $info['project'] = $project;
+    }
+    elseif (preg_match('!^(sites|profiles)/(.+)/(modules|themes)/([^/]+)($|/)!', $file->filename, $found)) {
+      // Grab top level directory name for projects hosted under sites/.../modules
+      // or themes as well as at similar places under install profiles. This
+      // might not be correct, but we do not have too much information to decide.
+      $names[$file->filename] = $info['project'] = $found[4];
+    }
+    elseif (preg_match('!^(modules|themes)/(.+)($|/)!', $file->filename, $found)) {
+      // Grab top level directory name for projects hosted under modules/ and
+      // themes/. People should theoretically not put stuff here, but distros,
+      // like Acquia Drupal do to work with the loading order sequence of core.
+      // Again, this might not be correct, but in cases like Acquia Drupal, the
+      // version information should be there in .info files, so we should not
+      // get here anyway. We do not have much information either.
+      $names[$file->filename] = $info['project'] = $found[2];
+    }
+  }
+}
+
+/**
+ * Look for disabled files in $list and return those as if all are enabled.
+ */
+function _potx_filter_disabled($list) {
+  $disabled = array();
+  foreach ($list as $key => $file) {
+    if (empty($file->status)) {
+      $file->status = 1;
+      $disabled[$key] = $file;
+    }
+  }
+  return $disabled;
+}
+
+/**
  * Implementation of hook_reviews(). Coder module integration.
  *
  * Provides the list of reviews provided by this module.
