/**
  * Declares the validation rules.
  */
 public function rules()
 {
     $themes = [];
     foreach (\humhub\components\Theme::getThemes() as $theme) {
         $themes[] = $theme->name;
     }
     return array(array('paginationSize', 'integer', 'max' => 200, 'min' => 1), array('theme', 'in', 'range' => $themes), array(['displayName', 'spaceOrder'], 'safe'), array('logo', 'file', 'extensions' => ['jpg', 'png', 'jpeg'], 'maxSize' => 3 * 1024 * 1024), array('logo', 'dimensionValidation', 'skipOnError' => true), array('dateInputDisplayFormat', 'in', 'range' => ['', 'php:d/m/Y']));
 }
 /**
  * Declares the validation rules.
  */
 public function rules()
 {
     $themes = \humhub\components\Theme::getThemes();
     return array(array('paginationSize', 'integer', 'max' => 200, 'min' => 1), array('theme', 'in', 'range' => $themes), array(['displayName', 'spaceOrder'], 'safe'), array('logo', 'file', 'extensions' => ['jpg', 'png', 'jpeg'], 'maxSize' => 3 * 1024 * 1024), array('logo', 'dimensionValidation', 'skipOnError' => true));
 }
 /**
  * E-Mail Mailing Settings
  */
 public function actionDesign()
 {
     $form = new \humhub\modules\admin\models\forms\DesignSettingsForm();
     #$assetPrefix = Yii::$app->assetManager->publish(dirname(__FILE__) . '/../resources', true, 0, defined('YII_DEBUG'));
     #Yii::$app->clientScript->registerScriptFile($assetPrefix . '/uploadLogo.js');
     if ($form->load(Yii::$app->request->post())) {
         $files = \yii\web\UploadedFile::getInstancesByName('logo');
         if (count($files) != 0) {
             $file = $files[0];
             $form->logo = $file;
         }
         if ($form->validate()) {
             Setting::Set('theme', $form->theme);
             Setting::Set('paginationSize', $form->paginationSize);
             Setting::Set('displayNameFormat', $form->displayName);
             Setting::Set('spaceOrder', $form->spaceOrder, 'space');
             if ($form->logo) {
                 $logoImage = new \humhub\libs\LogoImage();
                 $logoImage->setNew($form->logo);
             }
             // read and save colors from current theme
             \humhub\components\Theme::setColorVariables($form->theme);
             Yii::$app->getSession()->setFlash('data-saved', Yii::t('AdminModule.controllers_SettingController', 'Saved'));
             Yii::$app->response->redirect(Url::toRoute('/admin/setting/design'));
         }
     } else {
         $form->theme = Setting::Get('theme');
         $form->paginationSize = Setting::Get('paginationSize');
         $form->displayName = Setting::Get('displayNameFormat');
         $form->spaceOrder = Setting::Get('spaceOrder', 'space');
     }
     $themes = \humhub\components\Theme::getThemes();
     return $this->render('design', array('model' => $form, 'themes' => $themes, 'logo' => new \humhub\libs\LogoImage()));
 }
 /**
  * E-Mail Mailing Settings
  */
 public function actionDesign()
 {
     $form = new \humhub\modules\admin\models\forms\DesignSettingsForm();
     $form->theme = Setting::Get('theme');
     $form->paginationSize = Setting::Get('paginationSize');
     $form->displayName = Setting::Get('displayNameFormat');
     $form->spaceOrder = Setting::Get('spaceOrder', 'space');
     if ($form->load(Yii::$app->request->post())) {
         $files = \yii\web\UploadedFile::getInstancesByName('logo');
         if (count($files) != 0) {
             $file = $files[0];
             $form->logo = $file;
         }
         if ($form->validate()) {
             Setting::Set('theme', $form->theme);
             Setting::Set('paginationSize', $form->paginationSize);
             Setting::Set('displayNameFormat', $form->displayName);
             Setting::Set('spaceOrder', $form->spaceOrder, 'space');
             if ($form->logo) {
                 $logoImage = new \humhub\libs\LogoImage();
                 $logoImage->setNew($form->logo);
             }
             // read and save colors from current theme
             \humhub\components\Theme::setColorVariables($form->theme);
             DynamicConfig::rewrite();
             Yii::$app->getSession()->setFlash('data-saved', Yii::t('AdminModule.controllers_SettingController', 'Saved'));
             Yii::$app->response->redirect(Url::toRoute('/admin/setting/design'));
         }
     }
     $themes = [];
     foreach (\humhub\components\Theme::getThemes() as $theme) {
         $themes[$theme->name] = $theme->name;
     }
     return $this->render('design', array('model' => $form, 'themes' => $themes, 'logo' => new \humhub\libs\LogoImage()));
 }