Revision 1651
Added by darkviper over 12 years ago
CopyTheme.php | ||
---|---|---|
37 | 37 |
$this->_oDb = $GLOBALS['database']; |
38 | 38 |
$this->_aLang = $GLOBALS['MESSAGE']; |
39 | 39 |
// import global Consts |
40 |
$this->_aGlobals['TablePrefix'] = TABLE_PREFIX;
|
|
41 |
$this->_aGlobals['AddonTable'] = 'addons';
|
|
42 |
$this->_aGlobals['SettingsTable'] = 'settings';
|
|
40 |
$this->_aGlobals['TablePrefix'] = TABLE_PREFIX; |
|
41 |
$this->_aGlobals['AddonTable'] = 'addons'; |
|
42 |
$this->_aGlobals['SettingsTable'] = 'settings'; |
|
43 | 43 |
|
44 |
$this->_aGlobals['Debug'] = (defined('DEBUG') && DEBUG === true);
|
|
45 |
$this->_aGlobals['IsLinux'] = ((substr(__FILE__, 0, 1)) == '/');
|
|
46 |
$this->_aGlobals['StringDirMode'] = STRING_DIR_MODE;
|
|
47 |
$this->_aGlobals['StringFileMode'] = STRING_FILE_MODE;
|
|
44 |
$this->_aGlobals['Debug'] = (defined('DEBUG') && DEBUG === true); |
|
45 |
$this->_aGlobals['IsLinux'] = ((substr(__FILE__, 0, 1)) == '/'); |
|
46 |
$this->_aGlobals['DirMode'] = octdec(STRING_DIR_MODE);
|
|
47 |
$this->_aGlobals['FileMode'] = octdec(STRING_FILE_MODE);
|
|
48 | 48 |
} |
49 | 49 |
/** |
50 | 50 |
* start copy current theme into a new theme |
... | ... | |
153 | 153 |
} |
154 | 154 |
natsort($aFileList); |
155 | 155 |
}catch(Exeption $e) { |
156 |
$msg = 'CopyTheme::_copyTree => '.$this->_aLang['GENERIC_FAILED_COMPARE']; |
|
157 |
$msg .= '<br />'.$e->getMessage(); |
|
156 |
$msg = $this->_aLang['GENERIC_FAILED_COMPARE']; |
|
157 |
if($this->_aGlobals['Debug']) { |
|
158 |
$msg .= '<br />'.__CLASS__.'::'.__METHOD__. '<br />'.$e->getMessage(); |
|
159 |
} |
|
158 | 160 |
$this->_setError($msg); |
159 | 161 |
$bRetval = false; |
160 | 162 |
} |
... | ... | |
181 | 183 |
$sNewDir = $this->_sThemesBasePath.'/'.$this->_sNewThemeDir.$sDir; |
182 | 184 |
if(!file_exists($sNewDir) && mkdir($sNewDir, 0777, true)) { |
183 | 185 |
if($this->_aGlobals['IsLinux']) { |
184 |
if(!chmod($sNewDir, $this->_aGlobals['StringDirMode'])) { |
|
185 |
$sMsg = 'CopyTheme::createDirs::chmod('.$sNewDir.') >> ' |
|
186 |
.$this->_aLang['GENERIC_FAILED_COMPARE']; |
|
186 |
if(!chmod($sNewDir, $this->_aGlobals['DirMode'])) { |
|
187 |
$sMsg = $this->_aLang['UPLOAD_ERR_CANT_WRITE'].' ['.$sNewDir.']'; |
|
188 |
if($this->_aGlobals['Debug']) { |
|
189 |
$sMsg .= '<br />'.__CLASS__.'::'.__METHOD__.'::' |
|
190 |
. 'chmod(\''.$sNewDir.$_sThemePath.$sFile.'\', ' |
|
191 |
. decoct($this->_aGlobals['DirMode']).')'; |
|
192 |
} |
|
187 | 193 |
$this->_setError($sMsg); |
188 | 194 |
$bRetval = false; |
189 | 195 |
break; |
190 | 196 |
} |
191 | 197 |
} |
192 | 198 |
}else { |
193 |
$sMsg = 'CopyTheme::createDirs::mkdir('.$sNewDir.') >> ' |
|
194 |
.$this->_aLang['GENERIC_FAILED_COMPARE']; |
|
199 |
$sMsg = $this->_aLang['GENERIC_FAILED_COMPARE'].' ['.$sFile.']'; |
|
200 |
if($this->_aGlobals['Debug']) { |
|
201 |
$sMsg .= '<br />'.__CLASS__.'::'.__METHOD__.'::' |
|
202 |
. 'mkdir(\''.$sNewDir.'\', 0777, true)'; |
|
203 |
} |
|
195 | 204 |
$this->_setError($sMsg); |
196 | 205 |
$bRetval = false; |
197 | 206 |
break; |
... | ... | |
211 | 220 |
foreach($aFileList as $sFile) { |
212 | 221 |
if(copy($sSourceDir.$sFile, $sDestinationDir.$sFile)) { |
213 | 222 |
if($this->_aGlobals['IsLinux']) { |
214 |
if(!chmod($sDestinationDir.$sFile, $this->_aGlobals['StringFileMode'])) { |
|
215 |
$sMsg = 'CopyTheme::copyFiles::chmod('.$sDestinationDir.$sFile.') >> ' |
|
216 |
.$this->_aLang['GENERIC_FAILED_COMPARE']; |
|
223 |
if(!chmod($sDestinationDir.$sFile, $this->_aGlobals['FileMode'])) { |
|
224 |
$sMsg = $this->_aLang['GENERIC_FAILED_COMPARE'].' ['.$sFile.']'; |
|
225 |
if($this->_aGlobals['Debug']) { |
|
226 |
$sMsg .= '<br />'.__CLASS__.'::'.__METHOD__.'::' |
|
227 |
. 'chmod(\''.$sDestinationDir.$sFile.'\', ' |
|
228 |
.decoct($this->_aGlobals['FileMode']).', true)'; |
|
229 |
} |
|
217 | 230 |
$this->_setError($sMsg); |
218 | 231 |
$bRetval = false; |
219 | 232 |
break; |
220 | 233 |
} |
221 | 234 |
} |
222 | 235 |
}else { |
223 |
$sMsg = 'CopyTheme::copyFiles::copy('.$sDestinationDir.$sFile.') >> ' |
|
224 |
.$this->_aLang['GENERIC_FAILED_COMPARE']; |
|
236 |
$sMsg = $this->_aLang['GENERIC_FAILED_COMPARE'].' ['.$sFile.']'; |
|
237 |
if($this->_aGlobals['Debug']) { |
|
238 |
$sMsg .= '<br />'.__CLASS__.'::'.__METHOD__.'::' |
|
239 |
. 'copy(\''.$sSourceDir.$sFile.'\', ' |
|
240 |
. '\''.$sDestinationDir.$sFile.'\')'; |
|
241 |
} |
|
225 | 242 |
$this->_setError($sMsg); |
226 | 243 |
$bRetval = false; |
227 | 244 |
break; |
... | ... | |
249 | 266 |
. '`author`=\''.mysql_real_escape_string($aVariables['author']).'\', ' |
250 | 267 |
. '`license`=\''.mysql_real_escape_string($aVariables['license']).'\''; |
251 | 268 |
if(!$this->_oDb->query($sql)) { |
252 |
$sMsg = 'CopyTheme::registerNewTheme('.$this->_sNewThemeName.') >> ' |
|
253 |
.$this->_aLang['GENERIC_NOT_UPGRADED']; |
|
254 |
$sMsg .= (($this->_aGlobals['Debug']) ? '<br />'.$this->_oDb->get_error() : ''); |
|
269 |
|
|
270 |
$sMsg = $this->_aLang['GENERIC_NOT_UPGRADED'].' ['.$this->_sNewThemeDir.'/info.php]'; |
|
271 |
if($this->_aGlobals['Debug']) { |
|
272 |
$sMsg .= '<br />'.__CLASS__.'::'.__METHOD__. '<br />'.$this->_oDb->get_error(); |
|
273 |
} |
|
255 | 274 |
$this->_setError($sMsg); |
256 | 275 |
$bRetval = false; |
257 | 276 |
} |
... | ... | |
270 | 289 |
$aVariables['name'] = $this->_sNewThemeName; |
271 | 290 |
$aVariables['version'] = '0.0.1'; |
272 | 291 |
$aVariables['description'] = '(copy): '.$aVariables['description']; |
273 |
if(file_exists($sThemeInfoFile)) {
|
|
292 |
if(is_writeable($sThemeInfoFile)) {
|
|
274 | 293 |
$sInfoContent = file_get_contents($sThemeInfoFile); |
275 | 294 |
foreach($aVariables as $key=>$val) { |
276 | 295 |
$sSearch = '/(\$template_'.$key.'\s*=\s*(["\'])).*?(\2)\s*;/s'; |
... | ... | |
284 | 303 |
return true; |
285 | 304 |
} |
286 | 305 |
} |
287 |
$this->_setError('CopyTheme::modifyInfoFile('.$this->_sNewThemeDir.'/info.php) >> ' |
|
288 |
.$this->_aLang['GENERIC_NOT_UPGRADED']); |
|
306 |
$sMsg = $this->_aLang['GENERIC_NOT_UPGRADED'].' ['.$this->_sNewThemeDir.'/info.php]'; |
|
307 |
if($this->_aGlobals['Debug']) { |
|
308 |
$sMsg .= '<br />'.__CLASS__.'::'.__METHOD__.'(\''.$sThemeInfoFile.'\')'; |
|
309 |
} |
|
310 |
$this->_setError($sMsg); |
|
289 | 311 |
return $bRetval; |
290 | 312 |
} |
291 | 313 |
/** |
... | ... | |
329 | 351 |
'default_theme', |
330 | 352 |
$value = $this->_sNewThemeDir)) |
331 | 353 |
{ |
332 |
$sMsg = 'CopyTheme::activateTheme('.$this->_sNewThemeName.') >> ' |
|
333 |
.$this->_aLang['GENERIC_NOT_UPGRADED']; |
|
334 |
$sMsg .= (($this->_aGlobals['Debug']) ? '<br />'.$this->_oDb->get_error() : ''); |
|
354 |
$sMsg = $this->_aLang['GENERIC_NOT_UPGRADED']; |
|
355 |
if($this->_aGlobals['Debug']) { |
|
356 |
$sMsg .= '<br />'.__CLASS__.'::'.__METHOD__. '<br />'.$this->_oDb->get_error(); |
|
357 |
} |
|
335 | 358 |
$this->_setError($sMsg); |
336 | 359 |
$bRetval = false; |
337 | 360 |
} |
Also available in: Unified diff
fixed a little problem with chmod()