PHP 클래스 Prado\Web\THttpRequest

THttpRequest provides storage and access scheme for user request sent via HTTP. It also encapsulates a uniform way to parse and construct URLs. User post data can be retrieved from THttpRequest by using it like an associative array. For example, to test if a user supplies a variable named 'param1', you can use, if(isset($request['param1'])) ... equivalent to: if($request->contains('param1')) ... To get the value of 'param1', use, $value=$request['param1']; equivalent to: $value=$request->itemAt('param1'); To traverse the user post data, use foreach($request as $name=>$value) ... Note, POST and GET variables are merged together in THttpRequest. If a variable name appears in both POST and GET data, then POST data takes precedence. To construct a URL that can be recognized by Prado, use {@link constructUrl()}. The format of the recognizable URLs is determined according to {@link setUrlManager UrlManager}. By default, the following two formats are recognized: index.php?ServiceID=ServiceParameter&Name1=Value1&Name2=Value2 index.php/ServiceID,ServiceParameter/Name1,Value1/Name2,Value2 The first format is called 'Get' while the second 'Path', which is specified via {@link setUrlFormat UrlFormat}. For advanced users who want to use their own URL formats, they can write customized URL management modules and install the managers as application modules and set {@link setUrlManager UrlManager}. The ServiceID in the above URLs is as defined in the application configuration (e.g. the default page service's service ID is 'page'). As a consequence, your GET variable names should not conflict with the service IDs that your application supports. THttpRequest also provides the cookies sent by the user, user information such as his browser capabilities, accepted languages, etc. By default, THttpRequest is registered with {@link TApplication} as the request module. It can be accessed via {@link TApplication::getRequest()}.
부터: 3.0
저자: Qiang Xue ([email protected])
상속: extends Prado\TApplicationComponent, implements IteratorAggregate, implements ArrayAccess, implements Countable, implements Prado\IModule
파일 보기 프로젝트 열기: pradosoft/prado 1 사용 예제들

공개 메소드들

메소드 설명
add ( $key, $value ) Adds an item into the request.
clear ( ) Removes all items in the request.
constructUrl ( $serviceID, $serviceParam, $getItems = null, $encodeAmpersand = true, $encodeGetItems = true ) : string Constructs a URL that can be recognized by PRADO.
contains ( $key ) : boolean
count ( ) : integer Returns the number of items in the request.
getAbsoluteApplicationUrl ( $forceSecureConnection = null ) : string
getAcceptTypes ( ) : string
getApplicationFilePath ( ) : string
getApplicationUrl ( ) : string
getBaseUrl ( $forceSecureConnection = null ) : string
getBrowser ( ) : array
getCgiFix ( ) : integer
getContentType ( boolean $mimetypeOnly = true ) : string
getCookies ( ) : THttpCookieCollection
getCount ( ) : integer
getEnableCache ( ) : boolean
getEnableCookieValidation ( ) : boolean
getEnvironmentVariables ( ) : array
getHeaders ( $case = null ) : array
getHttpProtocolVersion ( ) : string
getID ( ) : string
getIsSecureConnection ( ) : boolean
getIterator ( ) : Iterator Returns an iterator for traversing the items in the list.
getKeys ( ) : array
getPathInfo ( ) : string
getQueryString ( ) : string
getRequestResolved ( ) : boolean
getRequestType ( ) : string
getRequestUri ( ) : string
getServerName ( ) : string
getServerPort ( ) : integer
getServerVariables ( ) : array
getServiceID ( ) : string
getServiceParameter ( ) : string
getUploadedFiles ( ) : array
getUrl ( ) : TUri
getUrlFormat ( ) : THttpRequestUrlFormat
getUrlManager ( ) : string
getUrlManagerModule ( ) : TUrlManager
getUrlParamSeparator ( ) : string
getUrlReferrer ( ) : string
getUserAgent ( ) : string
getUserHost ( ) : string
getUserHostAddress ( ) : string
getUserLanguages ( ) : array Returns a list of user preferred languages.
init ( $config ) Initializes the module.
itemAt ( $key ) : mixed Returns the item with the specified key.
offsetExists ( $offset ) : boolean Returns whether there is an element at the specified offset.
offsetGet ( $offset ) : mixed Returns the element at the specified offset.
offsetSet ( $offset, $item ) Sets the element at the specified offset.
offsetUnset ( $offset ) Unsets the element at the specified offset.
remove ( $key ) : mixed Removes an item from the request by its key.
resolveRequest ( $serviceIDs ) : string Resolves the requested service.
setCgiFix ( $value ) Enable this, if you're using PHP via CGI with php.ini setting "cgi.fix_pathinfo=1" and have trouble with friendly URL feature. Enable this only if you really know what you are doing!
setEnableCache ( $value ) Set true to cache the UrlManager instance. Consider to enable this cache when the application defines a lot of TUrlMappingPatterns
setEnableCookieValidation ( $value )
setID ( $value )
setServiceID ( $value ) Sets the requested service ID.
setServiceParameter ( $value ) Sets the requested service parameter.
setUrlFormat ( $value ) Sets the format of URLs constructed and interpretted by the request module.
setUrlManager ( $value ) Sets the URL manager module.
setUrlParamSeparator ( $value )
stripSlashes ( &$data ) : mixed Strips slashes from input data.
toArray ( ) : array

보호된 메소드들

메소드 설명
cacheUrlManager ( $manager ) : boolean Saves the current UrlManager instance to cache.
getCacheKey ( )
loadCachedUrlManager ( ) : TUrlManager Loads UrlManager instance from cache.
parseUrl ( ) : array Parses the request URL and returns an array of input parameters (excluding GET variables).

메소드 상세

add() 공개 메소드

Note, if the specified key already exists, the old value will be overwritten.
public add ( $key, $value )

cacheUrlManager() 보호된 메소드

Saves the current UrlManager instance to cache.
protected cacheUrlManager ( $manager ) : boolean
리턴 boolean true if UrlManager instance was cached, false otherwise.

clear() 공개 메소드

Removes all items in the request.
public clear ( )

constructUrl() 공개 메소드

The actual construction work is done by the URL manager module. This method may append session information to the generated URL if needed. You may provide your own URL manager module by setting {@link setUrlManager UrlManager} to provide your own URL scheme. Note, the constructed URL does not contain the protocol and hostname part. You may obtain an absolute URL by prepending the constructed URL with {@link getBaseUrl BaseUrl}.
또한 보기: TUrlManager::constructUrl
public constructUrl ( $serviceID, $serviceParam, $getItems = null, $encodeAmpersand = true, $encodeGetItems = true ) : string
리턴 string URL

contains() 공개 메소드

public contains ( $key ) : boolean
리턴 boolean whether the request contains an item with the specified key

count() 공개 메소드

This method is required by \Countable interface.
public count ( ) : integer
리턴 integer number of items in the request.

getAbsoluteApplicationUrl() 공개 메소드

public getAbsoluteApplicationUrl ( $forceSecureConnection = null ) : string
리턴 string entry script URL (w/ host part)

getAcceptTypes() 공개 메소드

public getAcceptTypes ( ) : string
리턴 string user browser accept types

getApplicationFilePath() 공개 메소드

public getApplicationFilePath ( ) : string
리턴 string application entry script file path (processed w/ realpath())

getApplicationUrl() 공개 메소드

public getApplicationUrl ( ) : string
리턴 string entry script URL (w/o host part)

getBaseUrl() 공개 메소드

public getBaseUrl ( $forceSecureConnection = null ) : string
리턴 string schema and hostname of the requested URL

getBrowser() 공개 메소드

또한 보기: get_browser
public getBrowser ( ) : array
리턴 array user browser capabilities

getCacheKey() 보호된 메소드

protected getCacheKey ( )

getCgiFix() 공개 메소드

public getCgiFix ( ) : integer
리턴 integer whether to use ORIG_PATH_INFO and/or ORIG_SCRIPT_NAME. Defaults to 0.

getContentType() 공개 메소드

public getContentType ( boolean $mimetypeOnly = true ) : string
$mimetypeOnly boolean whether to return only the mimetype (default: true)
리턴 string content type (e.g. 'application/json' or 'text/html; encoding=gzip') or null if not specified

getCookies() 공개 메소드

public getCookies ( ) : THttpCookieCollection
리턴 THttpCookieCollection list of cookies to be sent

getCount() 공개 메소드

public getCount ( ) : integer
리턴 integer the number of items in the request

getEnableCache() 공개 메소드

public getEnableCache ( ) : boolean
리턴 boolean true if urlmanager instance should be cached, false otherwise.

getEnableCookieValidation() 공개 메소드

public getEnableCookieValidation ( ) : boolean
리턴 boolean whether cookies should be validated. Defaults to false.

getEnvironmentVariables() 공개 메소드

public getEnvironmentVariables ( ) : array
리턴 array list of environment variables.

getHeaders() 공개 메소드

public getHeaders ( $case = null ) : array
리턴 array

getHttpProtocolVersion() 공개 메소드

public getHttpProtocolVersion ( ) : string
리턴 string the requested http procolol. Blank string if not defined.

getID() 공개 메소드

public getID ( ) : string
리턴 string id of this module

getIsSecureConnection() 공개 메소드

public getIsSecureConnection ( ) : boolean
리턴 boolean if the request is sent via secure channel (https)

getIterator() 공개 메소드

This method is required by the interface \IteratorAggregate.
public getIterator ( ) : Iterator
리턴 Iterator an iterator for traversing the items in the list.

getKeys() 공개 메소드

public getKeys ( ) : array
리턴 array the key list

getPathInfo() 공개 메소드

public getPathInfo ( ) : string
리턴 string part of the request URL after script name and before question mark.

getQueryString() 공개 메소드

public getQueryString ( ) : string
리턴 string part of that request URL after the question mark

getRequestResolved() 공개 메소드

public getRequestResolved ( ) : boolean
리턴 boolean true if request is already resolved, false otherwise.

getRequestType() 공개 메소드

public getRequestType ( ) : string
리턴 string request type, can be GET, POST, HEAD, or PUT

getRequestUri() 공개 메소드

public getRequestUri ( ) : string
리턴 string part of that request URL after the host info (including pathinfo and query string)

getServerName() 공개 메소드

public getServerName ( ) : string
리턴 string server name

getServerPort() 공개 메소드

public getServerPort ( ) : integer
리턴 integer server port number

getServerVariables() 공개 메소드

public getServerVariables ( ) : array
리턴 array list of server variables.

getServiceID() 공개 메소드

public getServiceID ( ) : string
리턴 string requested service ID

getServiceParameter() 공개 메소드

public getServiceParameter ( ) : string
리턴 string requested service parameter

getUploadedFiles() 공개 메소드

public getUploadedFiles ( ) : array
리턴 array list of uploaded files.

getUrl() 공개 메소드

public getUrl ( ) : TUri
리턴 TUri the request URL

getUrlFormat() 공개 메소드

public getUrlFormat ( ) : THttpRequestUrlFormat
리턴 THttpRequestUrlFormat the format of URLs. Defaults to THttpRequestUrlFormat::Get.

getUrlManager() 공개 메소드

public getUrlManager ( ) : string
리턴 string the ID of the URL manager module

getUrlManagerModule() 공개 메소드

public getUrlManagerModule ( ) : TUrlManager
리턴 TUrlManager the URL manager module

getUrlParamSeparator() 공개 메소드

public getUrlParamSeparator ( ) : string
리턴 string separator used to separate GET variable name and value when URL format is Path. Defaults to comma ','.

getUrlReferrer() 공개 메소드

public getUrlReferrer ( ) : string
리턴 string URL referrer, null if not present

getUserAgent() 공개 메소드

public getUserAgent ( ) : string
리턴 string user agent

getUserHost() 공개 메소드

public getUserHost ( ) : string
리턴 string user host name, null if cannot be determined

getUserHostAddress() 공개 메소드

public getUserHostAddress ( ) : string
리턴 string user IP address

getUserLanguages() 공개 메소드

The languages are returned as an array. Each array element represents a single language preference. The languages are ordered according to user preferences. The first language is the most preferred.
public getUserLanguages ( ) : array
리턴 array list of user preferred languages.

init() 공개 메소드

This method is required by IModule and is invoked by application.
public init ( $config )

itemAt() 공개 메소드

This method is exactly the same as {@link offsetGet}.
public itemAt ( $key ) : mixed
리턴 mixed the element at the offset, null if no element is found at the offset

loadCachedUrlManager() 보호된 메소드

Loads UrlManager instance from cache.
protected loadCachedUrlManager ( ) : TUrlManager
리턴 TUrlManager intance if load was successful, null otherwise.

offsetExists() 공개 메소드

This method is required by the interface \ArrayAccess.
public offsetExists ( $offset ) : boolean
리턴 boolean

offsetGet() 공개 메소드

This method is required by the interface \ArrayAccess.
public offsetGet ( $offset ) : mixed
리턴 mixed the element at the offset, null if no element is found at the offset

offsetSet() 공개 메소드

This method is required by the interface \ArrayAccess.
public offsetSet ( $offset, $item )

offsetUnset() 공개 메소드

This method is required by the interface \ArrayAccess.
public offsetUnset ( $offset )

parseUrl() 보호된 메소드

You may override this method to support customized URL format.
또한 보기: TUrlManager::parseUrl
protected parseUrl ( ) : array
리턴 array list of input parameters, indexed by parameter names

remove() 공개 메소드

Removes an item from the request by its key.
public remove ( $key ) : mixed
리턴 mixed the removed value, null if no such key exists.

resolveRequest() 공개 메소드

This method implements a URL-based service resolution. A URL in the format of /index.php?sp=serviceID.serviceParameter will be resolved with the serviceID and the serviceParameter. You may override this method to provide your own way of service resolution.
또한 보기: constructUrl
public resolveRequest ( $serviceIDs ) : string
리턴 string the currently requested service ID, null if no service ID is found

setCgiFix() 공개 메소드

Enable this, if you're using PHP via CGI with php.ini setting "cgi.fix_pathinfo=1" and have trouble with friendly URL feature. Enable this only if you really know what you are doing!
public setCgiFix ( $value )

setEnableCache() 공개 메소드

Set true to cache the UrlManager instance. Consider to enable this cache when the application defines a lot of TUrlMappingPatterns
public setEnableCache ( $value )

setEnableCookieValidation() 공개 메소드

public setEnableCookieValidation ( $value )

setID() 공개 메소드

public setID ( $value )

setServiceID() 공개 메소드

Sets the requested service ID.
public setServiceID ( $value )

setServiceParameter() 공개 메소드

Sets the requested service parameter.
public setServiceParameter ( $value )

setUrlFormat() 공개 메소드

A Get URL format is like index.php?name1=value1&name2=value2 while a Path URL format is like index.php/name1,value1/name2,value. Changing the UrlFormat will affect {@link constructUrl} and how GET variables are parsed.
public setUrlFormat ( $value )

setUrlManager() 공개 메소드

By default, {@link TUrlManager} is used for managing URLs. You may specify a different module for URL managing tasks by loading it as an application module and setting this property with the module ID.
public setUrlManager ( $value )

setUrlParamSeparator() 공개 메소드

public setUrlParamSeparator ( $value )

stripSlashes() 공개 메소드

This method is applied when magic quotes is enabled.
public stripSlashes ( &$data ) : mixed
리턴 mixed processed data

toArray() 공개 메소드

public toArray ( ) : array
리턴 array the list of items in array