PHP 클래스 AbstractView, atk4

They are used to take user input and return it in appropriate format.
파일 보기 프로젝트 열기: atk4/atk4 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$_tsBuffer
$auto_track_element boolean
$default_controller string automatically.
$dq DB_dsql Using dq property looks obsolete, but left for compatibility
$js of jQuery_Chains
$spot string $spot defines a place on a parent's template where render() will output() resulting HTML.
$template Template Example: $view->template->set('title', $my_title); Assuming you have tag in template file associated with this view - will insert text into this tag.
$template_flush string

공개 메소드들

메소드 설명
__clone ( ) For safety, you can't clone views. Use $view->newInstance instead.
_tsBuffer ( $t, $data )
defaultSpot ( ) : string Normally when you add a view, it's output is placed inside tag of its parent view. You can specify a different tag as 3rd argument for the add() method. If you wish for object to use different tag by default, you can override this method.
defaultTemplate ( ) : string This method is commonly redefined to set a default template for an object.
getHTML ( boolean $destroy = true, boolean $execute_js = true ) : string Converting View into string will render recursively and produce HTML.
getJSID ( ) : string
initTemplateTags ( ) This method is called to automatically fill in some of the tags in this view. Normally the call is bassed to $app->setTags(), however you can extend and add more tags to fill.
initializeTemplate ( string $template_spot = null, string | array $template_branch = null ) : AbstractView Called automatically during init for template initalization.
js ( string | boolean | null $when = null, array | jQuery_Chain | string $code = null, string $instance = null ) : jQuery_Chain Views in Agile Toolkit can assign javascript actions to themselves. This is done by calling $view->js() method.
modelRender ( ) When model is specified for a view, values of the model is inserted inside the template if corresponding tags exist.
moveJStoParent ( ) Append our chains to owner's chains. JS chains bubble up to app, which plugs them into template. If the object is being "cut" then only relevant chains will be outputed.
on ( $event, $selector = null, $js = null ) Views in Agile Toolkit can assign javascript actions to themselves. This is done by calling $view->js() or $view->on().
output ( string $txt ) Low level output function which append's to the parent object's template. For normal objects, you simply need to specify a suitable template.
recursiveRender ( ) Recursively renders all views. Calls render() for all or for the one being cut. In some cases you may want to redefine this function instead of render(). The difference is that this function is called before sub-views are rendered, but render() is called after.
region_render ( ) When "cut"-ing using cut_region we need to output only a specified tag. This method of cutting is mostly un-used now, and should be considered obsolete.
render ( ) Default rendering method. Generates HTML presentation of $this view.
setModel ( object | string $model, array | string | null $actual_fields = UNDEFINED ) : AbstractModel Associate view with a model. Additionally may initialize a controller which would copy fields from the model into the View.

메소드 상세

__clone() 공개 메소드

For safety, you can't clone views. Use $view->newInstance instead.
public __clone ( )

_tsBuffer() 공개 메소드

public _tsBuffer ( $t, $data )

defaultSpot() 공개 메소드

Normally when you add a view, it's output is placed inside tag of its parent view. You can specify a different tag as 3rd argument for the add() method. If you wish for object to use different tag by default, you can override this method.
public defaultSpot ( ) : string
리턴 string Tag / Spot in $this->owner->template

defaultTemplate() 공개 메소드

If you return string, object will try to clone specified region off the parent. If you specify array, it will load and parse a separate template. This is overriden by 4th argument in add() method
public defaultTemplate ( ) : string
리턴 string Template definition

getHTML() 공개 메소드

If argument is passed, JavaScript will be added into on_ready section of your document like when rendered normally. Note that you might require to destroy object if you don't want it's HTML to appear normally.
public getHTML ( boolean $destroy = true, boolean $execute_js = true ) : string
$destroy boolean Destroy object preventing it from rendering
$execute_js boolean Also capture JavaScript chains of object
리턴 string HTML

getJSID() 공개 메소드

public getJSID ( ) : string
리턴 string

initTemplateTags() 공개 메소드

This method is called to automatically fill in some of the tags in this view. Normally the call is bassed to $app->setTags(), however you can extend and add more tags to fill.
public initTemplateTags ( )

initializeTemplate() 공개 메소드

Called automatically during init for template initalization.
public initializeTemplate ( string $template_spot = null, string | array $template_branch = null ) : AbstractView
$template_spot string Where object's output goes
$template_branch string | array Where objects gets it's template
리턴 AbstractView $this

js() 공개 메소드

Method js() will return jQuery_Chain object which would record all calls to it's non-existant methods and convert them into jQuery call chain. js([action], [other_chain]); Action can represent javascript event, such as "click" or "mouseenter". If you specify action = true, then the event will ALWAYS be executed on pageload. It will also be executed if respective view is being reloaded by js()->reload() (Do not make mistake by specifying "true" instead of true) action = false will still return jQuery chain but will not bind it. You can bind it by passing to a different object's js() call as 2nd argument or output the chain in response to AJAX-ec call by calling execute() method. 1. Calling with arguments: $view->js(); // does nothing $a = $view->js()->hide(); // creates chain for hiding $view but does not bind to event yet. 2. Binding existing chains $img->js('mouseenter', $a); // binds previously defined chain to event on event of $img. Produced code: $('#img_id').click(function(ev){ ev.preventDefault(); $('view1').hide(); }); 3. $button->js('click',$form->js()->submit()); clicking button will result in form submit 4. $view->js(true)->find('.current')->text($text); Will convert calls to jQuery chain into JavaScript string: $('#view').find('.current').text('abc'); // The $text will be json-encoded to avoid JS injection. 5. ON YOUR OWN RISK $view->js(true,'alert(123)'); Will inject javascript un-escaped portion of javascript into chain. If you need to have a custom script then put it into file instead, save into templates/js/myfile.js and then include: $view->js()->_load('myfile'); It's highly suggested to bind your libraries with jQuery namespace by registered them as plugins, this way you can call your function easily: $view->js(true)->_load('myfile')->myplugin('myfunc',array($arg,$arg)); This approach is compatible with jQuery UI Widget factory and will keep your code clean
public js ( string | boolean | null $when = null, array | jQuery_Chain | string $code = null, string $instance = null ) : jQuery_Chain
$when string | boolean | null Event when chain will be executed
$code array | jQuery_Chain | string JavaScript chain(s) or code
$instance string Obsolete
리턴 jQuery_Chain

modelRender() 공개 메소드

This is used as default values and filled out before the actual render kicks in.
public modelRender ( )

moveJStoParent() 공개 메소드

Append our chains to owner's chains. JS chains bubble up to app, which plugs them into template. If the object is being "cut" then only relevant chains will be outputed.
public moveJStoParent ( )

on() 공개 메소드

on() method implements implementation of jQuery on() method. on(event, [selector], [other_chain]) Returned is a javascript chain wich is executed when event is triggered on specified selector (or all of the view if selector is ommitted). Optional other_chain argument can contain one or more chains (in array) which will also be executed. The chain returned by on() will properly select affected element. For example if the following view would contain multiple elements, then only the clicked-one will be hidden. on('click','a')->hide(); Other_chain can also be specified as a Callable. In this case the executable code you have specified here will be called with several arguments: function($js, $data){ $js->hide(); } In this case javascript method is executed on a clicked event but in a more AJAX-way If your method returns a javascript chain, it will be executed instead. You can execute both if you embed $js inside returned chain. The third argument passed to your method contains
public on ( $event, $selector = null, $js = null )
Low level output function which append's to the parent object's template. For normal objects, you simply need to specify a suitable template.
public output ( string $txt )
$txt string HTML chunk

recursiveRender() 공개 메소드

function recursiveRender(){ $this->add('Text')->set('test'); return parent::recursiveRender(); // will render Text also } When cut_object is specified in the GET arguments, then output of HTML would be limited to object with matching $name or $short_name. This method will be called instead of default render() and it will stop rendering process and output object's HTML once it finds a suitable object. Exception_StopRender is used to terminate rendering process and bubble up to the APP. This exception is not an error.
public recursiveRender ( )

region_render() 공개 메소드

When "cut"-ing using cut_region we need to output only a specified tag. This method of cutting is mostly un-used now, and should be considered obsolete.
사용 중단: 4.3.1
public region_render ( )

render() 공개 메소드

For most views, rendering the $this->template would be sufficient. If your view requires to do some heavy-duty work, please be sure to do it inside render() method. This way would save some performance in cases when your object is not being rendered. render method relies on method output(), which appeends HTML chunks to the parent's template.
public render ( )

setModel() 공개 메소드

Associate view with a model. Additionally may initialize a controller which would copy fields from the model into the View.
public setModel ( object | string $model, array | string | null $actual_fields = UNDEFINED ) : AbstractModel
$model object | string Class without "Model_" prefix or object
$actual_fields array | string | null List of fields in order to populate
리턴 AbstractModel object

프로퍼티 상세

$_tsBuffer 공개적으로 프로퍼티

public $_tsBuffer

$auto_track_element 공개적으로 프로퍼티

public bool $auto_track_element
리턴 boolean

$default_controller 공개적으로 프로퍼티

automatically.
public string $default_controller
리턴 string

$dq 공개적으로 프로퍼티

Using dq property looks obsolete, but left for compatibility
또한 보기: self::setModel()
public DB_dsql $dq
리턴 DB_dsql

$js 공개적으로 프로퍼티

of jQuery_Chains
public $js

$spot 공개적으로 프로퍼티

$spot defines a place on a parent's template where render() will output() resulting HTML.
또한 보기: output()
또한 보기: render()
public string $spot
리턴 string

$template 공개적으로 프로퍼티

Example: $view->template->set('title', $my_title); Assuming you have tag in template file associated with this view - will insert text into this tag.
public Template $template
리턴 Template

$template_flush 공개적으로 프로퍼티

public string $template_flush
리턴 string