/**
  * 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();
     }
 }
示例#2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Blog::find();
     $query->joinWith(['author']);
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $dataProvider->sort->attributes['fullname'] = ['asc' => ['{{%core_account}}.fullname' => SORT_ASC], 'desc' => ['{{%core_account}}.fullname' => SORT_DESC]];
     /* user's blog */
     if (Core::checkMCA(null, 'blog', 'manage')) {
         $query->andFilterWhere(['{{%core_blog}}.created_by' => Yii::$app->user->id]);
     }
     /* list all public blog */
     if (Core::checkMCA(null, 'blog', 'index')) {
         $query->andFilterWhere(['{{%core_blog}}.status' => Blog::STATUS_PUBLISHED]);
     }
     $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(['{{%core_blog}}.id' => $this->id, '{{%core_blog}}.created_by' => $this->created_by, '{{%core_blog}}.views' => $this->views, '{{%core_blog}}.status' => $this->status]);
     $query->andFilterWhere(['like', '{{%core_blog}}.title', $this->title])->andFilterWhere(['like', '{{%core_account}}.fullname', $this->fullname])->andFilterWhere(['like', '{{%core_blog}}.desc', $this->desc])->andFilterWhere(['like', '{{%core_blog}}.content', $this->content])->andFilterWhere(['like', '{{%core_blog}}.tags', $this->tags]);
     $query->andFilterWhere(['DATE(FROM_UNIXTIME(`{{%core_blog}}.updated_at`))' => $this->updated_at]);
     return $dataProvider;
 }
示例#3
0
 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);
         }
     }
 }
 /**
  * @inheritdoc
  */
 public function rules()
 {
     $captcha = [];
     if (Core::isReCaptchaEnabled()) {
         $captcha = [['verifyCode', 'required', 'message' => Yii::t('app', 'Prove you are NOT a robot')], ['verifyCode', ReCaptchaValidator::className(), 'message' => Yii::t('app', 'Prove you are NOT a robot')]];
     }
     $default = [['email', 'filter', 'filter' => 'trim'], ['email', 'filter', 'filter' => 'strtolower'], ['email', 'required'], ['email', 'email'], ['email', 'exist', 'targetClass' => 'common\\models\\Account', 'filter' => ['status' => Account::STATUS_ACTIVE], 'message' => Yii::t('app', 'There is no user with such email.')]];
     return array_merge($default, $captcha);
 }
 /**
  * @inheritdoc
  */
 public function rules()
 {
     $captcha = [];
     if (Core::isReCaptchaEnabled()) {
         $captcha = [['verifyCode', 'required', 'message' => Yii::t('app', 'Prove you are NOT a robot')], ['verifyCode', ReCaptchaValidator::className(), 'message' => Yii::t('app', 'Prove you are NOT a robot')]];
     }
     $default = [[['newEmail'], 'required'], ['newEmail', 'email'], ['newEmail', 'filter', 'filter' => 'trim'], ['newEmail', 'filter', 'filter' => 'strtolower'], ['newEmail', 'unique', 'targetAttribute' => 'email', 'targetClass' => 'common\\models\\Account', 'message' => Yii::t('app', 'This email address has already been taken.')]];
     return array_merge($default, $captcha);
 }
示例#6
0
 /**
  * get data for dropDownList in update setting page
  * @param $type
  * @return array
  */
 public static function getListData($type)
 {
     if ($type == '{TIMEZONE}') {
         return Core::getTimezoneList();
     }
     if ($type == '{LOCALE}') {
         return Core::getLocaleList();
     }
     return [];
 }
 /**
  * Index
  * @return string
  */
 public function actionIndex()
 {
     $searchModel = new MessageSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     /* new lang list */
     $langs = Core::getLocaleList();
     $currents = Message::getLocaleList([Yii::$app->sourceLanguage]);
     foreach ($currents as $key => $name) {
         unset($langs[$key]);
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'langs' => $langs]);
 }
 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']);
 }
 /**
  * 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']);
 }
示例#10
0
?>
</h1>
        </div>
        <div class="box-body">
            <div class="account-form">
                <?php 
$form = ActiveForm::begin(['action' => Yii::$app->urlManager->createUrl(['/account'])]);
?>
                <?php 
echo $form->field($model, 'fullname')->textInput(['maxlength' => true, 'disabled' => !$model->canChangeName()]);
?>
                <?php 
echo $form->field($model, 'language')->widget(Select2Widget::className(), ['bootstrap' => false, 'items' => \common\models\Message::getLocaleList()]);
?>
                <?php 
echo $form->field($model, 'timezone')->widget(Select2Widget::className(), ['bootstrap' => false, 'items' => Core::getTimezoneList()]);
?>
                <div class="form-group">
                    <?php 
echo Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-primary']);
?>
                </div
                <?php 
ActiveForm::end();
?>
            </div>
        </div>
    </div>
</div>

示例#11
0
                </div>

                <?php 
echo $form->field($model, 'keywords')->textInput(['maxlength' => true]);
?>
                <?php 
echo $form->field($model, 'thumbnail')->textInput(['maxlength' => false, 'placeholder' => Yii::t('app', 'Must be at least 160x90 pixels and at most 1920x1080 pixels')]);
?>
                <?php 
echo $form->field($model, 'status')->dropDownList(PageData::getStatusOption());
?>
                <?php 
echo $form->field($model->page, 'show_description')->dropDownList(Core::getYesNoOption());
?>
                <?php 
echo $form->field($model->page, 'show_update_date')->dropDownList(Core::getYesNoOption());
?>
                <div class="form-group">
                    <p class="pull-left">
                        <?php 
echo Html::submitButton($model->scenario == 'create' ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->scenario == 'create' ? 'btn btn-success' : 'btn btn-primary']);
?>
                    </p>
                    <?php 
if (count($languages) > 0) {
    ?>
                        <div class="btn-group pull-right">
                            <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"
                                    aria-haspopup="true" aria-expanded="false">
                                <?php 
    echo Yii::t('app', 'Languages');
示例#12
0
                <?php 
}
?>
            </div>
            <!-- /.navbar-collapse -->



            <!-- Navbar Right Menu -->
            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">
                    <?php 
if (!Yii::$app->user->isGuest) {
    ?>
                        <li class="<?php 
    echo Core::checkMCA('', 'account', '*') ? 'active' : '';
    ?>
">
                            <a href="<?php 
    echo Yii::$app->urlManager->createUrl(['/account']);
    ?>
">
                                <?php 
    echo Icon::widget(['icon' => 'user']);
    ?>
                                <span><?php 
    echo Yii::$app->user->identity->fullname;
    ?>
</span>
                            </a>
                        </li>
示例#13
0
 /**
  * account default items
  * @return array
  */
 protected function accountItems()
 {
     return [['label' => Yii::t('app', 'Personal settings')], ['icon' => 'user', 'label' => Yii::t('app', 'Profile'), 'url' => ['/account/index'], 'active' => Core::checkMCA(null, 'account', 'index')], ['icon' => 'envelope', 'label' => Yii::t('app', 'Email'), 'url' => ['/account/email'], 'active' => Core::checkMCA(null, 'account', 'email')], ['icon' => 'lock', 'label' => Yii::t('app', 'Password'), 'url' => ['/account/password'], 'active' => Core::checkMCA(null, 'account', 'password')], ['icon' => 'puzzle-piece', 'label' => Yii::t('app', 'Linked Accounts'), 'url' => ['/account/linked'], 'active' => Core::checkMCA(null, 'account', 'linked')], ['label' => Yii::t('app', 'Blog'), 'enabled' => Yii::$app->params['enableBlog']], ['icon' => 'rss-square', 'label' => Yii::t('app', 'My Blog'), 'url' => ['/blog/manage'], 'active' => Core::checkMCA(null, 'blog', 'manage'), 'enabled' => Yii::$app->params['enableBlog']], ['icon' => 'pencil-square', 'label' => Yii::t('app', 'Write'), 'url' => ['/blog/create'], 'active' => Core::checkMCA(null, 'blog', 'create'), 'enabled' => Yii::$app->params['enableBlog']]];
 }
示例#14
0
<footer class="main-footer">
    <div class="container">
        <div class="pull-right hidden-xs">
            <?php 
echo \common\Core::powered();
?>
        </div>
        <strong><?php 
echo Yii::t('app', 'Copyright');
?>
 &copy; <?php 
echo date('Y');
?>
 <?php 
echo Yii::$app->name;
?>
.</strong> <?php 
echo Yii::t('app', 'All rights reserved.');
?>
    </div>
</footer>
示例#15
0
<div class="account-reset">
    <div class="row">
        <div style="" class="col-xs-12">
            <h1 class="no-margin"><?php 
echo $this->title;
?>
</h1>
            <div><hr /></div>
            <?php 
$form = ActiveForm::begin(['id' => 'request-password-reset-form']);
?>
            <?php 
echo $form->field($model, 'email');
?>
            <?php 
if (Core::isReCaptchaEnabled()) {
    ?>
            <?php 
    echo $form->field($model, 'verifyCode')->widget(ReCaptcha::className())->label(false);
    ?>
            <?php 
}
?>
            <div class="form-group">
                <?php 
echo Html::submitButton(Yii::t('app', 'Reset Password'), ['class' => 'btn btn-primary']);
?>
            </div>
            <?php 
ActiveForm::end();
?>
示例#16
0
 /**
  * @inheritdoc
  * @param bool $insert
  * @return bool
  */
 public function beforeSave($insert)
 {
     if ($insert) {
         $this->setPassword();
         $this->generateAuthKey();
         /* default timezone and language */
         $this->language = empty($this->language) ? Yii::$app->language : $this->language;
         $this->status = self::STATUS_ACTIVE;
         $this->timezone = empty($this->timezone) ? Yii::$app->timeZone : $this->timezone;
     }
     $this->seo_name = Core::generateSeoName($this->fullname);
     return parent::beforeSave($insert);
 }
 /**
  * Finds the Blog model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Blog the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     $condition = ['id' => $id];
     if (Core::checkMCA(null, 'blog', 'view')) {
         $condition = ['id' => $id, 'status' => Blog::STATUS_PUBLISHED];
     }
     if (($model = Blog::find()->where($condition)->one()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
     }
 }
示例#18
0
</h3>
        </div>
        <div class="box-body">
            <?php 
if ($model->show_description) {
    ?>
                <p><?php 
    echo Html::encode($model->content->description);
    ?>
</p>
            <?php 
}
?>
            <div class="page-body">
                <?php 
echo Core::translateMessage($model->content->content, ['{APP_NAME}' => Yii::$app->name, '{APP_DOMAIN}' => Yii::$app->request->hostInfo]);
?>
            </div>
        </div>
        <?php 
if ($model->show_update_date) {
    ?>
            <div class="box-footer">
                <div class="pull-right font-light text-sm">
                    <?php 
    echo Yii::t('app', 'Last updated: {DATE}', ['DATE' => Yii::$app->formatter->asDate($model->content->updated_at)]);
    ?>
                </div>
            </div>
        <?php 
}
示例#19
0
 /**
  * Disable show addthis
  * @return bool
  */
 public static function isInMemberAreaPage()
 {
     $a = ['SiteError', 'SiteSearch', 'AccountLogin', 'AccountReset', 'AccountSignup', 'AccountIndex', 'AccountEmail', 'AccountPassword', 'AccountLinked', 'AccountResetConfirm', 'AccountEmailConfirm', 'BlogManage', 'BlogCreate', 'BlogUpdate'];
     if (in_array(Core::getMCA(), $a)) {
         return true;
     }
     return false;
 }
示例#20
0
 /**
  * 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;
 }
示例#21
0
 /**
  * @inheritdoc
  */
 public function beforeSave($insert)
 {
     /* author */
     if ($insert) {
         $this->created_by = Yii::$app->user->id;
     }
     /* slug */
     if (empty($this->slug)) {
         $this->slug = Core::generateSeoName($this->title);
     }
     /* published_at */
     if ($this->status == Blog::STATUS_PUBLISHED && empty($this->published_at)) {
         $this->published_at = time();
     }
     /* clean html */
     $config = ['HTML.MaxImgLength' => null, 'CSS.MaxImgLength' => null, 'HTML.Trusted' => true, 'Filter.YouTube' => true];
     $this->content = HtmlPurifier::process($this->content, $config);
     /* done */
     return parent::beforeSave($insert);
 }
示例#22
0
 /**
  * get menu active status
  * @return bool|null
  */
 public function getActiveStatus()
 {
     $path = $this->_path;
     if (!empty($this->active_route)) {
         $path = $this->active_route;
     }
     if (!empty($path)) {
         $count = substr_count($path, '/');
         $m = null;
         $c = null;
         $a = null;
         if ($count == 1) {
             list($c, $a) = explode('/', $path);
         } elseif ($count == 2) {
             list($m, $c, $a) = explode('/', $path);
         } else {
             return null;
         }
         $params = null;
         if (empty($this->active_route) && !empty($this->_query)) {
             parse_str($this->_query, $params);
         }
         return Core::checkMCA(explode('|', $m), explode('|', $c), explode('|', $a), $params);
     }
     return false;
 }
示例#23
0
//$this->registerJs($js);
$css = file_get_contents(__DIR__ . '/index.css');
$this->registerCss($css);
?>
<div class="i18n-message-index">
    <div class="box box-primary">
        <div class="box-body">
            <?php 
Pjax::begin(['id' => 'message-translation-wrap']);
?>
    <?php 
echo GridView::widget(['id' => 'i18n-message-grid', 'options' => ['class' => 'grid-view table-responsive'], 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'language', 'value' => 'language', 'filter' => Message::getLocaleList([Yii::$app->sourceLanguage])], ['attribute' => 'category', 'value' => 'source.category', 'filter' => SourceMessage::getCategoryList()], ['attribute' => 'message', 'value' => 'source.message'], ['attribute' => 'translation', 'format' => 'raw', 'value' => function ($model) {
    return \modernkernel\jeditable\Editable::widget(['content' => strip_tags($model->translation), 'saveUrl' => Yii::$app->urlManager->createUrl(['/i18n/save-translation']), 'options' => ['id' => 'message_' . $model->id . '_' . $model->language, 'class' => 'jeditable-text'], 'clientOptions' => ['tooltip' => Yii::t('app', 'Click to edit'), 'indicator' => Yii::t('app', 'Saving...'), 'width' => '93%']]);
}], ['attribute' => 'is_translated', 'value' => function ($model) {
    return Core::getYesNoText($model->is_translated);
}, 'filter' => Core::getYesNoOption()], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}']]]);
?>
            <?php 
Pjax::end();
?>
            <div>
                <?php 
echo \yii\helpers\Html::beginForm(Yii::$app->urlManager->createUrl(['/i18n/add']), 'post', ['class' => 'form-inline']);
?>
                    <div class="form-group">
                        <label for="language"><?php 
echo Yii::t('app', 'Language');
?>
</label>
                        <?php 
echo \yii\helpers\Html::dropDownList('language', null, $langs, ['class' => 'form-control']);
示例#24
0
echo Html::encode($this->title);
?>
</h1>
    <div class="row">
        <div class="col-xs-12">
            <?php 
$form = ActiveForm::begin(['id' => 'signup-form', 'enableAjaxValidation' => false]);
?>
            <?php 
echo $form->field($model, 'name');
?>
            <?php 
echo $form->field($model, 'email');
?>
            <?php 
if (\common\Core::isReCaptchaEnabled()) {
    ?>
            <?php 
    echo $form->field($model, 'captcha')->widget(ReCaptcha::className())->label(false);
    ?>
            <?php 
}
?>


            <p>
                <?php 
echo Yii::t('app', 'By clicking on the "Signup" button below, you certify that you have read and agree to our {TERMS} and {PRIVACY}.', ['TERMS' => Html::a('terms of use', Yii::$app->urlManager->createUrl(['/site/page', 'id' => 'terms']), ['target' => '_blank']), 'PRIVACY' => Html::a('privacy policy', Yii::$app->urlManager->createUrl(['/site/page', 'id' => 'privacy']), ['target' => '_blank'])]);
?>
            </p>