PHP Класс 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
Наследование: extends AbstractController
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$app App_Frontend
$frame_options array
$owner View | Grid
$page_class string
$page_template array | string
$type string

Защищенные свойства (Protected)

Свойство Тип Описание
$page Page

Открытые методы

Метод Описание
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.

Описание методов

addColumn() публичный метод

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() публичный метод

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() публичный метод

Simply returns a page we can put stuff on. This page would be displayed instead of regular page, so beware.
public getPage ( ) : Page
Результат Page page to be displayed

getURL() публичный метод

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
Результат URL

isActive() публичный метод

If no parameter is passed, then return active page mode.
public isActive ( string $mode = null ) : boolean | string
$mode string Optionally ask for specific mode
Результат boolean | string

set() публичный метод

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){ .. }

Описание свойств

$app публичное свойство

public App_Frontend $app
Результат App_Frontend

$frame_options публичное свойство

public array $frame_options
Результат array

$owner публичное свойство

public View|Grid $owner
Результат View | Grid

$page защищенное свойство

protected Page $page
Результат Page

$page_class публичное свойство

public string $page_class
Результат string

$page_template публичное свойство

public array|string $page_template
Результат array | string

$type публичное свойство

public string $type
Результат string