/**
  * Update settings
  */
 public function actionIndex()
 {
     // load settings
     /** @var YdSetting[] $settings */
     $settings = array();
     $_settings = YdSetting::model()->findAll();
     foreach ($_settings as $setting) {
         $settings[$setting->key] = $setting;
     }
     //        // load from items
     //        foreach (YdSetting::items() as $key => $value) {
     //            if (!isset($settings[$key])) {
     //                $settings[$key] = new YdSetting();
     //                $settings[$key]->key = $key;
     //                $settings[$key]->value = $value;
     //                $settings[$key]->save(false);
     //            }
     //        }
     // load from params
     foreach (Yii::app()->params as $key => $value) {
         if (is_scalar($value) && !isset($settings[$key])) {
             $settings[$key] = new YdSetting();
             $settings[$key]->key = $key;
             $settings[$key]->value = $value;
             $settings[$key]->save(false);
         }
     }
     // handle posted data
     if (isset($_POST['YdSetting'])) {
         // begin transaction
         $error = false;
         $transaction = YdSetting::model()->getDbConnection()->beginTransaction();
         // save settings
         foreach ($_POST['YdSetting'] as $key => $value) {
             $value = isset($value['value']) ? $value['value'] : 0;
             $settings[$key]->value = $value;
             if (!$settings[$key]->save()) {
                 $error = true;
                 break;
             }
         }
         if (!$error) {
             // commit transaction
             $transaction->commit();
             // clear cache
             Yii::app()->cache->flush();
             // flash and redirect
             Yii::app()->user->addFlash(Yii::t('dressing', 'Settings have been saved.'), 'success');
             $this->redirect(Yii::app()->returnUrl->getUrl(array('/setting/index')));
         }
         // rollback transaction and flash error
         $transaction->rollback();
         Yii::app()->user->addFlash(Yii::t('dressing', 'Settings could not be saved.'), 'error');
     } else {
         !empty($settings['script_path']) && ($settings['script_path']->value = empty($settings['script_path']->value) ? dirname($_SERVER['SCRIPT_FILENAME']) : $settings['script_path']->value);
         !empty($settings['script_url']) && ($settings['script_url']->value = empty($settings['script_url']->value) ? dirname($_SERVER['SCRIPT_NAME']) : $settings['script_url']->value);
         !empty($settings['server_name']) && ($settings['server_name']->value = empty($settings['server_name']->value) ? $_SERVER['SERVER_NAME'] : $settings['server_name']->value);
     }
     $this->render('index', array('settings' => $settings));
 }
Beispiel #2
0
echo $form->textFieldRow($settings['debug_levels'], 'value', array('name' => 'YdSetting[debug_levels][value]', 'labelOptions' => array('for' => 'YdSetting_debug_levels_value')));
echo $form->checkBoxRow($settings['debug_db'], 'value', array('name' => 'YdSetting[debug_db][value]', 'labelOptions' => array('for' => 'YdSetting_debug_db_value')));
echo $form->textFieldRow($settings['error_email'], 'value', array('name' => 'YdSetting[error_email][value]', 'labelOptions' => array('for' => 'YdSetting_error_email_value')));
echo '</fieldset>';
echo '<fieldset><legend>' . Yii::t('dressing', 'PHP Settings') . '</legend>';
echo $form->textFieldRow($settings['memory_limit'], 'value', array('name' => 'YdSetting[memory_limit][value]', 'labelOptions' => array('for' => 'YdSetting_memory_limit_value')));
echo $form->textFieldRow($settings['time_limit'], 'value', array('name' => 'YdSetting[time_limit][value]', 'labelOptions' => array('for' => 'YdSetting_time_limit_value')));
echo '</fieldset>';
echo '<fieldset><legend>' . Yii::t('dressing', 'Path Settings') . '</legend>';
echo $form->textFieldRow($settings['script_path'], 'value', array('name' => 'Setting[script_path][value]'));
echo $form->textFieldRow($settings['script_url'], 'value', array('name' => 'Setting[script_url][value]'));
echo $form->textFieldRow($settings['server_name'], 'value', array('name' => 'Setting[server_name][value]'));
echo '</fieldset>';
echo '<h2>' . Yii::t('dressing', 'App Settings') . '</h2>';
echo '<fieldset><legend>' . Yii::t('dressing', 'PHP Settings') . '</legend>';
echo $form->dropDownListRow($settings['theme'], 'value', YdSetting::themes(), array('name' => 'YdSetting[theme][value]', 'empty' => '', 'labelOptions' => array('for' => 'YdSetting_theme_value')));
echo $form->textFieldRow($settings['defaultPageSize'], 'value', array('name' => 'YdSetting[defaultPageSize][value]', 'labelOptions' => array('for' => 'YdSetting_defaultPageSize_value')));
echo '</fieldset>';
echo '<fieldset><legend>' . Yii::t('dressing', 'Login Settings') . '</legend>';
echo $form->checkBoxRow($settings['allowAutoLogin'], 'value', array('name' => 'YdSetting[allowAutoLogin][value]', 'labelOptions' => array('for' => 'YdSetting_allowAutoLogin_value')));
echo $form->checkBoxRow($settings['rememberMe'], 'value', array('name' => 'YdSetting[rememberMe][value]', 'labelOptions' => array('for' => 'YdSetting_rememberMe_value')));
echo '</fieldset>';
echo '<fieldset><legend>' . Yii::t('dressing', 'Company Settings') . '</legend>';
//echo $form->textFieldRow($settings['brand'], 'value', array('name' => 'YdSetting[brand][value]', 'labelOptions' => array('for' => 'YdSetting_brand_value')));
echo $form->textFieldRow($settings['name'], 'value', array('name' => 'YdSetting[name][value]', 'labelOptions' => array('for' => 'YdSetting_name_value')));
//echo $form->textAreaRow($settings['address'], 'value', array('name' => 'YdSetting[address][value]', 'labelOptions' => array('for' => 'YdSetting_address_value')));
//echo $form->textFieldRow($settings['phone'], 'value', array('name' => 'YdSetting[phone][value]', 'labelOptions' => array('for' => 'YdSetting_phone_value')));
//echo $form->textFieldRow($settings['website'], 'value', array('name' => 'YdSetting[website][value]', 'labelOptions' => array('for' => 'YdSetting_website_value')));
echo $form->textFieldRow($settings['email'], 'value', array('name' => 'YdSetting[email][value]', 'labelOptions' => array('for' => 'YdSetting_email_value')));
echo '</fieldset>';
echo $form->endModalWrap();
Beispiel #3
0
 * @author Brett O'Donnell <*****@*****.**>
 * @author Zain Ul abidin <*****@*****.**>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-dressing
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-dressing/master/license.txt
 */
$this->pageTitle = Yii::t('dressing', 'Settings');
$this->menu = SiteMenu::getItemsFromMenu(SiteMenu::MENU_MAIN);
/** @var YdActiveForm $form */
$form = $this->beginWidget('ActiveForm', array('id' => 'setting-form', 'layout' => TbHtml::FORM_LAYOUT_HORIZONTAL));
echo $form->beginModalWrap();
echo $form->errorSummary($settings);
echo '<h2>' . Yii::t('dressing', 'Core Settings') . '</h2>';
echo '<fieldset><legend>' . Yii::t('dressing', 'Version Settings') . '</legend>';
echo $form->textFieldControlGroup($settings['id'], 'value', array('name' => 'YdSetting[id][value]', 'labelOptions' => array('for' => 'YdSetting_id_value')));
echo $form->dropDownListControlGroup($settings['app_version'], 'value', YdSetting::appVersions(), array('name' => 'YdSetting[app_version][value]', 'labelOptions' => array('for' => 'YdSetting_app_version_value')));
//echo $form->dropDownListControlGroup($settings['yii_version'], 'value', YdSetting::yiiVersions(), array('name' => 'YdSetting[yii_version][value]', 'labelOptions' => array('for' => 'YdSetting_yii_version_value')));
//echo $form->checkBoxControlGroup($settings['yii_lite'], 'value', array('name' => 'YdSetting[yii_lite][value]', 'labelOptions' => array('for' => 'YdSetting_yii_lite_value')));
echo '</fieldset>';
echo '<fieldset><legend>' . Yii::t('dressing', 'Debug Settings') . '</legend>';
echo $form->checkBoxControlGroup($settings['debug'], 'value', array('name' => 'YdSetting[debug][value]', 'labelOptions' => array('for' => 'YdSetting_debug_value')));
echo $form->textFieldControlGroup($settings['debug_levels'], 'value', array('name' => 'YdSetting[debug_levels][value]', 'labelOptions' => array('for' => 'YdSetting_debug_levels_value')));
echo $form->checkBoxControlGroup($settings['debug_db'], 'value', array('name' => 'YdSetting[debug_db][value]', 'labelOptions' => array('for' => 'YdSetting_debug_db_value')));
echo $form->textFieldControlGroup($settings['error_email'], 'value', array('name' => 'YdSetting[error_email][value]', 'labelOptions' => array('for' => 'YdSetting_error_email_value')));
echo '</fieldset>';
echo '<fieldset><legend>' . Yii::t('dressing', 'PHP Settings') . '</legend>';
echo $form->textFieldControlGroup($settings['memory_limit'], 'value', array('name' => 'YdSetting[memory_limit][value]', 'labelOptions' => array('for' => 'YdSetting_memory_limit_value')));
echo $form->textFieldControlGroup($settings['time_limit'], 'value', array('name' => 'YdSetting[time_limit][value]', 'labelOptions' => array('for' => 'YdSetting_time_limit_value')));
echo '</fieldset>';
echo '<fieldset><legend>' . Yii::t('dressing', 'Path Settings') . '</legend>';
echo $form->textFieldControlGroup($settings['script_path'], 'value', array('name' => 'Setting[script_path][value]'));
Beispiel #4
0
 * @var $user YdUser
 *
 * @author Brett O'Donnell <*****@*****.**>
 * @author Zain Ul abidin <*****@*****.**>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-dressing
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-dressing/master/license.txt
 */
$this->pageTitle = Yii::t('dressing', 'Account Settings');
$this->menu = YdSiteMenu::getItemsFromMenu('User');
/** @var YdActiveForm $form */
$form = $this->beginWidget('dressing.widgets.YdActiveForm', array('id' => 'account-form', 'type' => 'horizontal'));
echo $form->beginModalWrap();
echo $form->errorSummary($user);
?>
    <div class="control-group">
        <?php 
echo CHtml::label(Yii::t('dressing', 'Theme'), 'UserEav_theme', array('class' => 'control-label'));
?>
        <div class="controls">
            <?php 
echo CHtml::dropDownList('UserEav[theme]', $user->getEavAttribute('theme'), YdSetting::themes());
?>
        </div>
    </div>
<?php 
echo $form->endModalWrap();
echo '<div class="' . $form->getSubmitRowClass() . '">';
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'icon' => 'ok white', 'label' => Yii::t('dressing', 'Save'), 'htmlOptions' => array('class' => 'pull-right')));
echo '</div>';
$this->endWidget();
Beispiel #5
0
 /**
  * @static
  * @return array
  */
 public static function items()
 {
     if (self::$_items) {
         return self::$_items;
     }
     return self::$_items = $_ENV['_core']['setting'];
 }