/[drupal]/contributions/modules/transliteration/transliteration.module
ViewVC logotype

Diff of /contributions/modules/transliteration/transliteration.module

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

revision 1.7, Fri Oct 9 12:19:44 2009 UTC revision 1.8, Thu Oct 15 20:01:47 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: transliteration.module,v 1.6 2009/09/24 19:19:53 smk Exp $  // $Id: transliteration.module,v 1.7 2009/10/09 12:19:44 smk Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 10  Line 10 
10   */   */
11    
12  /**  /**
13     * Sanitize a file path.
14     *
15     * Additionally removes invalid characters from a file name (which may include
16     * sub-directories) after transliteration.
17     *
18     * @param $filename
19     *   A file name.
20     * @param $source_langcode
21     *   Optional ISO 639 language code that denotes the language of the input.
22     *   Used to apply language-specific variations and defaults to the current
23     *   display language. If transliteration takes place during output (instead
24     *   of creation) and the source language is not known at that time, it is
25     *   recommended to set this argument to 'en' to produce consistent results
26     *   for all enabled languages.
27     * @return
28     *   Cleaned file name.
29     */
30    function transliteration_clean_filename($filename, $source_langcode = NULL) {
31      // Transliterate.
32      $filename = transliteration_get($filename, '', $source_langcode);
33      // Replace whitespace.
34      $filename = str_replace(' ', '_', $filename);
35      // Remove remaining unsafe characters.
36      $filename = preg_replace('![^0-9A-Za-z_./-]!', '', $filename);
37      // Force lowercase to prevent issues on case-insensitive file systems.
38      $filename = strtolower($filename);
39    
40      return $filename;
41    }
42    
43    /**
44   * Transliterate UTF-8 text to ASCII.   * Transliterate UTF-8 text to ASCII.
45   *   *
46   * Takes an input string in any language and character set, and tries to   * Takes an input string in any language and character set, and tries to

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.2