本文整理汇总了PHP中app\models\Language类的典型用法代码示例。如果您正苦于以下问题:PHP Language类的具体用法?PHP Language怎么用?PHP Language使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Language类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: create
public function create($firstName = '', $lastName = '', $email = '', $password = '')
{
$account = new Account();
$account->ip = Request::getClientIp();
$account->account_key = str_random(RANDOM_KEY_LENGTH);
// Track referal code
if ($referralCode = Session::get(SESSION_REFERRAL_CODE)) {
if ($user = User::whereReferralCode($referralCode)->first()) {
$account->referral_user_id = $user->id;
}
}
if ($locale = Session::get(SESSION_LOCALE)) {
if ($language = Language::whereLocale($locale)->first()) {
$account->language_id = $language->id;
}
}
$account->save();
$user = new User();
if (!$firstName && !$lastName && !$email && !$password) {
$user->password = str_random(RANDOM_KEY_LENGTH);
$user->username = str_random(RANDOM_KEY_LENGTH);
} else {
$user->first_name = $firstName;
$user->last_name = $lastName;
$user->email = $user->username = $email;
$user->password = bcrypt($password);
}
$user->confirmed = !Utils::isNinja();
$user->registered = !Utils::isNinja() && $user->email;
if (!$user->confirmed) {
$user->confirmation_code = str_random(RANDOM_KEY_LENGTH);
}
$account->users()->save($user);
return $account;
}
开发者ID:rasata,项目名称:invoice-ninja,代码行数:35,代码来源:AccountRepository.php
示例2: edit
public function edit($id)
{
$param['pageNo'] = 2;
$result = LanguageModel::find($id);
$param['language'] = $result;
return View::make('languages.edit')->with($param);
}
开发者ID:michaelotto126,项目名称:test_star,代码行数:7,代码来源:LanguageController.php
示例3: setLanguage
private function setLanguage()
{
$request = Yii::$app->request;
$cookie = $request->cookies->get('language');
if ($cookie) {
$lang = Language::findOne(['lang' => $cookie->value]);
if ($lang) {
Yii::$app->language = $lang->lang;
return;
}
}
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$accepts = $request->parseAcceptHeader($_SERVER['HTTP_ACCEPT_LANGUAGE']);
foreach ($accepts as $lang => $options) {
//FIXME: DBと整合をとってちゃんとやる
switch (strtolower($lang)) {
case 'ja':
case 'ja-jp':
Yii::$app->language = 'ja-JP';
return;
case 'en':
case 'en-US':
Yii::$app->language = 'en-US';
return;
}
}
}
Yii::$app->language = 'en-US';
}
开发者ID:ExceptionError,项目名称:stat.ink,代码行数:29,代码来源:Controller.php
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
try {
//DELETE TABLES
DB::table('osu_genres')->delete();
DB::table('osu_languages')->delete();
//COUNTS
if (!DB::table('osu_counts')->where('name', 'pp_rank_column')->get()) {
DB::table('osu_counts')->insert([['name' => 'pp_rank_column', 'count' => 90], ['name' => 'usercount', 'count' => 500000]]);
}
//END COUNTS
//GENRES
DB::table('osu_genres')->insert([['genre_id' => 99, 'name' => 'Any'], ['genre_id' => 1, 'name' => 'Unspecified'], ['genre_id' => 2, 'name' => 'Video Game'], ['genre_id' => 3, 'name' => 'Anime'], ['genre_id' => 4, 'name' => 'Rock'], ['genre_id' => 5, 'name' => 'Pop'], ['genre_id' => 6, 'name' => 'Other'], ['genre_id' => 7, 'name' => 'Novelty'], ['genre_id' => 9, 'name' => 'Hip Hop'], ['genre_id' => 10, 'name' => 'Electronic']]);
$any_genre = \App\Models\Genre::find(99);
$any_genre->genre_id = 0;
$any_genre->save();
// END GENRES
//LANGUAGES
DB::table('osu_languages')->insert([['language_id' => 99, 'name' => 'Any', 'display_order' => 0], ['language_id' => 1, 'name' => 'Other', 'display_order' => 11], ['language_id' => 2, 'name' => 'English', 'display_order' => 1], ['language_id' => 3, 'name' => 'Japanese', 'display_order' => 6], ['language_id' => 4, 'name' => 'Chinese', 'display_order' => 2], ['language_id' => 5, 'name' => 'Instrumental', 'display_order' => 10], ['language_id' => 6, 'name' => 'Korean', 'display_order' => 7], ['language_id' => 7, 'name' => 'French', 'display_order' => 3], ['language_id' => 8, 'name' => 'German', 'display_order' => 4], ['language_id' => 9, 'name' => 'Swedish', 'display_order' => 9], ['language_id' => 10, 'name' => 'Spanish', 'display_order' => 8], ['language_id' => 11, 'name' => 'Italian', 'display_order' => 5]]);
$any_language = \App\Models\Language::find(99);
$any_language->language_id = 0;
$any_language->save();
//END LANGUAGES
} catch (\Illuminate\Database\QueryException $e) {
echo $e->getMessage() . "\r\n";
} catch (Exception $ex) {
echo $ex->getMessage() . "\r\n";
}
}
开发者ID:ppy,项目名称:osu-web,代码行数:34,代码来源:MiscSeeder.php
示例5: edit
public function edit($id)
{
$param['pageNo'] = 1;
$result = DomainModel::find($id);
$param['domain'] = $result;
$param['language'] = LanguageModel::all();
$param['template'] = TemplateModel::all();
return View::make('domains.edit')->with($param);
}
开发者ID:michaelotto126,项目名称:test_star,代码行数:9,代码来源:DomainController.php
示例6: getAutoCompleteWordsAjax
public function getAutoCompleteWordsAjax(Request $request)
{
if (!$request->ajax()) {
return response()->json(['response' => 'reject', 'msg' => 'request Not Allowed', 'searchWord' => $request->searchWord, 'language' => $request->languageName, 'Ajax' => $request->ajax(), 'Request' => $request->method()]);
}
$searchWord = $request->searchWord;
$languageId = Language::where('id', '=', $request->languageId)->value('id');
$Words = Word::where('language_id', '=', $languageId)->where('word', 'LIKE', $searchWord . '%')->orderBy('word', 'asc')->limit(10)->get();
return $Words;
}
开发者ID:wayand,项目名称:ps-d-i-c-t-i-o-n-a-r-y,代码行数:10,代码来源:TranslationController.php
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$now = date('Y-m-d H:i:s', strtotime('now'));
$languages = [['name' => 'english', 'description' => 'the Language English', 'created_at' => $now, 'updated_at' => $now], ['name' => 'danish', 'description' => 'the Language Danish, spoken in Denmark', 'created_at' => $now, 'updated_at' => $now], ['name' => 'pashto', 'description' => 'the Language Pashto, spoken in Afghanistan', 'created_at' => $now, 'updated_at' => $now]];
foreach ($languages as $language) {
if (\App\Models\Language::where('name', '=', $language['name'])->exists()) {
echo $language['name'] . " Already exists\n";
} else {
\App\Models\Language::create($language);
}
}
//DB::table('words')->truncate();
//Schema::drop('words');
$passed = 0;
$exists = 0;
//word table - seed from a file
// $pashto_json = File::get(storage_path() . "/app/json_data/pashto.json");
// $pashto_word = json_decode($pashto_json);
//
// foreach ($pashto_word as $wordObj)
// {
// if(\App\Models\Word::where('word', '=', $wordObj->s2p[0])->exists())
// {
// echo $wordObj->s2p[0] . " Already exists\n";
// $exists++;
// }
// else
// {
// \App\Models\Word::create([
// 'language_id' => 3,
// 'user_id' => 3,
// 'word' => $wordObj->s2p[0],
// 'pronounce_audio_path' => '',
// 'pronounce_text' => 'pronounce_text missing',
// 'definition' => 'Word definition missing',
// 'created_at' => $now,
// 'updated_at' => $now,
// ]);
//
// $passed++;
// }
// }
foreach (File(storage_path() . "/app/danskOrde_49389.txt", FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES) as $word) {
if (App\Models\Word::where(['language_id' => 2, 'word' => $word])->exists()) {
echo $word . ": Already exists in Danish\n";
$exists++;
} else {
App\Models\Word::create(['language_id' => 2, 'user_id' => 3, 'word' => $word, 'pronounce_audio_path' => '', 'pronounce_text' => 'pronounce_text missing', 'definition' => 'Word definition missing', 'created_at' => $now, 'updated_at' => $now]);
$passed++;
}
}
echo "\n Words Already Exists: " . $exists;
echo "\n Words added: " . $passed . "\n";
}
开发者ID:wayand,项目名称:ps-d-i-c-t-i-o-n-a-r-y,代码行数:59,代码来源:DictionaryTablesSeeder.php
示例8: detectLanguageByCookie
private function detectLanguageByCookie()
{
$cookie = Yii::$app->request->cookies->get('language');
if (!$cookie) {
return false;
}
if (!($lang = Language::findOne(['lang' => $cookie->value]))) {
return false;
}
return $lang->lang;
}
开发者ID:frozenpandaman,项目名称:stat.ink,代码行数:11,代码来源:Controller.php
示例9: actionSelect
public function actionSelect($id, $current_url = '')
{
$language = Language::findOne($id);
Yii::$app->response->cookies->add(new Cookie(['name' => 'language', 'value' => $language->code, 'expire' => (new \Datetime())->modify('+1 year')->getTimestamp()]));
if ($current_url) {
$current_url = urldecode($current_url);
} else {
$current_url = ['site/index'];
}
return $this->redirect($current_url);
}
开发者ID:vsguts,项目名称:crm,代码行数:11,代码来源:LanguageController.php
示例10: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Language::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['l_id' => $this->l_id]);
$query->andFilterWhere(['like', 'short', $this->short])->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
开发者ID:emotionbanker,项目名称:emotionbanking,代码行数:18,代码来源:LanguageSearch.php
示例11: translateToAll
public function translateToAll($category, $message, $params = [])
{
if (self::$langs === null) {
self::$langs = Language::find()->all();
}
$i18n = Yii::$app->i18n;
$ret = [];
foreach (self::$langs as $lang) {
$ret[strtr($lang->lang, '-', '_')] = $i18n->translate($category, $message, $params, $lang->lang);
}
return $ret;
}
开发者ID:ExceptionError,项目名称:stat.ink,代码行数:12,代码来源:Translator.php
示例12: init
public function init()
{
parent::init();
if ($this->currentLanguage === null) {
$this->currentLanguage = Language::getCurrent();
}
if ($this->allowedLanguages === null) {
$this->allowedLanguages = Language::find()->where('`id` != :id', [':id' => $this->currentLanguage->id])->all();
}
$this->cssClass .= ' dropdown dropdown-language';
$this->options['class'] = trim($this->cssClass);
}
开发者ID:altairsoft,项目名称:plutos,代码行数:12,代码来源:LanguageBar.php
示例13: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Language::find();
$pageSize = Yii::$app->session->get('pageSize', Yii::$app->params['defaultPageSize']);
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize]]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['l_id' => $this->l_id]);
$query->andFilterWhere(['like', 'short', $this->short])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'label', $this->label])->andFilterWhere(['like', 'message', $this->message]);
return $dataProvider;
}
开发者ID:emotionbanker,项目名称:emotion-banking,代码行数:19,代码来源:LanguageSearch.php
示例14: setLanguage
private function setLanguage()
{
$request = Yii::$app->request;
$cookie = $request->cookies->get('language');
if ($cookie) {
$lang = Language::findOne(['lang' => $cookie->value]);
if ($lang) {
Yii::$app->language = $lang->lang;
return;
}
}
}
开发者ID:Bochozkar,项目名称:stat.ink,代码行数:12,代码来源:Controller.php
示例15: getLangByUrl
static function getLangByUrl($url = null)
{
if ($url === null) {
return null;
} else {
$language = Language::find()->where('url = :url', [':url' => $url])->one();
if ($language === null) {
return null;
} else {
return $language;
}
}
}
开发者ID:vagrant200192,项目名称:traning,代码行数:13,代码来源:Language.php
示例16: getLangUrl
public function getLangUrl()
{
if ($this->_lang_url === null) {
$this->_lang_url = $this->getUrl();
$url_list = explode('/', $this->_lang_url);
$lang_url = isset($url_list[1]) ? $url_list[1] : null;
Language::setCurrent($lang_url);
if ($lang_url !== null && $lang_url === Language::getCurrent()->url_key && strpos($this->_lang_url, Language::getCurrent()->url_key) === 1) {
$this->_lang_url = substr($this->_lang_url, strlen(Language::getCurrent()->url_key) + 1);
}
}
return $this->_lang_url;
}
开发者ID:altairsoft,项目名称:plutos,代码行数:13,代码来源:LangRequest.php
示例17: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Language::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(['id' => $this->id, 'default' => $this->default, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
$query->andFilterWhere(['like', 'url_key', $this->url_key])->andFilterWhere(['like', 'local', $this->local])->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
开发者ID:altairsoft,项目名称:plutos,代码行数:21,代码来源:LanguageSearch.php
示例18: run
public function run()
{
Eloquent::unguard();
$languages = [['name' => 'English', 'locale' => 'en'], ['name' => 'Italian', 'locale' => 'it'], ['name' => 'German', 'locale' => 'de'], ['name' => 'French', 'locale' => 'fr'], ['name' => 'Brazilian Portuguese', 'locale' => 'pt_BR'], ['name' => 'Dutch', 'locale' => 'nl'], ['name' => 'Spanish', 'locale' => 'es'], ['name' => 'Norwegian', 'locale' => 'nb_NO'], ['name' => 'Danish', 'locale' => 'da'], ['name' => 'Japanese', 'locale' => 'ja'], ['name' => 'Swedish', 'locale' => 'sv'], ['name' => 'Spanish - Spain', 'locale' => 'es_ES'], ['name' => 'French - Canada', 'locale' => 'fr_CA'], ['name' => 'Lithuanian', 'locale' => 'lt'], ['name' => 'Polish', 'locale' => 'pl'], ['name' => 'Czech', 'locale' => 'cs']];
foreach ($languages as $language) {
$record = Language::whereLocale($language['locale'])->first();
if ($record) {
$record->name = $language['name'];
$record->save();
} else {
Language::create($language);
}
}
Eloquent::reguard();
}
开发者ID:hannenijhuis,项目名称:invoiceninja,代码行数:15,代码来源:LanguageSeeder.php
示例19: index
public function index()
{
$fractal = new Manager();
$languages = Language::listing();
$genres = Genre::listing();
$data = new Collection(BeatmapSet::listing(), new BeatmapSetTransformer());
$beatmaps = $fractal->createData($data)->toArray();
// temporarily put filters here
$modes = [['id' => null, 'name' => trans('beatmaps.mode.any')], ['id' => Beatmap::OSU, 'name' => trans('beatmaps.mode.osu')], ['id' => Beatmap::TAIKO, 'name' => trans('beatmaps.mode.taiko')], ['id' => Beatmap::FRUITS, 'name' => trans('beatmaps.mode.fruits')], ['id' => Beatmap::MANIA, 'name' => trans('beatmaps.mode.mania')]];
$statuses = [['id' => null, 'name' => trans('beatmaps.status.any')], ['id' => 0, 'name' => trans('beatmaps.status.ranked-approved')], ['id' => 1, 'name' => trans('beatmaps.status.approved')], ['id' => 2, 'name' => trans('beatmaps.status.faves')], ['id' => 3, 'name' => trans('beatmaps.status.modreqs')], ['id' => 4, 'name' => trans('beatmaps.status.pending')], ['id' => 5, 'name' => trans('beatmaps.status.graveyard')], ['id' => 6, 'name' => trans('beatmaps.status.my-maps')]];
$extras = [['id' => 0, 'name' => trans('beatmaps.extra.video')], ['id' => 1, 'name' => trans('beatmaps.extra.storyboard')]];
$ranks = [['id' => 'XH', 'name' => trans('beatmaps.rank.silver-ss')], ['id' => 'X', 'name' => trans('beatmaps.rank.ss')], ['id' => 'SH', 'name' => trans('beatmaps.rank.silver-s')], ['id' => 'S', 'name' => trans('beatmaps.rank.s')], ['id' => 'A', 'name' => trans('beatmaps.rank.a')], ['id' => 'B', 'name' => trans('beatmaps.rank.b')], ['id' => 'C', 'name' => trans('beatmaps.rank.c')], ['id' => 'D', 'name' => trans('beatmaps.rank.d')]];
$filters = ['data' => compact('modes', 'statuses', 'genres', 'languages', 'extras', 'ranks')];
return view('beatmaps.index', compact('filters', 'beatmaps'));
}
开发者ID:nanaya,项目名称:osu-web,代码行数:15,代码来源:BeatmapController.php
示例20: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
if ($language = \App\Models\Language::whereLocale('sv')->first()) {
$language->delete();
}
if ($language = \App\Models\Language::whereLocale('es_ES')->first()) {
$language->delete();
}
if ($language = \App\Models\Language::whereLocale('fr_CA')->first()) {
$language->delete();
}
if ($language = \App\Models\Language::whereLocale('lt')->first()) {
$language->delete();
}
}
开发者ID:magicians,项目名称:invoiceninja,代码行数:20,代码来源:2015_04_12_093447_add_sv_language.php
注:本文中的app\models\Language类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论