Skip to content
This repository
Browse code

ENHANCEMENT Allowing to copy arbitrary default themes (in preparation…

… to adding a new "jquerymobile" theme)
  • Loading branch information...
commit 7f7e1280d2bc30095a3a4b31b85e5a321b848582 1 parent fd48ab0
Ingo Schommer chillu authored

Showing 1 changed file with 18 additions and 8 deletions. Show diff stats Hide diff stats

  1. +18 8 code/MobileSiteConfigExtension.php
26 code/MobileSiteConfigExtension.php
@@ -115,14 +115,20 @@ public function getMobileSiteTypes() {
115 115 * as a field on SiteConfig, then make sure that it's copied
116 116 * into the themes directory from the mobile module.
117 117 */
118   - public function requireDefaultRecords() {
119   - if($this->owner->getField('MobileTheme') == 'blackcandymobile') {
120   - $this->copyDefaultTheme();
  118 + public function augmentDatabase() {
  119 + $defaultThemes = array('blackcandymobile', 'jquerymobile');
  120 + $currentTheme = $this->owner->getField('MobileTheme');
  121 + if(!$currentTheme || in_array($currentTheme, $defaultThemes)) {
  122 + $this->copyDefaultTheme($currentTheme);
121 123 }
122 124 }
123 125
124   - public static function copyDefaultTheme() {
125   - $src = '../' . MOBILE_DIR . '/blackcandymobile';
  126 + /**
  127 + * @param String
  128 + */
  129 + public static function copyDefaultTheme($theme = null) {
  130 + if(!$theme) $theme = 'blackcandymobile';
  131 + $src = '../' . MOBILE_DIR . '/themes/' . $theme;
126 132 $dst = self::get_theme_copy_path();
127 133
128 134 if(!file_exists($dst)) {
@@ -130,13 +136,17 @@ public static function copyDefaultTheme() {
130 136 if(is_writable($dst)) {
131 137 rcopy($src, $dst);
132 138 DB::alteration_message(
133   - 'Default mobile theme "blackcandymobile" has been copied into the themes directory',
  139 + sprintf('Default mobile theme "%s" has been copied into the themes directory', $theme),
134 140 'created'
135 141 );
136 142 } else {
137 143 DB::alteration_message(
138   - 'Could not copy default mobile theme "blackcandymobile" into themes directory (permission denied).
139   - Please manually copy the "blackcandymobile" directory from the mobile module into the themes directory.',
  144 + sprintf(
  145 + 'Could not copy default mobile theme "%s" into themes directory (permission denied).
  146 + Please manually copy the "%s" directory from the mobile module into the themes directory.',
  147 + $theme,
  148 + $theme
  149 + ),
140 150 'error'
141 151 );
142 152 }

0 comments on commit 7f7e128

Please sign in to comment.
Something went wrong with that request. Please try again.