/[drupal]/contributions/modules/i18n/i18nstrings/i18nstrings.module
ViewVC logotype

Diff of /contributions/modules/i18n/i18nstrings/i18nstrings.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.8.2.32, Sat Aug 29 21:08:25 2009 UTC revision 1.8.2.33, Tue Nov 3 17:53:24 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: i18nstrings.module,v 1.8.2.31 2009/01/19 19:05:12 jareyero Exp $  // $Id: i18nstrings.module,v 1.8.2.32 2009/08/29 21:08:25 hass Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 771  function i18nstrings_title_callback($nam Line 771  function i18nstrings_title_callback($nam
771   *   Text group to refresh   *   Text group to refresh
772   * @param $delete   * @param $delete
773   *   Optional, delete existing (but not refresed, strings and translations)   *   Optional, delete existing (but not refresed, strings and translations)
774     * @return Boolean
775     *   True if the strings have been refreshed successfully. False otherwise.
776   */   */
777  function i18nstrings_refresh_group($group, $delete = FALSE) {  function i18nstrings_refresh_group($group, $delete = FALSE) {
778      // Check for the refresh callback
779      $refresh_callback = i18nstrings_group_info($group, 'refresh callback');
780      if (!$refresh_callback) {
781        return FALSE;
782      }
783    // Delete data from i18n_strings so it is recreated    // Delete data from i18n_strings so it is recreated
784    db_query("DELETE FROM {i18n_strings} WHERE lid IN (SELECT lid FROM {locales_source} WHERE textgroup = '%s')", $group);    db_query("DELETE FROM {i18n_strings} WHERE lid IN (SELECT lid FROM {locales_source} WHERE textgroup = '%s')", $group);
785    
786    module_invoke_all('locale', 'refresh', $group);    $result = call_user_func($refresh_callback);
787    
788    // Now delete all source strings that were not refreshed    // Now delete all source strings that were not refreshed
789    if ($delete) {    if ($result && $delete) {
790      $result = db_query("SELECT s.* FROM {locales_source} s LEFT JOIN {i18n_strings} i ON s.lid = i.lid WHERE s.textgroup = '%s' AND i.lid IS NULL", $group);      $result = db_query("SELECT s.* FROM {locales_source} s LEFT JOIN {i18n_strings} i ON s.lid = i.lid WHERE s.textgroup = '%s' AND i.lid IS NULL", $group);
791      while ($source = db_fetch_object($result)) {      while ($source = db_fetch_object($result)) {
792        db_query("DELETE FROM {locales_target} WHERE lid = %d", $source->lid);        db_query("DELETE FROM {locales_target} WHERE lid = %d", $source->lid);
# Line 788  function i18nstrings_refresh_group($grou Line 795  function i18nstrings_refresh_group($grou
795    }    }
796    
797    cache_clear_all('locale:'. $group .':', 'cache', TRUE);    cache_clear_all('locale:'. $group .':', 'cache', TRUE);
798      return $result;
799    }
800    
801    /**
802     * Get refresh callback for a text group
803     *
804     * @param $group
805     *
806     * @return callback
807     */
808    function i18nstrings_group_info($group = NULL, $property = NULL) {
809      static $info;
810    
811      if (!isset($callbacks)) {
812        $info = module_invoke_all('locale', 'info');
813      }
814    
815      if ($group && $property) {
816        return isset($info[$group][$property]) ? $info[$group][$property] : NULL;
817      }
818      elseif ($group) {
819        return isset($info[$group]) ? $info[$group] : array();
820      }
821      else {
822        return $info;
823      }
824  }  }
825    
826  /*** l10n client related functions ***/  /*** l10n client related functions ***/

Legend:
Removed from v.1.8.2.32  
changed lines
  Added in v.1.8.2.33

  ViewVC Help
Powered by ViewVC 1.1.2