Welcome Guest, Not a member yet? Register   Sign In
Suggest to add some code to input lib
#1

[eluser]Unknown[/eluser]
Here is code that maybe added to CI (line numbers for CI v1.7):

From 34 line:
Code:
var $request_method        = FALSE;
    var $is_post              = FALSE;

From 447 line:
Code:
// --------------------------------------------------------------------
    /**
     * Request method
     *
     * @access    public
     * @return    string
     */
    function request_method()
    {
        if ($this->request_method !== FALSE)
        {
            return $this->request_method;
        }

        $this->request_method = ( ! isset($_SERVER['REQUEST_METHOD'])) ? FALSE : $_SERVER['REQUEST_METHOD'];

        return $this->request_method;
    }
    
    // --------------------------------------------------------------------
    /**
     * Is post
     *
     * @access    public
     * @return    boolean
     */
    function is_post()
    {
        if ($this->is_post !== FALSE)
        {
            return $this->is_post;
        }

      $m = $this->request_method();
        if ($m !== FALSE)
        {
            $this->is_post = (strtolower($m) == 'post' ? TRUE : FALSE);
        }
        
    return $this->is_post;
    }
#2

[eluser]Colin Williams[/eluser]
Hrm.. for request method, you could just do $this->input->server('REQUEST_METHOD');
#3

[eluser]trice22[/eluser]
Thanks! —That's not a bad idea IMO. But why not extend CI's input class?
—trice
#4

[eluser]Unknown[/eluser]
[quote author="Colin Williams" date="1233115776"]Hrm.. for request method, you could just do $this->input->server('REQUEST_METHOD');[/quote]

Idea was to write this:

Code:
if($this->input->is_post() === TRUE) {
  //do this all waht you need only on post, like validation and show next screen for example
}

instead:

Code:
if (strtolower($this->input->server(‘REQUEST_METHOD’)) == 'post') {
  //......
}

What easier to use and find in docs?




Theme © iAndrew 2016 - Forum software by © MyBB