PHP Class CampURI

Mostra file Open project: sourcefabric/newscoop Class Usage Examples

Protected Properties

Property Type Description
$_themePath The theme path storage
$m_article MetaArticle Article object
$m_buildPath string
$m_buildQuery string
$m_buildQueryArray array
$m_config object
$m_errorCode integer Holds the URL process error code; null if no error
$m_fragment string
$m_host string
$m_issue MetaIssue Issue object
$m_language MetaLanguage Language object
$m_objects
$m_parts array The URI parts
$m_password string
$m_path string
$m_port integer
$m_preview boolean True if in preview mode
$m_previewParameters array The list of parameters used in preview mode
$m_publication MetaPublication Publication object
$m_query string
$m_scheme string
$m_section MetaSection Section object
$m_template MetaTemplate Template object
$m_type integer The URI type It can be either: Template Path = 1 Short Names = 2
$m_uri string The URI value
$m_user MetaUser
$m_validURI boolean Whether the URI is valid or not

Public Methods

Method Description
GetPreviewParameters ( )
__construct ( string $p_uri = 'SELF' ) Class constructor
__get ( string $p_property ) : boolean Sets an object property
__set ( string $p_property, mixed $p_value ) : boolean Sets an object property
getBase ( ) : string Gets the URI base, it is the scheme, host and (if exists) port.
getBasePath ( ) : string Gets the base plus the path from the current URI.
getCampsiteVector ( ) : array Returns campsite params: language, publication, issue, section, article.
getErrorCode ( ) : integer Returns the URL processing error code
getFragment ( ) : string Gets the fragment part from the current URI.
getHost ( ) : string Gets the host part from the current URI.
getPassword ( ) : string Gets the password part from the current URI.
getPath ( ) : string Gets the path part from the current URI.
getPort ( ) : integer Gets the port part from the current URI.
getQuery ( ) : string Gets the query part from the current URI.
getQueryArray ( array $p_keepParameters = [], array $p_removeParameters = [] ) : array Gets the array containing the query variables.
getQueryVar ( string $p_varName ) : string Gets the given variable from the URI query.
getRelativeBase ( ) : string Gets the relative URI base, it is '//', host and (if exists) port.
getRequestURI ( ) : string Gets the requested URI.
getScheme ( ) : string Gets the scheme part from the current URI.
getTemplate ( $p_templateIdOrName = null )
getThemePath ( )
getURI ( string $p_param = null, boolean $p_preview = false ) : string Returns the URI string based on given URL parameter.
getURIPath ( string $p_param = null, boolean $p_preview = false ) : string Returns the URI path based on given URL parameter.
getURL ( ) : string Gets the URL from the object attributes.
getURLParameters ( string $p_param = null, boolean $p_preview = false ) : string Returns the URI query parameters based on given URL parameter.
getURLType ( ) : integer Gets the URL type.
getUser ( ) : string Returns the user part from the current URI.
isRestrictedParameter ( string $p_parameterName ) : boolean Returns true if the given parameter is restricted and can not be set from outside the URL object.
isSSL ( ) : boolean Returns whether the site is running over SSL or not.
setFragment ( string $p_fragment ) : void Sets the URI fragment.
setHost ( string $p_host ) : void Sets the URI host.
setPassword ( $p_password ) : void Sets the URI password part.
setPath ( string $p_path ) : void Sets the URI path.
setPort ( integer $p_port ) : void Sets the URI port.
setQuery ( $p_query ) : void Gets the query part from the current URI.
setQueryVar ( string $p_varName, string $p_value = null ) : void Sets the given URI query variable.
setScheme ( string $p_scheme ) : void Sets the URI scheme.
setUser ( string $p_user ) : void Sets the URI user part.

Protected Methods

Method Description
QueryArrayToString ( array $p_queryArray, $p_HTMLEscape = true ) : string Builds a URI query string from the given query array.
addToQuery ( &$p_query, array $p_parameters ) Adds the given parameters to the query array
buildURI ( array &$p_params = [], boolean $p_preview = false ) : void Sets the URI path and query values based on given parameters.
clearParams ( array $parameters )
isValidCache ( ) : boolean Returns the cache valid state
isValidTemplate ( string $p_templateName ) : boolean Returns whether the template name given is a valid template resource.
render ( array $p_parts = [] ) : string Builds a URI string from the given parts.
resetList ( $listIdPrefix )
setURLType ( integer $p_type ) : void Sets the URL type.
validateCache ( boolean $p_valid ) Sets the cache validation for URI rendering

Private Methods

Method Description
parse ( string $p_uri ) : boolean Parses the given URI.
processImageOptions ( integer &$p_imageNo, array $p_params ) Process the image options given in the new format: where may be one of: number, ratio, width, height and an integer
processOldImageOptions ( integer &$p_imageNo, array $p_params ) Process the image options given in the old format (for compatibility): [ []] or: [ [width | height ]
readUser ( )

Method Details

GetPreviewParameters() public static method

public static GetPreviewParameters ( )

QueryArrayToString() protected static method

Builds a URI query string from the given query array.
protected static QueryArrayToString ( array $p_queryArray, $p_HTMLEscape = true ) : string
$p_queryArray array An array of query variables
return string $queryString The generated query string

__construct() public method

Class constructor
public __construct ( string $p_uri = 'SELF' )
$p_uri string The full URI string

__get() public method

Sets an object property
public __get ( string $p_property ) : boolean
$p_property string
return boolean

__set() public method

Sets an object property
public __set ( string $p_property, mixed $p_value ) : boolean
$p_property string
$p_value mixed
return boolean

addToQuery() protected method

Adds the given parameters to the query array
protected addToQuery ( &$p_query, array $p_parameters )
$p_parameters array

buildURI() protected method

Sets the URI path and query values based on given parameters.
protected buildURI ( array &$p_params = [], boolean $p_preview = false ) : void
$p_params array An array of valid URL parameters
$p_preview boolean If true, will keep the preview parameters in the URL
return void

clearParams() protected method

protected clearParams ( array $parameters )
$parameters array

getBase() public method

Gets the URI base, it is the scheme, host and (if exists) port.
public getBase ( ) : string
return string $base The URI base

getBasePath() public method

Gets the base plus the path from the current URI.
public getBasePath ( ) : string
return string The URI base path

getCampsiteVector() public method

Returns campsite params: language, publication, issue, section, article.
public getCampsiteVector ( ) : array
return array

getErrorCode() public method

Returns the URL processing error code
public getErrorCode ( ) : integer
return integer

getFragment() public method

Gets the fragment part from the current URI.
public getFragment ( ) : string
return string $m_fragment The fragment value

getHost() public method

Gets the host part from the current URI.
public getHost ( ) : string
return string $m_host The host value

getPassword() public method

Gets the password part from the current URI.
public getPassword ( ) : string
return string $m_password The password value

getPath() public method

Gets the path part from the current URI.
public getPath ( ) : string
return string $m_path The path value

getPort() public method

Gets the port part from the current URI.
public getPort ( ) : integer
return integer $m_port The port value

getQuery() public method

Gets the query part from the current URI.
public getQuery ( ) : string
return string $m_query The query part

getQueryArray() public method

Gets the array containing the query variables.
public getQueryArray ( array $p_keepParameters = [], array $p_removeParameters = [] ) : array
$p_keepParameters array
$p_removeParameters array
return array $m_queryArray The array of query vars

getQueryVar() public method

Gets the given variable from the URI query.
public getQueryVar ( string $p_varName ) : string
$p_varName string The variable name
return string null on failure, otherwise the variable value

getRelativeBase() public method

Gets the relative URI base, it is '//', host and (if exists) port.
public getRelativeBase ( ) : string
return string $relativeBase The relative URI base

getRequestURI() public method

Gets the requested URI.
public getRequestURI ( ) : string
return string The requested URI string

getScheme() public method

Gets the scheme part from the current URI.
public getScheme ( ) : string
return string $m_scheme The scheme value

getTemplate() public method

public getTemplate ( $p_templateIdOrName = null )

getThemePath() public method

public getThemePath ( )

getURI() public method

Returns the URI string based on given URL parameter.
public getURI ( string $p_param = null, boolean $p_preview = false ) : string
$p_param string The URL parameter
$p_preview boolean If true, will keep the preview parameters in the URL
return string The URI string requested

getURIPath() public method

Returns the URI path based on given URL parameter.
public getURIPath ( string $p_param = null, boolean $p_preview = false ) : string
$p_param string The URL parameter
$p_preview boolean If true, will keep the preview parameters in the URL
return string The URI path string requested

getURL() public method

Gets the URL from the object attributes.
public getURL ( ) : string
return string $url The full URL

getURLParameters() public method

Returns the URI query parameters based on given URL parameter.
public getURLParameters ( string $p_param = null, boolean $p_preview = false ) : string
$p_param string
$p_preview boolean If true, will keep the preview parameters in the URL
return string The URI query string requested

getURLType() public method

Gets the URL type.
public getURLType ( ) : integer
return integer

getUser() public method

Returns the user part from the current URI.
public getUser ( ) : string
return string The username value

isRestrictedParameter() abstract public method

Returns true if the given parameter is restricted and can not be set from outside the URL object.
abstract public isRestrictedParameter ( string $p_parameterName ) : boolean
$p_parameterName string
return boolean

isSSL() public method

Returns whether the site is running over SSL or not.
public isSSL ( ) : boolean
return boolean true on success, false on failure

isValidCache() protected method

Returns the cache valid state
protected isValidCache ( ) : boolean
return boolean

isValidTemplate() protected method

Returns whether the template name given is a valid template resource.
protected isValidTemplate ( string $p_templateName ) : boolean
$p_templateName string The name of the template from the URI path
return boolean true on success, false on failure

render() protected method

Builds a URI string from the given parts.
protected render ( array $p_parts = [] ) : string
$p_parts array The array of URI parts
return string $uriString The rendered URI

resetList() protected method

protected resetList ( $listIdPrefix )

setFragment() public method

Sets the URI fragment.
public setFragment ( string $p_fragment ) : void
$p_fragment string The fragment part
return void

setHost() public method

Sets the URI host.
public setHost ( string $p_host ) : void
$p_host string The host name
return void

setPassword() public method

Sets the URI password part.
public setPassword ( $p_password ) : void
return void

setPath() public method

Sets the URI path.
public setPath ( string $p_path ) : void
$p_path string The path
return void

setPort() public method

Sets the URI port.
public setPort ( integer $p_port ) : void
$p_port integer The port number
return void

setQuery() public method

Gets the query part from the current URI.
public setQuery ( $p_query ) : void
return void $m_query The query value

setQueryVar() public method

Sets the given URI query variable.
public setQueryVar ( string $p_varName, string $p_value = null ) : void
$p_varName string The name of the URI query variable
$p_value string The value for the variable
return void

setScheme() public method

Sets the URI scheme.
public setScheme ( string $p_scheme ) : void
$p_scheme string The scheme value
return void

setURLType() protected method

Sets the URL type.
protected setURLType ( integer $p_type ) : void
$p_type integer The URL type number
return void

setUser() public method

Sets the URI user part.
public setUser ( string $p_user ) : void
$p_user string The user name
return void

validateCache() protected method

Sets the cache validation for URI rendering
protected validateCache ( boolean $p_valid )
$p_valid boolean

Property Details

$_themePath protected_oe property

The theme path storage
protected $_themePath

$m_article protected_oe property

Article object
protected MetaArticle $m_article
return MetaArticle

$m_buildPath protected_oe property

protected string $m_buildPath
return string

$m_buildQuery protected_oe property

protected string $m_buildQuery
return string

$m_buildQueryArray protected_oe property

protected array $m_buildQueryArray
return array

$m_config protected_oe property

protected object $m_config
return object

$m_errorCode protected_oe property

Holds the URL process error code; null if no error
protected int $m_errorCode
return integer

$m_fragment protected_oe property

protected string $m_fragment
return string

$m_host protected_oe property

protected string $m_host
return string

$m_issue protected_oe property

Issue object
protected MetaIssue $m_issue
return MetaIssue

$m_language protected_oe property

Language object
protected MetaLanguage $m_language
return MetaLanguage

$m_objects protected_oe static_oe property

protected static $m_objects

$m_parts protected_oe property

The URI parts
protected array $m_parts
return array

$m_password protected_oe property

protected string $m_password
return string

$m_path protected_oe property

protected string $m_path
return string

$m_port protected_oe property

protected int $m_port
return integer

$m_preview protected_oe property

True if in preview mode
protected bool $m_preview
return boolean

$m_previewParameters protected_oe static_oe property

The list of parameters used in preview mode
protected static array $m_previewParameters
return array

$m_publication protected_oe property

Publication object
protected MetaPublication $m_publication
return MetaPublication

$m_query protected_oe property

protected string $m_query
return string

$m_scheme protected_oe property

protected string $m_scheme
return string

$m_section protected_oe property

Section object
protected MetaSection $m_section
return MetaSection

$m_template protected_oe property

Template object
protected MetaTemplate $m_template
return MetaTemplate

$m_type protected_oe property

The URI type It can be either: Template Path = 1 Short Names = 2
protected int $m_type
return integer

$m_uri protected_oe property

The URI value
protected string $m_uri
return string

$m_user protected_oe property

protected MetaUser $m_user
return MetaUser

$m_validURI protected_oe property

Whether the URI is valid or not
protected bool $m_validURI
return boolean