/**
  * Create SiteConfig with defaults from language file.
  * if Translatable is enabled on SiteConfig, see if one already exist
  * and use those values for the translated defaults. 
  * 
  * @param string $locale
  * @return SiteConfig
  */
 static function make_site_config($locale = null)
 {
     if (!$locale) {
         $locale = Translatable::get_current_locale();
     }
     $siteConfig = new SiteConfig();
     $siteConfig->Title = _t('SiteConfig.SITENAMEDEFAULT', "Your Site Name");
     $siteConfig->Tagline = _t('SiteConfig.TAGLINEDEFAULT', "your tagline here");
     if ($siteConfig->hasExtension('Translatable')) {
         $defaultConfig = DataObject::get_one('SiteConfig');
         if ($defaultConfig) {
             $siteConfig->Title = $defaultConfig->Title;
             $siteConfig->Tagline = $defaultConfig->Tagline;
         }
         // TODO Copy view/edit group settings
         // set the correct Locale
         $siteConfig->Locale = $locale;
     }
     $siteConfig->write();
     return $siteConfig;
 }
Esempio n. 2
0
 /**
  * Create SiteConfig with defaults from language file.
  * if Translatable is enabled on SiteConfig, see if one already exist
  * and use those values for the translated defaults. 
  * 
  * @param string $locale
  * @return SiteConfig
  */
 static function make_site_config($locale = null)
 {
     if (class_exists('Translatable') && !$locale) {
         $locale = Translatable::get_current_locale();
     }
     $siteConfig = new SiteConfig();
     $siteConfig->Title = _t('SiteConfig.SITENAMEDEFAULT', "Your Site Name");
     $siteConfig->Tagline = _t('SiteConfig.TAGLINEDEFAULT', "your tagline here");
     if (class_exists('Translatable') && $siteConfig->hasExtension('Translatable')) {
         Translatable::disable_locale_filter();
         $defaultConfig = SiteConfig::get()->first();
         Translatable::enable_locale_filter();
         if ($defaultConfig) {
             return $defaultConfig->createTranslation($locale);
         }
         // TODO Copy view/edit group settings
         // set the correct Locale
         $siteConfig->Locale = $locale;
     }
     $siteConfig->write();
     return $siteConfig;
 }