PHP 클래스 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=
상속: extends AbstractView
파일 보기 프로젝트 열기: atk4/atk4 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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.

보호된 프로퍼티들

프로퍼티 타입 설명
$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.

공개 메소드들

메소드 설명
_ ( 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 )

메소드 상세

_() 공개 메소드

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
리턴 string Localized string

__construct() 공개 메소드

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() 공개 메소드

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

addGlobalMethod() 공개 메소드

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.
또한 보기: AbstractObject::hasMethod()
또한 보기: AbstractObject::__call()
public addGlobalMethod ( string $name, callable $callable )
$name string Name of the method
$callable callable Calls your function($object, $arg1, $arg2)

addLocation() 공개 메소드

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

caughtException() 공개 메소드

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

configExceptionOrDefault() 공개 메소드

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() 공개 메소드

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

encodeHtmlChars() 공개 메소드

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
리턴 string

getBaseURL() 공개 메소드

Returns base URL of this Web application installation. If you require link to a page, you can use URL::useAbsoluteURL();.
또한 보기: URL::useAbsoluteURL()
public getBaseURL ( ) : string
리턴 string

getConfig() 공개 메소드

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

getLogger() 공개 메소드

Initialize logger or return existing one.
public getLogger ( string $class_name = UNDEFINED ) : Logger
$class_name string
리턴 Logger

getStickyArguments() 공개 메소드

public getStickyArguments ( ) : array
리턴 array

getVersion() 공개 메소드

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

hasGlobalMethod() 공개 메소드

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

locate() 공개 메소드

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
리턴 string | object | array

locatePath() 공개 메소드

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

locateURL() 공개 메소드

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

normalizeClassName() 공개 메소드

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
리턴 string | object Full, normalized class name or received object

normalizeName() 공개 메소드

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
리턴 string Normalized string

outputDebug() 공개 메소드

사용 중단: 4.3.2
public outputDebug ( $object, $msg, $shift )

outputWarning() 공개 메소드

사용 중단: 4.3.2
public outputWarning ( $msg, $shift )

readAllConfig() 공개 메소드

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

readConfig() 공개 메소드

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

removeGlobalMethod() 공개 메소드

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

requires() 공개 메소드

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
리턴 boolean

setConfig() 공개 메소드

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

url() 공개 메소드

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
리턴 URL

versionRequirement() 공개 메소드

public versionRequirement ( $v, $location = null )

프로퍼티 상세

$atk_version 공개적으로 프로퍼티

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
리턴 string

$compat_42 공개적으로 프로퍼티

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

$config 공개적으로 프로퍼티

Once configuration file is read, data is saved inside this property.
또한 보기: getConfig()
또한 보기: readConfig()
public array $config
리턴 array

$config_files 공개적으로 프로퍼티

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

$config_files_loaded 공개적으로 프로퍼티

Contains list of loaded config files.
public array $config_files_loaded
리턴 array

$config_location 공개적으로 프로퍼티

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

$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.
또한 보기: dbConnect()
public DB $db
리턴 DB

$locale 공개적으로 프로퍼티

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
리턴 string

$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
public Logger $logger
리턴 Logger

$logger_class 공개적으로 프로퍼티

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

$max_name_length 공개적으로 프로퍼티

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
리턴 integer

$pagemanager_class 보호되어 있는 프로퍼티

Change a different Page Manager class.
protected string $pagemanager_class
리턴 string

$pagemanager_options 보호되어 있는 프로퍼티

Set to array('debug' => true) to debug Page Manager.
protected array $pagemanager_options
리턴 array

$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.
public PathFinder $pathfinder
리턴 PathFinder

$pathfinder_class 보호되어 있는 프로퍼티

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

$pm 공개적으로 프로퍼티

PageManager object
또한 보기: Controller_PageManager::init()
public Controller_PageManager $pm
리턴 Controller_PageManager

$pr 공개적으로 프로퍼티

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
리턴 object

$unique_hashes 공개적으로 프로퍼티

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
리턴 array