PHP Class App_CLI, atk4

(c) 2008-2013 Agile Toolkit Limited Distributed under Affero General Public License v3 and commercial license. See LICENSE or LICENSE_COM for more information =====================================================ATK4=
Inheritance: extends AbstractView
Afficher le fichier Open project: atk4/atk4 Class Usage Examples

Méthodes publiques

Свойство Type Description
$atk_version string This is a major version of Agile Toolkit. The APP of Agile Toolkit is very well established and changes rarely. Your application would generally be compatible throughout the same major version of Agile Tooolkit.
$compat_42 boolean | Controller_Compat42 If you want Agile Toolkit to be compatible with 4.2 version, include compatibility controller.
$config array Once configuration file is read, data is saved inside this property.
$config_files array If you are loading additional config later, use readConfig() instead Order of this array is important.
$config_files_loaded array Contains list of loaded config files.
$config_location string ." or inside "config" sub-folder by setting value to 'config' to better reflect your application layout.
$db DB In a typical application, one connection to the database is enough for majority of applications. Calling $app->dbConnect will read Database data from config file and store it in $db property. If you requires a more advanced connectivity or multiple connections, you can manually initialize more database connections.
$locale string This is the default locale for the application. You change this manually inside application APP class or use some controller which will pull this variable out of the URL. This variable will be respected throughout the framework.
$logger Logger Without logger, APP will dump out errors and exceptions in a very brief and straigtforward way. Logger is a controller which enhances error output and in most cases you do need one. Logger can be further configured to either output detailed errors or show brief message instead.
$logger_class If you want to use your own logger class, redefine this property.
$max_name_length integer Agile Toolkit implements a mechanism which will replace common beginning of objects with an abbreviation thus keeping object name length under control. This variable defines the maximum length of the object's $name. Be mindful that some objects will concatinate theri name with fields, so the maximum letgth of GET argument names can exceed this value by the length of your field. We recommend you to increase SUHOSIN get limits if you encounter any problems. Set this value to "false" to turn off name shortening.
$pathfinder PathFinder PathFinder is a controller which is responsible for locating resources, such as PHP includes, JavaScript files, templates, etc. APP Initializes PathFinder as soon as possible, then defines "Locations" which describe type of data found in different folders.
$pm Controller_PageManager PageManager object
$pr object Profiler measures relative time it took in certain parts of your application to help you find a slow-perfoming parts of application. By default $pr points to empty profiler object, which implements empty methods. All the lines referencing $pr myst be prefixed with the 4-symbol sequence "/ ** /" (no spaces). If you want to speed up Agile Toolkit further, you can eliminate all lines started with this sequence from your source code.
$unique_hashes array As more names are shortened, the substituted part is being placed into this hash and the value contains the new key. This helps to avoid creating many sequential prefixes for the same character sequenece.

Protected Properties

Свойство Type Description
$pagemanager_class string Change a different Page Manager class.
$pagemanager_options array Set to array('debug' => true) to debug Page Manager.
$pathfinder_class string If you would want to use your own PathFinder class, you must change this property and include it.

Méthodes publiques

Méthode Description
_ ( string $str ) : string Redefine this function to introduce your localization.
__construct ( string $realm = null, array $options = [] ) Regular objects in Agile Toolkit use init() and are added through add().
_beforeInit ( ) Finds out which page is requested. We don't need this method for CLI, but others might need it.
addGlobalMethod ( string $name, callable $callable ) Agile Toolkit objects allow method injection. This is quite similar to technique used in JavaScript:.
addLocation ( array $contents, mixed $obsolete = UNDEFINED ) : PathFinder_Location Add new location with additional resources.
caughtException ( Exception $e ) Is executed if exception is raised during execution.
configExceptionOrDefault ( string $default, string $exceptiontext ) Executed when trying to access config parameter which is not find in the file.
dbConnect ( mixed $dsn = null ) : DB Use database configuration settings from config file to establish default connection.
encodeHtmlChars ( string $s, integer $flags = null, string $encode = null, boolean $double_encode = false ) : string Encodes HTML special chars.
getBaseURL ( ) : string Returns base URL of this Web application installation. If you require link to a page, you can use URL::useAbsoluteURL();.
getConfig ( string $path, mixed $default_value = UNDEFINED ) : string Load config if necessary and look up corresponding setting.
getLogger ( string $class_name = UNDEFINED ) : Logger Initialize logger or return existing one.
getStickyArguments ( ) : array
getVersion ( string $of = 'atk' ) : string Determine version of Agile Toolkit or specified plug-in.
hasGlobalMethod ( string $name ) : boolean Returns if a global method with such name was defined.
locate ( string $type, string $filename = '', string $return = 'relative' ) : string | object | array Find relative path to the resource respective to the current directory.
locatePath ( string $type, string $filename = '' ) : string | object | array Return full system path to specified resource.
locateURL ( string $type, string $filename = '' ) : string | object | array Calculate URL pointing to specified resource.
normalizeClassName ( string | object $name, string $prefix = null ) : string | object First normalize class name, then add specified prefix to class name if it's passed and not already added.
normalizeName ( string $name, string $separator = '_' ) : string Normalize field or identifier name. Can also be used in URL normalization.
outputDebug ( $object, $msg, $shift )
outputWarning ( $msg, $shift )
readAllConfig ( ) Will include all files as they are defined in $this->config_files from folder $config_location.
readConfig ( string $file = 'config.php' ) : boolean Read config file and store it in $this->config. Use getConfig() to access.
removeGlobalMethod ( string $name ) Removes global method.
requires ( string $addon = 'atk', string $v, string $location = null ) : boolean Verifies version. Should be used by addons. For speed improvement, redefine this into empty function.
setConfig ( array $config = [], mixed $val = UNDEFINED ) Manually set configuration option.
url ( mixed $page = null, array $arguments = [] ) : URL Generates URL for specified page. Useful for building links on pages or emails. Returns URL object.
versionRequirement ( $v, $location = null )

Method Details

_() public méthode

Agile Toolkit will pass all system strings through this method. If some methods are not properly passed through, please fork Agile Toolkit from http://github.com/atk4/atk4/ , modify, commit, push your fix and notify authors of Agile Toolkit using contact form on http://agiletoolkit.org/contact. See file CONTRIBUTING
public _ ( string $str ) : string
$str string String which needs localization
Résultat string Localized string

__construct() public méthode

Application class is differente, you use "new" keyword because it's the first class to be created. That's why constructor will perform quite a bit of initialization. Do not redefine constructor but instead use init(); $realm defines a top-level name of your application. This impacts all id= prefixes in your HTML code, form field names and many other things, such as session name. If you have two application classes which are part of same web app and may want to use same realm, but in other cases it's preferably that you keep realm unique on your domain in the interests of security.
public __construct ( string $realm = null, array $options = [] )
$realm string Will become $app->name
$options array

_beforeInit() public méthode

Finds out which page is requested. We don't need this method for CLI, but others might need it.
public _beforeInit ( )

addGlobalMethod() public méthode

obj.test = function() { .. } All non-existant method calls on all Agile Toolkit objects will be tried against local table of registered methods and then against global registered methods. addGlobalmethod allows you to register a globally-recognized for all agile toolkit object. PHP is not particularly fast about executing methods like that, but this technique can be used for adding backward-compatibility or debugging, etc.
See also: AbstractObject::hasMethod()
See also: AbstractObject::__call()
public addGlobalMethod ( string $name, callable $callable )
$name string Name of the method
$callable callable Calls your function($object, $arg1, $arg2)

addLocation() public méthode

Add new location with additional resources.
public addLocation ( array $contents, mixed $obsolete = UNDEFINED ) : PathFinder_Location
$contents array
$obsolete mixed
Résultat PathFinder_Location

caughtException() public méthode

Re-define to have custom handling of exceptions system-wide.
public caughtException ( Exception $e )
$e Exception

configExceptionOrDefault() public méthode

Executed when trying to access config parameter which is not find in the file.
public configExceptionOrDefault ( string $default, string $exceptiontext )
$default string
$exceptiontext string

dbConnect() public méthode

Use database configuration settings from config file to establish default connection.
public dbConnect ( mixed $dsn = null ) : DB
$dsn mixed
Résultat DB

encodeHtmlChars() public méthode

By default does not encode already encoded ones.
public encodeHtmlChars ( string $s, integer $flags = null, string $encode = null, boolean $double_encode = false ) : string
$s string
$flags integer
$encode string
$double_encode boolean
Résultat string

getBaseURL() public méthode

Returns base URL of this Web application installation. If you require link to a page, you can use URL::useAbsoluteURL();.
See also: URL::useAbsoluteURL()
public getBaseURL ( ) : string
Résultat string

getConfig() public méthode

Load config if necessary and look up corresponding setting.
public getConfig ( string $path, mixed $default_value = UNDEFINED ) : string
$path string
$default_value mixed
Résultat string

getLogger() public méthode

Initialize logger or return existing one.
public getLogger ( string $class_name = UNDEFINED ) : Logger
$class_name string
Résultat Logger

getStickyArguments() public méthode

public getStickyArguments ( ) : array
Résultat array

getVersion() public méthode

Determine version of Agile Toolkit or specified plug-in.
public getVersion ( string $of = 'atk' ) : string
$of string
Résultat string

hasGlobalMethod() public méthode

Returns if a global method with such name was defined.
public hasGlobalMethod ( string $name ) : boolean
$name string Name of the method
Résultat boolean if registered

locate() public méthode

Find relative path to the resource respective to the current directory.
public locate ( string $type, string $filename = '', string $return = 'relative' ) : string | object | array
$type string
$filename string
$return string
Résultat string | object | array

locatePath() public méthode

Return full system path to specified resource.
public locatePath ( string $type, string $filename = '' ) : string | object | array
$type string
$filename string
Résultat string | object | array

locateURL() public méthode

Calculate URL pointing to specified resource.
public locateURL ( string $type, string $filename = '' ) : string | object | array
$type string
$filename string
Résultat string | object | array

normalizeClassName() public méthode

Class name can have namespaces and they are treated prefectly. If object is passed as $name parameter, then same object is returned. Example: normalizeClassName('User','Model') == 'Model_User';
public normalizeClassName ( string | object $name, string $prefix = null ) : string | object
$name string | object Name of class or object
$prefix string Optional prefix for class name
Résultat string | object Full, normalized class name or received object

normalizeName() public méthode

This will replace all non alpha-numeric characters with separator. Multiple separators in a row is replaced with one. Separators in beginning and at the end of name are removed. Sample input: "Hello, Dear Jon!" Sample output: "Hello_Dear_Jon"
public normalizeName ( string $name, string $separator = '_' ) : string
$name string String to process
$separator string Character acting as separator
Résultat string Normalized string

outputDebug() public méthode

Deprecation: 4.3.2
public outputDebug ( $object, $msg, $shift )

outputWarning() public méthode

Deprecation: 4.3.2
public outputWarning ( $msg, $shift )

readAllConfig() public méthode

Will include all files as they are defined in $this->config_files from folder $config_location.
public readAllConfig ( )

readConfig() public méthode

Read config file and store it in $this->config. Use getConfig() to access.
public readConfig ( string $file = 'config.php' ) : boolean
$file string Filename
Résultat boolean

removeGlobalMethod() public méthode

Removes global method.
public removeGlobalMethod ( string $name )
$name string

requires() public méthode

Verifies version. Should be used by addons. For speed improvement, redefine this into empty function.
public requires ( string $addon = 'atk', string $v, string $location = null ) : boolean
$addon string
$v string
$location string
Résultat boolean

setConfig() public méthode

Manually set configuration option.
public setConfig ( array $config = [], mixed $val = UNDEFINED )
$config array
$val mixed

url() public méthode

Generates URL for specified page. Useful for building links on pages or emails. Returns URL object.
public url ( mixed $page = null, array $arguments = [] ) : URL
$page mixed
$arguments array
Résultat URL

versionRequirement() public méthode

public versionRequirement ( $v, $location = null )

Property Details

$atk_version public_oe property

This is a major version of Agile Toolkit. The APP of Agile Toolkit is very well established and changes rarely. Your application would generally be compatible throughout the same major version of Agile Tooolkit.
public string $atk_version
Résultat string

$compat_42 public_oe property

If you want Agile Toolkit to be compatible with 4.2 version, include compatibility controller.
public bool|Controller_Compat42 $compat_42
Résultat boolean | Controller_Compat42

$config public_oe property

Once configuration file is read, data is saved inside this property.
See also: getConfig()
See also: readConfig()
public array $config
Résultat array

$config_files public_oe property

If you are loading additional config later, use readConfig() instead Order of this array is important.
public array $config_files
Résultat array

$config_files_loaded public_oe property

Contains list of loaded config files.
public array $config_files_loaded
Résultat array

$config_location public_oe property

." or inside "config" sub-folder by setting value to 'config' to better reflect your application layout.
public string $config_location
Résultat string

$db public_oe property

In a typical application, one connection to the database is enough for majority of applications. Calling $app->dbConnect will read Database data from config file and store it in $db property. If you requires a more advanced connectivity or multiple connections, you can manually initialize more database connections.
See also: dbConnect()
public DB $db
Résultat DB

$locale public_oe property

This is the default locale for the application. You change this manually inside application APP class or use some controller which will pull this variable out of the URL. This variable will be respected throughout the framework.
public string $locale
Résultat string

$logger public_oe property

Without logger, APP will dump out errors and exceptions in a very brief and straigtforward way. Logger is a controller which enhances error output and in most cases you do need one. Logger can be further configured to either output detailed errors or show brief message instead.
See also: Logger
public Logger $logger
Résultat Logger

$logger_class public_oe property

If you want to use your own logger class, redefine this property.
public $logger_class

$max_name_length public_oe property

Agile Toolkit implements a mechanism which will replace common beginning of objects with an abbreviation thus keeping object name length under control. This variable defines the maximum length of the object's $name. Be mindful that some objects will concatinate theri name with fields, so the maximum letgth of GET argument names can exceed this value by the length of your field. We recommend you to increase SUHOSIN get limits if you encounter any problems. Set this value to "false" to turn off name shortening.
public int $max_name_length
Résultat integer

$pagemanager_class protected_oe property

Change a different Page Manager class.
protected string $pagemanager_class
Résultat string

$pagemanager_options protected_oe property

Set to array('debug' => true) to debug Page Manager.
protected array $pagemanager_options
Résultat array

$pathfinder public_oe property

PathFinder is a controller which is responsible for locating resources, such as PHP includes, JavaScript files, templates, etc. APP Initializes PathFinder as soon as possible, then defines "Locations" which describe type of data found in different folders.
public PathFinder $pathfinder
Résultat PathFinder

$pathfinder_class protected_oe property

If you would want to use your own PathFinder class, you must change this property and include it.
protected string $pathfinder_class
Résultat string

$pm public_oe property

PageManager object
See also: Controller_PageManager::init()
public Controller_PageManager $pm
Résultat Controller_PageManager

$pr public_oe property

Profiler measures relative time it took in certain parts of your application to help you find a slow-perfoming parts of application. By default $pr points to empty profiler object, which implements empty methods. All the lines referencing $pr myst be prefixed with the 4-symbol sequence "/ ** /" (no spaces). If you want to speed up Agile Toolkit further, you can eliminate all lines started with this sequence from your source code.
public object $pr
Résultat object

$unique_hashes public_oe property

As more names are shortened, the substituted part is being placed into this hash and the value contains the new key. This helps to avoid creating many sequential prefixes for the same character sequenece.
public array $unique_hashes
Résultat array