/**
  * update settings
  */
 public static function updateSetting()
 {
     $s = [['key' => 'title', 'value' => 'Yii2 Skeleton', 'title' => 'Title', 'description' => 'Homepage title', 'group' => 'General', 'type' => 'textInput', 'data' => '[]', 'default' => 'Yii2 Skeleton', 'rules' => json_encode(['required' => []])], ['key' => 'keywords', 'value' => 'Yii2, Skeleton', 'title' => 'Keywords', 'description' => 'Homepage keywords', 'group' => 'General', 'type' => 'textInput', 'data' => '[]', 'default' => 'Yii2, Skeleton', 'rules' => json_encode(['required' => []])], ['key' => 'description', 'value' => 'Skeleton for Yii Framework', 'title' => 'Description', 'description' => 'Homepage description', 'group' => 'General', 'type' => 'textInput', 'data' => '[]', 'default' => 'Skeleton for Yii Framework', 'rules' => json_encode(['required' => []])], ['key' => 'language', 'value' => 'en-US', 'title' => 'Language', 'description' => 'Site language', 'group' => 'General', 'type' => 'dropDownList', 'data' => '{LOCALE}', 'default' => 'en-US', 'rules' => json_encode(['required' => []])], ['key' => 'timezone', 'value' => 'Asia/Ho_Chi_Minh', 'title' => 'Timezone', 'description' => 'Server Timezone', 'group' => 'General', 'type' => 'dropDownList', 'data' => '{TIMEZONE}', 'default' => 'Asia/Ho_Chi_Minh', 'rules' => json_encode(['required' => []])], ['key' => 'maxNameChange', 'value' => '1', 'title' => 'Max Name Change', 'description' => 'Max name change allowed', 'group' => 'Account', 'type' => 'textInput', 'data' => '[]', 'default' => '1', 'rules' => json_encode(['required' => [], 'number' => ['min' => -1]])], ['key' => 'tokenExpiryTime', 'value' => '3600', 'title' => 'Token Expiry Time', 'description' => 'Expiration time in seconds', 'group' => 'Account', 'type' => 'textInput', 'data' => '[]', 'default' => '3600', 'rules' => json_encode(['required' => [], 'number' => ['min' => 3600]])], ['key' => 'rememberMeDuration', 'value' => '2592000', 'title' => 'Remember Me Duration', 'description' => 'Customize the duration of the Remember Me in seconds', 'group' => 'Account', 'type' => 'textInput', 'data' => '[]', 'default' => '2592000', 'rules' => json_encode(['required' => [], 'number' => ['min' => 86400]])], ['key' => 'blogTitle', 'value' => 'My Blog', 'title' => 'Title', 'description' => 'Blog page title', 'group' => 'Blog', 'type' => 'textInput', 'data' => json_encode(Core::getYesNoOption()), 'default' => 'My Blog', 'rules' => json_encode(['required' => []])], ['key' => 'blogDesc', 'value' => 'Welcome to my world.', 'title' => 'Description', 'description' => 'Blog page description', 'group' => 'Blog', 'type' => 'textInput', 'data' => json_encode(Core::getYesNoOption()), 'default' => 'Welcome to my world.', 'rules' => json_encode(['required' => []])], ['key' => 'blogKeywords', 'value' => 'blog, my blog', 'title' => 'Keywords', 'description' => 'Blog page keywords', 'group' => 'Blog', 'type' => 'textInput', 'data' => json_encode(Core::getYesNoOption()), 'default' => 'blog, my blog', 'rules' => json_encode(['required' => []])], ['key' => 'blogThumbnail', 'value' => '', 'title' => 'Thumbnail Image', 'description' => 'Blog page thumbnail', 'group' => 'Blog', 'type' => 'textInput', 'data' => json_encode(Core::getYesNoOption()), 'default' => '', 'rules' => json_encode(['url' => []])], ['key' => 'outgoingMail', 'value' => '*****@*****.**', 'title' => 'Outgoing Mail', 'description' => 'Outgoing email address', 'group' => 'Mail', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['required' => [], 'email' => []])], ['key' => 'mailProtocol', 'value' => 'php', 'title' => 'Mail Protocol', 'description' => 'Outgoing email protocol', 'group' => 'Mail', 'type' => 'dropDownList', 'data' => json_encode(['php' => 'php', 'smtp' => 'smtp']), 'default' => 'php', 'rules' => json_encode(['required' => []])], ['key' => 'smtpHost', 'value' => '', 'title' => 'SMTP Host', 'description' => 'SMTP host', 'group' => 'Mail', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'smtpUsername', 'value' => '', 'title' => 'SMTP Username', 'description' => 'SMTP username', 'group' => 'Mail', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'smtpPassword', 'value' => '', 'title' => 'SMTP Password', 'description' => 'SMTP password', 'group' => 'Mail', 'type' => 'passwordInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'smtpPort', 'value' => '', 'title' => 'SMTP Port', 'description' => 'SMTP port', 'group' => 'Mail', 'type' => 'textInput', 'data' => '[]', 'default' => '25', 'rules' => json_encode(['safe' => [], 'number' => []])], ['key' => 'smtpEncryption', 'value' => '', 'title' => 'SMTP Encryption', 'description' => 'SMTP Encryption', 'group' => 'Mail', 'type' => 'textInput', 'data' => '[]', 'default' => 'ssl', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'fbPageUrl', 'value' => '', 'title' => 'Facebook Page URL', 'description' => 'Facebook Page URL', 'group' => 'Social', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'url' => []])], ['key' => 'fbAppId', 'value' => '', 'title' => 'Facebook App ID', 'description' => 'Facebook App ID', 'group' => 'Social', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'fbAdmins', 'value' => '', 'title' => 'Facebook Admins', 'description' => 'Facebook Admins ID', 'group' => 'Social', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'gpPageUrl', 'value' => '', 'title' => 'Google+ Page URL', 'description' => 'Google+ Page URL', 'group' => 'Social', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'url' => []])], ['key' => 'twitterSite', 'value' => '', 'title' => 'Twitter Card Site', 'description' => '@username for the website used', 'group' => 'Social', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'reCaptchaKey', 'value' => '', 'title' => 'reCaptcha Site Key', 'description' => 'reCaptcha Site Key', 'group' => 'API', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'reCaptchaSecret', 'value' => '', 'title' => 'reCaptcha Secret', 'description' => 'reCaptcha Secret', 'group' => 'API', 'type' => 'passwordInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'facebookAppId', 'value' => '', 'title' => 'Facebook App ID', 'description' => 'Facebook App ID', 'group' => 'API', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'facebookAppSecret', 'value' => '', 'title' => 'Facebook App Secret', 'description' => 'Facebook App Secret', 'group' => 'API', 'type' => 'passwordInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'googleClientId', 'value' => '', 'title' => 'Google Client ID', 'description' => 'Google Client ID', 'group' => 'API', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'googleClientSecret', 'value' => '', 'title' => 'Google Client Secret', 'description' => 'Google Client Secret', 'group' => 'API', 'type' => 'passwordInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'flickrClientKey', 'value' => '', 'title' => 'Flickr Client Key', 'description' => 'Flickr Client Key', 'group' => 'API', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'flickrClientSecret', 'value' => '', 'title' => 'Flickr Client Secret', 'description' => 'Flickr Client Secret', 'group' => 'API', 'type' => 'passwordInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'androidThemeColor', 'value' => '#3c8dbc', 'title' => 'Android Theme Color', 'description' => 'Android theme color', 'group' => 'Theme', 'type' => 'textInput', 'data' => '[]', 'default' => '#3c8dbc', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'msTileColor', 'value' => '#3c8dbc', 'title' => 'MS Tile Color', 'description' => 'Background color for a live tile', 'group' => 'Theme', 'type' => 'textInput', 'data' => '[]', 'default' => '#3c8dbc', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'safariMaskColor', 'value' => '#3c8dbc', 'title' => 'Safari Mask Color', 'description' => 'Safari pinned tab color', 'group' => 'Theme', 'type' => 'textInput', 'data' => '[]', 'default' => '#3c8dbc', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'googleCustomSearch', 'value' => '', 'title' => 'Google Custom Search', 'description' => 'CX code: 123456789012345678901:abcdefjh123', 'group' => 'Enhancements', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'googleAnalytics', 'value' => '', 'title' => 'Google Analytics', 'description' => 'Tracking ID: UA-1111111-22', 'group' => 'Enhancements', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'disqus', 'value' => '', 'title' => 'Disqus', 'description' => 'Disqus shortname', 'group' => 'Enhancements', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'zopim', 'value' => '', 'title' => 'Zopim Chat', 'description' => 'Zopim ID: 5d8f1e3c8f77c45608ada76d51256aad', 'group' => 'Enhancements', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'addthis', 'value' => '', 'title' => 'Addthis', 'description' => 'Addthis ID: ra-123a1234567890b1', 'group' => 'Enhancements', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'headJs', 'value' => '', 'title' => 'Header JS', 'description' => 'Header Javascript', 'group' => 'Enhancements', 'type' => 'textarea', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'adsense', 'value' => '', 'title' => 'Google Adsense', 'description' => 'Client ID: ca-pub-1234567890123456', 'group' => 'Ads', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'amzTracking', 'value' => '', 'title' => 'Amazon Tracking ID', 'description' => 'Tracking ID: yourname-11', 'group' => 'Ads', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'amzAds', 'value' => '', 'title' => 'Amazon Native Ads', 'description' => 'Ad Instance ID: 12abc1ab-ab12-1234-a123-1abcd123456a', 'group' => 'Ads', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'amzSearchAds', 'value' => '', 'title' => 'Amazon Search Ads', 'description' => 'Link ID: 12abc1ab-ab12-1234-a123-1abcd123456a', 'group' => 'Ads', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'languageUrlCode', 'value' => '0', 'title' => 'Language URL', 'description' => 'Include language code in URL', 'group' => 'System', 'type' => 'dropDownList', 'data' => json_encode(Core::getYesNoOption()), 'default' => '0', 'rules' => json_encode(['required' => [], 'boolean' => []])], ['key' => 'debug', 'value' => '0', 'title' => 'Debug Mode', 'description' => 'Turn debug mode ON/OFF', 'group' => 'System', 'type' => 'dropDownList', 'data' => json_encode(Core::getYesNoOption()), 'default' => '0', 'rules' => json_encode(['required' => [], 'boolean' => []])]];
     /* delete old settings */
     $settings = Setting::find()->all();
     foreach ($settings as $setting) {
         if (!in_array($setting->key, array_column($s, 'key'))) {
             $setting->delete();
         }
     }
     /* sync */
     foreach ($s as $i => $setting) {
         $conf = Setting::findOne($setting['key']);
         if (!$conf) {
             $conf = new Setting();
             $conf->key = $setting['key'];
             $conf->value = $setting['value'];
         }
         $conf->title = $setting['title'];
         $conf->description = $setting['description'];
         $conf->group = $setting['group'];
         $conf->type = $setting['type'];
         $conf->data = $setting['data'];
         $conf->default = $setting['default'];
         $conf->rules = $setting['rules'];
         $conf->key_order = $i;
         $conf->save();
     }
 }
Ejemplo n.º 2
0
 public function sendEmail($mail)
 {
     $setting = Setting::find()->where(['id' => 1])->one();
     $username = $setting->sendgridUsername;
     $password = $setting->sendgridPassword;
     $mail_admin = $setting->emailAdmin;
     $sendgrid = new \SendGrid($username, $password, array("turn_off_ssl_verification" => true));
     $email = new \SendGrid\Email();
     $subject = 'Registrasi Berhasil';
     $body = 'Thanks ' . $this->username . ',';
     $body .= "\n";
     $body .= "Registrasi anda berhasil, kami akan segera mereview kembali registrasi anda. \n";
     $body .= "Thanks, \n";
     $body .= Yii::$app->name;
     //$body_message = $this->template($subject, $body, $logo);
     $email->addTo($mail)->setFrom($mail_admin)->setSubject('Registrasi berhasil')->setHtml($body)->addCategory("registrasi");
     $response = $sendgrid->send($email);
     //return $response;
     //send whatsapp
     if ($setting->whatsappNumber && $setting->whatsappPassword) {
         $number = $setting->whatsappNumber;
         $app = Yii::$app->name;
         $password = $setting->whatsappPassword;
         $w = new WhatsApp($number, $app, $password);
         $w->send($setting->whatsappSend, $body);
     }
 }
 public function sendMail()
 {
     /* @var $user User */
     $user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
     if ($user) {
         if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
             $user->generatePasswordResetToken();
         }
         if ($user->save()) {
             $setting = Setting::find()->where(['id' => 1])->one();
             $username = $setting->sendgridUsername;
             $password = $setting->sendgridPassword;
             $mail_admin = $setting->emailAdmin;
             $sendgrid = new \SendGrid($username, $password, array("turn_off_ssl_verification" => true));
             $email = new \SendGrid\Email();
             $mail = $user->email;
             //echo $user->email;exit(0);
             $resetLink = \Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]);
             $body_message = 'Hello ' . Html::encode($user->username) . ', <br>
             Follow the link below to reset your password:  <br>
             ' . Html::a(Html::encode($resetLink), $resetLink);
             $email->addTo($user->email)->setFrom($mail_admin)->setSubject('Password reset for ' . \Yii::$app->name)->setHtml($body_message);
             $response = $sendgrid->send($email);
             return $response;
         }
     }
     return false;
 }
Ejemplo n.º 4
0
 /**
  * @return string|\yii\web\Response
  */
 public function actionSetting()
 {
     $model = Setting::find()->one();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->getSession()->setFlash('setting-update-success');
         return $this->redirect(['setting']);
     }
     return $this->render('setting', ['model' => $model]);
 }
Ejemplo n.º 5
0
 protected function getSetting($id = 1)
 {
     $model = Setting::find()->where(['id' => $id])->one();
     if ($model !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('Настройки сайта не найдены.');
     }
 }
Ejemplo n.º 6
0
 /**
  * Lists all Post models.
  * @return mixed
  */
 public function actionIndex()
 {
     $model = new Setting();
     $dataProvider = new ActiveDataProvider(['query' => Setting::find()]);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     }
     return $this->render('index', ['dataProvider' => $dataProvider, 'model' => $model]);
 }
Ejemplo n.º 7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Setting::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'userCreate' => $this->userCreate, 'userUpdate' => $this->userUpdate, 'createDate' => $this->createDate, 'updateDate' => $this->updateDate]);
     $query->andFilterWhere(['like', 'emailAdmin', $this->emailAdmin])->andFilterWhere(['like', 'emailSupport', $this->emailSupport])->andFilterWhere(['like', 'emailOrder', $this->emailOrder])->andFilterWhere(['like', 'sendgridUsername', $this->sendgridUsername])->andFilterWhere(['like', 'sendgridPassword', $this->sendgridPassword])->andFilterWhere(['like', 'whatsappNumber', $this->whatsappNumber])->andFilterWhere(['like', 'whatsappPassword', $this->whatsappPassword])->andFilterWhere(['like', 'whatsappSend', $this->whatsappSend])->andFilterWhere(['like', 'facebook', $this->facebook])->andFilterWhere(['like', 'instagram', $this->instagram])->andFilterWhere(['like', 'google', $this->google])->andFilterWhere(['like', 'twitter', $this->twitter])->andFilterWhere(['like', 'privacyPolicy', $this->privacyPolicy])->andFilterWhere(['like', 'terms', $this->terms])->andFilterWhere(['like', 'legalNotice', $this->legalNotice]);
     return $dataProvider;
 }
 public function actionPurpose()
 {
     $left_purpose = Setting::find()->where(['key' => 'left_purpose'])->one();
     $mid_purpose = Setting::find()->where(['key' => 'mid_purpose'])->one();
     $right_purpose = Setting::find()->where(['key' => 'right_purpose'])->one();
     $bottom_purpose = Setting::find()->where(['key' => 'bottom_purpose'])->one();
     $purpose_name = Setting::find()->where(['key' => 'purpose_name'])->one();
     $name_p1 = Setting::find()->where(['key' => 'name_p1'])->one();
     $name_p2 = Setting::find()->where(['key' => 'name_p2'])->one();
     $name_p3 = Setting::find()->where(['key' => 'name_p3'])->one();
     return $this->render('purpose', ['left_purpose' => $left_purpose->settingLan->index, 'mid_purpose' => $mid_purpose->settingLan->index, 'right_purpose' => $right_purpose->settingLan->index, 'bottom_purpose' => $bottom_purpose->settingLan->index, 'purpose_name' => $purpose_name->settingLan->index, 'name_p1' => $name_p1->settingLan->index, 'name_p2' => $name_p2->settingLan->index, 'name_p3' => $name_p3->settingLan->index]);
 }
Ejemplo n.º 9
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Setting::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'key', $this->key])->andFilterWhere(['like', 'value', $this->value])->andFilterWhere(['like', 'desc', $this->desc]);
     return $dataProvider;
 }
Ejemplo n.º 10
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     $labels = ['id' => 'ID', 'title' => 'Заголовок', 'content' => 'Сообщение', 'attachment' => 'Вложение', 'status' => 'Статус', 'created_at' => 'Создан', 'updated_at' => 'Отредактирован', 'created_user_id' => 'Создал', 'updated_user_id' => 'Отредактировал', 'created_user_name' => 'Создал', 'updated_user_name' => 'Отредактировал', 'for_document_id' => 'Принадлежность документу', 'for_user_id' => 'Принадлежность пользователю', 'parent_message_id' => 'Родительское сообщение (ID)', 'created_ip' => 'IP создателя'];
     /** @var \common\models\Setting $setting */
     $setting = Setting::find()->one();
     if ($setting && $setting->message_options_names) {
         $names = explode(',', $setting->message_options_names);
     }
     for ($i = 1; $i <= Message::OPTIONS_COUNT; $i++) {
         $item = $i - 1;
         $labels['option_' . $i] = isset($names[$item]) ? $names[$item] : 'Опция ' . $i;
     }
     return $labels;
 }
Ejemplo n.º 11
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Setting::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'summary', $this->summary])->andFilterWhere(['like', 'meta_key', $this->meta_key])->andFilterWhere(['like', 'meta_value', $this->meta_value]);
     return $dataProvider;
 }
Ejemplo n.º 12
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Setting::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['like', 'key', $this->key])->andFilterWhere(['like', 'value', $this->value])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'group', $this->group]);
     //$query->andFilterWhere([
     //    'DATE(FROM_UNIXTIME(`created_at`))' => $this->created_at,
     //]);
     return $dataProvider;
 }
Ejemplo n.º 13
0
 public function actionIndex()
 {
     $article = Article::find()->orderBy(['date_time' => SORT_DESC])->one();
     if ($article->articlePhotos[0]->photo_path == '') {
         if (Yii::$app->language == 'ru') {
             $articleimage = Yii::getAlias('@resource/img/news_ru.jpg');
         } else {
             $articleimage = Yii::getAlias('@resource/img/news_en.jpg');
         }
     } else {
         $articleimage = $article->articlePhotos[0]->photo_path;
     }
     $event = Event::find()->orderBy(['start_timedate' => SORT_ASC])->limit(3)->all();
     $section = Section::find()->limit(8)->all();
     $innovation_text_on_main_page = Setting::find()->where(['key' => 'innovation_text_on_main_page'])->one();
     $cooperation_with_aic = Setting::find()->where(['key' => 'cooperation_with_aic'])->one();
     $fill_in_the_blank = Setting::find()->where(['key' => 'fill_in_the_blank'])->one();
     $find_out_how_we_can_help_you = Setting::find()->where(['key' => 'find_out_how_we_can_help_you'])->one();
     $information_for_Students = Setting::find()->where(['key' => 'information_for_Students'])->one();
     $for_scientists_and_enterpreneurs = Setting::find()->where(['key' => 'for_scientists_and_enterpreneurs'])->one();
     return $this->render('index', ['article' => $article, 'articleimage' => $articleimage, 'event' => $event, 'section' => $section, 'innovation_text_on_main_page' => $innovation_text_on_main_page->settingLan->index, 'cooperation_with_aic' => $cooperation_with_aic->settingLan->index, 'fill_in_the_blank' => $fill_in_the_blank->settingLan->index, 'find_out_how_we_can_help_you' => $find_out_how_we_can_help_you->settingLan->index, 'information_for_Students' => $information_for_Students->settingLan->index, 'for_scientists_and_enterpreneurs' => $for_scientists_and_enterpreneurs->settingLan->index]);
 }
Ejemplo n.º 14
0
<?php

/* @var $this \yii\web\View */
/* @var $content string */
use yii\helpers\Html;
use frontend\assets\AppAsset;
use common\helpers\CFF;
use common\models\Setting;
AppAsset::register($this);
?>

<?php 
$this->beginPage();
$setting = Setting::find()->one();
?>

<!DOCTYPE html>
<html lang="<?php 
echo Yii::$app->language;
?>
">

    <head>
        <meta charset="<?php 
echo Yii::$app->charset;
?>
">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <?php 
echo Html::csrfMetaTags();
?>
Ejemplo n.º 15
0
<?php

use yii\helpers\Html;
use frontend\assets\AppAsset;
use common\models\Config;
use common\models\Logo;
use common\models\Slider;
use common\models\Category;
use common\models\Setting;
/* @var $this \yii\web\View */
/* @var $content string */
$this->title = 'SunFrogShirts';
AppAsset::register($this);
$categories = Category::find()->select('id, name')->orderBy('priority ASC, name')->all();
$setting_id = Setting::find()->select('name,value')->where('active = 1')->one();
$logo = Logo::find()->orderBy('id')->one();
if ($logo === null) {
    $logo = new Logo();
}
$this->beginPage();
?>
<!DOCTYPE html>
<html lang="<?php 
echo Yii::$app->language;
?>
">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="<?php 
echo Yii::$app->charset;
Ejemplo n.º 16
0
 public function actionDetail()
 {
     $product_id = Yii::$app->request->get('id');
     if (!empty($product_id)) {
         $product = Product::find()->where('id=:id', [':id' => $product_id])->one();
         if ($product) {
             $related_products = Product::find()->select('id, image, price, original_url')->where('category_id=:id and id !=:pid', [':id' => $product->category_id, ':pid' => $product_id])->orderBy('rand()')->limit(6)->all();
             $setting_id = Setting::find()->select('name,value')->where('active = 1')->one();
             return $this->render('detail', ['product' => $product, 'related_products' => $related_products, 'setting_id' => $setting_id ? '?' . $setting_id->name : '']);
         } else {
             throw new Exception("Page not found", 1);
         }
     } else {
         throw new Exception("Error Processing Request", 1);
     }
 }
Ejemplo n.º 17
0
 public static function getSetting()
 {
     $setting = Setting::find()->where(['active' => self::STATUS_ACTIVE])->one();
     return $setting;
 }
Ejemplo n.º 18
0
 public function actionSample()
 {
     //$objPHPExcel = new \PHPExcel();
     $template = Util::templateExcel();
     $model = new Setting();
     $date = date('YmdHis');
     $name = $date . Setting;
     //$attributes = $model->attributeLabels();
     $models = Setting::find()->all();
     $excelChar = Util::excelChar();
     $not = Util::excelNot();
     foreach ($model->attributeLabels() as $k => $v) {
         if (!in_array($k, $not)) {
             $attributes[$k] = $v;
         }
     }
     $objReader = \PHPExcel_IOFactory::createReader('Excel5');
     $objPHPExcel = $objReader->load(Yii::getAlias($template));
     return $this->render('sample', ['models' => $models, 'attributes' => $attributes, 'excelChar' => $excelChar, 'not' => $not, 'name' => $name, 'objPHPExcel' => $objPHPExcel]);
 }
 /**
  * Lists all Setting models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Setting::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }