PHP Class VirtualPage, atk4

VirtualPage gives you a unique URL to the page where you can add objects. VirtualPage is intelligent enough to act differently depending on where you add it. This way you can create popup on page load. $vp = $this->add('VirtualPage'); $this->js(true)->univ()->frameURL('MyPopup',$vp->getURL()); $vp->set(function($vp){ $vp->add('LoremIpsum'); // <-- will appear within a frame }); Here is how you can bind it to a button or other view through JS element. Calling "bindEvent" will automatically tie in frameURL for you. $b=$page->add('Button')->set('Open popup'); $b->add('VirtualPage') ->bindEvent('My Cool Title','click') ->set(function($page){ $page->add('LoremIpsum'); }); This would add a button into a Grid which would show you row's ID. $grid->add('VirtualPage') ->addColumn('edit') ->set(function($page){ $id = $_GET[$page->short_name.'_id']; $page->add('Text')->set('ID='.$id); }); There are many other uses for VirtualPage, especially when you extract it's URL. $b = $page->add('Button')->set('Request new password'); $b->js('click')->univ()->location( $this->add('VirtualPage') ->set(function($p){ $p->add('Text')->set('Check your email for confirmation'); }) ->getURL() ); (If you do this, be mindful of stickyGET arguments and don't call from inside form's submit code
Inheritance: extends AbstractController
Mostrar archivo Open project: atk4/atk4 Class Usage Examples

Public Properties

Property Type Description
$app App_Frontend
$frame_options array
$owner View | Grid
$page_class string
$page_template array | string
$type string

Protected Properties

Property Type Description
$page Page

Public Methods

Method Description
addColumn ( string $name, string $title = null, array | string $buttontext = null, Grid $grid = null ) Call this if you are adding this inside a grid.
bindEvent ( string $title = '', string $event = 'click', string $selector = null ) Bind owner's event (click by default) to a JavaScript chain which would open a new frame (or dialog, depending on $type property), and execute associated code inside it.
getPage ( ) : Page Simply returns a page we can put stuff on. This page would be displayed instead of regular page, so beware.
getURL ( string $arg = 'true' ) : URL Return the URL which would trigger execution of the associated code within a separate page.
isActive ( string $mode = null ) : boolean | string Returns true if the URL is requesting the page to be shown.
set ( callable $method_or_arg, callable $method = null ) Associates code with the page. This code will be executed within a brand new page when called by URL.

Method Details

addColumn() public method

Call this if you are adding this inside a grid.
public addColumn ( string $name, string $title = null, array | string $buttontext = null, Grid $grid = null )
$name string Field Name (must not contain spaces)
$title string Header for the column
$buttontext array | string Text to put on the button
$grid Grid Specify grid to use, other than $owner

bindEvent() public method

Bind owner's event (click by default) to a JavaScript chain which would open a new frame (or dialog, depending on $type property), and execute associated code inside it.
public bindEvent ( string $title = '', string $event = 'click', string $selector = null )
$title string Title of the frame
$event string JavaScript event
$selector string Not all parent will respond to click but only a selector

getPage() public method

Simply returns a page we can put stuff on. This page would be displayed instead of regular page, so beware.
public getPage ( ) : Page
return Page page to be displayed

getURL() public method

Return the URL which would trigger execution of the associated code within a separate page.
public getURL ( string $arg = 'true' ) : URL
$arg string Argument to pass to the page
return URL

isActive() public method

If no parameter is passed, then return active page mode.
public isActive ( string $mode = null ) : boolean | string
$mode string Optionally ask for specific mode
return boolean | string

set() public method

Associates code with the page. This code will be executed within a brand new page when called by URL.
public set ( callable $method_or_arg, callable $method = null )
$method_or_arg callable Optional argument
$method callable function($page){ .. }

Property Details

$app public_oe property

public App_Frontend $app
return App_Frontend

$frame_options public_oe property

public array $frame_options
return array

$owner public_oe property

public View|Grid $owner
return View | Grid

$page protected_oe property

protected Page $page
return Page

$page_class public_oe property

public string $page_class
return string

$page_template public_oe property

public array|string $page_template
return array | string

$type public_oe property

public string $type
return string