[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/Web/ -> THttpRequest.php (sommaire)

THttpRequest, THttpCookie, THttpCookieCollection, TUri class file

Author: Qiang Xue <qiang.xue@gmail.com>
Copyright: Copyright © 2005 PradoSoft
License: http://www.pradosoft.com/license/
Version: $Id: THttpRequest.php 1539 2006-12-02 19:20:40Z xue $
Poids: 1226 lignes (31 kb)
Inclus ou requis: 1 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 5 classes

THttpRequest:: (60 méthodes):
  getID()
  setID()
  init()
  stripSlashes()
  getUrl()
  getUrlManager()
  setUrlManager()
  getUrlManagerModule()
  getUrlFormat()
  setUrlFormat()
  getUrlParamSeparator()
  setUrlParamSeparator()
  getRequestType()
  getIsSecureConnection()
  getPathInfo()
  getQueryString()
  getRequestUri()
  getBaseUrl()
  getApplicationUrl()
  getAbsoluteApplicationUrl()
  getApplicationFilePath()
  getServerName()
  getServerPort()
  getUrlReferrer()
  getBrowser()
  getUserAgent()
  getUserHostAddress()
  getUserHost()
  getAcceptTypes()
  getUserLanguages()
  getEnableCookieValidation()
  setEnableCookieValidation()
  getCookies()
  getUploadedFiles()
  getServerVariables()
  getEnvironmentVariables()
  constructUrl()
  parseUrl()
  resolveRequest()
  getRequestResolved()
  getAvailableServices()
  setAvailableServices()
  getServiceID()
  setServiceID()
  getServiceParameter()
  setServiceParameter()
  getIterator()
  getCount()
  count()
  getKeys()
  itemAt()
  add()
  remove()
  clear()
  contains()
  toArray()
  offsetExists()
  offsetGet()
  offsetSet()
  offsetUnset()

THttpCookieCollection:: (5 méthodes):
  __construct()
  insertAt()
  removeAt()
  itemAt()
  findCookieByName()

THttpCookie:: (13 méthodes):
  __construct()
  getDomain()
  setDomain()
  getExpire()
  setExpire()
  getName()
  setName()
  getValue()
  setValue()
  getPath()
  setPath()
  getSecure()
  setSecure()

TUri:: (10 méthodes):
  __construct()
  getUri()
  getScheme()
  getHost()
  getPort()
  getUser()
  getPassword()
  getPath()
  getQuery()
  getFragment()

THttpRequestUrlFormat:: (0 méthodes):


Classe: THttpRequest  - X-Ref

THttpRequest class

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,
<code>
if(isset($request['param1'])) ...
// equivalent to:
// if($request->contains('param1')) ...
</code>
To get the value of 'param1', use,
<code>
$value=$request['param1'];
// equivalent to:
//   $value=$request->itemAt('param1');
</code>
To traverse the user post data, use
<code>
foreach($request as $name=>$value) ...
</code>
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:
<code>
/index.php?ServiceID=ServiceParameter&Name1=Value1&Name2=Value2
/index.php/ServiceID,ServiceParameter/Name1,Value1/Name2,Value2
</code>
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()}.

getID()   X-Ref

return: string id of this module

setID($value)   X-Ref

param: string id of this module

init($config)   X-Ref
Initializes the module.
This method is required by IModule and is invoked by application.

param: TXmlElement module configuration

stripSlashes(&$data)   X-Ref
Strips slashes from input data.
This method is applied when magic quotes is enabled.

param: mixed input data to be processed
param: mixed processed data

getUrl()   X-Ref

return: TUri the request URL

getUrlManager()   X-Ref

return: string the ID of the URL manager module

setUrlManager($value)   X-Ref
Sets the URL manager module.
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.

param: string the ID of the URL manager module

getUrlManagerModule()   X-Ref

return: TUrlManager the URL manager module

getUrlFormat()   X-Ref

return: THttpRequestUrlFormat the format of URLs. Defaults to THttpRequestUrlFormat::Get.

setUrlFormat($value)   X-Ref
Sets the format of URLs constructed and interpretted by the request module.
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.

param: THttpRequestUrlFormat the format of URLs.

getUrlParamSeparator()   X-Ref

return: string separator used to separate GET variable name and value when URL format is Path. Defaults to comma ','.

setUrlParamSeparator($value)   X-Ref

param: string separator used to separate GET variable name and value when URL format is Path.

getRequestType()   X-Ref

return: string request type, can be GET, POST, HEAD, or PUT

getIsSecureConnection()   X-Ref

return: boolean if the request is sent via secure channel (https)

getPathInfo()   X-Ref

return: string part of the request URL after script name and before question mark.

getQueryString()   X-Ref

return: string part of that request URL after the question mark

getRequestUri()   X-Ref

return: string part of that request URL after the host info (including pathinfo and query string)

getBaseUrl()   X-Ref

return: string schema and hostname of the requested URL

getApplicationUrl()   X-Ref

return: string entry script URL (w/o host part)

getAbsoluteApplicationUrl()   X-Ref

return: string entry script URL (w/ host part)

getApplicationFilePath()   X-Ref

return: string application entry script file path (processed w/ realpath())

getServerName()   X-Ref

return: string server name

getServerPort()   X-Ref

return: integer server port number

getUrlReferrer()   X-Ref

return: string URL referrer, null if not present

getBrowser()   X-Ref

return: array user browser capabilities

getUserAgent()   X-Ref

return: string user agent

getUserHostAddress()   X-Ref

return: string user IP address

getUserHost()   X-Ref

return: string user host name, null if cannot be determined

getAcceptTypes()   X-Ref

return: string user browser accept types

getUserLanguages()   X-Ref
Returns a list of user preferred languages.
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.

return: array list of user preferred languages.

getEnableCookieValidation()   X-Ref

return: boolean whether cookies should be validated. Defaults to false.

setEnableCookieValidation($value)   X-Ref

param: boolean whether cookies should be validated.

getCookies()   X-Ref

return: THttpCookieCollection list of cookies to be sent

getUploadedFiles()   X-Ref

return: array list of uploaded files.

getServerVariables()   X-Ref

return: array list of server variables.

getEnvironmentVariables()   X-Ref

return: array list of environment variables.

constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=true,$encodeGetItems=true)   X-Ref
Constructs a URL that can be recognized by PRADO.
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.

param: string service ID
param: string service parameter
param: array GET parameters, null if not needed
param: boolean whether to encode the ampersand in URL, defaults to true.
param: boolean whether to encode the GET parameters (their names and values), defaults to false.
return: string URL

parseUrl()   X-Ref
Parses the request URL and returns an array of input parameters (excluding GET variables).
You may override this method to support customized URL format.

return: array list of input parameters, indexed by parameter names

resolveRequest()   X-Ref
Resolves the requested servie.
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.


getRequestResolved()   X-Ref

return: boolean true if request is already resolved, false otherwise.

getAvailableServices()   X-Ref

return: array IDs of the available services

setAvailableServices($services)   X-Ref

param: array IDs of the available services

getServiceID()   X-Ref

return: string requested service ID

setServiceID($value)   X-Ref
Sets the requested service ID.

param: string requested service ID

getServiceParameter()   X-Ref

return: string requested service parameter

setServiceParameter($value)   X-Ref
Sets the requested service parameter.

param: string requested service parameter

getIterator()   X-Ref
Returns an iterator for traversing the items in the list.
This method is required by the interface IteratorAggregate.

return: Iterator an iterator for traversing the items in the list.

getCount()   X-Ref

return: integer the number of items in the request

count()   X-Ref
Returns the number of items in the request.
This method is required by Countable interface.

return: integer number of items in the request.

getKeys()   X-Ref

return: array the key list

itemAt($key)   X-Ref
Returns the item with the specified key.
This method is exactly the same as {@link offsetGet}.

param: mixed the key
return: mixed the element at the offset, null if no element is found at the offset

add($key,$value)   X-Ref
Adds an item into the request.
Note, if the specified key already exists, the old value will be overwritten.

param: mixed key
param: mixed value

remove($key)   X-Ref
Removes an item from the request by its key.

param: mixed the key of the item to be removed
return: mixed the removed value, null if no such key exists.

clear()   X-Ref
Removes all items in the request.


contains($key)   X-Ref

param: mixed the key
return: boolean whether the request contains an item with the specified key

toArray()   X-Ref

return: array the list of items in array

offsetExists($offset)   X-Ref
Returns whether there is an element at the specified offset.
This method is required by the interface ArrayAccess.

param: mixed the offset to check on
return: boolean

offsetGet($offset)   X-Ref
Returns the element at the specified offset.
This method is required by the interface ArrayAccess.

param: integer the offset to retrieve element.
return: mixed the element at the offset, null if no element is found at the offset

offsetSet($offset,$item)   X-Ref
Sets the element at the specified offset.
This method is required by the interface ArrayAccess.

param: integer the offset to set element
param: mixed the element value

offsetUnset($offset)   X-Ref
Unsets the element at the specified offset.
This method is required by the interface ArrayAccess.

param: mixed the offset to unset element

Classe: THttpCookieCollection  - X-Ref

THttpCookieCollection class.

THttpCookieCollection implements a collection class to store cookies.
Besides using all functionalities from {@link TList}, you can also
retrieve a cookie by its name using either {@link findCookieByName} or
simply:
<code>
$cookie=$collection[$cookieName];
</code>

__construct($owner=null)   X-Ref
Constructor.

param: mixed owner of this collection.

insertAt($index,$item)   X-Ref
Inserts an item at the specified position.
This overrides the parent implementation by performing additional
operations for each newly added THttpCookie object.

param: integer the speicified position.
param: mixed new item

removeAt($index)   X-Ref
Removes an item at the specified position.
This overrides the parent implementation by performing additional
cleanup work when removing a TCookie object.

param: integer the index of the item to be removed.
return: mixed the removed item.

itemAt($index)   X-Ref

param: integer|string index of the cookie in the collection or the cookie's name
return: THttpCookie the cookie found

findCookieByName($name)   X-Ref
Finds the cookie with the specified name.

param: string the name of the cookie to be looked for
return: THttpCookie the cookie, null if not found

Classe: THttpCookie  - X-Ref

THttpCookie class.

A THttpCookie instance stores a single cookie, including the cookie name, value,
domain, path, expire, and secure.

__construct($name,$value)   X-Ref
Constructor.

param: string name of this cookie
param: string value of this cookie

getDomain()   X-Ref

return: string the domain to associate the cookie with

setDomain($value)   X-Ref

param: string the domain to associate the cookie with

getExpire()   X-Ref

return: integer the time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch.

setExpire($value)   X-Ref

param: integer the time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch.

getName()   X-Ref

return: string the name of the cookie

setName($value)   X-Ref

param: string the name of the cookie

getValue()   X-Ref

return: string the value of the cookie

setValue($value)   X-Ref

param: string the value of the cookie

getPath()   X-Ref

return: string the path on the server in which the cookie will be available on, default is '/'

setPath($value)   X-Ref

param: string the path on the server in which the cookie will be available on

getSecure()   X-Ref

return: boolean whether the cookie should only be transmitted over a secure HTTPS connection

setSecure($value)   X-Ref

param: boolean ether the cookie should only be transmitted over a secure HTTPS connection

Classe: TUri  - X-Ref

TUri class

TUri represents a URI. Given a URI
http://joe:whatever@example.com:8080/path/to/script.php?param=value#anchor
it will be decomposed as follows,
- scheme: http
- host: example.com
- port: 8080
- user: joe
- password: whatever
- path: /path/to/script.php
- query: param=value
- fragment: anchor

__construct($uri)   X-Ref
Constructor.
Decomposes the specified URI into parts.

param: string URI to be represented

getUri()   X-Ref

return: string URI

getScheme()   X-Ref

return: string scheme of the URI, such as 'http', 'https', 'ftp', etc.

getHost()   X-Ref

return: string hostname of the URI

getPort()   X-Ref

return: integer port number of the URI

getUser()   X-Ref

return: string username of the URI

getPassword()   X-Ref

return: string password of the URI

getPath()   X-Ref

return: string path of the URI

getQuery()   X-Ref

return: string query string of the URI

getFragment()   X-Ref

return: string fragment of the URI

Classe: THttpRequestUrlFormat  - X-Ref

THttpRequestUrlFormat class.
THttpRequestUrlFormat defines the enumerable type for the possible URL formats
that can be recognized by {@link THttpRequest}.

The following enumerable values are defined:
- Get: the URL format is like /path/to/index.php?name1=value1&name2=value2...
- Path: the URL format is like /path/to/index.php/name1,value1/name2,value2...



Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7