Project

General

Profile

« Previous | Next » 

Revision 1902

Added by darkviper about 11 years ago

added posssibility to use different adaptors for each module
added new adaptor to access language definitions in a MySQL database

View differences:

Translate.php
92 92
			throw new TranslationException('unable to load adaptor: '.$sAdaptor);
93 93
		}
94 94
		$this->sAdaptor       = 'TranslateAdaptor'.$sAdaptor;
95
		$this->bUseCache      = (($iOptions & self::CACHE_DISABLED) == 0);
96
		$this->bRemoveMissing = (($iOptions & self::KEEP_MISSING) == 0);
95
		$this->bUseCache      = (!($iOptions & self::CACHE_DISABLED));
96
		$this->bRemoveMissing = (!($iOptions & self::KEEP_MISSING));
97 97
		// if no system language is set then use language 'en'
98 98
		$this->sSystemLanguage = (trim($sSystemLanguage) == '' ? 'en' : $sSystemLanguage);
99 99
		// if no default language is set then use system language
......
132 132
/**
133 133
 * Add new addon
134 134
 * @param string Addon descriptor (i.e. 'modules\myAddon')
135
 * @param string (optional)Adaptor name (default: $this->sAdaptor)
135 136
 * @return bool 
136 137
 */	
137
	public function addAddon($sAddon)
138
	public function addAddon($sAddon, $sAdaptor = null)
138 139
	{
140
		if($sAdaptor) {
141
			if(!class_exists('TranslateAdaptor'.$sAdaptor)) {
142
				throw new TranslationException('unable to load adaptor: '.$sAdaptor);
143
			}
144
			$sAdaptor = 'TranslateAdaptor'.$sAdaptor;
145
		}else {
146
			$sAdaptor = $this->sAdaptor;
147
		}
139 148
		$sAddon = str_replace('/', '\\', $sAddon);
140 149
		if(!(strtolower($sAddon) == 'core' || $sAddon == '' || isset($this->aLoadedAddons[$sAddon]))) {
141 150
		// load requested addon translations if needed and possible
......
144 153
			                             $this->sDefaultLanguage, 
145 154
			                             $this->sUserLanguage,
146 155
			                             $this->bUseCache);
147
			$this->aLoadedAddons[$sAddon] = $oTmp->load($this->sAdaptor);
156
			$this->aLoadedAddons[$sAddon] = $oTmp->load($sAdaptor);
148 157
		}
149 158
	}
150 159
/**
151 160
 * Activate Addon
152 161
 * @param string Addon descriptor (i.e. 'modules\myAddon')
162
 * @param string (optional)Adaptor name (default: $this->sAdaptor)
153 163
 */	
154
	public function enableAddon($sAddon)
164
	public function enableAddon($sAddon, $sAdaptor = null)
155 165
	{
156 166
		$sAddon = str_replace('/', '\\', $sAddon);
157 167
		if(!(strtolower($sAddon) == 'core' || $sAddon == '')) {
158 168
			if(!isset($this->aLoadedAddons[$sAddon])) {
159
				$this->addAddon($sAddon);
169
				$this->addAddon($sAddon, $sAdaptor);
160 170
			}
161 171
			$this->aActiveTranslations[1] = $this->aLoadedAddons[$sAddon];
162 172
		}

Also available in: Unified diff