diff options
| -rw-r--r-- | it_text.class | 22 | 
1 files changed, 11 insertions, 11 deletions
| diff --git a/it_text.class b/it_text.class index c920941..247369d 100644 --- a/it_text.class +++ b/it_text.class @@ -35,21 +35,25 @@ class it_text   * @param $p['forcelanguage'] optional language to use instead of user's preferred language   * @param $p['global'] store text object in global it_text for global functions (default: true)   * @param $p['phpfile'] optional texts file(s), default: all texts.php in include path + * @param $p['phpfiles'] text files to load in addition to $p['phpfile'] (Note: $p['phpfile'] defaults to all texts.php files in include path)   */  function it_text($p = array())  {  	if (!$p['phpfile'])  	{  		# Find all texts.php in path (abs path in case we need to save) -		foreach (array_unique(explode(PATH_SEPARATOR, ini_get('include_path'))) as $dir) +		foreach (explode(PATH_SEPARATOR, ini_get('include_path')) as $dir)  			if (file_exists($phpfile = "$dir/texts.php")) -				$p['phpfile'][] = $phpfile; +				$p['phpfiles'][] = $phpfile;  	} -	$this->p = ($p += array('global' => true)); +	$this->p = ($p += array( +		'global' => true, +		'phpfiles' => array_unique(array_merge((array)$p['phpfiles'], (array)$p['phpfile'])), +	));  	# Read and merge texts from php files if none defined yet -	foreach ((array)$p['phpfile'] as $phpfile) +	foreach ($p['phpfiles'] as $phpfile)  	{  		$oldtext = $this->statictext;  		if (is_array($ret = include($phpfile))) @@ -231,15 +235,11 @@ function dump_php()  	$result = false;  	# Special sorting: natural, but _ is the first entry -	$keys = array_keys($this->statictext); -	natsort($keys); -	foreach ($keys as $key) -		$text[$key] = $this->statictext[$key]; -	$this->statictext = array_merge(array('_' => $text['_']), $text); +	uksort($this->statictext, "strnatcmp"); +	$this->statictext = array_merge(array('_' => $this->statictext['_']), $this->statictext);  	$oldmask = umask(002); -	$phpfiles = (array)$this->p['phpfile']; -	if ($f = fopen(count($phpfiles) == 1 ? $phpfiles[0] : null, 'w')) +	if ((count($this->p['phpfiles']) == 1) && ($f = fopen($this->p['phpfiles'][0], 'w')))  	{  		$result = (fputs($f, '<?php return ' . strtr(var_export($this->statictext, true), array("=> \n  array (" => "=> array(", "array (\n  '_'" => "array(\n'_'", "\n  ),\n  " => "\n),\n", "\n  ),\n" => "\n),\n", "\r" => "")) . ";\n?>\n") !== false);  		fclose($f); |