Project

General

Profile

« Previous | Next » 

Revision 1962

Added by darkviper about 11 years ago

package Translate: creating language path in TranslateAdaptorWbOldStyle with modified admin-path fixed

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12
===============================================================================
13 13

  
14
18 Sep-2013 Build 1962 M.v.d.Decken(DarkViper)
15
# package Translate: creating language path in TranslateAdaptorWbOldStyle with modified admin-path fixed
14 16
05 Sep-2013 Build 1961 M.v.d.Decken(DarkViper)
15 17
# /admin/settings/save now also allows empty entries for 'website_title','website_description' and 'website_keywords'
16 18
22 Aug-2013 Build 1960 M.v.d.Decken(DarkViper)
branches/2.8.x/wb/admin/interface/version.php
51 51

  
52 52
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
53 53
if(!defined('VERSION')) define('VERSION', '2.8.3');
54
if(!defined('REVISION')) define('REVISION', '1961');
54
if(!defined('REVISION')) define('REVISION', '1962');
55 55
if(!defined('SP')) define('SP', '');
branches/2.8.x/wb/framework/TranslateAdaptorWbOldStyle.php
52 52
 */
53 53
	public function loadLanguage($sLangCode)
54 54
	{
55
		$this->_getAddonPath();
55
		$sLanguagePath = $this->_getAddonPath();
56 56
		$aTranslations = array();
57 57
		$sLangFile = strtolower($sLangCode.'.php');
58
		if( ($aDirContent = scandir($this->sFilePath)) !== false) {
58
		if( ($aDirContent = scandir($sLanguagePath)) !== false) {
59 59
			foreach($aDirContent as $sFile) {
60 60
				if($sLangFile === strtolower($sFile)) {
61
					$sLangFile = $this->sFilePath.$sFile;
61
					$sLangFile = $sLanguagePath.$sFile;
62 62
					if(is_readable($sLangFile)) {
63 63
						$aTmp = $this->_importArrays($sLangFile);
64 64
						$aTranslations = array_merge($aTranslations, $aTmp);
......
75 75
 */
76 76
	public function findFirstLanguage()
77 77
	{
78
		$this->_getAddonPath();
78
		$sLanguagePath = $this->_getAddonPath();
79 79
	// search for first available and readable language file
80 80
		$sRetval = '';
81
		if(is_readable($this->sFilePath)) {
82
			$iterator = new DirectoryIterator($this->sFilePath);
81
		if(is_readable($sLanguagePath)) {
82
			$iterator = new DirectoryIterator($sLanguagePath);
83 83
			foreach ($iterator as $oFileInfo) {
84 84
				$sPattern = '/^[a-z]{2,3}\.php/siU';
85 85
				if(!preg_match($sPattern, $oFileInfo->getBasename())) { continue; }
......
97 97
 */
98 98
	private function _getAddonPath()
99 99
	{
100
		$sAddon   = str_replace('\\', '/', $this->sAddon);
101
		$sDirname = str_replace('\\', '/', dirname(dirname(__FILE__))).'/';
102
		$this->sFilePath = $sDirname.$sAddon.'/languages/';
103
		if(!is_readable($this->sFilePath) && (strpos('admin', $this->sAddon) === 0)) {
104
		// correct modified admin directory
100
	// set environment
101
		$sAddon   = trim(str_replace('\\', '/', $this->sAddon), '/');
102
		$sAppDirname = str_replace('\\', '/', dirname(dirname(__FILE__))).'/';
103
		$sLanguagePath = $sAppDirname.$sAddon.'/languages/';
104
		if(is_dir($sLanguagePath) && is_readable($sLanguagePath)) {
105
		// valid directory found
106
			return $sLanguagePath;
107
		}
108
		if(preg_match('/^admin.*/sU', $sAddon))
109
		{
110
		// get used acp dirname
105 111
			$sTmp = trim(WbAdaptor::getInstance()->AcpDir, '/');
106
			$this->sFilePath = $sDirname.preg_replace('/^admin/', $sTmp, $sAddon).'/languages/';
107
			if(!is_readable($this->sFilePath)) {
108
				throw new TranslationException('missing language definitions in: '.$sAddon.'/languages');
112
		// if path starts with 'admin/' then replace with used acp dirname
113
			$sLanguagePath = $sAppDirname.preg_replace('/^admin/sU', $sTmp, $sAddon).'/languages/';
114
			if(is_dir($sLanguagePath) && is_readable($sLanguagePath)) {
115
			// valid directory found
116
				return $sLanguagePath;
109 117
			}
110 118
		}
119
		throw new TranslationException('\''.$sAddon.'/languages\' is not a direcory or not readable!');
111 120
	}
112 121
/**
113 122
 * Import language definitions into array

Also available in: Unified diff