本文整理汇总了PHP中app\models\Language::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::find方法的具体用法?PHP Language::find怎么用?PHP Language::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Language
的用法示例。
在下文中一共展示了Language::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
public function edit($id)
{
$param['pageNo'] = 2;
$result = LanguageModel::find($id);
$param['language'] = $result;
return View::make('languages.edit')->with($param);
}
示例2: 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";
}
}
示例3: 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;
}
示例4: 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;
}
示例5: 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);
}
示例6: 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;
}
示例7: 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;
}
}
}
示例8: 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;
}
示例9: languageLinkTags
public static function languageLinkTags()
{
$controller = Yii::$app->controller;
$request = Yii::$app->request;
if (!$controller || !$request || !$request->isGet) {
return '';
}
$params = $request->get();
unset($params['_lang_']);
if (!($route = $controller->route)) {
return '';
}
$ret = [];
foreach (Language::find()->asArray()->all() as $lang) {
$newParams = array_merge([$route, '_lang_' => $lang['lang']], $params);
$ret[] = Html::tag('link', '', ['rel' => 'alternate', 'hreflang' => $lang['lang'], 'href' => Url::to($newParams, true)]);
}
return implode("\n", $ret) . "\n";
}
示例10: init
public function init()
{
parent::init();
Yii::$app->session->open();
$language = Yii::$app->request->cookies->getValue('language');
if ($language && strlen($language) == 5) {
Yii::$app->language = $language;
} else {
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$languages = Language::find()->orderBy(['name' => SORT_ASC])->all();
$codes = [];
foreach ($languages as $language) {
$codes[] = $language->code;
}
if (preg_match("/(" . implode('|', $codes) . ")+(-|;|,)?(.*)?/", $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches)) {
$browser_language = $matches[1];
Yii::$app->response->cookies->add(new Cookie(['name' => 'language', 'value' => $browser_language, 'expire' => (new \Datetime())->modify('+1 year')->getTimestamp()]));
Yii::$app->language = $browser_language;
}
}
}
}
示例11: run
public function run()
{
return $this->render('lang/view', ['current' => Language::getCurrent(), 'langs' => Language::find()->where('id != :current_id', [':current_id' => Language::getCurrent()->id])->all()]);
}
示例12: actionForm
public function actionForm()
{
$model = new Report();
if ($model->load(Yii::$app->request->post())) {
$model->location_is_precise = true;
$date = new DateTime();
$model->time_sent = $date->format('Y-m-d H:i:s');
$model->time_updated = $date->format('Y-m-d H:i:s');
if ($model->validate()) {
$model->save();
\Yii::$app->session->setFlash('submittedForm');
return $this->refresh();
}
}
$languages = Language::find()->all();
$language_arr = [];
foreach ($languages as $language) {
$language_arr[$language->id_language] = $language->name . " (" . $language->dialect . ")";
}
$disabilities = DisabilityCategory::find()->all();
$disability_arr = [];
foreach ($disabilities as $disability) {
$disability_arr[$disability->id_disability_category] = $disability->category;
}
$problems = ProblemCategory::find()->all();
$problem_arr = [];
foreach ($problems as $problem) {
$problem_arr[$problem->id_problem_category] = $problem->category;
}
return $this->render('form', ['model' => $model, 'languages' => $language_arr, 'disabilities' => $disability_arr, 'problems' => $problem_arr]);
}
示例13: trim
$items[] = ['label' => __('Settings'), 'visible' => $user->can('setting_manage'), 'active' => $controller_id == 'setting', 'url' => ['/setting/index']];
}
$menu_items[] = ['label' => __('Administration'), 'visible' => !!$items, 'active' => in_array($controller_id, ['upload', 'export', 'user', 'user-role', 'country', 'state', 'setting']) && !$is_profile, 'items' => $items];
// Languages
$languages = Language::find()->orderBy(['name' => SORT_ASC])->all();
$select_language = false;
$lang_items = [];
foreach ($languages as $language) {
if ($language->code == Yii::$app->language) {
$select_language = $language;
// break;
}
$lang_items[] = ['label' => $language->name, 'url' => ['language/select', 'id' => $language->id, 'current_url' => Url::to()], 'active' => $language == $select_language];
}
if (!$select_language) {
$select_language = Language::find()->where(['code' => 'en-US'])->one();
}
$menu_items[] = ['label' => $select_language->short_name, 'items' => $lang_items];
// Account
$help_menu = ['items' => ['contact' => ['label' => __('Contact'), 'url' => ['/site/contact']], 'about' => ['label' => __('About'), 'url' => ['/site/about']]], 'active' => $controller_id == 'site' && in_array($action_id, ['contact', 'about'])];
if (Yii::$app->user->isGuest) {
$menu_items[] = ['label' => __('Sign up'), 'url' => ['/site/signup']];
$menu_items[] = ['label' => __('Sign in'), 'url' => ['/site/login']];
$menu_items[] = ['label' => __('Help'), 'active' => $help_menu['active'], 'items' => $help_menu['items']];
} else {
$name = trim($user->identity->name);
if (empty($name)) {
$name = $user->identity->email;
}
$menu_items[] = ['label' => '<i class="glyphicon glyphicon-user"></i>', 'active' => $is_profile || $help_menu['active'], 'items' => [Html::tag('li', Html::a(__('Signed in as <br><b>{name}</b>', ['name' => $name])), ['class' => 'disabled']), '<li class="divider"></li>', ['label' => __('Profile'), 'url' => ['/user/update', 'id' => $user->identity->id], 'active' => $is_profile], ['label' => __('Logout'), 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']], '<li class="divider"></li>', $help_menu['items']['contact'], $help_menu['items']['about']]];
}
示例14: render
/**
* @return string
*/
public function render()
{
$model = $this->form->instance;
if (empty($model)) {
return false;
}
$fields = array();
foreach ($this->_getLanguageData() as $languageId => $data) {
$language = Models\Language::find($languageId);
foreach ($data as $fieldCode => $fieldData) {
$name = $this->fields[$fieldCode]['name'];
$fieldTitle = $this->useTabs ? $name : $name . ' [' . $language->name . ']';
$validationRules = isset($this->fields[$fieldCode]['validation']) ? explode('|', $this->fields[$fieldCode]['validation']) : [];
switch ($this->fields[$fieldCode]['type']) {
case 'ckeditor':
$options = ['id' => lcfirst($fieldCode) . '[' . $languageId . ']', 'data-editor' => Textarea::EDITOR_WYSIHTML];
$fields[$languageId][] = HtmlBuilder::textarea(lcfirst($fieldCode) . '[' . $languageId . ']', $fieldTitle, $fieldData, $this->getOptions($options, $validationRules));
break;
case 'textarea':
$options = ['id' => lcfirst($fieldCode) . '[' . $languageId . ']'];
$fields[$languageId][] = HtmlBuilder::textarea(lcfirst($fieldCode) . '[' . $languageId . ']', $fieldTitle, $fieldData, $this->getOptions($options, $validationRules));
break;
case 'checkbox':
$hotelLanguage = $model->getRepository()->getHotelLanguage($languageId);
$options = array('id' => lcfirst($fieldCode) . '[' . $languageId . ']');
$oldCheckbox = Admin::$instance->formBuilder->getSessionStore()->getOldInput(lcfirst($fieldCode));
if (is_null($oldCheckbox)) {
if ($hotelLanguage && $hotelLanguage->active) {
$options = array_merge($options, array('checked' => 'checked'));
}
} else {
if ($oldCheckbox[$languageId] == 1) {
$options = array_merge($options, array('checked' => 'checked'));
}
$allOldInputs = Admin::$instance->formBuilder->getSessionStore()->get('_old_input');
$fieldName = lcfirst($fieldCode);
if (isset($allOldInputs[$fieldName])) {
if (isset($allOldInputs[$fieldName][$languageId])) {
unset($allOldInputs[$fieldName][$languageId]);
}
}
Admin::$instance->formBuilder->getSessionStore()->set('_old_input', $allOldInputs);
}
$fields[$languageId][] = HtmlBuilder::checkbox(lcfirst($fieldCode) . '[' . $languageId . ']', $fieldTitle, $fieldData, $this->getOptions($options, $validationRules));
break;
default:
$options = ['id' => lcfirst($fieldCode) . '[' . $language->name . ']'];
$fields[$languageId][] = HtmlBuilder::text(lcfirst($fieldCode) . '[' . $languageId . ']', $fieldTitle, $fieldData, $this->getOptions($options, $validationRules));
break;
}
}
}
return view('admin/form/languages_fields')->with('code', $this->modelMethod)->with('withTabs', $this->useTabs)->with('languages', $this->_getAvailableLanguages())->with('fields', $fields)->with('blockId', uniqid())->with('title', $this->label);
}
示例15: actionIndex
/**
* Lists all Language models.
* @return mixed
*/
public function actionIndex()
{
$dataProvider = new ActiveDataProvider(['query' => Language::find()]);
return $this->render('index', ['dataProvider' => $dataProvider]);
}