includes/lang.php
changeset 536 218a627eb53e
parent 519 94214ec0871c
child 555 ac4c6a7f01d8
equal deleted inserted replaced
533:698a8f04957c 536:218a627eb53e
     1 <?php
     1 <?php
     2 
     2 
     3 /*
     3 /*
     4  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
     4  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
     5  * Version 1.1.1
     5  * Version 1.1.4 (Caoineag alpha 4)
     6  * Copyright (C) 2006-2007 Dan Fuhry
     6  * Copyright (C) 2006-2008 Dan Fuhry
     7  *
     7  *
     8  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
     8  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
     9  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
     9  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    10  *
    10  *
    11  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
    11  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
   597   
   597   
   598   function get($string_id, $substitutions = false)
   598   function get($string_id, $substitutions = false)
   599   {
   599   {
   600     if ( !is_array($substitutions) )
   600     if ( !is_array($substitutions) )
   601       $substitutions = array();
   601       $substitutions = array();
       
   602     // if this isn't a valid language string ID, just return the string unprocessed.
       
   603     if ( !preg_match('/^([a-z0-9]+)((_[a-z0-9]+)+)$/', $string_id) )
       
   604       return $string_id;
   602     return $this->substitute($this->get_uncensored($string_id), $substitutions);
   605     return $this->substitute($this->get_uncensored($string_id), $substitutions);
   603   }
   606   }
   604   
   607   
   605   /**
   608   /**
   606    * The same as get(), but does not perform any substitution or filtering. Used in get() (of course) and in the admin panel, where
   609    * The same as get(), but does not perform any substitution or filtering. Used in get() (of course) and in the admin panel, where
   623       $string = $this->strings[$category][$string_name];
   626       $string = $this->strings[$category][$string_name];
   624     }
   627     }
   625     if ( !$found )
   628     if ( !$found )
   626     {
   629     {
   627       // Ehh, the string wasn't found. Rerun fetch() and try again.
   630       // Ehh, the string wasn't found. Rerun fetch() and try again.
       
   631       // Or if it's the installer, no use in refetching, so just fail.
   628       if ( defined('IN_ENANO_INSTALL') )
   632       if ( defined('IN_ENANO_INSTALL') )
   629       {
   633       {
   630         return $string_id;
   634         return $string_id;
   631       }
   635       }
   632       $this->fetch();
   636       $this->fetch();