Revision 2090
Added by darkviper almost 12 years ago
| UpgradeHelper.php | ||
|---|---|---|
| 35 | 35 |
class UpgradeHelper {
|
| 36 | 36 |
|
| 37 | 37 |
/** |
| 38 |
* do not delete start directory of deltree |
|
| 39 |
*/ |
|
| 40 |
const DEL_ROOT_PRESERVE = 0; |
|
| 41 |
/** |
|
| 42 |
* delete start directory of deltree |
|
| 43 |
*/ |
|
| 44 |
const DEL_ROOT_DELETE = 1; |
|
| 45 |
/** |
|
| 46 |
* clear logs |
|
| 47 |
*/ |
|
| 48 |
const LOG_CLEAR = true; |
|
| 49 |
/** |
|
| 50 |
* preserve logs |
|
| 51 |
*/ |
|
| 52 |
const LOG_PRESERVE = false; |
|
| 53 |
/** |
|
| 54 |
* to store the last delTree log |
|
| 55 |
*/ |
|
| 56 |
static $aDelTreeLog = array(); |
|
| 57 |
|
|
| 58 |
/** |
|
| 38 | 59 |
* Compare available tables against a list of tables |
| 39 | 60 |
* @param array list of needed table names without TablePrefix |
| 40 | 61 |
* @return array list of missing tables |
| ... | ... | |
| 265 | 286 |
} |
| 266 | 287 |
return false; |
| 267 | 288 |
} |
| 289 |
/** |
|
| 290 |
* Delete all contents of basedir, but not the basedir itself |
|
| 291 |
* @param string $sRootDir the content of which should be deleted |
|
| 292 |
* @param integer $iMode the mode can be set to self::DEL_ROOT_PRESERVE(default) or self::DEL_ROOT_DELETE |
|
| 293 |
* @return boolean false if a file or directory can't be deleted |
|
| 294 |
*/ |
|
| 295 |
static public function delTree($sRootDir, $iMode = self::DEL_ROOT_PRESERVE) |
|
| 296 |
{
|
|
| 297 |
// check if root dir is inside the installation and is writeable |
|
| 298 |
$oReg = WbAdaptor::getInstance(); |
|
| 299 |
self::$aDelTreeLog = array(); |
|
| 300 |
$bResult = true; |
|
| 301 |
if (!is_writeable($sRootDir)) {
|
|
| 302 |
self::$aDelTreeLog[] = str_replace($oReg->AppPath, '', $sRootDir); |
|
| 303 |
return false; |
|
| 304 |
} |
|
| 305 |
$oIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($sRootDir), RecursiveIteratorIterator::CHILD_FIRST); |
|
| 306 |
foreach ($oIterator as $oPath) {
|
|
| 307 |
$sPath = rtrim(str_replace('\\', '/', $oPath->__toString()), '/');
|
|
| 308 |
if ($oPath->isDir() && !preg_match('/\.$/s', $sPath)) {
|
|
| 309 |
// proceed directories |
|
| 310 |
if (!rmdir($sPath)) {
|
|
| 311 |
$bResult = false; |
|
| 312 |
self::$aDelTreeLog[] = str_replace($oReg->AppPath, '', $sPath); |
|
| 313 |
} |
|
| 314 |
} elseif ($oPath->isFile()) {
|
|
| 315 |
// proceed files |
|
| 316 |
if (!unlink($sPath)) {
|
|
| 317 |
$bResult = false; |
|
| 318 |
self::$aDelTreeLog[] = str_replace($oReg->AppPath, '', $sPath); |
|
| 319 |
} |
|
| 320 |
} |
|
| 321 |
} |
|
| 322 |
if (($iMode & self::DEL_ROOT_DELETE) && $bResult) {
|
|
| 323 |
// delete RootDir if there was no error before |
|
| 324 |
if (!rmdir($sRootDir)) {
|
|
| 325 |
$bResult = false; |
|
| 326 |
self::$aDelTreeLog[] = str_replace($oReg->AppPath, '', $sRootDir); |
|
| 327 |
} |
|
| 328 |
} |
|
| 329 |
return $bResult; |
|
| 330 |
} |
|
| 331 |
/** |
|
| 332 |
* returns the log of the last delTree request |
|
| 333 |
* @param bool $bClearLog TRUE clears the log after request, FALSE preserve the log |
|
| 334 |
* @return array |
|
| 335 |
*/ |
|
| 336 |
static public function getDelTreeLog($bClearLog = self::LOG_CLEAR) |
|
| 337 |
{
|
|
| 338 |
$aRetval = self::$aDelTreeLog; |
|
| 339 |
if($bClearLog) { self::$aDelTreeLog = array(); }
|
|
| 340 |
return $aRetval; |
|
| 341 |
} |
|
| 268 | 342 |
|
| 343 |
|
|
| 269 | 344 |
} // end of class UpgradeHelper |
| 270 | 345 |
|
Also available in: Unified diff
- templates/argos_theme
- templates/allcss
- templates/wb_theme
+ templates/WbTheme
! all upgrade/install and all other files needed to change defaults