Changeset 3180 in subversion


Ignore:
Timestamp:
Dec 14, 2009 2:37:32 AM (3 years ago)
Author:
alec
Message:
  • don't use preg_replace with /e modifier + code cleanup
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/rcmail.php

    r3177 r3180  
    637637 
    638638    $nr = is_numeric($attrib['nr']) ? $attrib['nr'] : 1; 
    639     $vars = isset($attrib['vars']) ? $attrib['vars'] : ''; 
    640  
    641     $command_name = !empty($attrib['command']) ? $attrib['command'] : NULL; 
    642     $alias = $attrib['name'] ? $attrib['name'] : ($command_name && $command_label_map[$command_name] ? $command_label_map[$command_name] : ''); 
    643      
     639    $name = $attrib['name'] ? $attrib['name'] : ''; 
     640 
    644641    // check for text with domain 
    645     if ($domain && ($text_item = $this->texts[$domain.'.'.$alias])) 
     642    if ($domain && ($text_item = $this->texts[$domain.'.'.$name])) 
    646643      ; 
    647644    // text does not exist 
    648     else if (!($text_item = $this->texts[$alias])) { 
    649       /* 
    650       raise_error(array( 
    651         'code' => 500, 
    652         'type' => 'php', 
    653         'line' => __LINE__, 
    654         'file' => __FILE__, 
    655         'message' => "Missing localized text for '$alias' in '$sess_user_lang'"), TRUE, FALSE); 
    656       */ 
    657       return "[$alias]"; 
     645    else if (!($text_item = $this->texts[$name])) { 
     646      return "[$name]"; 
    658647    } 
    659648 
     
    685674    if (is_array($attrib['vars'])) { 
    686675      foreach ($attrib['vars'] as $var_key => $var_value) 
    687         $a_replace_vars[$var_key{0}=='$' ? substr($var_key, 1) : $var_key] = $var_value; 
    688     } 
    689  
    690     if ($a_replace_vars) 
    691       $text = preg_replace('/\$\{?([_a-z]{1}[_a-z0-9]*)\}?/ei', '$a_replace_vars["\1"]', $text); 
     676        $text = str_replace($var_key[0]!='$' ? '$'.$var_key : $var_key, $var_value, $text); 
     677    } 
    692678 
    693679    // format output 
Note: See TracChangeset for help on using the changeset viewer.