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

Diff of /contributions/modules/transliteration/transliteration.inc

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

revision 1.8, Fri Oct 9 12:19:44 2009 UTC revision 1.9, Thu Oct 15 20:01:47 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: transliteration.inc,v 1.7 2009/09/05 22:24:26 smk Exp $  // $Id: transliteration.inc,v 1.8 2009/10/09 12:19:44 smk Exp $
   
 /**  
  * Sanitize a file name.  
  *  
  * Transliterates the file name and removes invalid characters.  
  *  
  * @param $filename  
  *   A file name.  
  * @param $source_langcode  
  *   Optional ISO 639 language code that denotes the language of the input.  
  *   Used to apply language-specific variations and defaults to the current  
  *   display language. If transliteration takes place during output (instead  
  *   of creation) and the source language is not known at that time, it is  
  *   recommended to set this argument to 'en' to produce consistent results  
  *   for all enabled languages.  
  * @return  
  *   Cleaned file name.  
  */  
 function transliteration_clean_filename($filename, $source_langcode = NULL) {  
   // Trim any leading/trailing dots.  
   $filename = trim($filename, '.');  
   // Transliterate to ASCII.  
   $filename = transliteration_process($filename, '', $source_langcode);  
   // Replace whitespace.  
   $filename = str_replace(' ', '_', $filename);  
   // Remove any remaining non-safe characters.  
   $filename = preg_replace('/[^0-9A-Za-z_.-]/', '', $filename);  
   // Force lowercase to prevent issues on case insensitive file systems.  
   $filename = strtolower($filename);  
   
   return $filename;  
 }  
3    
4  /**  /**
5   * Transliterate UTF-8 text to ASCII.   * Transliterate UTF-8 text to ASCII.

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

  ViewVC Help
Powered by ViewVC 1.1.2