Skip to content

Commit

Permalink
ENHANCEMENT Allowing to copy arbitrary default themes (in preparation…
Browse files Browse the repository at this point in the history
… to adding a new "jquerymobile" theme)
  • Loading branch information
chillu committed Oct 16, 2011
1 parent fd48ab0 commit 7f7e128
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions code/MobileSiteConfigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,28 +115,38 @@ public function getMobileSiteTypes() {
* as a field on SiteConfig, then make sure that it's copied
* into the themes directory from the mobile module.
*/
public function requireDefaultRecords() {
if($this->owner->getField('MobileTheme') == 'blackcandymobile') {
$this->copyDefaultTheme();
public function augmentDatabase() {
$defaultThemes = array('blackcandymobile', 'jquerymobile');
$currentTheme = $this->owner->getField('MobileTheme');
if(!$currentTheme || in_array($currentTheme, $defaultThemes)) {
$this->copyDefaultTheme($currentTheme);
}
}

public static function copyDefaultTheme() {
$src = '../' . MOBILE_DIR . '/blackcandymobile';
/**
* @param String
*/
public static function copyDefaultTheme($theme = null) {
if(!$theme) $theme = 'blackcandymobile';
$src = '../' . MOBILE_DIR . '/themes/' . $theme;
$dst = self::get_theme_copy_path();

if(!file_exists($dst)) {
@mkdir($dst);
if(is_writable($dst)) {
rcopy($src, $dst);
DB::alteration_message(
'Default mobile theme "blackcandymobile" has been copied into the themes directory',
sprintf('Default mobile theme "%s" has been copied into the themes directory', $theme),
'created'
);
} else {
DB::alteration_message(
'Could not copy default mobile theme "blackcandymobile" into themes directory (permission denied).
Please manually copy the "blackcandymobile" directory from the mobile module into the themes directory.',
sprintf(
'Could not copy default mobile theme "%s" into themes directory (permission denied).
Please manually copy the "%s" directory from the mobile module into the themes directory.',
$theme,
$theme
),
'error'
);
}
Expand Down

0 comments on commit 7f7e128

Please sign in to comment.