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
Afficher le fichier Open project: atk4/atk4 Class Usage Examples

Méthodes publiques

Свойство Type Description
$app App_Frontend
$frame_options array
$owner View | Grid
$page_class string
$page_template array | string
$type string

Protected Properties

Свойство Type Description
$page Page

Méthodes publiques

Méthode 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 méthode

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 méthode

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 méthode

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

getURL() public méthode

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
Résultat URL

isActive() public méthode

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

set() public méthode

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
Résultat App_Frontend

$frame_options public_oe property

public array $frame_options
Résultat array

$owner public_oe property

public View|Grid $owner
Résultat View | Grid

$page protected_oe property

protected Page $page
Résultat Page

$page_class public_oe property

public string $page_class
Résultat string

$page_template public_oe property

public array|string $page_template
Résultat array | string

$type public_oe property

public string $type
Résultat string