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


PHP request::is_ajax方法代码示例

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


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

示例1: auth

 public function auth()
 {
     if (!identity::active_user()->admin) {
         access::forbidden();
     }
     access::verify_csrf();
     $form = self::_form();
     $valid = $form->validate();
     $user = identity::active_user();
     if ($valid) {
         module::event("user_auth", $user);
         if (!request::is_ajax()) {
             message::success(t("Successfully re-authenticated!"));
         }
         url::redirect(Session::instance()->get_once("continue_url"));
     } else {
         $name = $user->name;
         log::warning("user", t("Failed re-authentication for %name", array("name" => $name)));
         module::event("user_auth_failed", $name);
         if (request::is_ajax()) {
             $v = new View("reauthenticate.html");
             $v->form = $form;
             $v->user_name = identity::active_user()->name;
             json::reply(array("html" => (string) $v));
         } else {
             self::_show_form($form);
         }
     }
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:29,代码来源:reauthenticate.php

示例2: __construct

 public function __construct()
 {
     parent::__construct();
     if (request::is_ajax()) {
         $this->template = new View('blank');
     }
 }
开发者ID:peebeebee,项目名称:Simple-Photo-Gallery,代码行数:7,代码来源:photo_website.php

示例3: index

 /**
  * Show shouts or shout
  */
 public function index()
 {
     $shout = new Shout_Model();
     $form_values = $shout->as_array();
     $form_errors = array();
     // Check post
     if (csrf::valid() && ($post = $this->input->post())) {
         $shout->author_id = $this->user->id;
         $shout->shout = $post['shout'];
         try {
             $shout->save();
             if (!request::is_ajax()) {
                 url::redirect(url::current());
             }
         } catch (ORM_Validation_Exception $e) {
             $form_errors = $e->validation->errors();
             $form_values = arr::overwrite($form_values, $post);
         }
     }
     $shouts = ORM::factory('shout')->find_all(10);
     $view = View_Mod::factory('generic/shout', array('mod_title' => __('Shouts'), 'shouts' => $shouts, 'can_shout' => ORM::factory('shout')->has_access(Shout_Model::ACCESS_WRITE, $this->user), 'errors' => $form_errors, 'values' => $form_values));
     if (request::is_ajax()) {
         echo $view;
         return;
     }
     widget::add('main', $view);
 }
开发者ID:anqqa,项目名称:Anqh,代码行数:30,代码来源:shout.php

示例4: __construct

 /**
  * Template loading and setup routine.
  */
 public function __construct()
 {
     parent::__construct();
     // checke request is ajax
     $this->ajax_request = request::is_ajax();
     // Load the template
     $this->template = new View($this->template);
     if ($this->auto_render == TRUE) {
         Event::add('system.post_controller', array($this, '_render'));
     }
     /**
      * 判断用户登录情况
      */
     if (isset($_REQUEST['session_id'])) {
         $session = Session::instance($_REQUEST['session_id']);
         $manager = role::get_manager($_REQUEST['session_id']);
     } else {
         $session = Session::instance();
         $manager = role::get_manager();
     }
     /* 当前请求的URL */
     $current_url = urlencode(url::current(TRUE));
     //当前用户管理的站点的ID
     $this->site_id = site::id();
 }
开发者ID:RenzcPHP,项目名称:3dproduct,代码行数:28,代码来源:kc_template.php

示例5: profile_pic

 public function profile_pic()
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $client_id = $this->auth->get_user()->id;
         //print_r($_FILES['profile-image']);exit;
         if (!empty($_FILES['profile-image']['name'])) {
             $tempFile = $_FILES["profile-image"]["tmp_name"];
             $filename = $_FILES["profile-image"]["name"];
             $targetPath = 'assets/uploads/';
             $temp = explode(".", $filename);
             $extension = end($temp);
             if (!is_dir($targetPath)) {
                 mkdir($targetPath, 0700);
                 $salt = 'user-' . $client_id . '-' . uniqid() . '-';
                 $targetFile = $targetPath . $salt . $filename;
                 $file_data_name = array("name" => $filename, "location" => $targetPath, "extension" => $extension);
                 $this->start_upload($targetFile, $tempFile);
                 $json = json_encode($file_data_name, TRUE);
             } else {
                 $salt = 'user-' . $client_id . '-' . uniqid() . '-';
                 $targetFile = $targetPath . $salt . $filename;
                 $file_data_name = array("name" => $filename, "location" => $targetFile, "extension" => $extension);
                 $this->start_upload($targetFile, $tempFile);
                 $json = json_encode($file_data_name, TRUE);
             }
         } else {
             $json = $this->auth->get_user()->user_avatar;
         }
         $data_profile_pic = array("user_avatar" => $json);
         log_helper::add("2", $this->user_log, $this->user_id, "Profile Picture was Successfully Updated");
         $this->setting_model->update_user($this->auth->get_user()->id, $data_profile_pic);
     }
 }
开发者ID:humbleBeginner,项目名称:inventory-pho2,代码行数:34,代码来源:profile.php

示例6: __construct

 public function __construct()
 {
     parent::__construct();
     //$this->session = Session::instance();
     //$this->auth = new Auth;
     // Check to see if the request is a HXR call
     if (request::is_ajax()) {
         // Send the 403 header
         header('HTTP/1.1 403 Forbidden');
         //$t = new View('blank');
         return;
     }
     /*
     		if (Kohana::config_load('cw', true))
     			$this->cfg  = Kohana::config('cw');
     */
     /*		if (IN_PRODUCTION === FALSE)
     		{
     			$this->profiler = new Profiler;
     		}*/
     $t =& $this->template;
     $t->header = new View('components/header');
     $t->footer = new View('components/footer');
     //$this->db = Database::instance();
 }
开发者ID:holandacz,项目名称:nb4,代码行数:25,代码来源:mywebsite.php

示例7: delete_template

 public function delete_template()
 {
     if (request::is_ajax()) {
         $this->auto_render = false;
         $this->dstemplate_model->deleteTemplate($this->input->post('id'));
     }
 }
开发者ID:steamboy,项目名称:ds,代码行数:7,代码来源:dstemplate.php

示例8: __construct

 public function __construct()
 {
     parent::__construct();
     $this->template->title = 'Kohana Forum';
     # configure filters.
     $url_array = $this->uri->segment_array();
     $this->action = empty($url_array['2']) ? 'category' : $url_array['2'];
     $this->filter = isset($url_array['3']) ? $url_array['3'] : '';
     $this->filter2 = isset($url_array['4']) ? $url_array['4'] : '';
     # configure sorters.
     $this->sort = isset($_GET['sort']) ? $_GET['sort'] : 'newest';
     $this->sort_by = (empty($_GET['sort']) or 'votes' == $_GET['sort']) ? 'vote_count' : 'created';
     $this->order = (empty($_GET['sort']) or 'oldest' != $_GET['sort']) ? 'desc' : 'asc';
     /*
      * Notes:
      * We make everything run through _index or _ajax
      * because it's easier to delegate modular functionality
      * based on whether a request is ajax or not.
      * mapping publically (i.e. site.com/controller/method)
      * would mean we'd have to have ajax/non-ajax logic within each method
      * which i think is harder to maintain and read.
      */
     # handle ajax requests of course =0
     if (request::is_ajax()) {
         die($this->_ajax());
     }
     # handle non-ajax.
     die($this->_index());
 }
开发者ID:plusjade,项目名称:kohana-fizzle,代码行数:29,代码来源:forum.php

示例9: index

 /**
  * Used to display the index page but also uses a jquery and the pagination to do preload of next pages
  * of the news articles. Which are then displaye don scroll 
  * @param integer $page the page number  (Matt are you sure this is needed, the pagination is smart enough not to need this). 
  */
 public function index($page = 1)
 {
     $total = orm::factory('news')->where('group', 'site')->where('status', 'approved')->count_all();
     $paging = new Pagination(array('total_items' => $total, 'items_per_page' => 3));
     $articles = orm::factory('news')->where('group', 'site')->where('status', 'approved')->find_all($paging->items_per_page, $paging->sql_offset);
     $view = new View(url::location());
     $view->articles = $articles;
     $view->pagination = $paging->render();
     $view->page_number = $paging->page_number();
     // If the request is an ajax request, then the page is attempting to autoupdate
     // the items with in the news, so just send through the news items.
     if (request::is_ajax()) {
         // if the ajax is attempting to get a page which doesnt exist, send 404
         if ($page > $paging->total_pages) {
             Event::run('system.404');
         } else {
             $this->ajax['view'] = $view;
         }
     } else {
         // otherwise its a http request, send throught he entire page with template.
         $this->template->title = 'About Us › News & Updates Archive';
         $this->breadcrumbs->add()->url(false)->title('Archive');
         $view->breadcrumbs = $this->breadcrumbs->cut();
         $this->template->content = $view;
     }
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:31,代码来源:archive.php

示例10: __construct

 /**
  * Template loading and setup routine.
  */
 public function __construct()
 {
     parent::__construct();
     $this->obj_session = Session::instance();
     $this->obj_user_lib = User::instance();
     // checke request is ajax
     $this->ajax_request = request::is_ajax();
     if ($this->auto_render == TRUE) {
         Event::add('system.post_controller', array($this, '_render'));
     }
     //$session = Session::instance();
     $user = array();
     $user = $this->obj_session->get('USER');
     //var_dump($_SESSION);
     if (!empty($user)) {
         $this->_user = $this->obj_user_lib->get_user_by_uid($user['id']);
     }
     unset($user);
     $data = array();
     $data['site_config'] = Kohana::config('site_config.site');
     $host = $_SERVER['HTTP_HOST'];
     $dis_site_config = Kohana::config('distribution_site_config');
     if (array_key_exists($host, $dis_site_config) == true && isset($dis_site_config[$host])) {
         $data['site_config']['site_title'] = $dis_site_config[$host]['site_name'];
         $data['site_config']['keywords'] = $dis_site_config[$host]['keywords'];
         $data['site_config']['description'] = $dis_site_config[$host]['description'];
     }
     $this->_site_config = $data;
 }
开发者ID:RenzcPHP,项目名称:3dproduct,代码行数:32,代码来源:template.php

示例11: is_allowed

 public static function is_allowed($permission = 'default', $site_id = 0, $type = NULL)
 {
     $verify = true;
     $site_ids = role::get_site_ids($type);
     //超级管理员root不需要检查权限 zhu modify
     if (role::is_root()) {
         $verify = true;
     } else {
         if ($site_id > 0 && !in_array($site_id, $site_ids)) {
             $verify = false;
         }
         $acl = Session::instance()->get(self::$acl_tag);
         if ($acl) {
             $acl = unserialize($acl);
         } else {
             $acl = self::acl_init();
         }
         $manager = role::get_manager();
         $verify = $acl->is_allowed($manager["username"], $permission);
     }
     //验证操作
     if ($verify) {
         return $site_ids;
     } else {
         if (request::is_ajax()) {
             $return_struct = array('status' => 0, 'code' => 501, 'msg' => Kohana::lang('o_global.access_denied'), 'content' => array());
             die(json_encode($return_struct));
         } else {
             $referrer = tool::referrer_url();
             remind::set('权限不足', $referrer, 'error');
         }
     }
 }
开发者ID:RenzcPHP,项目名称:3dproduct,代码行数:33,代码来源:acltool.php

示例12: __construct

 /**
  * constructor; set display template
  *
  * @author Andy Bennett
  */
 function __construct()
 {
     Acl::instance()->redirect(Steamauth::instance()->get_role(), 'edit', null, '../');
     parent::__construct();
     parent::init();
     $tpl = request::is_ajax() || isset($_GET['ajax']) ? 'template-ajax' : 'template-admin';
     Display::instance()->set_template($tpl);
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:13,代码来源:tree.php

示例13: http_auth_prompt_login

 /**
  * Sends an HTTP AUTH prompt.
  *
  * @return void
  */
 public function http_auth_prompt_login()
 {
     header('HTTP/1.0 401 Unauthorized');
     // Avoid popping login box for ajax requests
     if (!request::is_ajax()) {
         header('WWW-Authenticate: Basic realm="Ushahidi API"');
     }
 }
开发者ID:Dirichi,项目名称:Ushahidi_Web,代码行数:13,代码来源:MY_Auth.php

示例14: getOne

 public function getOne()
 {
     if (request::is_ajax() and request::method() == 'get') {
         $this->auto_render = FALSE;
         $setting = $this->setting_model->getOne();
         echo json_encode($setting);
     }
 }
开发者ID:humbleBeginner,项目名称:inventory-pho2,代码行数:8,代码来源:settings.php

示例15: _prompt_for_reauth

 private static function _prompt_for_reauth($controller_name, $args)
 {
     if (request::method() == "get" && !request::is_ajax()) {
         // Avoid anti-phishing protection by passing the url as session variable.
         Session::instance()->set("continue_url", url::current(true));
     }
     url::redirect("reauthenticate");
 }
开发者ID:andyst,项目名称:gallery3,代码行数:8,代码来源:admin.php


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