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


PHP Request::instance方法代码示例

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


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

示例1: action_edit

 public function action_edit($role_id = 0)
 {
     $role_id = intval($role_id);
     if ($role_id <= 0) {
         Request::instance()->redirect('/admin/role/index');
     }
     $role = BLL_Role::getById($role_id);
     if (!$role) {
         Request::instance()->redirect('/admin/role/index');
     }
     $data = array();
     if (Request::$method == "POST") {
         if (intval($_POST['role_id']) != $role_id) {
             Request::instance()->redirect('/admin/role/index');
         }
         $post = $role->validate_update($_POST);
         if ($post->check()) {
             $post_values = $post->as_array();
             $role->name = $post_values['name'];
             $role->description = $post_values['description'];
             $role->save();
             Request::instance()->redirect('/admin/role/index');
         } else {
             $_POST = $post->as_array();
             $data['errors'] = $post->errors('admin/role/form');
         }
     }
     $this->template->title = __("Sửa nhóm tài khoản");
     $this->template->section_title = __("Sửa nhóm tài khoản");
     $data['role'] = $role;
     $this->template->content = View::factory('admin/role/edit', $data);
 }
开发者ID:abdul-baten,项目名称:hbcms,代码行数:32,代码来源:role.php

示例2: createFirstUser

 public function createFirstUser()
 {
     $request = \Request::instance();
     $method = $request->method();
     if (Verbs::GET === $method) {
         if (!User::adminExists()) {
             $data = ['version' => \Config::get('df.api_version'), 'email' => '', 'name' => '', 'first_name' => '', 'last_name' => ''];
             return view('firstUser', $data);
         } else {
             return redirect()->to('/');
         }
     } else {
         if (Verbs::POST === $method) {
             $data = $request->all();
             $registrar = new Registrar();
             $validator = $registrar->validator($data);
             if ($validator->fails()) {
                 $errors = $validator->getMessageBag()->all();
                 $data = array_merge($data, ['errors' => $errors, 'version' => \Config::get('df.api_version')]);
                 return view('firstUser', $data);
             } else {
                 $registrar->create($data);
                 return redirect()->to('/');
             }
         }
     }
 }
开发者ID:sadiq7753,项目名称:dreamfactory,代码行数:27,代码来源:SplashController.php

示例3: action_add_to_controller

 public function action_add_to_controller($controller_id)
 {
     $data = array();
     $this->template->title = 'Manage action in Controller';
     $data['controller'] = $controller = Model_SysController::getSysControllerToArray($controller_id);
     if ($_POST) {
         $_sysA = new Model_Action();
         $post = $_sysA->validate_create($_POST);
         if ($post->check()) {
             //$_sysA->values($post);
             $_post = $post->as_array();
             unset($post);
             $_sysA->name = $_post['name'];
             $_sysA->description = $_post['description'];
             //$controller = new Model_SysController($controlder_id);
             $_sysA->controller = $controller;
             $_sysA->save();
             Request::instance()->redirect('sysaction/in_controller/' . $controller_id);
         } else {
             $data['errors'] = $post->errors('sysaction/add_to_controller/' . $controller_id);
             #Repopulate $_POST data
             $_POST = $post->as_array();
         }
     }
     $view = View::factory('racl/sysaction/add_to_controller', $data);
     $this->template->content = $view->render();
 }
开发者ID:abdul-baten,项目名称:hbcms,代码行数:27,代码来源:sysaction.php

示例4: getInstance

 public static function getInstance()
 {
     if (self::$instance === false) {
         self::$instance = new Request();
     }
     return self::$instance;
 }
开发者ID:rasstroen,项目名称:vkontakte,代码行数:7,代码来源:Request.php

示例5: parse

 public static function parse()
 {
     $resources = Config::get('resource');
     $resource = null;
     $resource_uri = parse_url($_SERVER['REQUEST_URI']);
     $resource_uri = str_replace('/index.php', '', $resource_uri['path']);
     $request = Request::instance();
     foreach ($resources as $key => $val) {
         preg_match('#' . $key . '#', $resource_uri, $matches);
         if (!empty($matches[0])) {
             $resource = $val;
             foreach ($matches as $k => $match) {
                 if (!is_int($k)) {
                     $request->set_data($k, $match);
                 }
             }
             break;
         }
     }
     if (!empty($resource)) {
         require_once RESOURCE_PATH . $resource . '.php';
     } else {
         throw new Route_Exception('resource not found: ' . $resource_uri);
     }
     return $resource;
 }
开发者ID:sxhao,项目名称:resty-1,代码行数:26,代码来源:route.php

示例6: getInstance

 static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new Request();
     }
     return self::$instance;
 }
开发者ID:NaszvadiG,项目名称:DivaSul,代码行数:7,代码来源:Request.php

示例7: getInstance

 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new Request();
     }
     return self::$instance;
 }
开发者ID:educask,项目名称:EducaskCore,代码行数:7,代码来源:Request.php

示例8: action_add

 public function action_add()
 {
     $this->template->title = 'Add Role';
     //print_r($data['roles']);
     $data = array();
     if ($_POST) {
         $role = new Model_Role();
         $post = $role->validate_create($_POST);
         if ($post->check()) {
             $values = $post->as_array();
             unset($post);
             $role->name = $values['name'];
             $role->description = $values['description'];
             $role->save();
             Request::instance()->redirect('role/index');
         } else {
             #Get errors for display in view
             $data['errors'] = $post->errors('racl/role/add', TRUE);
             #Repopulate $_POST data
             $_POST = $post->as_array();
         }
     }
     //
     $this->template->content = View::factory('racl/role/add', $data);
 }
开发者ID:abdul-baten,项目名称:hbcms,代码行数:25,代码来源:role.php

示例9: addAward

 private function addAward()
 {
     $success = true;
     $errors = array();
     $data = Arr::merge($this->sanitize($_POST), $_FILES);
     Upload::$default_directory = Kohana::config('myshot.basePath');
     if ($stage_path = Upload::save($data['photo'])) {
         $award = $this->site->createAward($this->sanitize($data['name']), $data);
         foreach ($this->site->imageTypes as $imageType) {
             $name = $imageType->name;
             if ($name == self::FULL) {
                 Library_Akamai::factory()->addToDir($stage_path, Kohana::config('akamai.honordir'));
                 $award->addImage(self::FULL, $this->webPath($stage_path));
             } else {
                 if (ImageTypes::types()->{$name}) {
                     $resized = $this->resizeHonor($stage_path, ImageTypes::types()->{$name}->size);
                     $award->addImage($name, $this->webPath($resized));
                 }
             }
         }
     } else {
         $success = false;
         $errors[] = "Image failed to load.";
     }
     if ($success) {
         Message::set(Message::SUCCESS, 'You have successfully added an award.');
         Request::instance()->redirect('admin/awards');
     } else {
         Message::set(Message::ERROR, Arr::flatten($errors));
     }
 }
开发者ID:natgeo,项目名称:kids-myshot,代码行数:31,代码来源:awards.php

示例10: action_create

 public function action_create()
 {
     $this->template->title = __("Thêm mới kênh truyền hình");
     $this->template->section_title = __("Thêm mới kênh truyền hình");
     $data = array();
     if (Request::$method == "POST") {
         $channel = new LichTruyenHinh();
         $post = $channel->validate_create($_POST);
         if ($post->check()) {
             $post = $post->as_array();
             $channel->user_id = Auth::instance()->get_user()->id;
             $channel->channel_name = $post['channel_name'];
             $channel->active = true;
             $channel->slug = $post['slug'];
             $channel->meta_keys = $post['meta_keys'];
             $channel->meta_desc = $post['meta_desc'];
             $channel->xml_uri = $post['xml_uri'];
             $channel->created_at = date("Y-m-d h:i:s");
             $channel->save();
             Message::success('Thêm mới kênh truyền hình thành công!');
             Request::instance()->redirect('/admin/lichtruyenhinh/index');
         } else {
             $_POST = $post->as_array();
             $data['errors'] = $post->errors();
         }
     }
     //        $categories = TruyenCuoiCategory::bll()->getCatById_WithStoryCount();
     //        $data['categories'] = $categories;
     $this->template->content = View::factory('/admin/lichtruyenhinh/create', $data);
 }
开发者ID:abdul-baten,项目名称:hbcms,代码行数:30,代码来源:lichtruyenhinh.php

示例11: initialize

 public static function initialize($path)
 {
     Config::setPath($path . 'config/');
     self::$request = Request::instance();
     self::$config = Config::instance();
     self::$store = Store::instance();
 }
开发者ID:erkie,项目名称:cowl,代码行数:7,代码来源:current.php

示例12: action_authorize

 public function action_authorize()
 {
     if ($this->token and $this->token->token !== Arr::get($_GET, 'oauth_token')) {
         // Delete the token, it is not valid
         Cookie::delete($this->cookie);
         // Send the user back to the beginning
         Request::instance()->redirect($this->request->uri(array('action' => 'index')));
     }
     // Get the verifier
     $verifier = Arr::get($_GET, 'oauth_verifier');
     // Store the verifier in the token
     $this->token->verifier($verifier);
     // Exchange the request token for an access token
     $this->token = $this->provider->access_token($this->consumer, $this->token);
     // Store the access token
     Cookie::set($this->cookie, serialize($this->token));
     // At this point, we need to retrieve a unique twitter id for the user.
     $response = OAuth_Request::factory('resource', 'GET', 'http://api.twitter.com/1/account/verify_credentials.json')->param('oauth_consumer_key', Kohana::config('oauth.twitter.key'))->param('oauth_token', $this->token)->sign(OAuth_Signature::factory('HMAC-SHA1'), $this->consumer, $this->token)->execute();
     $response = json_decode($response);
     $twitter_id = $response->screen_name;
     $user = ORM::factory('user')->where('username', '=', $twitter_id)->find();
     !$user->id and Request::instance()->redirect('/auth/confirm?id=' . $twitter_id);
     Auth::instance()->force_login($user);
     Session::instance()->set('notification', 'Succesfully logged in.');
     Request::instance()->redirect('/');
 }
开发者ID:badsyntax,项目名称:2do,代码行数:26,代码来源:oauth.php

示例13: render

 public static function render(array $vars = array(), array $globals = array(), $file = false, array $options = array())
 {
     if (isset($vars['_data'])) {
         $data = $vars['_data'];
     } else {
         $data = array();
         $config = Kohana::config('render');
         $expose = isset($config['json_expose']) ? $config['json_expose'] : (isset($config['expose']) ? $config['expose'] : array());
         foreach ($expose as $var) {
             if (isset($vars[$var])) {
                 $data[$var] = $vars[$var];
             }
         }
     }
     if (empty($vars['_no_header']) && (!empty(Request::$is_ajax) || !empty($vars['_force_header']))) {
         // only send json if it is an XMLHttpRequest (subject to overrides)
         Request::instance()->headers['Content-Type'] = 'application/json';
         $result = json_encode($data);
     } elseif (empty($vars['_plain'])) {
         // if we are sending it as HTML we probably want this
         $result = htmlspecialchars(json_encode($data));
     } else {
         // unless we are sure!
         $result = json_encode($data);
     }
     return $result;
 }
开发者ID:pg7812,项目名称:kohana-module-smarty,代码行数:27,代码来源:json.php

示例14: action_categories

 public function action_categories()
 {
     // Get the category model
     $categories = Jelly::select('category');
     /*
      * If the route is something like this: categories/alias-of-category/2, 
      *	 then we know that we're accessing the children of "alias-of-category" but display is limited to 2 levels only
      */
     $category = $this->request->param('category', NULL);
     $category = Jelly::select('category', $category);
     $limit = $this->request->param('limit', $this->params->get('maxLevel', -1));
     if ($category->loaded()) {
         // Get the children of the category
         $categories->where('parent_id', '=', $category->id);
     } else {
         // Just get all the 1st Level Categories
         $categories->where('level', '=', 1);
     }
     // Set the result in the View
     $items = View::factory('categories/list')->set('categories', $categories->execute())->set('limit', $limit)->set('level', 1)->render();
     // If this is an internal HMVC call, then we don't need to display the template which displays the headings
     if (Request::instance() !== Request::current()) {
         $this->request->response = $items;
         return;
     }
     // Combine the 2 views, this view loads the Title and Description, then inserts the previous view "items" above
     $this->request->response = View::factory('categories/template')->set('items', $items)->set('page_heading', $this->params->get('page_title'))->render();
 }
开发者ID:raeldc,项目名称:kojo-klinks,代码行数:28,代码来源:links.php

示例15: Request

 /**
  * Singleton initiator
  *
  * @return Request
  */
 public static function &getInstance()
 {
     if (empty(self::$instance)) {
         self::$instance = new Request();
     }
     return self::$instance;
 }
开发者ID:b3cft,项目名称:camra_nbss,代码行数:12,代码来源:Request.class.php


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