PHP Класс Gdn_Controller, vanilla

A base class that all controllers can inherit for common properties and methods.
Наследование: extends Gdn_Pluggable
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$Application The name of the application that this controller can be found in.
$ApplicationFolder The name of the application folder that this controller can be found in.
$Assets An associative array that contains content to be inserted into the master view. All assets are placed in this array before being passed to the master view. If an asset's key is not called by the master view, that asset will not be rendered.
$ControllerName The name of the controller that holds the view (used by $this->FetchView when retrieving the view). Default value is $this->ClassName.
$CssClass A CSS class to apply to the body tag of the page. Note: you can only assume that the master view will use this property (ie. a custom theme may not decide to implement this property).
$Data The data that a controller method has built up from models and other calculations.
$Head The Head module that this controller should use to add CSS files.
$MasterView The name of the master view that has been requested. Typically this is part of the master view's file name. ie. $this->MasterView.'.master.tpl'
$Menu A Menu module for rendering the main menu on each page.
$ModuleSortContainer An associative array of assets and what order their modules should be rendered in. You can set module sort orders in the config using Modules.ModuleSortContainer.AssetName.
$OriginalRequestMethod The method that was requested before the dispatcher did any re-routing.
$RedirectUrl The url to redirect the user to by ajax'd forms after the form is successfully saved.
$ReflectArgs The arguments passed into the controller mapped to their proper argument names.
$Request Reference to the Request object that spawned this controller.
$RequestArgs This is typically an array of arguments passed after the controller name and controller method in the query string. Additional arguments are parsed out by the @@Dispatcher and sent to $this->RequestArgs as an array. If there are no additional arguments specified, this value will remain FALSE. ie. http://localhost/index.php?/controller_name/controller_method/arg1/arg2/arg3 translates to: array('arg1', 'arg2', 'arg3');
$RequestMethod The method that has been requested. The request method is defined by the
$ResolvedPath Fully resolved path to the application/controller/method.
$SelfUrl The requested url to this controller.
$StatusMessage The message to be displayed on the screen by ajax'd forms after the form is successfully saved.
$SyndicationMethod by the dispatcher: SYNDICATION_RSS, SYNDICATION_ATOM, or SYNDICATION_NONE (default).
$Theme The name of the folder containing the views to be used by this controller. This value is retrieved from the $Configuration array when this class is instantiated. Any controller can then override the property before render if there is a need.
$ThemeOptions Specific options on the currently selected theme.
$View Name of the view that has been requested. Typically part of the view's file name. ie. $this->View.'.php'

Защищенные свойства (Protected)

Свойство Тип Описание
$_CanonicalUrl string
$_CssFiles An array of CSS file names to search for in theme folders & include in the page.
$_Definitions A collection of definitions that will be written to the screen in a hidden unordered list so that JavaScript has access to them (ie. for language translations, web root, etc).
$_DeliveryMethod An enumerator indicating how the response should be delivered to the output buffer. Options are: DELIVERY_METHOD_XHTML: page contents are delivered as normal. DELIVERY_METHOD_JSON: page contents and extra information delivered as JSON. The default value is DELIVERY_METHOD_XHTML.
$_DeliveryType An enumerator indicating what should be delivered to the screen. Options are: DELIVERY_TYPE_ALL: The master view and everything in the requested asset (DEFAULT). DELIVERY_TYPE_ASSET: Everything in the requested asset. DELIVERY_TYPE_VIEW: Only the requested view. DELIVERY_TYPE_BOOL: Deliver only the success status (or error) of the request DELIVERY_TYPE_NONE: Deliver nothing
$_ErrorMessages A string of html containing error messages to be displayed to the user.
$_FormSaved Allows overriding 'FormSaved' property to send with DELIVERY_METHOD_JSON.
$_Headers An associative array of header values to be sent to the browser before the page is rendered.
$_InformMessages A collection of "inform" messages to be displayed to the user.
$_JsFiles An array of JS file names to search for in app folders & include in the page.
$_Json If JSON is going to be delivered to the client (see the render method), this property will hold the values being sent.
$_PageName string | null
$_ViewLocations A collection of view locations that have already been found. Used to prevent re-finding views.
$internalMethods An array of internal methods that cannot be dispatched.

Открытые методы

Метод Описание
__construct ( )
addAsset ( string $AssetContainer, mixed $Asset, string $AssetName = '' ) Adds as asset (string) to the $this->Assets collection.
addBreadcrumb ( string $Name, string $Link = null, string $Position = 'back' ) Add a breadcrumb to the list.
addCssFile ( string $FileName, string $AppFolder = '', $Options = null ) Adds a CSS file to search for in the theme folder(s).
addDefinition ( string $Term, string $Definition = null ) Adds a key-value pair to the definition collection for JavaScript.
addInternalMethod ( string $methodName ) Add an method to the list of internal methods.
addJsFile ( string $FileName, string $AppFolder = '', $Options = null ) Adds a JS file to search for in the application or global js folder(s).
addModule ( mixed $Module, string $AssetTarget = '' ) Adds the specified module to the specified asset target.
allowJSONP ( null $Value = null ) : mixed | null
canonicalUrl ( null $Value = null ) : null | string
clearCssFiles ( )
clearJsFiles ( ) Clear all js files from the collection.
contentType ( $ContentType )
cssFiles ( ) : array
data ( string $Path, mixed $Default = '' ) : mixed Get a value out of the controller's data array.
definitionList ( boolean $wrap = true ) : string Gets the javascript definition list used to pass data to the client.
deliveryMethod ( string $Default = '' ) Returns the requested delivery method of the controller if $Default is not provided. Sets and returns the delivery method otherwise.
deliveryType ( string $Default = '' ) Returns the requested delivery type of the controller if $Default is not provided. Sets and returns the delivery type otherwise.
description ( boolean $Value = false, boolean $PlainText = false ) : mixed
errorMessage ( string $Messages ) Add error messages to be displayed to the user.
fetchView ( string $View = '', string $ControllerName = false, string $ApplicationFolder = false ) Fetches the contents of a view into a string and returns it. Returns false on failure.
fetchViewLocation ( string $View = '', boolean | string $ControllerName = false, boolean | string $ApplicationFolder = false, boolean $ThrowError = true, boolean $useController = true ) : string Fetches the location of a view into a string and returns it. Returns false on failure.
finalize ( ) Cleanup any remaining resources for this controller.
getAsset ( string $assetName )
getImports ( )
getJson ( ) : array
getStatusMessage ( $StatusCode ) : string
image ( mixed $Img = false ) : array Allows images to be specified for the page, to be used by the head module to add facebook open graph information.
informMessage ( string $Message, mixed $Options = ['CssClass' => 'Dismissable AutoDismiss'] ) Add an "inform" message to be displayed to the user.
initialize ( ) The initialize method is called by the dispatcher after the constructor has completed, objects have been passed along, assets have been retrieved, and before the requested method fires. Use it in any extended controller to do things like loading script and CSS into the head.
isInternal ( string $methodName ) : boolean Determines whether a method on this controller is internal and can't be dispatched.
jsFiles ( ) : array
json ( string $Key, mixed $Value = null ) : mixed If JSON is going to be sent to the client, this method allows you to add extra values to the JSON array.
jsonTarget ( $Target, $Data, string $Type = 'Html' )
masterView ( ) Define & return the master view.
pageName ( string | null $Value = null ) Gets or sets the name of the page for the controller.
permission ( mixed $Permission, boolean $FullMatch = true, string $JunctionTable = '', integer $JunctionID = '' ) Checks that the user has the specified permissions. If the user does not, they are redirected to the DefaultPermission route.
removeCssFile ( string $FileName ) Removes a CSS file from the collection.
removeJsFile ( string $FileName ) Removes a JS file from the collection.
renderAsset ( string $AssetName ) Searches $this->Assets for a key with $AssetName and renders all items within that array element to the screen. Note that any element in $this->Assets can contain an array of elements itself. This way numerous assets can be rendered one after another in one place.
renderData ( null $Data = null ) : boolean Render the data array.
renderException ( Exception $Ex ) Render an exception as the sole output.
renderMaster ( )
sendHeaders ( ) Sends all headers in $this->_Headers (defined with $this->SetHeader()) to the browser.
setData ( string | array $key, mixed $value = null, mixed $addProperty = false ) : mixed Set data from a method call.
setFormSaved ( boolean $Saved = true ) Set $this->_FormSaved for JSON Renders.
setHeader ( string $Name, string $Value ) Allows the adding of page header information that will be delivered to the browser before rendering.
setJson ( string $Key, string $Value = '' ) If JSON is going to be sent to the client, this method allows you to add extra values to the JSON array.
setLastModified ( string $LastModifiedDate ) Looks for a Last-Modified header from the browser and compares it to the supplied date. If the Last-Modified date is after the supplied date, the controller will send a "304 Not Modified" response code to the web browser and stop all execution. Otherwise it sets the Last-Modified header for this page and continues processing.
statusCode ( $StatusCode, null $Message = null, boolean $SetHeader = true ) : null | string
title ( string $Title = null, $Subtitle = null ) If this object has a "Head" object as a property, this will set it's Title value.
xRender ( string $View = '', string $ControllerName = false, string $ApplicationFolder = false, string $AssetName = 'Content' ) Defines & retrieves the view and master view. Renders all content within them to the screen.

Защищенные методы

Метод Описание
_fixUrlScheme ( &$Value, $Key, $Scheme )
_renderXml ( mixed $Data, string $Node = 'Data', string $Indent = '' ) A simple default method for rendering xml.
setAccessControl ( ) Set Access-Control-Allow-Origin header.

Описание методов

__construct() публичный Метод

public __construct ( )

_fixUrlScheme() защищенный статический Метод

protected static _fixUrlScheme ( &$Value, $Key, $Scheme )
$Value
$Key
$Scheme

_renderXml() защищенный Метод

A simple default method for rendering xml.
protected _renderXml ( mixed $Data, string $Node = 'Data', string $Indent = '' )
$Data mixed The data to render. This is usually $this->Data.
$Node string The name of the root node.
$Indent string The indent before the data for layout that is easier to read.

addAsset() публичный Метод

The assets will later be added to the view if their $AssetName is called by $this->RenderAsset($AssetName) within the view.
public addAsset ( string $AssetContainer, mixed $Asset, string $AssetName = '' )
$AssetContainer string The name of the asset container to add $Asset to.
$Asset mixed The asset to be rendered in the view. This can be one of: - string: The string will be rendered. - Gdn_IModule: Gdn_IModule::Render() will be called.
$AssetName string The name of the asset being added. This can be used later to sort assets before rendering.

addBreadcrumb() публичный Метод

Add a breadcrumb to the list.
public addBreadcrumb ( string $Name, string $Link = null, string $Position = 'back' )
$Name string Translation code
$Link string Optional. Hyperlink this breadcrumb somewhere.
$Position string Optional. Where in the list to add it? 'front', 'back'

addCssFile() публичный Метод

Adds a CSS file to search for in the theme folder(s).
public addCssFile ( string $FileName, string $AppFolder = '', $Options = null )
$FileName string The CSS file to search for.
$AppFolder string The application folder that should contain the CSS file. Default is to use the application folder that this controller belongs to. - If you specify plugins/PluginName as $AppFolder then you can contain a CSS file in a plugin's design folder.

addDefinition() публичный Метод

Adds a key-value pair to the definition collection for JavaScript.
public addDefinition ( string $Term, string $Definition = null )
$Term string
$Definition string

addInternalMethod() публичный Метод

Add an method to the list of internal methods.
public addInternalMethod ( string $methodName )
$methodName string The name of the internal method to add.

addJsFile() публичный Метод

Adds a JS file to search for in the application or global js folder(s).
public addJsFile ( string $FileName, string $AppFolder = '', $Options = null )
$FileName string The js file to search for.
$AppFolder string The application folder that should contain the JS file. Default is to use the application folder that this controller belongs to.

addModule() публичный Метод

If no asset target is defined, it will use the asset target defined by the module's AssetTarget method.
public addModule ( mixed $Module, string $AssetTarget = '' )
$Module mixed A module or the name of a module to add to the page.
$AssetTarget string

allowJSONP() публичный Метод

public allowJSONP ( null $Value = null ) : mixed | null
$Value null
Результат mixed | null

canonicalUrl() публичный Метод

public canonicalUrl ( null $Value = null ) : null | string
$Value null
Результат null | string

clearCssFiles() публичный Метод

public clearCssFiles ( )

clearJsFiles() публичный Метод

Clear all js files from the collection.
public clearJsFiles ( )

contentType() публичный Метод

public contentType ( $ContentType )
$ContentType

cssFiles() публичный Метод

public cssFiles ( ) : array
Результат array

data() публичный Метод

Get a value out of the controller's data array.
См. также: GetValueR()
public data ( string $Path, mixed $Default = '' ) : mixed
$Path string The path to the data.
$Default mixed The default value if the data array doesn't contain the path.
Результат mixed

definitionList() публичный Метод

Gets the javascript definition list used to pass data to the client.
public definitionList ( boolean $wrap = true ) : string
$wrap boolean Whether or not to wrap the result in a `script` tag.
Результат string Returns a string containing the `