/** * @inheritdoc */ public function init() { parent::init(); if (empty($this->adClient)) { $this->adClient = Setting::getValue('adsense'); } }
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; }
public static function register() { if (!Core::isInMemberAreaPage() && Yii::$app->id != 'app-backend') { if ($id = Setting::getValue('addthis')) { Yii::$app->view->registerJsFile('//s7.addthis.com/js/300/addthis_widget.js#pubid=' . $id); } } }
public static function register() { $js = Setting::getValue('headJs'); if (!empty($js)) { $view = Yii::$app->getView(); $view->registerJs($js, View::POS_HEAD); } }
/** * Finds the Post model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Post the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Setting::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @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]); }
protected function getSetting($id = 1) { $model = Setting::find()->where(['id' => $id])->one(); if ($model !== null) { return $model; } else { throw new NotFoundHttpException('Настройки сайта не найдены.'); } }
/** * @inheritdoc */ public function run() { $shortname = Setting::getValue('disqus'); if (!empty($shortname)) { $js = $this->registerVariables($shortname); Yii::$app->view->registerJs($js, \yii\web\View::POS_END); echo Html::tag('div', '', ['id' => 'disqus_thread']); } }
private function _setInfo() { $setting = Setting::getSetting(); if ($setting && $setting->server_ip != '' && $setting->server_port != '') { $this->ip = $setting->server_ip; $this->port = $setting->server_port; return true; } return false; }
/** * @inheritdoc */ public function run() { parent::run(); // TODO: Change the autogenerated stub $tracking = Setting::getValue('amzTracking'); $searchAds = Setting::getValue('amzSearchAds'); if (!empty($tracking) && !empty($searchAds)) { return $this->render('amzSearchAds', ['tracking' => $tracking, 'searchAds' => $searchAds]); } }
public function actionTest() { $setting = \common\models\Setting::findOne(1); $number = $setting->whatsappNumber; $app = Yii::$app->name; $password = $setting->whatsappPassword; $phone = '6281575068530'; $message = 'this is just test, please dont remain'; $w = new WhatsApp($number, $app, $password); echo $w->send($phone, $message); }
/** * 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; }
/** * @inheritdoc */ public function init() { parent::init(); /* facebook */ if (empty($this->fb['appId'])) { $this->fb['appId'] = Setting::getValue('fbAppId'); } if (empty($this->fb['language'])) { $this->fb['language'] = str_ireplace('-', '_', Yii::$app->language); } }
public function actionInit() { $model = new User(); $model->username = '******'; $model->auth_key = 'OocVKRx-iludROmUFYj4HmxNeC8v0-FG'; $model->password_hash = '$2y$13$0d3FeUDYGSyZft.3I77hV.E357FsqqAJFqaWPstWODMbdlSvxV2gC'; $model->email = '*****@*****.**'; $model->phone = '6281575068530'; $model->role = User::ROLE_ADMIN; $model->status = User::STATUS_ACTIVE; if ($model->save()) { echo "\r\n success insert user, with username:admin and password:123456 \r\n"; } else { echo json_encode($model->getErrors()); } $model = new Member(); $model->username = '******'; $model->auth_key = 'OocVKRx-iludROmUFYj4HmxNeC8v0-FG'; $model->password_hash = '$2y$13$0d3FeUDYGSyZft.3I77hV.E357FsqqAJFqaWPstWODMbdlSvxV2gC'; $model->email = '*****@*****.**'; $model->phone = '6281575068530'; $model->role = Member::ROLE_ADMIN; $model->status = Member::STATUS_ACTIVE; if ($model->save()) { echo "\r\n success insert member, with username:admin and password:123456 \r\n"; } else { echo json_encode($model->getErrors()); } $setting = new Setting(); $setting->emailAdmin = '*****@*****.**'; $setting->emailSupport = '*****@*****.**'; $setting->emailOrder = '*****@*****.**'; $setting->facebook = 'https://www.facebook.com/sintret'; $setting->instagram = 'https://instagram.com/andyfitria/'; $setting->google = 'https://google.com/sintret/'; if ($setting->save()) { echo "\r\n success insert advanced settings... \r\n"; } else { echo json_encode($setting->getErrors()); } }
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]); }
protected function insertSettings() { $s = [['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' => 'title', 'value' => 'Yii2 Skeleton', 'title' => 'Title', 'description' => 'Homepage title', 'group' => 'SEO', 'type' => 'textInput', 'data' => '[]', 'default' => 'Yii2 Skeleton', 'rules' => json_encode(['required' => []])], ['key' => 'keywords', 'value' => 'Yii2, Skeleton', 'title' => 'Keywords', 'description' => 'Homepage keywords', 'group' => 'SEO', 'type' => 'textInput', 'data' => '[]', 'default' => 'Yii2, Skeleton', 'rules' => json_encode(['required' => []])], ['key' => 'description', 'value' => 'Skeleton for Yii Framework', 'title' => 'Description', 'description' => 'Homepage description', 'group' => 'SEO', 'type' => 'textInput', 'data' => '[]', 'default' => 'Skeleton for Yii Framework', 'rules' => json_encode(['required' => []])], ['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' => []])], ['key' => 'smtpUsername', 'value' => '', 'title' => 'SMTP Username', 'description' => 'SMTP username', 'group' => 'Mail', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => []])], ['key' => 'smtpPassword', 'value' => '', 'title' => 'SMTP Password', 'description' => 'SMTP password', 'group' => 'Mail', 'type' => 'passwordInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => []])], ['key' => 'smtpPort', 'value' => '', 'title' => 'SMTP Port', 'description' => 'SMTP port', 'group' => 'Mail', 'type' => 'textInput', 'data' => '[]', 'default' => '25', 'rules' => json_encode(['safe' => []])], ['key' => 'smtpEncryption', 'value' => '', 'title' => 'SMTP Encryption', 'description' => 'SMTP port', 'group' => 'Mail', 'type' => 'textInput', 'data' => '[]', 'default' => 'ssl', 'rules' => json_encode(['safe' => []])], ['key' => 'reCaptchaKey', 'value' => '', 'title' => 'reCaptcha Site Key', 'description' => 'reCaptcha Site Key', 'group' => 'API', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => []])], ['key' => 'reCaptchaSecret', 'value' => '', 'title' => 'reCaptcha Secret', 'description' => 'reCaptcha Secret', 'group' => 'API', 'type' => 'passwordInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => []])], ['key' => 'facebookAppId', 'value' => '', 'title' => 'Facebook App ID', 'description' => 'Facebook App ID', 'group' => 'API', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => []])], ['key' => 'facebookAppSecret', 'value' => '', 'title' => 'Facebook App Secret', 'description' => 'Facebook App Secret', 'group' => 'API', 'type' => 'passwordInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => []])], ['key' => 'googleClientId', 'value' => '', 'title' => 'Google Client ID', 'description' => 'Google Client ID', 'group' => 'API', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => []])], ['key' => 'googleClientSecret', 'value' => '', 'title' => 'Google Client Secret', 'description' => 'Google Client Secret', 'group' => 'API', 'type' => 'passwordInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => []])], ['key' => 'flickrClientKey', 'value' => '', 'title' => 'Flickr Client Key', 'description' => 'Flickr Client Key', 'group' => 'API', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => []])], ['key' => 'flickrClientSecret', 'value' => '', 'title' => 'Flickr Client Secret', 'description' => 'Flickr Client Secret', 'group' => 'API', 'type' => 'passwordInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => []])], ['key' => 'debug', 'value' => '0', 'title' => 'Debug Mode', 'description' => 'Turn on debug mode', 'group' => 'System', 'type' => 'dropDownList', 'data' => json_encode(Core::getYesNoOption()), 'default' => '0', 'rules' => json_encode(['required' => []])]]; 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(); } //return $this->redirect(['index']); }
/** * 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; }
/** * insert settings */ protected function insertSettings() { $s = [['key' => 'languageUrlCode', 'value' => '0', 'title' => 'Language URL', 'description' => 'Include language code in URL', 'group' => 'SEO', 'type' => 'dropDownList', 'data' => json_encode(Core::getYesNoOption()), 'default' => '0', 'rules' => json_encode(['required' => [], 'boolean' => []])]]; 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(); } //return $this->redirect(['index']); }
/** * set new email * @return bool */ public function changeEmail() { $user = Yii::$app->user->identity; if (!Account::isTokenValid($user->change_email_token)) { $user->generateChangeEmailToken(); } $user->new_email = $this->newEmail; if ($user->save()) { Yii::$app->language = $user->language; $subject = Yii::t('app', '[{APP_NAME}] Please verify your email address', ['APP_NAME' => Yii::$app->name]); return Yii::$app->mailer->compose(['html' => 'change-email-html', 'text' => 'change-email-text'], ['title' => $subject, 'user' => $user])->setFrom([Setting::getValue('outgoingMail')])->setTo($user->new_email)->setSubject($subject)->send(); } return false; }
/** * @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; }
/** * Sends an email with a link, for resetting the password. * * @return boolean whether the email was send */ public function sendEmail() { $user = Account::findOne(['status' => Account::STATUS_ACTIVE, 'email' => $this->email]); if ($user) { if (!Account::isTokenValid($user->password_reset_token)) { $user->generatePasswordResetToken(); } if ($user->save()) { $email = Yii::$app->mailer->compose(['html' => 'password-reset-token-html', 'text' => 'password-reset-token-text'], ['user' => $user])->setFrom([Setting::getValue('outgoingMail') => \Yii::$app->name])->setTo($this->email)->setSubject(Yii::t('app', 'Password reset for {APP_NAME}', ['APP_NAME' => \Yii::$app->name])); return $email->send(); } } return false; }
/** * @inheritdoc */ public function run() { $baseUrl = Yii::$app->request->baseUrl; $themeColor = Setting::getValue('androidThemeColor'); $data = <<<EOB <link rel="apple-touch-icon" sizes="180x180" href="{$baseUrl}/favicon/apple-touch-icon.png"> <link rel="icon" type="image/png" href="{$baseUrl}/favicon/favicon-32x32.png" sizes="32x32"> <link rel="icon" type="image/png" href="{$baseUrl}/favicon/favicon-16x16.png" sizes="16x16"> <link rel="manifest" href="{$baseUrl}/favicon/manifest.json"> <link rel="mask-icon" href="{$baseUrl}/favicon/safari-pinned-tab.svg" color="{$themeColor}"> <meta name="msapplication-config" content="{$baseUrl}/favicon/browserconfig.xml"> <meta name="theme-color" content="{$themeColor}"> EOB; return $data; }
public static function register() { $id = Setting::getValue('googleAnalytics'); if (!empty($id)) { $js = <<<EOB (function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,"script","https://www.google-analytics.com/analytics.js","ga"); ga("create", "{$id}", "auto"); ga("send", "pageview"); EOB; $view = Yii::$app->getView(); $view->registerJs($js, View::POS_HEAD); } }
/** * Sends an email with a link, for resetting the password. * * @return boolean whether the email was send */ public function sendEmail() { /* @var $user User */ $user = Member::findOne(['status' => Member::STATUS_ACTIVE, 'email' => $this->email]); if ($user) { if (!User::isPasswordResetTokenValid($user->password_reset_token)) { $user->generatePasswordResetToken(); } $setting = Setting::findOne(1); $from = $setting->emailSupport; if ($user->save()) { return \Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user])->setFrom([$from => \Yii::$app->name . ' robot'])->setTo($this->email)->setSubject('Password reset for ' . \Yii::$app->name)->send(); } } return false; }
/** * 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; }
/** * 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; }
/** * for user account settings * @param $e [] exception * @return array */ public static function getLocaleList($e = []) { /* current translation languages */ $l = (new Query())->select(['language'])->distinct()->from('{{%core_message}}')->column(); $l[] = Yii::$app->sourceLanguage; /* site default language */ $default = Setting::getValue('language'); if (!in_array($default, $l)) { $l[] = $default; } $list = Core::getLocaleList($l); /* exception */ if (is_array($e)) { foreach ($e as $key) { unset($list[$key]); } } return $list; }
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]); }
/** * Displays a single Blog model. * @param string $name * @return mixed */ public function actionView($name) { $this->layout = 'main'; $model = $this->findBySlug($name); // $new=new Blog(); // $new->attributes=$model->attributes; // $new->slug=$new->slug.'-'.rand(1000,9999); // $new->id=null; // if(!$new->save()){ // var_dump($new->errors); // } /* views ++ */ $model->updateViews(); /* metaData */ $title = $model->title; $keywords = $model->tags; $description = $model->desc; $metaTags[] = ['name' => 'keywords', 'content' => $keywords]; $metaTags[] = ['name' => 'description', 'content' => $description]; /* Facebook */ $metaTags[] = ['property' => 'og:title', 'content' => $title]; $metaTags[] = ['property' => 'og:description', 'content' => $description]; $metaTags[] = ['property' => 'og:type', 'content' => 'article']; // article, product, profile etc $metaTags[] = ['property' => 'og:image', 'content' => $model->thumbnail]; //best 1200 x 630 $metaTags[] = ['property' => 'og:url', 'content' => $model->getViewUrl(true)]; if ($appId = Setting::getValue('fbAppId')) { $metaTags[] = ['property' => 'fb:app_id', 'content' => $appId]; } //$metaTags[]=['property' => 'fb:app_id', 'content' => '']; //$metaTags[]=['property' => 'fb:admins', 'content' => '']; /* Twitter */ $metaTags[] = ['name' => 'twitter:card', 'content' => 'summary_large_image']; $metaTags[] = ['name' => 'twitter:site', 'content' => Setting::getValue('twitterSite')]; // $metaTags[]=['name'=>'twitter:title', 'content'=>$title]; // $metaTags[]=['name'=>'twitter:description', 'content'=>$description]; // $metaTags[]=['name'=>'twitter:card', 'content'=>'summary']; // $metaTags[]=['name'=>'twitter:site', 'content'=>'']; // $metaTags[]=['name'=>'twitter:image', 'content'=>'']; // $metaTags[]=['name'=>'twitter:data1', 'content'=>'']; // $metaTags[]=['name'=>'twitter:label1', 'content'=>'']; // $metaTags[]=['name'=>'twitter:data2', 'content'=>'']; // $metaTags[]=['name'=>'twitter:label2', 'content'=>'']; /* jsonld */ $imageObject = $model->getImageObject(); $jsonLd = (object) ['@type' => 'Article', 'http://schema.org/name' => $model->title, 'http://schema.org/headline' => $model->desc, 'http://schema.org/articleBody' => $model->content, 'http://schema.org/dateCreated' => Yii::$app->formatter->asDate($model->created_at, 'php:c'), 'http://schema.org/dateModified' => Yii::$app->formatter->asDate($model->updated_at, 'php:c'), 'http://schema.org/datePublished' => Yii::$app->formatter->asDate($model->published_at, 'php:c'), 'http://schema.org/url' => $model->getViewUrl(true), 'http://schema.org/image' => (object) ['@type' => 'ImageObject', 'http://schema.org/url' => $imageObject['url'], 'http://schema.org/width' => $imageObject['width'], 'http://schema.org/height' => $imageObject['height']], 'http://schema.org/author' => (object) ['@type' => 'Person', 'http://schema.org/name' => $model->author->fullname], 'http://schema.org/publisher' => (object) ['@type' => 'Organization', 'http://schema.org/name' => Yii::$app->name, 'http://schema.org/logo' => (object) ['@type' => 'ImageObject', 'http://schema.org/url' => Yii::$app->urlManager->createAbsoluteUrl(Yii::$app->homeUrl . '/images/logo.png')]], 'http://schema.org/mainEntityOfPage' => (object) ['@type' => 'WebPage', '@id' => Yii::$app->urlManager->createAbsoluteUrl($model->viewUrl)]]; /* OK */ $data['title'] = $title; $data['metaTags'] = $metaTags; $data['jsonLd'] = $jsonLd; $this->registerMetaTagJsonLD($data); return $this->render('view', ['model' => $model]); }