예제 #1
0
파일: dmDataLoad.php 프로젝트: jwegner/diem
 protected function loadSettings()
 {
     $array = array('site_name' => array('default_value' => dmString::humanize(dmProject::getKey()), 'description' => 'The site name', 'group_name' => 'site'), 'site_active' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'Is the site ready for visitors ?', 'group_name' => 'site'), 'site_indexable' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'Is the site ready for search engine crawlers ?', 'group_name' => 'site'), 'site_working_copy' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'Is this site the current working copy ?', 'group_name' => 'site'), 'ga_key' => array('description' => 'The google analytics key without javascript stuff ( e.g. UA-9876614-1 )', 'group_name' => 'tracking', 'credentials' => 'google_analytics'), 'ga_token' => array('description' => 'Auth token gor Google Analytics, computed from password', 'group_name' => 'internal', 'credentials' => 'google_analytics'), 'gwt_key' => array('description' => 'The google webmaster tools filename without google and .html ( e.g. a913b555ba9b4f13 )', 'group_name' => 'tracking', 'credentials' => 'google_webmaster_tools'), 'xiti_code' => array('type' => 'textarea', 'description' => 'The xiti html code', 'group_name' => 'tracking', 'credentials' => 'xiti'), 'search_stop_words' => array('type' => 'textarea', 'description' => 'Words to exclude from searches (e.g. the, a, to )', 'group_name' => 'search engine', 'credentials' => 'search_engine'), 'base_urls' => array('type' => 'textarea', 'description' => 'Diem base urls for different applications/environments/cultures', 'group_name' => 'internal', 'credentials' => 'system'), 'image_resize_method' => array('type' => 'select', 'default_value' => 'center', 'description' => 'Default method when an image needs to be resized', 'params' => 'fit=Fit scale=Scale inflate=Inflate top=Top right=Right left=Left bottom=Bottom center=Center', 'group_name' => 'interface', 'credentials' => 'interface_settings'), 'image_resize_quality' => array('type' => 'number', 'default_value' => 95, 'description' => 'Jpeg default quality when generating thumbnails', 'group_name' => 'interface', 'credentials' => 'interface_settings'), 'link_external_blank' => array('type' => 'boolean', 'default_value' => 0, 'description' => 'Links to other domain get automatically a _blank target', 'group_name' => 'interface', 'credentials' => 'interface_settings'), 'link_current_span' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'Links to current page are changed from <a> to <span>', 'group_name' => 'interface', 'credentials' => 'interface_settings'), 'link_use_page_title' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'Add an automatic title on link based on the target page title', 'group_name' => 'interface', 'credentials' => 'interface_settings'), 'title_prefix' => array('default_value' => '', 'description' => 'Append something at the beginning of all pages title', 'group_name' => 'seo', 'credentials' => 'manual_metas'), 'title_suffix' => array('default_value' => ' | ' . dmString::humanize(dmProject::getKey()), 'description' => 'Append something at the end of all pages title', 'group_name' => 'seo', 'credentials' => 'manual_metas'), 'smart_404' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'When a page is not found, user is redirect to a similar page. The internal search index is used to find the best page for requested url.', 'group_name' => 'seo', 'credentials' => 'url_redirection'));
     $existingSettings = dmDb::query('DmSetting s INDEXBY s.name')->withI18n()->fetchRecords();
     foreach ($array as $name => $config) {
         if (!isset($existingSettings[$name])) {
             $setting = new DmSetting();
             $setting->set('name', $name);
             $setting->fromArray($config);
             $setting->save();
         } elseif (!$existingSettings[$name]->hasCurrentTranslation()) {
             /*
              * Try to find an existing config from another culture
              */
             $existing = dmDb::query('DmSettingTranslation s')->where('s.id = ?', $existingSettings[$name]->id)->limit(1)->fetchArray();
             if ($existing = dmArray::first($existing)) {
                 $config = $existing;
                 unset($config['id'], $config['lang']);
             }
             $existingSettings[$name]->fromArray($config)->getCurrentTranslation()->save();
         }
     }
     dmConfig::load(false);
 }
예제 #2
0
$defaultCulture = sfConfig::get('sf_default_culture');
$user->setCulture($defaultCulture);
dmDb::query('DmSetting s')->where('s.name = ?', 'test')->delete()->execute();
$t->diag('create new setting');
$setting = dmDb::create('DmSetting', array('name' => 'test', 'description' => 'This is just a test setting', 'value' => $defaultCulture . ' value', 'default_value' => $defaultCulture . ' default', 'type' => 'text', 'group_name' => 'test group'))->saveGet();
dmConfig::load();
try {
    dmConfig::get('i_do_not_exist_for_sure');
    $t->pass('Get non-existant config');
} catch (dmException $e) {
    $t->fail('Get non-existant config');
}
try {
    dmConfig::set('i_do_not_exist_for_sure', 'value');
    $t->pass('Set non-existant config');
} catch (dmException $e) {
    $t->fail('Set non-existant config');
}
$t->is(dmConfig::get('test'), $defaultCulture . ' value', 'test value is ' . $defaultCulture . ' value');
dmConfig::set('test', 'new ' . $defaultCulture . ' value');
$t->is(dmConfig::get('test'), 'new ' . $defaultCulture . ' value', 'test value is new ' . $defaultCulture . ' value');
dmConfig::load();
$t->is(dmConfig::get('test'), 'new ' . $defaultCulture . ' value', 'test value is new ' . $defaultCulture . ' value');
$user->setCulture('c1');
$t->is(dmConfig::get('test'), 'new ' . $defaultCulture . ' value', 'test value is new ' . $defaultCulture . ' value ( by non-existing c1 culture fallback )');
dmConfig::set('test', 'c1 value');
$t->is(dmConfig::get('test'), 'c1 value', 'test value is c1 value');
$user->setCulture($defaultCulture);
$t->is(dmConfig::get('test'), 'new ' . $defaultCulture . ' value', 'test value is new ' . $defaultCulture . ' value');
$user->setCulture($userCulture);
$setting->delete();
예제 #3
0
 public function preExecute()
 {
     parent::preExecute();
     dmConfig::load(false);
 }