示例#1
0
文件: base.php 项目: Hinton/langify
 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
0
 /**
  * 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
0
 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
0
 public function action_load($path)
 {
     // Load the pages
     $template = $this->template;
     $template->title = Kohana::message('titles', $path);
     $template->content = View::factory("static/{$path}");
 }
示例#5
0
 /**
  * Просмотр запроса
  * @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
0
 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!');
     }
 }
 public function after()
 {
     if (empty($this->template->title)) {
         $this->template->title = Kohana::message('titles', "{$this->request->controller}/{$this->request->action}");
     }
     return parent::after();
 }
示例#8
0
 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
0
 /**
  * Редактирование страницы фильтра
  * @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
0
 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
0
 /**
  * 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
0
 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
0
文件: auto.php 项目: boltogriz/kohana
 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
0
 /**
  * Удаление новости автосервиса
  * @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
0
 public function validate_attributes(array $attribute)
 {
     if (!$attribute['answer']) {
         $this->_validation_errors['attributes'] = Kohana::message('question', 'open.not_empty');
         return false;
     }
     return true;
 }
示例#16
0
文件: Auth.php 项目: ariol/adminshop
 public function action_reset_password_step_1()
 {
     if ($result = $this->do_reset_password_step_1()) {
         $email_from = Kohana::$config->load('email.from');
         Email::send($result['email'], $email_from, Kohana::message('email', 'reset_password.admin'), View::factory('email/reset_password/admin', array('code' => $result['code'])), FALSE);
         HTTP::redirect('/' . Extasy_Url::url_to_route('admin-auth:reset_password_step_1_thankyou'));
     }
 }
示例#17
0
 /**
  * Save the config and checks functions availability
  *
  * @param array $config driver config
  */
 public function __construct(array $config)
 {
     $this->_config = $config;
     // Checks if driver can be used
     if (!$this->check()) {
         throw new Kohana_Transfer_Exception(Kohana::message('transfer', 'not_related_functions'), array(':url' => $this->info()));
     }
 }
示例#18
0
文件: Errors.php 项目: Konro1/pms
 public static function message($error_filename, $attribute, $error, $params)
 {
     if ($message = Kohana::message($error_filename, "{$attribute}.{$error}")) {
     } elseif ($message = Kohana::message('validators', $error)) {
     } else {
         return $error_filename . ":{$attribute}.{$error}";
     }
     return __($message, $params);
 }
示例#19
0
 public function validate_attributes(array $attributes)
 {
     $valid_items = array_filter($attributes['items']);
     if (count($valid_items) < 2) {
         $this->_validation_errors['attributes'] = Kohana::message('question', 'ordering.atleast_two');
         return false;
     }
     return true;
 }
示例#20
0
文件: validate.php 项目: TdroL/hurtex
 public function fields($fields)
 {
     $file = $fields;
     $path = NULL;
     if (strpos($fields, '.', 1)) {
         list($file, $path) = explode('.', $fields, 2);
     }
     $fields = Kohana::message($file, $path);
     return parent::labels($fields);
 }
示例#21
0
 /**
  * Sign out the user AND redirect him to the frontpage.
  */
 public function action_index()
 {
     if ($this->request->method() == HTTP_Request::POST) {
         Hint::success(Kohana::message('user', 'logout.success'));
         $this->auth->logout();
         $this->redirect('');
     } else {
         $this->view = new View_User_Logout();
     }
 }
示例#22
0
 /**
  * Perform user logout
  */
 public function action_logout()
 {
     Kohana::$log->add(Kohana::DEBUG, 'Executing Controller_Auth::action_logout');
     $this->a1->logout();
     Kohana::$log->add('ACCESS', 'Successful logout made by user.');
     Message::instance()->info(Kohana::message('a2', 'logout.success'));
     if (!$this->_internal) {
         $this->request->redirect(Route::get('admin')->uri());
     }
 }
示例#23
0
 /**
  * Sets up admin framework controllers
  *
  * - Redirects invalid internal-only access requests to the admin main
  * - Loads resources if required, and redirects if invalid
  * - Performs ACL checking, and redirects if denied
  */
 public function before()
 {
     parent::before();
     // Set common variables
     $this->a2 = A2::instance('auth');
     $this->a1 = $this->a2->a1;
     $this->session = Session::instance();
     // Check if internal request
     if ($this->request !== Request::instance() or Request::$is_ajax) {
         $this->_internal = TRUE;
     }
     // Check if internal-only request
     if (in_array($this->request->action, $this->_internal_only) and !$this->_internal) {
         Kohana::$log->add(Kohana::INFO, 'Attempt to access internal URL, ' . $this->request->uri . ', externally');
         Request::instance()->redirect(Route::get('admin')->uri());
     }
     // Perform resource loads and ACL check
     try {
         if (in_array($this->request->action, $this->_resource_required)) {
             $this->_load_resource();
         }
         if ($this->_acl_required === 'all' or in_array($this->request->action, $this->_acl_required)) {
             $privilege = isset($this->_acl_map[$this->request->action]) ? $this->_acl_map[$this->request->action] : $this->_acl_map['default'];
             $this->a2->allowed($this->_resource, $privilege, TRUE);
         }
     } catch (A2_Exception $ae) {
         // Redirect to login form if not logged in
         if (!($user = $this->a2->get_user())) {
             $this->session->set('referrer', Request::instance()->uri);
             Message::instance()->error(Kohana::message('a2', 'login.required'));
             $this->request->redirect(Route::get('admin/auth')->uri());
         }
         Kohana::$log->add('ACCESS', 'Failed attempt to access resource, ' . $this->_resource . ', by user, ' . $user->username . ', with url, ' . $this->request->uri);
         Message::instance()->error($ae->getMessage(), array(':resource' => $this->_resource));
         // If internal request, redirect to denied action
         if ($this->_internal) {
             $this->request->action = 'denied';
         } else {
             // If controller-level access is denied, redirect to admin main
             if ($this->request->action == 'index') {
                 $this->request->redirect(Route::get('admin')->uri());
             } else {
                 $this->request->redirect($this->request->uri(array('action' => 'index', 'id' => NULL)));
             }
         }
     } catch (Kohana_Exception $ke) {
         // Catch 404 exceptions triggered by invalid resource loads
         if ($ke->getCode() == 404) {
             Message::instance()->error($ke->getMessage());
             $this->request->redirect($this->request->uri(array('action' => '', 'id' => NULL)));
         } else {
             throw $ke;
         }
     }
 }
示例#24
0
 public static function t($file, $key, $args, $escape = true)
 {
     if ($escape) {
         $args = array_map(array('HTML', 'chars'), $args);
     }
     $s = Kohana::message($file, $key);
     $keys = array_map(function ($k) {
         return '{' . $k . '}';
     }, array_keys($args));
     return str_replace($keys, $args, $s);
 }
示例#25
0
文件: view.php 项目: kanikaN/qload
 public function translate($str)
 {
     $new_str = $str;
     if (Formo::config($this->_field, 'use_messages') === TRUE) {
         $msg_file = Formo::config($this->_field, 'message_file');
         $new_str = Kohana::message($msg_file, $str, $str);
     }
     if (Formo::config($this->_field, 'translate') === TRUE) {
         $new_str = __($new_str);
     }
     return $new_str;
 }
示例#26
0
文件: layout.php 项目: Hinton/langify
 /**
  * Grab all the translations avaible
  */
 public function translations()
 {
     $translations = array();
     foreach (Kohana::message('langify', 'translations') as $key => $value) {
         $selected = FALSE;
         if (I18n::$lang === $key) {
             $selected = TRUE;
         }
         $translations[] = array('value' => $key, 'name' => $value, 'selected' => $selected);
     }
     return $translations;
 }
示例#27
0
文件: main.php 项目: boltogriz/kohana
 public function action_index()
 {
     I18n::lang('ru');
     $text = Model::factory('index')->showIndex();
     $user = Model::factory('index')->showUser();
     $block_center = View::factory('v_index', array('text' => $text, 'username' => $user));
     $messag = Kohana::message('forms/contact', 'errors.user_not_found');
     //вывод шаблона
     // $this->template->page_title = 'Главная';
     $this->template->page_title = Kohana::$config->load('myconf.page_title');
     $this->template->block_center = array($block_center, $messag);
 }
示例#28
0
 /**
  * Locate a message and replace any parameters
  *
  * @param string $message_file message file to load from - will be located in messages/{message_file}.php
  * @param string $path         path of the message to load
  * @param string $params       array of params to replace in the message if required
  *
  * @return string
  */
 protected function lookup_message($message_file, $path, $params)
 {
     //@todo: Refactor the KohanaMessage class to be clean and allow better parameter substitution and string lookup
     $message = \Kohana::message($message_file, $path);
     if ($message) {
         return strtr($message, $params);
     } else {
         $full_path = $message_file . ":" . $path;
         \Kohana::$log->add(\Log::WARNING, "Unknown message - " . $full_path);
         return $full_path . ' ' . json_encode($params);
     }
 }
示例#29
0
 /**
  * Creates a new item.
  */
 public function action_create()
 {
     $item = RDFORM::factory('item');
     $item->load_from_array($_POST);
     $item->save();
     if ($item->saved) {
         $data['flash'] = Kohana::message('item_created');
     } else {
         $data['flash'] = Kohana::message('error_creating_item');
         $data['errors'] = $item->validation_errors;
     }
     $this->template->data = $data;
 }
示例#30
0
 protected function get_orm_model($model_name, $redirect_url = NULL)
 {
     $model = ORM::factory($model_name, $this->request->param('id', NULL));
     if (!$model->loaded()) {
         Message::set(Message::ERROR, __(Kohana::message('admin', $model_name . '.not_found')));
         if ($redirect_url) {
             $this->request->redirect($redirect_url);
         } else {
             $this->request->redirect('admin');
         }
     }
     return $model;
 }