PHP 클래스 WPDKView

## Overview To create a view use $view = new WPDKView( 'my-view' ); $view->content = 'Hello World"; $view->display(); Or $view = WPDKView::initWithContent( 'my-view', '', 'Hello World' ); $view->display(); Or, suggested method class MyView extends WPDKView { public function __construct() { parent::__construct( 'my-id', 'additional class' ); } Override public function draw() { echo 'Hello World'; } } ### draw() VS content If you like use a WPDKView directly, you will use the content property. Otherwise, you can sub class the WPDKView and then use the method draw() to diplay the content of the view. ### Observing You can observe some event via filters and actions. For example you can catch when a content has been drawed. For fo this you can use the filter wpdk_view_did_draw_content: add_action( 'wpdk_view_did_draw_content', array( $this, 'wpdk_view_did_draw_content') ); public function wpdk_view_did_draw_content( $view ) { if ( is_a( $view, 'WPDKHeaderView' ) ) { Do something } } In this case we had used the "is_a" function to understand which type of view was passed. Alternatively you can check the view id, for example. public function wpdk_view_did_draw_content( $view ) { if ( 'my_id' == $view->id ) { Do something } }
저자: =undo= ([email protected])
상속: extends WPDKObject
파일 보기 프로젝트 열기: wpxtreme/wpdk 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$__version string Override version
$class array The CSS class or list of classes
$content string The HTML markup content of this view
$data array Key value pairs array Attribute data: data-attribute = value
$id string The unique id for this view
$style array Inline style
$subviews array An array list with the subviews of this view
$superview WPDKView The parent root WPDKView

공개 메소드들

메소드 설명
__construct ( string $id, array | string $class = '' ) : WPDKView Create an instance of WPDKView class
addSubview ( WPDKView $view ) : WPDKView Add a view in queue views
display ( ) : string Display the HTML markup content for this view.
draw ( ) Draw the view content
html ( ) : string Return the HTML markup content of this view
initWithContent ( string $id, array | string $class = '', string $content = '' ) : boolean | WPDKView Create an instance of WPDKView class with a content
initWithFrame ( $id, $rect ) TODO Experimental
removeFromSuperview ( ) Remove this view from its superview

메소드 상세

__construct() 공개 메소드

Create an instance of WPDKView class
public __construct ( string $id, array | string $class = '' ) : WPDKView
$id string The unique id for this view
$class array | string Optional. The CSS classes for this view
리턴 WPDKView

addSubview() 공개 메소드

Add a view in queue views
public addSubview ( WPDKView $view ) : WPDKView
$view WPDKView
리턴 WPDKView

display() 공개 메소드

Display the HTML markup content for this view.
public display ( ) : string
리턴 string

draw() 공개 메소드

Draw the view content
public draw ( )

html() 공개 메소드

Return the HTML markup content of this view
public html ( ) : string
리턴 string

initWithContent() 공개 정적인 메소드

Create an instance of WPDKView class with a content
public static initWithContent ( string $id, array | string $class = '', string $content = '' ) : boolean | WPDKView
$id string The unique id for this view
$class array | string Optional. The CSS classes for this view
$content string Optional. An HTML markup content
리턴 boolean | WPDKView Return an instance of WPDKView or FALSE if error

initWithFrame() 공개 정적인 메소드

TODO Experimental
public static initWithFrame ( $id, $rect )

removeFromSuperview() 공개 메소드

Remove this view from its superview
public removeFromSuperview ( )

프로퍼티 상세

$__version 공개적으로 프로퍼티

Override version
public string $__version
리턴 string

$class 공개적으로 프로퍼티

The CSS class or list of classes
public array $class
리턴 array

$content 공개적으로 프로퍼티

The HTML markup content of this view
public string $content
리턴 string

$data 공개적으로 프로퍼티

Key value pairs array Attribute data: data-attribute = value
public array $data
리턴 array

$id 공개적으로 프로퍼티

The unique id for this view
public string $id
리턴 string

$style 공개적으로 프로퍼티

Inline style
public array $style
리턴 array

$subviews 공개적으로 프로퍼티

An array list with the subviews of this view
public array $subviews
리턴 array

$superview 공개적으로 프로퍼티

The parent root WPDKView
public WPDKView $superview
리턴 WPDKView