/** * E-Mail Mailing Settings */ public function actionDesign() { Yii::import('admin.forms.*'); $form = new DesignSettingsForm(); // uncomment the following code to enable ajax-based validation if (isset($_POST['ajax']) && $_POST['ajax'] === 'design-settings-form') { echo CActiveForm::validate($form); Yii::app()->end(); } if (isset($_POST['DesignSettingsForm'])) { $_POST['DesignSettingsForm'] = Yii::app()->input->stripClean($_POST['DesignSettingsForm']); $form->attributes = $_POST['DesignSettingsForm']; if ($form->validate()) { HSetting::Set('theme', $form->theme); HSetting::Set('paginationSize', $form->paginationSize); HSetting::Set('displayNameFormat', $form->displayName); // set flash message Yii::app()->user->setFlash('data-saved', Yii::t('AdminModule.controllers_SettingController', 'Saved')); $this->redirect(Yii::app()->createUrl('//admin/setting/design')); } } else { $form->theme = HSetting::Get('theme'); $form->paginationSize = HSetting::Get('paginationSize'); $form->displayName = HSetting::Get('displayNameFormat'); } $themes = HTheme::getThemes(); $themes[''] = Yii::t('AdminModule.controllers_SettingController', 'No theme'); $this->render('design', array('model' => $form, 'themes' => $themes)); }
/** * E-Mail Mailing Settings */ public function actionDesign() { Yii::import('admin.forms.*'); $form = new DesignSettingsForm(); // uncomment the following code to enable ajax-based validation if (isset($_POST['ajax']) && $_POST['ajax'] === 'design-settings-form') { echo CActiveForm::validate($form); Yii::app()->end(); } $assetPrefix = Yii::app()->assetManager->publish(dirname(__FILE__) . '/../resources', true, 0, defined('YII_DEBUG')); Yii::app()->clientScript->registerScriptFile($assetPrefix . '/uploadLogo.js'); if (isset($_POST['DesignSettingsForm'])) { $_POST['DesignSettingsForm'] = Yii::app()->input->stripClean($_POST['DesignSettingsForm']); $form->attributes = $_POST['DesignSettingsForm']; $files = CUploadedFile::getInstancesByName('logo'); if (count($files) != 0) { $file = $files[0]; $form->logo = $file; } if ($form->validate()) { HSetting::Set('theme', $form->theme); HSetting::Set('paginationSize', $form->paginationSize); HSetting::Set('displayNameFormat', $form->displayName); HSetting::Set('spaceOrder', $form->spaceOrder, 'space'); if ($form->logo) { $logoImage = new LogoImage(); $logoImage->setNew($form->logo); } // set flash message Yii::app()->user->setFlash('data-saved', Yii::t('AdminModule.controllers_SettingController', 'Saved')); $this->redirect(Yii::app()->createUrl('//admin/setting/design')); } } else { $form->theme = HSetting::Get('theme'); $form->paginationSize = HSetting::Get('paginationSize'); $form->displayName = HSetting::Get('displayNameFormat'); $form->spaceOrder = HSetting::Get('spaceOrder', 'space'); } $themes = HTheme::getThemes(); //$themes[''] = Yii::t('AdminModule.controllers_SettingController', 'No theme'); $this->render('design', array('model' => $form, 'themes' => $themes, 'logo' => new LogoImage())); }
/** * Declares the validation rules. */ public function rules() { $themes = HTheme::getThemes(); return array(array('paginationSize', 'numerical', 'integerOnly' => true, 'max' => 200, 'min' => 1), array('theme', 'in', 'range' => $themes), array('displayName, spaceOrder', 'safe'), array('logo', 'file', 'types' => 'jpg, png, jpeg', 'maxSize' => 3 * 1024 * 1024, 'allowEmpty' => true), array('logo', 'dimensionValidation', 'skipOnError' => true)); }
/** * Declares the validation rules. */ public function rules() { $themes = HTheme::getThemes(); return array(array('paginationSize', 'numerical', 'integerOnly' => true, 'max' => 200, 'min' => 1), array('theme', 'in', 'range' => $themes), array('displayName', 'safe')); }