当前位置: 首页>>代码示例>>PHP>>正文


PHP Input::is_ajax方法代码示例

本文整理汇总了PHP中Input::is_ajax方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::is_ajax方法的具体用法?PHP Input::is_ajax怎么用?PHP Input::is_ajax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Input的用法示例。


在下文中一共展示了Input::is_ajax方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_create

 public function action_create()
 {
     if (\Input::method() == 'POST') {
         $msg = ['msg' => '', 'errcode' => 0, 'status' => 'succ'];
         //检测必要的订单信息
         $data = \Input::post();
         //生成订单明细
         $details = [];
         foreach ($data['goods'] as $id) {
             $item = \Model_Trolley::find_one_by('goods_id', $id);
             array_push($details, $item->to_array());
         }
         $this->load_details($details);
         //生成优惠信息
         $this->load_preferential($data['coupons']);
         if (!$this->save($data)) {
             $msg = ['msg' => $this->result_message, 'errcode' => 20, 'status' => 'err'];
         }
         if (\Input::is_ajax()) {
             die(json_encode($msg));
         }
     }
     $params = ['title' => ''];
     $params['trolley_ids'] = [1, 2, 3];
     \View::set_global($params);
     $this->template->title = '创建订单';
     $this->template->content = \View::forge("{$this->theme}/create");
 }
开发者ID:wxl2012,项目名称:wx,代码行数:28,代码来源:mall.php

示例2: before

 /**
  * @param   none
  * @throws  none
  * @returns	void
  */
 public function before()
 {
     $result = array();
     // users need to be logged in to access this controller
     if (!\Sentry::check()) {
         $result = array('message' => 'You need to be logged in to access that page.', 'url' => '/admin/login');
         // Don't show this message if url is just 'admin'
         if (\Uri::string() == 'admin/admin/index') {
             unset($result['message']);
         }
         \Session::set('redirect_to', \Uri::admin('current'));
     } else {
         if (!\Sentry::user()->is_admin()) {
             $result = array('message' => 'Access denied. You need to be a member of staff to access that page.', 'url' => '/admin/login');
             \Session::set('redirect_to', \Uri::admin('current'));
         }
     }
     if (!empty($result)) {
         if (\Input::is_ajax()) {
             \Messages::error('You need to be logged in to complete this action.');
             echo \Messages::display('left', false);
             exit;
         } else {
             if (isset($result['message'])) {
                 \Messages::warning($result['message']);
             }
             \Response::redirect($result['url']);
         }
     }
     parent::before();
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:36,代码来源:admin.php

示例3: action_add_blocked

 public function action_add_blocked($block = null)
 {
     if (empty($block) === true) {
         $block = $_POST['blocked'];
     } else {
         $block = str_replace('-', '.', $block);
     }
     $blacklist_item = Model_Blacklist::query()->where('expression', $block)->get_one();
     if (empty($blacklist_item) === true) {
         $blacklist_item = Model_Blacklist::forge(array('expression' => $block));
         $blacklist_item->save();
         if (Input::is_ajax() === true) {
             echo $blacklist_item->id;
         }
     } else {
         if (Input::is_ajax() === true) {
             print_r(Format::forge(array('error' => 'Already Exists'))->to_json());
         } else {
             Session::set('error', $block . ' is already in the blacklist!');
         }
     }
     if (Input::is_ajax() === true) {
         die;
     }
     Response::Redirect_Back();
 }
开发者ID:aircross,项目名称:MeeLa-Premium-URL-Shortener,代码行数:26,代码来源:admin.php

示例4: action_index

 /**
  * The index action
  * 
  * @access public
  * @return void
  */
 public function action_index()
 {
     $settings = \Config::load('autoresponder.db');
     // $autoResponder = Model_Setting::find(array('where' => array(array('meta_key', '=', 'auto-responders'))));
     if (\Input::post()) {
         $input = \Input::post();
         if (!\Input::is_ajax()) {
             $val = Model_Setting::validate('create');
             if (!$val->run()) {
                 if ($val->error() != array()) {
                     // show validation errors
                     \Messages::error('<strong>There was an error while trying to create settings</strong>');
                     foreach ($val->error() as $e) {
                         \Messages::error($e->get_message());
                     }
                 }
             } else {
                 try {
                     \Config::save('autoresponder.db', array('logo_url' => $input['logo_url'], 'company_name' => $input['company_name'], 'address' => $input['address'], 'website' => $input['website'], 'phone' => $input['phone'], 'email_address' => $input['email_address'], 'sender_email_address' => $input['sender_email_address'], 'contact_us_email_address' => $input['contact_us_email_address'], 'instagram_account_name' => $input['instagram_account_name'], 'facebook_account_name' => $input['facebook_account_name']));
                     // $setting->save();
                     \Messages::success('Settings successfully created.');
                     \Response::redirect('admin/settings');
                 } catch (\Database_Exception $e) {
                     // show validation errors
                     \Messages::error('<strong>There was an error while trying to create settings.</strong>');
                     // Uncomment lines below to show database errors
                     $errors = $e->getMessage();
                     \Messages::error($errors);
                 }
             }
         }
     }
     \View::set_global('title', 'Settings');
     \Theme::instance()->set_partial('content', $this->view_dir . 'index')->set('settings', $settings, false);
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:41,代码来源:settings.php

示例5: action_login

 public function action_login()
 {
     $url_redirect = \Uri::create('system/index/index');
     if (\Auth::check()) {
         \Response::redirect($url_redirect);
     }
     if (\Input::is_ajax()) {
         $val = \Validation::forge('validate_login');
         $val->add_field('email', 'Email', 'required|valid_email');
         $val->add_field('password', 'Password', 'required');
         if ($val->run(array())) {
             if (\Auth::instance()->login(\Input::param('email'), \Input::param('password'))) {
                 if (\Input::param('remember', false)) {
                     \Auth::remember_me();
                 } else {
                     \Auth::dont_remember_me();
                 }
                 $response = array('status' => 'success', 'url' => $url_redirect);
             } else {
                 $messages = \Auth::get_error();
                 $response = array('status' => 'error', 'msg' => $messages);
             }
         } else {
             $messages = $val->error_message();
             $response = array('status' => 'error', 'msg' => $messages);
         }
         return \Response::forge(json_encode($response));
     }
     $this->theme->set_template('login');
     $this->theme->get_template()->set('content', \view::forge('default/login', $this->_arrParam));
 }
开发者ID:khoapossible,项目名称:vision_system,代码行数:31,代码来源:default.php

示例6: before

 public function before()
 {
     parent::before();
     if (!Input::is_ajax()) {
         $this->_init_nav();
     }
 }
开发者ID:alexshaffer,项目名称:ashaffer,代码行数:7,代码来源:site.php

示例7: action_save

 /**
  * 编辑保存被投票项目
  * @param int $id
  * @throws \Exception
  * @throws \FuelException
  */
 public function action_save($id = 0)
 {
     if (\Input::method() == 'POST') {
         $msg = ['status' => 'err', 'msg' => '', 'errcode' => 10];
         $data = \Input::post();
         $data['start_at'] = $data['start_at'] ? strtotime($data['start_at']) : 0;
         $data['end_at'] = $data['end_at'] ? strtotime($data['end_at']) : 0;
         $data['account_id'] = \Session::get('WXAccount')->id;
         $data['seller_id'] = \Session::get('WXAccount')->seller_id;
         $data['type'] = 'VOTE';
         $market = \Model_Marketing::find($id);
         if (!$market) {
             $market = \Model_Marketing::forge();
         }
         $market->set($data);
         if ($market->save()) {
             $limit = \Model_MarketingLimit::forge(['involved_total_num' => 1, 'marketing_id' => $market->id]);
             $limit->save();
             $msg = ['status' => 'succ', 'msg' => '', 'errcode' => 0, 'data' => $market->to_array()];
         }
         if (\Input::is_ajax()) {
             die(json_encode($msg));
         }
         \Session::set_flash('msg', $msg);
     }
 }
开发者ID:wxl2012,项目名称:wx,代码行数:32,代码来源:vote.php

示例8: output

 public static function output($status = 'success', $message = '', $data = array())
 {
     $output = (object) array('status' => $status, 'message' => $message, 'data' => $data);
     $response = \Request::active()->controller_instance->response;
     if (\Input::is_ajax()) {
         $response->set_header('Content-type', 'application/json');
     }
     return $response->body(json_encode($output));
 }
开发者ID:ClixLtd,项目名称:pccupload,代码行数:9,代码来源:json.php

示例9: action_parse_info_table

 /**
  * Parse info tab content
  * 
  * @param $table = Table to parse
  */
 public function action_parse_info_table($table = false)
 {
     if (\Input::is_ajax()) {
         $table = \Input::post('table', '');
         echo $this->parse_info_table($table);
     }
     if (\Request::is_hmvc()) {
         echo $this->parse_info_table($table);
     }
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:15,代码来源:infotab.php

示例10: post_is_unique

 public function post_is_unique()
 {
     if (Input::is_ajax()) {
         //            $this->format = 'json';
         $username = Input::post('username');
         $username = Model_User::query()->where('email', $username)->get_one();
         if ($username === null) {
             return $this->response(array('unique' => true));
         }
         return $this->response(array('unique' => false));
     }
     return false;
 }
开发者ID:daniel-rodas,项目名称:rodasnet.com,代码行数:13,代码来源:user.php

示例11: action_ajax_test_ftp

 public function action_ajax_test_ftp()
 {
     // is ajax
     if (!\Input::is_ajax()) {
         \Response::redirect(\Uri::create('admin'));
     }
     // check permission
     if (\Model_AccountLevelPermission::checkAdminPermission('config_global', 'config_global') == false) {
         \Session::set_flash('form_status', array('form_status' => 'error', 'form_status_message' => \Lang::get('admin_permission_denied', array('page' => \Uri::string()))));
         return null;
     }
     if (\Input::method() == 'POST') {
         // get post value and test connection
         $config['hostname'] = trim(\Input::post('hostname'));
         $config['username'] = trim(\Input::post('username'));
         $config['password'] = trim(\Input::post('password'));
         $config['port'] = (int) trim(\Input::post('port'));
         $config['passive'] = trim(\Input::post('passive')) == 'true' ? true : false;
         $config['ssl_mode'] = false;
         $config['debug'] = false;
         $basepath = trim(\Input::post('basepath'));
         // connect to ftp
         $ftp = \Ftp::forge($config);
         $ftp->connect();
         $ftp->change_dir($basepath);
         $files = $ftp->list_files();
         $ftp->close();
         $output = array();
         if ($files !== false) {
             $output['form_status'] = 'success';
             $output['form_status_message'] = \Lang::get('config_ftp_connected_check_basepath_from_dir_structure_below');
             natsort($files);
             $output['list_files'] = '<ul>';
             foreach ($files as $file) {
                 $output['list_files'] .= '<li>' . $file . '</li>';
             }
             $output['list_files'] .= '</ul>';
         } else {
             // got false from list_files means cannot connect
             $output['form_status'] = 'error';
             $output['form_status_message'] = \Lang::get('config_ftp_could_not_connect_to_server');
         }
         // clear no use variables
         unset($basepath, $config, $file, $files, $ftp);
         // send out json values
         $response = new \Response();
         $response->set_header('Content-Type', 'application/json');
         $response->body(json_encode($output));
         return $response;
     }
 }
开发者ID:rundiz,项目名称:fuel-start,代码行数:51,代码来源:config.php

示例12: action_menus

 public function action_menus()
 {
     $params = array('title' => "菜单项", 'menu' => 'wechat-menu', 'action_name' => "自定义菜单");
     $account = \Model_WXAccount::find(\Session::get('WXAccount')->id);
     if (!$account) {
         if (\Input::is_ajax()) {
             die(json_encode(array('status' => 'err', 'msg' => '您还未绑定有效公众帐户', 'errcode' => 10)));
         }
         die('您还未绑定有效公众帐户');
     }
     $params['items'] = isset($account->menu) && $account->menu ? json_decode($account->menu) : '';
     \View::set_global($params);
     return \View::forge("ace/mp/coustom_menu/moblie");
 }
开发者ID:wxl2012,项目名称:wx,代码行数:14,代码来源:function.php

示例13: action_index

 /**
  * The index action
  * 
  * @access public
  * @return void
  */
 public function action_index()
 {
     $settings = \Config::load('backup.db');
     if (\Input::post()) {
         $input = \Input::post();
         if (!\Input::is_ajax()) {
             $val = Model_Backup::validate('create');
             if (!$val->run()) {
                 if ($val->error() != array()) {
                     // show validation errors
                     \Messages::error('<strong>There was an error while trying to create settings</strong>');
                     foreach ($val->error() as $e) {
                         \Messages::error($e->get_message());
                     }
                 }
             } else {
                 try {
                     \Config::save('backup.db', array('enable' => $input['enable'], 'email' => $input['email'], 'period' => $input['period']));
                     //save cronjob
                     $output = shell_exec('crontab -l');
                     $db_backup_cron_file = "/tmp/db_backup_cron.txt";
                     if ($input['enable']) {
                         if ($input['period'] == 'daily') {
                             $daily_backup_command = '0 0 * * * wget ' . \Uri::create('backup/execute');
                             file_put_contents($db_backup_cron_file, $daily_backup_command . PHP_EOL);
                         } else {
                             if ($input['period'] == 'weekly') {
                                 $weekly_backup_command = '0 0 * * 0 wget ' . \Uri::create('backup/execute');
                                 file_put_contents($db_backup_cron_file, $weekly_backup_command . PHP_EOL);
                             }
                         }
                     } else {
                         file_put_contents($db_backup_cron_file, "" . PHP_EOL);
                     }
                     exec("crontab {$db_backup_cron_file}");
                     \Messages::success('Settings successfully created.');
                     \Response::redirect('admin/backup');
                 } catch (\Database_Exception $e) {
                     // show validation errors
                     \Messages::error('<strong>There was an error while trying to create settings.</strong>');
                     // Uncomment lines below to show database errors
                     $errors = $e->getMessage();
                     \Messages::error($errors);
                 }
             }
         }
     }
     \View::set_global('title', 'Backup');
     \Theme::instance()->set_partial('content', $this->view_dir . 'index')->set('settings', $settings, false);
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:56,代码来源:backup.php

示例14: after

 /**
  * After controller method has run, render the theme template
  *
  * @param  Response  $response
  */
 public function after($response)
 {
     if (!\Input::is_ajax()) {
         // If nothing was returned set the theme instance as the response
         if (empty($response)) {
             $response = \Response::forge(\Theme::instance());
         }
         if (!$response instanceof Response) {
             $response = \Response::forge($response);
         }
         return $response;
     }
     return parent::after($response);
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:19,代码来源:template.php

示例15: action_index

 /**
  * Returns a list of event agenda items.
  * The method is mainly intended to be called using ajax
  * in this case, a json-formated string is returned.
  * @param int $event_id
  */
 public function action_index($event_id = null)
 {
     !isset($event_id) and Response::redirect("event");
     $event = Model_Orm_Event::find($event_id, array("related" => array("agendas")));
     !isset($event) and Response::redirect("event");
     if (Input::is_ajax()) {
         $response = Response::forge(Format::forge()->to_json($event->agendas));
         $response->set_header("Content-Type", "application/json");
         return $response;
     } else {
         $data['event'] = $event;
         $this->template->title = "Agenda items: " . $event->title;
         $this->template->content = View::forge('agenda/index', $data);
     }
 }
开发者ID:beingsane,项目名称:TTII_2012,代码行数:21,代码来源:agenda.php


注:本文中的Input::is_ajax方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。