コード例 #1
0
	function parsing_add_messages($path, $sourcefile, $textdomain='') {	
		require_once('class.parser.php');
		$parser = new csp_l10n_parser($path, $textdomain);
		$r = $parser->parseFile($sourcefile);
		$gettext = $r['gettext'];
		$not_gettext = $r['not_gettext'];
		if (count($gettext)) {
			foreach($gettext as $match) {
				$entry = null;
				if (isset($this->map[$match['msgid']]))
					$entry = $this->map[$match['msgid']];
				if (!is_array($entry)) {
					$entry = $this->_new_entry(
						$match['msgid'], 
						str_pad('', (isset($match['P']) ? $this->nplurals -1 : 0), "\0"),
						$match['R'],
						false, false,false,
						$match['LTD']
					);
				}
				else{
					if (!in_array($match['R'], $entry['R']))
						$entry['R'][] = $match['R'];
				}
				if (!in_array($match['LTD'], $entry['LTD'])) {
					$entry['LTD'][] = $match['LTD'];
				}
				foreach($match['CC'] as $cc) {
					if (!in_array($cc, $entry['CC'])) {
						$entry['CC'][] = $cc;
					}
				}
				
				if(preg_match("/(%[A-Za-z0-9])/", $match['msgid']) > 0) {
					if (!is_array($entry['F'])||(!in_array('php-format', $entry['F']))) {
						$entry['F'][] = 'php-format';
					}
				}			
				$this->map[$match['msgid']] = $entry;				
			}
		}
		if (count($not_gettext)) {
			foreach($not_gettext as $match) {
				$entry = null;
				if (isset($this->map[$match['msgid']]))
					$entry = $this->map[$match['msgid']];
				if (!is_array($entry)) {
					$entry = $this->_new_entry(
						$match['msgid'], 
						'',
						$match['R'],
						false,
						false,
						$match['CC'],
						$match['LTD']
					);
				}
				else{
					if (!in_array($match['R'], $entry['R'])) {
						$entry['R'][] = $match['R'];
					}
					foreach($match['CC'] as $cc) {
						if (!in_array($cc, $entry['CC'])) {
							$entry['CC'][] = $cc;
						}
					}
				}
				if (!in_array($match['LTD'], $entry['LTD'])) {
					$entry['LTD'][] = $match['LTD'];
				}
				$this->map[$match['msgid']] = $entry;				
			}
		}
	}
コード例 #2
0
 function parsing_add_messages($path, $sourcefile, $textdomain = '')
 {
     require_once 'class.parser.php';
     $parser = new csp_l10n_parser($path, $textdomain, true, false);
     $r = $parser->parseFile($sourcefile, $this->component_type);
     $this->add_messages($r);
 }
コード例 #3
0
<?php

//simple safety check
$a = str_replace("\\", '/', dirname(__FILE__));
$b = str_replace("\\", '/', dirname($_POST['file']));
$da = implode('/', array_slice(explode('/', $a), 0, -4));
$idx = strpos($b, $da);
if ($idx === false || $idx > 0) {
    exit;
}
require_once dirname(__FILE__) . '/class.parser.php';
$parser = new csp_l10n_parser($_POST['path'], $_POST['textdomain'], true, false);
$r = $parser->parseFile($_POST['file'], $_POST['type']);
echo base64_encode(serialize($r));
exit;