public function register($userName, $email, $password, $pwdChk, &$err = null) { $init_err = $err; Utils::checkEmail($email, $err); Utils::checkPassword($password, $err); if (strcmp($password, $pwdChk) !== 0) { $err[] = I18n::get("error_pwd_mismatch"); } $email = mb_strtolower($email, 'UTF-8'); $lowUsername = mb_strtolower($userName, 'UTF-8'); $others = $this->db->getUsersByUserNameOrEmail($lowUsername, $email); if ($others) { foreach ($others as $o) { if (strcmp(mb_strtolower($o["username"], 'UTF-8'), $lowUsername) == 0) { $err[] = I18n::get("error_username_already_taken"); } if (strcmp($o["email"], $email) == 0) { $err[] = I18n::get("error_email_already_taken"); } } } if ($init_err != $err) { return false; } $password = password_hash($password, PASSWORD_DEFAULT); $this->db->createUser($userName, $email, $password); return true; }
/** * Get a i18n message from a file. Messages are arbitary strings that are stored * in the messages/i18/en-en, messages/i18/ru-ru directories and reference by a key. * * // Get "username" from messages/i18n/en-en/text.php * $username = Ku_I18n::message('text', 'username'); * * @uses Kohana::message * * @param string|array file name * @param string key path to get * @param string default message * @param array array values to substititution * @return string message string for the given path * @return array complete message list, when no path is specified */ public static function message($file, $path = NULL, $default = NULL, array $values = NULL) { $file = (array) $file; foreach ($file as $filename) { $message = Kohana::message('i18n/' . I18n::$lang . '/' . $filename, $path); if ($message === NULL) { // Try common message $message = Kohana::message($filename, $path); if ($message) { $message = I18n::get($message); break; } } else { break; } } if ($message === NULL) { // Try common message $message = is_string($default) ? I18n::get($default) : $default; } if ($message and $values) { $message = strtr($message, $values); } return $message; }
function __($string, array $values = NULL, $lang = 'en-us') { if ($lang !== I18n::$lang) { $string = I18n::get($string); } return empty($values) ? $string : strtr($string, $values); }
public function action_index() { $photos = ORM::factory('Storage')->where('publication_id', '>', '0')->find_all(); foreach ($photos as $photo) { if ($photo->publication_type == 'news') { $news = ORM::factory('News', $photo->publication_id); if ($news->loaded()) { $title = $news->title; } } elseif ($photo->publication_type == 'leader') { $page = ORM::factory('Leader', $photo->publication_id); if ($page->loaded()) { $title = $page->name; } } else { $page = ORM::factory('Pages_content', $photo->publication_id); if ($page->loaded()) { $title = $page->name; } } if (!isset($title)) { $title = I18n::get("This publication is absent"); } $photo_arr[] = array('date' => $photo->date, 'path' => $photo->file_path, 'publication_id' => $photo->publication_id, 'type' => $photo->publication_type, 'title' => $title); } $this->set('photos', $photo_arr); $this->add_cumb('Photos', '/'); }
/** * Tests i18n::get() * * @test * @dataProvider provider_get * @param boolean $input Input for File::mime * @param boolean $expected Output for File::mime */ public function test_get($lang, $input, $expected) { I18n::lang($lang); $this->assertSame($expected, I18n::get($input)); // Test immediate translation, issue #3085 I18n::lang('en-us'); $this->assertSame($expected, I18n::get($input, $lang)); }
/** * Kohana translation/internationalization function. The PHP function * [strtr](http://php.net/strtr) is used for replacing parameters. * * __('Welcome back, :user', array(':user' => $username)); * * @uses I18n::get * @param string text to translate * @param array values to replace in the translated text * @param string target language * @return string */ function __($string, array $values = NULL, $lang = 'en-us') { if ($lang !== I18n::$lang) { // The message and target languages are different // Get the translation for this message $string = I18n::get($string); } return empty($values) ? $string : strtr($string, $values); }
function __n($singular, $plural, $count, array $values = array()) { if (I18n::$lang !== I18n::$default_lang) { $string = $count === 1 ? I18n::get($singular) : I18n::get_plural($plural, $count); } else { $string = $count === 1 ? $singular : $plural; } return strtr($string, array_merge($values, array('%count' => $count))); }
/** * Kohana translation/internationalization function. The PHP function * [strtr](http://php.net/strtr) is used for replacing parameters. * * __('Welcome back, :user', array(':user' => $username)); * * [!!] The target language is defined by [I18n::$lang]. The default source * language is defined by [I18n::$source]. * * @uses I18n::get * @param string text to translate * @param array values to replace in the translated text * @param string source language * @return string */ function __($string, array $values = NULL, $source = NULL) { if (!$source) { // Use the default source language $source = I18n::$source; } if ($source !== I18n::$lang) { // The message and target languages are different // Get the translation for this message $string = I18n::get($string); } return empty($values) ? $string : strtr($string, $values); }
public function action_read() { $scope = Security::xss_clean($this->request->param('scope')); $scope_category = ORM::factory('Library_Category')->where('key', '=', $scope)->find(); if (!$scope_category->loaded()) { throw new HTTP_Exception_404(); } if ($scope_category->published == 0) { throw new HTTP_Exception_404(); } $this->set('scope', $scope_category); $id = (int) $this->request->param('id', 0); $number = (int) Arr::get($_GET, 'chapter', 0); $book = ORM::factory('Book', $id)->where('published', '=', 1)->and_where('show_' . I18n::$lang, '=', 1); if (!$book->loaded()) { throw new HTTP_Exception_404(); } $bookprov = ORM::factory('Book', $id); if (!$bookprov->translation(I18n::$lang)) { throw new HTTP_Exception_404('no_translation'); //$this->redirect(URL::media('')); } $this->set('book', $book); $this->add_cumb($scope_category->name, 'books/' . $scope_category->key); $cumb = $book->title; if ($book->author != '') { $cumb .= '. ' . $book->author; } $this->add_cumb($book->category->name, 'books/' . $scope_category->key . '?category=' . $book->category->id); $this->add_cumb($cumb, 'books/' . $scope_category->key . '/view/' . $book->id); if ($book->type == 'pdf') { $this->add_cumb('View', '/'); } if ($book->type == 'txt') { $chapters = $book->chapters->find_all(); $this->add_cumb('View', 'books/' . $scope_category->key . '/read/' . $book->id . '?chapter=' . $chapters[0]->number); } if ($book->type == 'txt') { $chapter = ORM::factory('Book_Chapter')->where('number', '=', $number)->and_where('book_id', '=', $book->id)->find(); if (!$chapter->loaded()) { throw new HTTP_Exception_404(); } $this->set('chapter', $chapter); $next = ORM::factory('Book_Chapter')->where('number', '>', $chapter->number)->and_where('book_id', '=', $book->id)->limit(1)->find(); if ($next->loaded()) { $this->set('next', $next); } $this->add_cumb(I18n::get('Chapter') . ' ' . $chapter->number . '. ' . $chapter->title, '/'); } }
public static function checkUserName($userName, $err) { $errors_init = $err; if (mb_strlen($userName, 'UTF-8') < 3) { $errors[] = I18n::get("error_username_too_short"); } if (mb_strlen($userName, 'UTF-8') > 32) { $errors[] = I18n::get("error_username_too_long"); } if (!preg_match("^[a-zA-Z0-9\\-_]+\$", $userName)) { $errors[] = I18n::get("error_username_invalid_char"); } return $err == $errors_init; }
public function action_index() { $alphabet = array('ru' => array('А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я'), 'kz' => array('А', 'Ә', 'Б', 'В', 'Г', 'Ғ', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Қ', 'Л', 'М', 'Н', 'Ң', 'О', 'Ө', 'П', 'Р', 'С', 'Т', 'У', 'Ү', 'Ұ', 'Ф', 'Х', 'Һ', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'I', 'Ь', 'Э', 'Ю', 'Я'), 'en' => array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z')); $lang = Security::xss_clean($this->request->param('language')); foreach ($alphabet[$lang] as $alpha) { $biog = ORM::factory('Biography')->where('published', '=', 1)->where_open()->where('name_' . $lang, 'like', $alpha . '%')->or_where('name_' . $lang, 'like', '% ' . $alpha . '%')->where_close()->find(); if ($biog->loaded()) { $alphabet_new[] = $alpha; } } $this->set('alphabet', $alphabet_new); $categories1 = ORM::factory('Biography_Category')->where('era', '=', '1')->find_all(); $halyk_kaharmany = ORM::factory('Biography_Category', 9); $this->set('halyk_kaharmany', $halyk_kaharmany); $categories2 = ORM::factory('Biography_Category')->where('era', '=', '2')->find_all(); $this->set('categories1', $categories1)->set('categories2', $categories2); $category = (int) $this->request->param('category', 0); $alpha = Security::xss_clean($this->request->param('alpha', "")); //SEO. закрываем сортировку if ($alpha != '') { $sort = 1; Kotwig_View::set_global('sort', $sort); } //end_SEO $biography = ORM::factory('Biography')->where('published', '=', 1)->where('name_' . $this->language, '<>', ''); if ($category != 0) { $biography = $biography->where('category_id', '=', $category); $this->add_cumb('Personalia', 'biography'); $cat = ORM::factory('Biography_Category', $category); $this->add_cumb($cat->title, '/'); } else { $biography = $biography->where('category_id', 'NOT IN', array(3, 4, 6, 7, 8, 15)); $this->add_cumb('Personalia', '/'); } if (!empty($alpha)) { $biography = $biography->where_open()->where('name_' . $lang, 'like', $alpha . '%')->or_where('name_' . $lang, 'like', '% ' . $alpha . '%')->where_close(); } $biography = $biography->order_by('order'); $paginate = Paginate::factory($biography)->paginate(NUll, NULL, 10)->render(); $biography = $biography->find_all(); if (count($biography) == 0) { $this->set('error', I18n::get('Sorry.')); } /* метатэг description */ $biography_meta = ORM::factory('Page')->where('key', '=', 'biography_' . $category . '_1')->find(); $this->metadata->description($biography_meta->description); $this->set('list', $biography)->set('paginate', $paginate)->set('category', $category)->set('alpha', $alpha); }
/** * Handle a POST request to reset a user's password. * * @return Response */ public function postReset() { $credentials = Input::only('email', 'password', 'password_confirmation', 'token'); $response = Password::reset($credentials, function ($user, $password) { $user->password = Hash::make($password); $user->save(); }); switch ($response) { case Password::INVALID_PASSWORD: case Password::INVALID_TOKEN: case Password::INVALID_USER: return Redirect::back()->with('error', I18n::get($response)); case Password::PASSWORD_RESET: return Redirect::to('/')->with('success', 'Votre nouveau mot de passe est bien enregistré !'); } }
/** * 默认函数 */ public function actionIndex() { // 多语言使用,要连数据库,表为w_language,参看enterprise数据库 // 按规定填入数据 // 使用方式 I18n::$lang = 'vi-vn'; echo I18n::get('平台管理'); // smarty模板使用方式 // {%I18n var=平台管理%} // // 项目路径 // echo Wave::app()->projectPath; // //当前域名 // echo Wave::app()->request->hostInfo; // //除域名外以及index.php // echo Wave::app()->request->pathInfo; // //除域名外的地址 // echo Wave::app()->homeUrl; // //除域名外的根目录地址 // echo Wave::app()->request->baseUrl; // 关闭自动加载 // spl_autoload_unregister(array('WaveLoader','loader')); // 开启自动加载 // spl_autoload_register(array('WaveLoader','loader')); // $User = new User(); // echo "User model 加载成功!"; $this->username = '******'; // 然后查看 templates/site/index.html 文件 // 输出 {%$username%} // mecache使用 // Wave::app()->memcache->set('key', '11111', 30); // echo "Store data in the cache (data will expire in 30 seconds)"; // $get_result = Wave::app()->memcache->get('key'); // echo " Memcache Data from the cache:$get_result"; // redis使用 // Wave::app()->redis->set('key', '11111', 30); // echo "Store data in the cache (data will expire in 30 seconds)"; // $get_result = Wave::app()->redis->get('key'); // echo " Redis Data from the cache:$get_result"; }
public function action_variantpublish() { $id = $this->request->param('id', 0); $variant = ORM::factory('Test_Questvar', $id); if (!$variant->loaded()) { throw new HTTP_Exception_404(); } if ($variant->published) { $variant->published = 0; $variant->save(); Message::success(I18n::get('Variant hided')); } else { $variant->published = 1; $variant->save(); Message::success(I18n::get('Variant unhided')); } $this->redirect('manage/tests/variants/' . $variant->quests_id); }
public function action_materials() { if (!Auth::instance()->logged_in()) { $this->redirect('/', 301); } $user_id = $this->user->id; $materials = ORM::factory('Material')->where('user_id', '=', $user_id); $paginate = Paginate::factory($materials)->paginate(NULL, NULL, 3)->render(); $materials = $materials->find_all(); $this->set('materials', $materials); $this->set('paginate', $paginate); $uploader = View::factory('storage/materials')->set('user_id', $user_id)->render(); $this->set('uploader', $uploader); if ($this->request->method() == Request::POST) { $journal = (int) Arr::get($_POST, 'material_type', 0); if ($journal !== 1) { $journal = 0; } try { $material = ORM::factory('Material'); $material->theme = substr(Arr::get($_POST, 'theme', ''), 0, 250); $material->message = substr(Arr::get($_POST, 'message', ''), 0, 500); $material->user_id = $user_id; $material->date = date('Y-m-d H:i:s'); $material->lang_notice = strtolower(Kohana_I18n::lang()); if ($journal) { $material->is_journal = 1; $material->is_moderator = 0; } $material->save(); $files = Arr::get($_POST, 'files', ''); if ($files) { foreach ($files as $key => $file) { if ($key > 7) { break; } if ($file) { $storage = ORM::factory('Storage', (int) $file); try { $upload = ORM::factory('Material_File'); $upload->user_id = $user_id; $upload->material_id = $material->id; $upload->date = date('Y-m-d H:i:s'); $upload->storage_id = (int) $file; $upload->filesize = filesize($storage->file_path); $upload->save(); } catch (ORM_Validation_Exception $e) { } } } } Message::success(i18n::get('The material sent to the moderator. Thank you!')); $user = ORM::factory('User', $user_id); $user_email = $user->email; Email::connect(); Email::View('review_now_' . i18N::lang()); Email::set(array('message' => I18n::get('Оставленный вами материал находится на рассмотрении редакционной коллегии портала'))); Email::send($user_email, array('*****@*****.**', 'e-history.kz'), I18n::get('Рассмотрение материала на портале "История Казахстана" e-history.kz'), '', true); if ($journal != 1) { $material_type = 'Интересные материалы'; $url = URL::media('/manage/materials', TRUE); } else { $material_type = 'Журнал e-history'; $url = URL::media('/manage/materials/ehistory', TRUE); } $user_profile = ORM::factory('User_Profile', $user_id); if ($user_profile->first_name != '') { $user_name = $user_profile->first_name . ' ' . $user_profile->last_name; } else { $user_name = $user->username; } $email = '*****@*****.**'; Email::connect(); Email::View('new_material'); Email::set(array('url' => $url, 'material_type' => $material_type, 'username' => $user_name)); Email::send($email, array('*****@*****.**', 'e-history.kz'), "Новый материал на e-history.kz", '', true); $this->redirect('profile/materials', 301); } catch (ORM_Validation_Exception $e) { $errors = $e->errors($e->alias()); $files = Arr::get($_POST, 'files', ''); $this->set('errors', $errors)->set('material', $_POST)->set('files', $files); } } $this->add_cumb('User profile', 'profile'); $this->add_cumb('Downloaded Content', '/'); }
public function action_deletecategory() { $id = (int) $this->request->param('id', 0); $category = ORM::factory('Zhuze', $id); if (!$category->loaded()) { throw new HTTP_Exception_404(); } $token = Arr::get($_POST, 'token', false); if ($this->request->method() == Request::POST && Security::token() === $token) { $category->delete(); Message::success(I18n::get("Category deleted")); $this->redirect('manage/specprojects/zhuzes'); } else { $this->set('record', $category)->set('token', Security::token(true))->set('cancel_url', Url::media('manage/specprojects/zhuzes')); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { if (Auth::check()) { $user = Auth::user(); if (!empty($user)) { if ($user->hasRole('admin')) { $user = User::find($id); if (!empty($user) || isset($user)) { $user->delete(); } } } App::abort(403, I18n::get('auth.you_are_not_authorized')); } else { return Redirect::route('admin.login')->with('notice', I18n::get('auth.you_must_be_logged')); } }
function __($string, array $values = NULL) { $string = I18n::get($string); return empty($values) ? $string : strtr($string, $values); }
/** * Tests i18n::get() * * @test * @dataProvider provider_get * @param boolean $input Input for File::mime * @param boolean $expected Output for File::mime */ public function test_get($lang, $input, $expected) { I18n::lang($lang); $this->assertSame($expected, I18n::get($input)); }
public function testLoadDirectory() { I18n::set(__DIR__ . '/../dir/'); I18n::load('en_CA'); $this->assertEquals('More Testing!', I18n::get('test.testing')); }
public function action_index() { header('Access-Control-Allow-Origin: *'); $alphabet = array('ru' => array('А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я'), 'kz' => array('А', 'Ә', 'Б', 'В', 'Г', 'Ғ', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Қ', 'Л', 'М', 'Н', 'Ң', 'О', 'Ө', 'П', 'Р', 'С', 'Т', 'У', 'Ү', 'Ұ', 'Ф', 'Х', 'Һ', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'I', 'Ь', 'Э', 'Ю', 'Я'), 'en' => array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z')); $lang = Security::xss_clean($this->request->param('language')); foreach ($alphabet[$lang] as $alpha) { $biog = ORM::factory('Biography')->where('published', '=', 1)->where_open()->where('name_' . $lang, 'like', $alpha . '%')->or_where('name_' . $lang, 'like', '% ' . $alpha . '%')->where_close()->find(); if ($biog->loaded()) { $alphabet_new[] = $alpha; } } $this->data['alphabet'] = $alphabet_new; $categories1 = ORM::factory('Biography_Category')->where('era', '=', '1')->find_all(); $halyk_kaharmany = ORM::factory('Biography_Category', 9); foreach ($categories1 as $k => $v) { $cat = array(); $cat['id'] = $v->id; $cat['title'] = $v->title; $this->data['categories1'][] = $cat; } $this->data['halyk_kaharmany'] = array('id' => $halyk_kaharmany->id, 'title' => $halyk_kaharmany->title); $category = (int) $this->request->param('id', 0); $biography = ORM::factory('Biography')->where('published', '=', 1)->where('name_' . $this->language, '<>', ''); if ($category != 0) { $biography = $biography->where('category_id', '=', $category); $cat = ORM::factory('Biography_Category', $category); } else { $biography = $biography->where('category_id', 'NOT IN', array(3, 4, 6, 7, 8, 15)); } $alpha = Security::xss_clean($this->request->param('category', "")); //SEO. закрываем сортировку if ($alpha != '') { $sort = 1; Kotwig_View::set_global('sort', $sort); } //end_SEO if (!empty($alpha)) { $biography = $biography->where_open()->where('name_' . $lang, 'like', $alpha . '%')->or_where('name_' . $lang, 'like', '% ' . $alpha . '%')->where_close(); } $biography = $biography->order_by('order'); $paginate = Paginate::factory($biography)->paginate(NUll, NULL, 10)->page_count(); $biography = $biography->find_all(); if (count($biography) == 0) { $this->data['error'] = I18n::get('Sorry.'); } else { foreach ($biography as $k => $v) { $bio = array(); $bio['id'] = $v->id; $bio['name'] = $v->name; $bio['image'] = URL::media('/images/w140-h187-cct-si/' . $v->picture->file_path, true); $bio['date_start'] = $v->getYear('date_start'); $bio['date_finish'] = $v->getYear('date_finish'); $bio['desc'] = $v->desc; $bio['url'] = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->language . URL::site('api/smartpersonalii/view/' . $v->id); $this->data['list'][] = $bio; } } $this->data['pagecount'] = $paginate; $this->data['alpha'] = $alpha; $this->data['category'] = $category; $this->response->body(json_encode($this->data)); }
/** * Add parameters for display. * If we have data in the comment, use that * * @param array $field * @return array $field */ protected function configure_field($field) { $this->set_field_value($field, 'disabled', false); $this->set_field_value($field, 'relation', null); $this->set_field_value($field, 'name', $field); $this->set_field_value($field, 'field_name', $this->container . '[' . $this->fields[$field]['name'] . ']'); $this->set_field_value($field, 'field_id', trim(str_replace(array('[', ']'), '_', $this->fields[$field]['field_name']), '_')); $this->set_field_value($field, 'value', ''); #if (!isset($this->fields[$field]['label']) || !$this->fields[$field]['label']) $this->fields[$field]['label'] = ucwords(str_replace('_', ' ', $this->fields[$field]['name'])); $this->set_field_value($field, 'label', ucwords(str_replace('_', ' ', $this->fields[$field]['name']))); $this->set_field_value($field, 'error', false); $this->set_field_value($field, 'error_text', ''); $attributes = array('id' => $this->fields[$field]['field_id']); if (isset($this->fields[$field]['comment'])) { $comment = explode("\n", $this->fields[$field]['comment']); foreach ($comment as $line) { if (false !== strpos($line, ':')) { list($field, $value) = preg_split('/ *: */', $line, 2); $this->set_field_value($field, trim($field), trim($value)); } } } $this->set_field_value($field, 'help', ''); if (isset($this->fields[$field]['options'])) { if (isset($this->fields[$field]['dont_reindex_options'])) { if ($this->fields[$field]['is_nullable'] || $this->is_new() && $this->fields[$field]['display_as'] == 'select') { $this->fields[$field]['options'] = array('' => '') + $this->fields[$field]['options']; } } else { $options = array(); if ($this->fields[$field]['is_nullable']) { $options[''] = ''; } foreach ($this->fields[$field]['options'] as $option) { $i18id = "option_name_" . $option; $i18name = I18n::get($i18id); if ($i18name == "" || $i18name == $i18id) { $options[$option] = $option; } else { $options[$option] = $i18name; } } $this->fields[$field]['options'] = $options; } } if ($this->fields[$field]['name'] == $this->primary_key) { $this->set_field_value($field, 'display_as', 'hidden'); } elseif (isset($this->fields[$field]['data_type']) && $this->fields[$field]['data_type'] == 'enum') { $this->set_field_value($field, 'display_as', 'select'); } elseif (isset($this->fields[$field]['data_type']) && $this->fields[$field]['data_type'] == 'set') { $this->set_field_value($field, 'display_as', 'checkboxes'); $this->fields[$field]['value'] = explode(',', $this->fields[$field]['value']); } elseif (isset($this->fields[$field]['data_type']) && $this->fields[$field]['data_type'] == 'tinyint' && $this->fields[$field]['display'] == '1') { $this->set_field_value($field, 'display_as', 'bool'); } elseif (isset($this->fields[$field]['type']) && preg_match('/^(.*int|decimal|float)$/', $this->fields[$field]['type'])) { $this->set_field_value($field, 'display_as', 'text'); $this->set_field_value($field, 'input_type', 'number'); } elseif (isset($this->fields[$field]['data_type']) && preg_match('/.*text$/', $this->fields[$field]['data_type'])) { $this->set_field_value($field, 'display_as', 'textarea'); } else { $this->set_field_value($field, 'display_as', 'text'); $this->set_field_value($field, 'input_type', 'text'); if (isset($this->fields[$field]['character_maximum_length'])) { $attributes['maxlength'] = $this->fields[$field]['character_maximum_length']; } } $required = isset($this->fields[$field]['is_nullable']) && !$this->fields[$field]['is_nullable']; $this->set_field_value($field, 'required', $required); # $attributes['required'] = $required; // this triggers browser behaviour, which doesn't seem quite ready yet. $this->set_field_value($field, 'attributes', $attributes); }
/** * Kohana translation/internationalization function. The PHP function * [strtr](http://php.net/strtr) is used for replacing parameters. * * __('Welcome back, :user', array(':user' => $username)); * * [!!] The target language is defined by [I18n::$lang]. * * @uses I18n::get * @param string $string text to translate * @param array $values values to replace in the translated text * @param string $lang source language * @return string */ function __($string, array $values = NULL, $lang = 'en-us') { $messages = I18n::load(I18n::$lang); //print_r($messages); $file = Kohana::find_file('i18n', I18n::$lang, NULL, FALSE); if (isset($file[0]) && file_exists($file[0])) { if (array_key_exists($string, $messages)) { //echo $string."> ano"; } else { //echo $string."> NE"; $messages[$string] = $string; $file_content = "<?php defined('SYSPATH') OR die('No direct script access.');" . "return " . var_export($messages, TRUE) . ";"; file_put_contents($file[0], $file_content); } } if ($lang !== I18n::$lang) { // The message and target languages are different // Get the translation for this message $string = I18n::get($string); } return empty($values) ? $string : strtr($string, $values); }
function __get($name) { return I18n::get(substr($name, 2)); }
public function action_variantpublish() { $id = $this->request->param('id', 0); $variant = ORM::factory('aq', $id); if (!$variant->loaded()) { throw new HTTP_Exception_404(); } if ($variant->published) { $variant->published = 0; $variant->save(); Message::success(I18n::get('Ответ скрыт')); } else { $variant->published = 1; $variant->save(); Message::success(I18n::get('Ответ опубликован')); } $this->redirect('manage/tests/variants/' . $variant->id_qv); }
/** * 输出语言包 * * [strtr](http://php.net/strtr) is used for replacing parameters. * * __('Welcome back, :user', array(':user' => $username)); * * @uses I18n::get * @param string text to translate * @param array values to replace in the translated text * @param string target language * @return string */ function __($string, array $values = null) { static $have_i18n_class = false; if (false === $have_i18n_class) { $have_i18n_class = (bool) class_exists('I18n', true); } if ($have_i18n_class) { $string = I18n::get($string); } return empty($values) ? $string : strtr($string, $values); }
public function action_showchapter() { $id = (int) $this->request->param('id', 0); $chapter = ORM::factory('Book_Chapter', $id); if (!$chapter->loaded()) { throw new HTTP_Exception_404(); } if ($chapter->published) { $chapter->published = 0; $chapter->save(); Message::success(I18n::get('Record hided')); } else { $chapter->published = 1; $chapter->save(); Message::success(I18n::get('Record unhided')); } $this->redirect('manage/library/chapters/' . $chapter->book_id); }
<table class="table borderless"> <tr> <td><a href="/about"><?php echo I18n::get("about"); ?> </a></td> <td><a href="/contact"><?php echo I18n::get("contact"); ?> </a></td> <td><a href="/legal"><?php echo I18n::get("legal"); ?> </a></td> <td><a href="/cookies"><?php echo I18n::get("cookies"); ?> </a></td> </tr> </table> </div> </footer> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <!-- Latest compiled and minified JavaScript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> <script src="https://maxcdn.bootstrapcdn.com/js/ie10-viewport-bug-workaround.js"></script>
<div id="home" class="container"> <div class="page-header"> <h1><?php echo I18n::get("demands_title"); ?> </h1> </div> <p class="lead"><?php echo I18n::get("tuto_desc"); ?> </p> <h2><?php echo I18n::get("demands"); ?> </h2> <p><?php echo I18n::get("tuto_demands"); ?> </p> <h2><?php echo I18n::get("offers"); ?> </h2> <p><?php echo I18n::get("tuto_offers"); ?> </p> </div> <?php include_once __DIR__ . "/template/bottom.php";
/** * Translate strings to the page language or a given language * * The PHP function [strtr](http://php.net/strtr) is used for replacing parameters. * <code> * __('Welcome back, :user', array(':user' => $username)); * </code> * * [!!] The target language is defined by [I18n::$lang]. * * @param string $string Text to translate * @param array $values Values to replace in the translated text. [Optional] * An associative array of replacements to make after translation. * Incidences of any key in this array are replaced with the corresponding value. * Based on the first character of the key, the value is escaped and/or themed: * - !variable: inserted as is * - :variable: inserted as is * - @variable: escape plain text to HTML (HTML::chars) * - %variable: escape text and theme as a placeholder for user-submitted * - ^variable: escape text and uppercase the first character of each word in a string * - ~variable: escape text and make a string's first character uppercase * content (HTML::chars + theme_placeholder) * @param string $lang Source language [Optional] * @return string * * @uses I18n::get * @uses HTML::chars */ function __($string, array $values = NULL, $lang = 'en-us') { if ($lang !== I18n::$lang) { // The message and target languages are different // Get the translation for this message $string = I18n::get($string); } if (empty($values)) { return $string; } else { // Transform arguments before inserting them. foreach ($values as $key => $value) { switch ($key[0]) { case '@': // Escaped only $values[$key] = HTML::chars($value); break; case '%': // Escaped and placeholder $values[$key] = '<em class="placeholder">' . HTML::chars($value) . '</em>'; break; case '^': // Escaped and uppercase the first character of each word in a string $values[$key] = ucwords(HTML::chars($value)); break; case '~': // Escaped and make a string's first character uppercase $values[$key] = ucfirst(HTML::chars($value)); break; case '!': case ':': default: // Pass-through } } } return strtr($string, $values); }