| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/core/src/lmbPHPTokenizer.class.php'); 10 lmb_require('limb/i18n/src/translation/lmbSourceDictionaryExtractor.class.php'); 11 lmb_require('limb/i18n/src/translation/lmbI18NDictionary.class.php'); 12 13 /** 14 * class lmbPHPDictionaryExtractor. 15 * 16 * @package i18n 17 * @version $Id: lmbPHPDictionaryExtractor.class.php 5945 2007-06-06 08:31:43Z pachanga $ 18 */ 19 class lmbPHPDictionaryExtractor extends lmbSourceDictionaryExtractor 20 { 21 protected $tokenizer; 22 23 function __construct() 24 { 25 $this->tokenizer = new lmbPHPTokenizer(); 26 } 27 28 function extract($code, &$dictionaries = array(), $response = null) 29 { 30 $this->tokenizer->input($code); 31 32 while($token = $this->tokenizer->next()) 33 { 34 if(is_array($token) && $token[0] == T_STRING && $token[1] == 'lmb_i18n') 35 { 36 $parenthesis = array(); 37 if($this->tokenizer->next() == "(") 38 { 39 $text_token = $this->tokenizer->next(); 40 if(!is_array($text_token) || $text_token[0] != T_CONSTANT_ENCAPSED_STRING) 41 continue; 42 43 array_push($parenthesis, 1); 44 $text = trim($text_token[1], '"\''); 45 46 //getting tokens until function closes its last ) 47 $buffer = array(); 48 while($parenthesis && $token = $this->tokenizer->next()) 49 { 50 if($token == ")") 51 array_pop($parenthesis); 52 elseif($token == "(") 53 array_push($parenthesis, 1); 54 55 $buffer[] = $token; 56 } 57 58 $domain = 'default'; 59 if(sizeof($buffer) > 2) 60 { 61 $domain_token = $buffer[sizeof($buffer)-2]; 62 if(is_array($domain_token) && $domain_token[0] == T_CONSTANT_ENCAPSED_STRING) 63 $domain = trim($domain_token[1], '"\''); 64 } 65 66 if($response) 67 $response->write("PHP source: '$text'@$domain\n"); 68 69 if(!isset($dictionaries[$domain])) 70 { 71 $dictionary = new lmbI18NDictionary(); 72 $dictionaries[$domain] = $dictionary; 73 } 74 else 75 $dictionary = $dictionaries[$domain]; 76 77 $dictionary->add($text); 78 } 79 } 80 } 81 } 82 } 83 84 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Aug 29 04:49:26 2008 | Cross-referenced by PHPXref 0.7 |