WPDK  1.5.0
WordPress Development Kit
 All Data Structures Files Functions Variables Pages
WPDKView Class Reference
Inheritance diagram for WPDKView:
WPDKObject WPDKDynamicTableView WPDKHeaderView WPDKjQueryTabsView WPDKMetaBoxView WPDKPreferencesView

Public Member Functions

 __construct ($id, $class= '')
 Construct. More...
 
 html ()
 Get HTML markup content. More...
 
 draw ()
 Draw. More...
 
 addSubview ($view)
 Add a subview. More...
 
 removeFromSuperview ()
 Remove this view. More...
 
- Public Member Functions inherited from WPDKObject
 __className ()
 Returns the class object. More...
 
 __parentClass ()
 Returns the class object for the receiver’s superclass. More...
 
 __isClass ($class)
 Brief. More...
 
 __isSubclassOfClass ($class)
 Return TRUE if the receiving class is a subclass of —or identical to— $class, otherwise FALSE. More...
 

Static Public Member Functions

static initWithContent ($id, $class= '', $content= '')
 Init a WPDKView. More...
 
static initWithFrame ($id, $rect)
 
- Static Public Member Functions inherited from WPDKObject
static __delta ($last_version, $old_version)
 Object delta compare for combine. More...
 
static delta ($last_version, $old_version)
 
static __dump ($var, $monitor=false)
 Dump a variable. More...
 

Data Fields

 $__version = '1.1.2'
 Version. More...
 
 $class
 Class. More...
 
 $style
 Inline style. More...
 
 $content
 The content. More...
 
 $data
 
 $id
 ID. More...
 
 $subviews
 List of sub views. More...
 
 $superview
 The superview. More...
 
- Data Fields inherited from WPDKObject
 $__version = '1.0.0'
 The version number assigned to the class. More...
 

Protected Attributes

 $views
 List of views. More...
 

Detailed Description

The base view class

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
  }
}
Author
=undo= info@.nosp@m.wpxt.nosp@m.re.me
Date
2014-01-08
Version
1.1.2

Definition at line 63 of file wpdk-view.php.

Constructor & Destructor Documentation

__construct (   $id,
  $class = '' 
)

Construct.

Create an instance of WPDKView class

Parameters
string$idThe unique id for this view
array | string$classOptional. The CSS classes for this view
Returns
WPDKView

Definition at line 155 of file wpdk-view.php.

Member Function Documentation

addSubview (   $view)

Add a subview.

Add a view in queue views

Parameters
WPDKView$view
Returns
WPDKView

Definition at line 273 of file wpdk-view.php.

draw ( )

Draw.

Draw the view content

Note
This method can be over-ridden in a sub-class.

Definition at line 257 of file wpdk-view.php.

html ( )

Get HTML markup content.

Return the HTML markup content of this view

Returns
string

Definition at line 197 of file wpdk-view.php.

static initWithContent (   $id,
  $class = '',
  $content = '' 
)
static

Init a WPDKView.

Create an instance of WPDKView class with a content

Parameters
string$idThe unique id for this view
array | string$classOptional. The CSS classes for this view
string$contentOptional. An HTML markup content
Returns
bool|WPDKView Return an instance of WPDKView or FALSE if error

Definition at line 175 of file wpdk-view.php.

static initWithFrame (   $id,
  $rect 
)
static

Definition at line 186 of file wpdk-view.php.

removeFromSuperview ( )

Remove this view.

Remove this view from its superview

Definition at line 289 of file wpdk-view.php.

Field Documentation

string $__version = '1.1.2'

Version.

Override version

Definition at line 72 of file wpdk-view.php.

array $class

Class.

The CSS class or list of classes

Definition at line 81 of file wpdk-view.php.

string $content

The content.

The HTML markup content of this view

Definition at line 99 of file wpdk-view.php.

array $data

Key value pairs array Attribute data: data-attribute = value

Definition at line 106 of file wpdk-view.php.

string $id

ID.

The unique id for this view

Definition at line 115 of file wpdk-view.php.

array $style

Inline style.

Inline style

Definition at line 90 of file wpdk-view.php.

array $subviews

List of sub views.

An array list with the subviews of this view

Definition at line 124 of file wpdk-view.php.

WPDKView $superview

The superview.

The parent root WPDKView

Definition at line 133 of file wpdk-view.php.

array $views
protected

List of views.

An array list with views of this view controller

Deprecated:
Since 1.0.0.b4 - Use subviews instead

Definition at line 143 of file wpdk-view.php.


The documentation for this class was generated from the following file: