本文整理汇总了PHP中Kohana::message方法的典型用法代码示例。如果您正苦于以下问题:PHP Kohana::message方法的具体用法?PHP Kohana::message怎么用?PHP Kohana::message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kohana
的用法示例。
在下文中一共展示了Kohana::message方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
public function before()
{
parent::before();
// Borrowed from userguide
if (isset($_GET['lang'])) {
$lang = $_GET['lang'];
// Make sure the translations is valid
$translations = Kohana::message('langify', 'translations');
if (in_array($lang, array_keys($translations))) {
// Set the language cookie
Cookie::set('langify_language', $lang, Date::YEAR);
}
// Reload the page
$this->request->redirect($this->request->uri());
}
// Set the translation language
I18n::$lang = Cookie::get('langify_language', Kohana::config('langify')->lang);
// Borrowed from Vendo
// Automaticly load a view class based on action.
$view_name = $this->view_prefix . Request::current()->action();
if (Kohana::find_file('classes', strtolower(str_replace('_', '/', $view_name)))) {
$this->view = new $view_name();
$this->view->set('version', $this->version);
}
}
示例2: connect
/**
* Connect operation
*/
public function connect()
{
if ($this->_ssh2 != null) {
// Already connected
return;
}
// Connect to server
$host = isset($this->_config['hostname']) ? $this->_config['hostname'] : 'localhost';
$port = isset($this->_config['port']) ? $this->_config['port'] : 22;
$username = isset($this->_config['username']) ? $this->_config['username'] : '';
$password = isset($this->_config['password']) ? $this->_config['password'] : null;
$this->_ssh2 = ssh2_connect($host, $port);
if ($this->_ssh2 === FALSE) {
throw new Kohana_Transfer_Exception(Kohana::message('transfer', 'fail_open_connection'), array(':host' => $host, 'port' => $port));
}
// Check fingerprint if it is specified
if (isset($this->_config['fingerprint'])) {
if (strtolower(ssh2_fingerprint($this->_ssh2)) != strtolower($this->_config['fingerprint'])) {
throw new Kohana_Transfer_Exception(Kohana::message('transfer', 'fail_fingerprint_validation'), array(':key' => ssh2_fingerprint($this->_ssh2)));
}
}
// Connect with certificate if it is specified
if (isset($this->_config['pubkeyfile']) and isset($this->_config['privkeyfile'])) {
if (!@ssh2_auth_pubkey_file($this->_ssh2, $username, $this->_config['pubkeyfile'], $this->_config['privkeyfile'], $password)) {
throw new Kohana_Transfer_Exception(Kohana::message('transfer', 'fail_authentication'));
}
} else {
if (!@ssh2_auth_password($this->_ssh2, $username, $password)) {
throw new Kohana_Transfer_Exception(Kohana::message('transfer', 'fail_authentication'));
}
}
// Enable SFTP mode
$this->_sftp = ssh2_sftp($this->_ssh2);
}
示例3: action_delete
public function action_delete()
{
$car = ORM::factory('car_brand', $this->request->param('id', NULL));
if (!$car->loaded()) {
Message::set(Message::ERROR, Kohana::message('admin', 'carbrand_not_found'));
$this->request->redirect('admin/item/carbrand');
}
$name = $car->name . ' ' . $car->name_ru;
$services_count = count($car->services->find_all());
if ($_POST) {
if (Arr::get($_POST, 'submit')) {
$car->remove('services');
$car->content->delete();
$car->delete();
$msg = __('car_brand_delete_success', array(':name' => $name));
if ($services_count > 0) {
$msg .= __('car_brand_delete_success_services', array(':count' => $services_count));
}
Message::set(Message::SUCCESS, $msg);
$this->request->redirect('admin/item/carbrand');
} else {
$this->request->redirect('admin/item/carbrand');
}
}
$text = __('car_brand_delete', array(':name' => $name));
if ($services_count > 0) {
$text .= __('car_brand_delete_services_count', array(':count' => $services_count));
}
$this->template->title = 'Удаление марки автомобиля';
$this->template->bc['#'] = $this->template->title;
$this->view = View::factory('backend/delete')->set('from_url', 'admin/item/carbrand')->set('url', $this->request->url())->set('title', $this->template->title)->set('text', $text);
$this->template->content = $this->view;
}
示例4: action_load
public function action_load($path)
{
// Load the pages
$template = $this->template;
$template->title = Kohana::message('titles', $path);
$template->content = View::factory("static/{$path}");
}
示例5: action_view
/**
* Просмотр запроса
* @return void
*/
public function action_view()
{
$feedback = ORM::factory('feedback', $this->request->param('id', NULL));
if (!$feedback->loaded()) {
Message::set(Message::ERROR, Kohana::message('admin', 'feedback_not_found'));
$this->request->redirect('admin/feedback');
}
/*
switch ($feedback->type)
{
case 1:
$this->view = View::factory('backend/feedback/view_feedback');
break;
case 2:
$this->view = View::factory('backend/feedback/view_adv');
break;
}
$this->view->set('feedback', $feedback);
$this->template->title = $title_pie.' от пользователя '.$feedback->user->username;
*/
$this->view = View::factory('backend/feedback/view')->set('feedback', $feedback);
$title_pie = $feedback->type == 1 ? 'Запрос' : 'Заявка на рекламу';
$this->template->title = $title_pie . ' от пользователя ' . $feedback->user->username;
$this->template->bc['#'] = $this->template->title;
$this->template->content = $this->view;
}
示例6: action_complete
public function action_complete()
{
// Get the transaction details.
$fetch = $this->_gateway->fetchTransaction($this->_payment_vars())->send();
$data = $fetch->getData();
// Add the buyer email to parameters.
$parameters = $this->_payment_vars() + array('email' => $data['EMAIL']);
/** @var Payment_PayPal_CreateRecurringPaymentsRequest $request */
$request = $this->_gateway->createRecurringPaymentsProfile($parameters);
// Overwrite Item Category.
$data = $request->getData();
$data['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = $this->_config['itemCategory'];
/** @var Omnipay\PayPal\Message\ExpressAuthorizeResponse $response */
$response = $request->sendData($data);
if ($response->isSuccessful()) {
$response_data = $response->getData();
// Get the transaction details.
// $fetch = $this->_gateway->fetchTransaction($this->_payment_vars())->send();
// $data = $fetch->getData();
ORM::factory('Payment_Subscription')->values(array('user_id' => $this->user->id, 'package_id' => $this->_package->id, 'status' => Model_Payment_Subscription::PENDING, 'recurring_payment_id' => $response_data['PROFILEID']))->create();
Hint::success(Kohana::message('payment', 'payment.success'));
$this->redirect(Route::get('payment')->uri());
} else {
// Log the error.
Kohana::$log->add(Log::ERROR, IPN::array_to_string($response->getData()));
throw HTTP_Exception::factory('403', 'Something went wrong, no cash should have been drawn, if the error proceeds contact support!');
}
}
示例7: after
public function after()
{
if (empty($this->template->title)) {
$this->template->title = Kohana::message('titles', "{$this->request->controller}/{$this->request->action}");
}
return parent::after();
}
示例8: action_login
public function action_login()
{
$this->template->menu_login = TRUE;
// Если залогинен, то перекидываем на дерево
if (Auth::instance()->logged_in()) {
$this->redirect(Route::url('user/id', array('user_id' => Auth::instance()->get_user()->id)));
}
$post = Arr::extract($this->request->post(), array('email', 'password'));
$data['errors'] = NULL;
if ($this->request->method() == 'POST') {
$valid = Validation::factory($post)->rules('email', array(array('not_empty')))->rules('password', array(array('not_empty')))->labels(array('email' => 'Адрес электронной почты', 'password' => 'Пароль'));
if (!$valid->check()) {
$data['errors'] = $valid->errors('valid');
} else {
if (Auth::instance()->login($valid['email'], $valid['password'], TRUE)) {
// Авторизация прошла успешно
if (!is_null($this->request->referrer())) {
$this->redirect($this->request->referrer());
} else {
$this->redirect(Route::url('user/id', array('user_id' => Auth::instance()->get_user()->id)));
}
} else {
$data['errors'] = array('usermail' => '', 'userpass' => Kohana::message('valid', 'login.incorrect'));
}
}
}
$data += $post;
$this->template->content = View::factory('auth/login', $data);
}
示例9: action_edit
/**
* Редактирование страницы фильтра
* @return void
*/
public function action_edit()
{
$content = ORM::factory('content_filter', $this->request->param('id', NULL));
if (!$content->loaded()) {
Message::set(Message::ERROR, Kohana::message('admin', 'content_not_found'));
$this->request->redirect('admin/content/filter');
}
// Город страницы
$city = $content->city->name;
$type = __('filter_type_' . $content->type);
if ($_POST) {
try {
$content->text = Arr::get($_POST, 'text', NULL);
$content->date_edited = Date::formatted_time();
$content->update();
Message::set(Message::SUCCESS, 'Страница фильтра для города ' . $city . ' успешно отредактирована');
$this->request->redirect('admin/content/filter/index/' . $content->type);
} catch (ORM_Validation_Exception $e) {
$this->errors = $e->errors('models');
$this->values = $_POST;
}
} else {
$this->values = $content->as_array();
}
$this->view = View::factory('backend/content/filter/edit')->set('url', 'admin/content/filter/edit/' . $content->id)->set('city', $city)->set('type', $type)->set('values', $this->values)->set('errors', $this->errors);
$this->template->title = 'Редактирование страницы фильтра для г. ' . $city;
$this->template->bc['#'] = $this->template->title;
$this->template->content = $this->view;
}
示例10: action_delete
function action_delete()
{
$vacancy = ORM::factory('vacancy', $this->request->param('id', NULL));
if (!$vacancy->loaded() or $vacancy->user_id != $this->user->id) {
Message::set(Message::ERROR, Kohana::message('cabinet', 'vacancy_not_found'));
$this->request->redirect('cabinet/vacancy');
}
if ($_POST) {
$action = Arr::extract($_POST, array('submit', 'cancel'));
if ($action['cancel']) {
$this->request->redirect('cabinet/vacancy');
}
if ($action['submit']) {
$title = $vacancy->title;
$service_name = $vacancy->service->name;
$vacancy->delete();
Message::set(Message::SUCCESS, 'Вакансия "' . $title . '" для фирмы "' . $service_name . '" удалена');
$this->request->redirect('cabinet/vacancy');
}
}
$this->view = View::factory('frontend/cabinet/delete')->set('url', 'cabinet/vacancy/delete/' . $vacancy->id)->set('text', 'Вы действительно хотите удалить вакансию ' . $vacancy->title . ' для фирмы ' . $vacancy->service->name);
$this->template->title = $this->site_name . 'Удаление вакансии';
$this->template->bc['#'] = 'Удаление вакансии';
$this->template->content = $this->view;
}
示例11: action_login
/**
* Action login
*/
public function action_login()
{
$post = $this->request->post();
$username = Arr::get($post, 'username');
$password = Arr::get($post, 'password');
$remember = Arr::get($post, 'remember') ?: 0;
// If there is post login
if ($this->request->post('login')) {
// ログインチェック
if (Auth::instance()->login($username, $password, $remember)) {
// ロールチェック
if (Auth::instance()->logged_in('direct') or Auth::instance()->logged_in('admin') or Auth::instance()->logged_in('edit')) {
// Add success notice
Notice::add(Notice::SUCCESS, Kohana::message('auth', 'login_success'), array(':user' => $username));
// Redirect to home
$this->redirect(URL::site($this->settings->backend_name, 'http'));
} else {
// Add error notice
Notice::add(Notice::ERROR, Kohana::message('auth', 'login_refusal'), NULL, Kohana::message('auth', 'login_refusal_messages'));
}
} else {
// Add error notice
Notice::add(Notice::ERROR, Kohana::message('auth', 'login_failed'), NULL, Kohana::message('auth', 'login_failed_messages'));
}
}
/**
* View
*/
// Get content
$content_file = Tpl::get_file('login', $this->settings->back_tpl_dir . '/auth');
$this->content = Tpl::factory($content_file)->set('post', $post);
}
示例12: action_view
function action_view()
{
$open_coupon = Arr::get($_GET, 'print_coupon', FALSE);
$service = ORM::factory('service', $this->request->param('id', NULL));
if (!$service->loaded() || !$service->active) {
Message::set(Message::ERROR, 'Такой сервис не найден');
$this->request->redirect('/');
}
$this->validation = Validation::factory($_POST)->rule('antibot', 'not_empty');
if ($_POST) {
$review = ORM::factory('review');
try {
$review->values($_POST, array('text', 'email'));
$review->date = Date::formatted_time();
$review->service_id = $service->id;
$review->active = 0;
//$review->user_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
$review->save($this->validation);
Message::set(Message::SUCCESS, Kohana::message('success_msg', 'review_created'));
$this->request->redirect('services/' . $service->id);
} catch (ORM_Validation_Exception $e) {
$this->errors = $e->errors('models');
$this->values = $_POST;
}
}
$this->view = View::factory('frontend/services/view_service')->set('service', $service)->set('open_coupon', $open_coupon)->set('coupon_frame', HTML::iframe('services/get_coupon/' . $service->id, 'coupon_frame'))->set('values', $this->values)->set('errors', $this->errors);
$this->template->bc['/'] = 'Главная';
$this->template->bc['#'] = $service->name;
$this->template->title = 'Автосервис ' . $service->name . ' ' . $service->about;
$this->template->meta_description = strip_tags($service->about);
$this->add_js('http://api-maps.yandex.ru/1.1/index.xml?key=' . $this->settings['YMaps_key'] . '&onerror=map_alert');
$this->add_js('assets/js/maps_detail.js');
$this->add_js('assets/share42/share42.js');
$this->template->content = $this->view;
}
示例13: action_login
public function action_login()
{
$auth = Auth::instance();
if (Auth::instance()->logged_in()) {
header('Location: /catalog');
exit;
}
if ($this->request->method() == 'POST') {
$data = Arr::extract($_POST, array('username', 'password', 'remeber'));
$status = $auth->login($data['username'], $data['password'], (bool) $data['remeber']);
if ($status) {
if ($auth->logged_in('admin')) {
header('Location: /admin/');
exit;
}
header('Location: /catalog');
exit;
} else {
$error = array(Kohana::message('auth/user', 'no_user'));
}
}
$content = View::factory('/index/auth/v_auth_login')->bind('error', $error);
//выводим в шаблон
$this->template->page_title = 'Вход';
$this->template->block_center = array($content);
}
示例14: action_delete
/**
* Удаление новости автосервиса
* @return void
*/
function action_delete()
{
$settings = ORM::factory('payment_settings', $this->request->param('id', null));
if (!$settings->loaded()) {
Message::set(Message::ERROR, Kohana::message('admin', 'payment.settings_not_found'));
$this->request->redirect('admin/payment/settings');
}
if ($settings->system == 'Y') {
Message::set(Message::NOTICE, 'Нельзя удалять системные настройки');
$this->request->redirect('admin/payment/settings');
}
if ($_POST) {
$action = Arr::extract($_POST, array('submit', 'cancel'));
if ($action['cancel']) {
$this->request->redirect('admin/payment/settings');
}
if ($action['submit']) {
$name = $settings->name;
$settings->delete();
Message::set(Message::SUCCESS, 'Платежная настройка <strong>' . $name . '</strong> удалена');
$this->request->redirect('admin/payment/settings');
}
}
$this->view = View::factory('backend/delete')->set('url', 'admin/payment/settings/delete/' . $settings->id)->set('from_url', 'admin/payment/settings')->set('title', 'Удаление платежной настройки: ' . $settings->name)->set('text', 'Вы действительно хотите удалить "' . $settings->name . '?');
$this->template->title = 'Удаление новости "' . $settings->name . '"';
$this->template->bc['#'] = $this->template->title;
$this->template->content = $this->view;
}
示例15: validate_attributes
public function validate_attributes(array $attribute)
{
if (!$attribute['answer']) {
$this->_validation_errors['attributes'] = Kohana::message('question', 'open.not_empty');
return false;
}
return true;
}