+$view = \Atk4\Ui\View::addTo($app, ['template' => new HtmlTemplate('
Empty lister with custom template
{List}
{$name}
{empty}no flags to show here{/}{/}
')]);
-$lister = \atk4\ui\Lister::addTo($view, [], ['List']);
-$lister->onHook(\atk4\ui\Lister::HOOK_BEFORE_ROW, function (\atk4\ui\Lister $lister) {
+$lister = \Atk4\Ui\Lister::addTo($view, [], ['List']);
+$lister->onHook(\Atk4\Ui\Lister::HOOK_BEFORE_ROW, function (\Atk4\Ui\Lister $lister) {
$lister->current_row->set('iso', mb_strtolower($lister->current_row->get('iso')));
});
$lister->setModel(new Country($app->db))
->addCondition('id', -1); // no such records so model will be empty
-\atk4\ui\View::addTo($app, ['ui' => 'clearing divider']);
-\atk4\ui\Header::addTo($app, ['Item per page', 'subHeader' => 'Lister can display a certain amount of items']);
+\Atk4\Ui\View::addTo($app, ['ui' => 'clearing divider']);
+\Atk4\Ui\Header::addTo($app, ['Item per page', 'subHeader' => 'Lister can display a certain amount of items']);
-$container = \atk4\ui\View::addTo($app);
+$container = \Atk4\Ui\View::addTo($app);
-$view = \atk4\ui\View::addTo($container, ['template' => new HtmlTemplate('
+$view = \Atk4\Ui\View::addTo($container, ['template' => new HtmlTemplate('
{List}
{name}andorra{/}
{/}
{$Content}
')]);
-$lister = \atk4\ui\Lister::addTo($view, [], ['List']);
-$lister->onHook(\atk4\ui\Lister::HOOK_BEFORE_ROW, function (\atk4\ui\Lister $lister) {
+$lister = \Atk4\Ui\Lister::addTo($view, [], ['List']);
+$lister->onHook(\Atk4\Ui\Lister::HOOK_BEFORE_ROW, function (\Atk4\Ui\Lister $lister) {
$lister->current_row->set('iso', mb_strtolower($lister->current_row->get('iso')));
});
$model = $lister->setModel(new Country($app->db))->setLimit(12);
-$ipp = \atk4\ui\ItemsPerPageSelector::addTo($view, ['label' => 'Select how many countries:', 'pageLengthItems' => [12, 24, 36]], ['Content']);
+$ipp = \Atk4\Ui\ItemsPerPageSelector::addTo($view, ['label' => 'Select how many countries:', 'pageLengthItems' => [12, 24, 36]], ['Content']);
$ipp->onPageLengthSelect(function ($ipp) use ($model, $container) {
$model->setLimit($ipp);
diff --git a/demos/collection/multitable.php b/demos/collection/multitable.php
index 8a916e494a..4f1b2ae580 100644
--- a/demos/collection/multitable.php
+++ b/demos/collection/multitable.php
@@ -2,25 +2,25 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
// Re-usable component implementing counter
-/** @var \atk4\ui\Columns $finderClass */
-$finderClass = get_class(new class() extends \atk4\ui\Columns {
+/** @var \Atk4\Ui\Columns $finderClass */
+$finderClass = get_class(new class() extends \Atk4\Ui\Columns {
public $route = [];
- public function setModel(\atk4\data\Model $model, $route = [])
+ public function setModel(\Atk4\Data\Model $model, $route = [])
{
parent::setModel($model);
$this->addClass('internally celled');
// lets add our first table here
- $table = \atk4\ui\Table::addTo($this->addColumn(), ['header' => false, 'very basic selectable'])->addStyle('cursor', 'pointer');
+ $table = \Atk4\Ui\Table::addTo($this->addColumn(), ['header' => false, 'very basic selectable'])->addStyle('cursor', 'pointer');
$table->setModel($model, [$model->title_field]);
$selections = explode(',', $_GET[$this->name] ?? '');
@@ -30,9 +30,9 @@ public function setModel(\atk4\data\Model $model, $route = [])
}
$path = [];
- $jsReload = new \atk4\ui\JsReload($this, [$this->name => new \atk4\ui\JsExpression('[]+[]', [
+ $jsReload = new \Atk4\Ui\JsReload($this, [$this->name => new \Atk4\Ui\JsExpression('[]+[]', [
$path ? (implode(',', $path) . ',') : '',
- new \atk4\ui\JsExpression('$(this).data("id")'),
+ new \Atk4\Ui\JsExpression('$(this).data("id")'),
])]);
$table->on('click', 'tr', $jsReload);
@@ -54,16 +54,16 @@ public function setModel(\atk4\data\Model $model, $route = [])
$pushModel = $pushModel->ref($ref);
- $table = \atk4\ui\Table::addTo($this->addColumn(), ['header' => false, 'very basic selectable'])->addStyle('cursor', 'pointer');
+ $table = \Atk4\Ui\Table::addTo($this->addColumn(), ['header' => false, 'very basic selectable'])->addStyle('cursor', 'pointer');
$table->setModel($pushModel->setLimit(10), [$pushModel->title_field]);
if ($selections) {
$table->js(true)->find('tr[data-id=' . $selections[0] . ']')->addClass('active');
}
- $jsReload = new \atk4\ui\JsReload($this, [$this->name => new \atk4\ui\JsExpression('[]+[]', [
+ $jsReload = new \Atk4\Ui\JsReload($this, [$this->name => new \Atk4\Ui\JsExpression('[]+[]', [
$path ? (implode(',', $path) . ',') : '',
- new \atk4\ui\JsExpression('$(this).data("id")'),
+ new \Atk4\Ui\JsExpression('$(this).data("id")'),
])]);
$table->on('click', 'tr', $jsReload);
}
@@ -76,16 +76,16 @@ public function setModel(\atk4\data\Model $model, $route = [])
$model->addCondition('parent_folder_id', null);
$model->setOrder(['is_folder' => 'desc', 'name']);
-\atk4\ui\Header::addTo($app, ['MacOS File Finder', 'subHeader' => 'Component built around Table, Columns and JsReload']);
+\Atk4\Ui\Header::addTo($app, ['MacOS File Finder', 'subHeader' => 'Component built around Table, Columns and JsReload']);
-$vp = \atk4\ui\VirtualPage::addTo($app)->set(function ($vp) use ($model) {
+$vp = \Atk4\Ui\VirtualPage::addTo($app)->set(function ($vp) use ($model) {
$model->action('delete')->execute();
$model->importFromFilesystem('.');
- \atk4\ui\Button::addTo($vp, ['Import Complete', 'big green fluid'])->link('multitable.php');
+ \Atk4\Ui\Button::addTo($vp, ['Import Complete', 'big green fluid'])->link('multitable.php');
$vp->js(true)->closest('.modal')->find('.header')->remove();
});
-\atk4\ui\Button::addTo($app, ['Re-Import From Filesystem', 'top attached'])->on('click', new \atk4\ui\JsModal('Now importing ... ', $vp));
+\Atk4\Ui\Button::addTo($app, ['Re-Import From Filesystem', 'top attached'])->on('click', new \Atk4\Ui\JsModal('Now importing ... ', $vp));
$finderClass::addTo($app, ['bottom attached'])
->addClass('top attached segment')
diff --git a/demos/collection/table.php b/demos/collection/table.php
index edf0c62959..304cbd5eea 100644
--- a/demos/collection/table.php
+++ b/demos/collection/table.php
@@ -2,22 +2,22 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-use atk4\ui\Table;
+use Atk4\Ui\Table;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
if ($id = $_GET['id'] ?? null) {
- $app->layout->js(true, new \atk4\ui\JsToast('Details link is in simulation mode.'));
+ $app->layout->js(true, new \Atk4\Ui\JsToast('Details link is in simulation mode.'));
}
-$bb = \atk4\ui\View::addTo($app, ['ui' => 'buttons']);
+$bb = \Atk4\Ui\View::addTo($app, ['ui' => 'buttons']);
-$table = \atk4\ui\Table::addTo($app, ['celled' => true]);
-\atk4\ui\Button::addTo($bb, ['Refresh Table', 'icon' => 'refresh'])
- ->on('click', new \atk4\ui\JsReload($table));
+$table = \Atk4\Ui\Table::addTo($app, ['celled' => true]);
+\Atk4\Ui\Button::addTo($bb, ['Refresh Table', 'icon' => 'refresh'])
+ ->on('click', new \Atk4\Ui\JsReload($table));
$bb->on('click', $table->js()->reload());
@@ -34,7 +34,7 @@
$table->addColumn('salary', new Table\Column\Money());
$table->addColumn('logo_url', [Table\Column\Image::class, 'caption' => 'Our Logo']);
-$table->onHook(Table\Column::HOOK_GET_HTML_TAGS, function ($table, \atk4\data\Model $row) {
+$table->onHook(Table\Column::HOOK_GET_HTML_TAGS, function ($table, \Atk4\Data\Model $row) {
switch ($row->getId()) {
case 1: $color = 'yellow';
@@ -63,7 +63,7 @@
['name' => 'Brett', 'surname' => 'Bird', 'birthdate' => '1988-12-20', 'cv' => null],
];
-$table = \atk4\ui\Table::addTo($app);
+$table = \Atk4\Ui\Table::addTo($app);
$table->setSource($myArray, ['name']);
//$table->addColumn('name');
diff --git a/demos/collection/table2.php b/demos/collection/table2.php
index 183ac974a8..e6db9db8fa 100644
--- a/demos/collection/table2.php
+++ b/demos/collection/table2.php
@@ -2,11 +2,11 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-use atk4\ui\Table;
+use Atk4\Ui\Table;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
$data = [
@@ -15,12 +15,12 @@
['id' => 3, 'action' => 'Tax', 'amount' => -40],
];
-$model = new \atk4\data\Model(new \atk4\data\Persistence\Static_($data));
+$model = new \Atk4\Data\Model(new \Atk4\Data\Persistence\Static_($data));
$model->getField('amount')->type = 'money';
-\atk4\ui\Header::addTo($app, ['Table with various headers', 'subHeader' => 'Demonstrates how you can add subheaders, footnotes and other insertions into your data table', 'icon' => 'table']);
+\Atk4\Ui\Header::addTo($app, ['Table with various headers', 'subHeader' => 'Demonstrates how you can add subheaders, footnotes and other insertions into your data table', 'icon' => 'table']);
-$table = \atk4\ui\Table::addTo($app);
+$table = \Atk4\Ui\Table::addTo($app);
$table->setModel($model, ['action']);
$table->addColumn('amount', [Table\Column\Money::class]);
@@ -29,7 +29,7 @@
$table->template->dangerouslyAppendHtml('Body', '
This is part of body, goes before other rows
');
// Hook can be used to display data before row. You can also inject and format extra rows.
-$table->onHook(\atk4\ui\Lister::HOOK_BEFORE_ROW, function (Table $table) {
+$table->onHook(\Atk4\Ui\Lister::HOOK_BEFORE_ROW, function (Table $table) {
if ($table->current_row->getId() === 2) {
$table->template->dangerouslyAppendHtml('Body', '
This goes above row with ID=2 (' . $table->current_row->get('action') . ')
{/}
{$Content}')]);
-$lister = \atk4\ui\Lister::addTo($view, [], ['List']);
-$lister->onHook(\atk4\ui\Lister::HOOK_BEFORE_ROW, function (\atk4\ui\Lister $lister) {
+$lister = \Atk4\Ui\Lister::addTo($view, [], ['List']);
+$lister->onHook(\Atk4\Ui\Lister::HOOK_BEFORE_ROW, function (\Atk4\Ui\Lister $lister) {
$lister->current_row->set('iso', mb_strtolower($lister->current_row->get('iso')));
});
diff --git a/demos/interactive/scroll-table.php b/demos/interactive/scroll-table.php
index c6397cb6f3..7176347ebb 100644
--- a/demos/interactive/scroll-table.php
+++ b/demos/interactive/scroll-table.php
@@ -2,20 +2,20 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
-\atk4\ui\Button::addTo($app, ['Dynamic scroll in Lister', 'small left floated basic blue', 'icon' => 'left arrow'])
+\Atk4\Ui\Button::addTo($app, ['Dynamic scroll in Lister', 'small left floated basic blue', 'icon' => 'left arrow'])
->link(['scroll-lister']);
-\atk4\ui\Button::addTo($app, ['Dynamic scroll in Container', 'small right floated basic blue', 'iconRight' => 'right arrow'])
+\Atk4\Ui\Button::addTo($app, ['Dynamic scroll in Container', 'small right floated basic blue', 'iconRight' => 'right arrow'])
->link(['scroll-container']);
-\atk4\ui\View::addTo($app, ['ui' => 'ui clearing divider']);
+\Atk4\Ui\View::addTo($app, ['ui' => 'ui clearing divider']);
-\atk4\ui\Header::addTo($app, ['Dynamic scroll in Table']);
+\Atk4\Ui\Header::addTo($app, ['Dynamic scroll in Table']);
-$table = \atk4\ui\Table::addTo($app);
+$table = \Atk4\Ui\Table::addTo($app);
$model = $table->setModel(new Country($app->db));
//$model->addCondition('name','like','A%');
diff --git a/demos/interactive/sse.php b/demos/interactive/sse.php
index 7f2ff0c65c..0e221fddb4 100644
--- a/demos/interactive/sse.php
+++ b/demos/interactive/sse.php
@@ -2,21 +2,21 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
-\atk4\ui\Header::addTo($app, ['SSE with ProgressBar']);
+\Atk4\Ui\Header::addTo($app, ['SSE with ProgressBar']);
-$bar = \atk4\ui\ProgressBar::addTo($app);
+$bar = \Atk4\Ui\ProgressBar::addTo($app);
-$button = \atk4\ui\Button::addTo($app, ['Turn On']);
-$buttonStop = \atk4\ui\Button::addTo($app, ['Turn Off']);
+$button = \Atk4\Ui\Button::addTo($app, ['Turn On']);
+$buttonStop = \Atk4\Ui\Button::addTo($app, ['Turn Off']);
// non-SSE way
//$button->on('click', $bar->js()->progress(['percent'=> 40]));
-$sse = \atk4\ui\JsSse::addTo($app, ['showLoader' => true]);
+$sse = \Atk4\Ui\JsSse::addTo($app, ['showLoader' => true]);
$button->on('click', $sse->set(function () use ($button, $sse, $bar) {
$sse->send($button->js()->addClass('disabled'));
@@ -39,11 +39,11 @@
$buttonStop->on('click', [$button->js()->atkServerEvent('stop'), $button->js()->removeClass('disabled')]);
-\atk4\ui\View::addTo($app, ['ui' => 'divider']);
-\atk4\ui\Header::addTo($app, ['SSE operation with user confirmation']);
+\Atk4\Ui\View::addTo($app, ['ui' => 'divider']);
+\Atk4\Ui\Header::addTo($app, ['SSE operation with user confirmation']);
-$sse = \atk4\ui\JsSse::addTo($app);
-$button = \atk4\ui\Button::addTo($app, ['Click me to change my text']);
+$sse = \Atk4\Ui\JsSse::addTo($app);
+$button = \Atk4\Ui\Button::addTo($app, ['Click me to change my text']);
$button->on('click', $sse->set(function ($jsChain) use ($sse, $button) {
$sse->send($button->js()->text('Please wait for 2 seconds...'));
diff --git a/demos/interactive/tabs.php b/demos/interactive/tabs.php
index abd5793f51..b9b4ca2d1d 100644
--- a/demos/interactive/tabs.php
+++ b/demos/interactive/tabs.php
@@ -2,50 +2,50 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
/**
* Demonstrates how to use tabs.
*/
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
-$tabs = \atk4\ui\Tabs::addTo($app);
+$tabs = \Atk4\Ui\Tabs::addTo($app);
// static tab
-\atk4\ui\HelloWorld::addTo($tabs->addTab('Hello'));
+\Atk4\Ui\HelloWorld::addTo($tabs->addTab('Hello'));
$tab = $tabs->addTab('Static Tab');
-\atk4\ui\Message::addTo($tab, ['Content of this tab will refresh only if you reload entire page']);
-\atk4\ui\LoremIpsum::addTo($tab);
+\Atk4\Ui\Message::addTo($tab, ['Content of this tab will refresh only if you reload entire page']);
+\Atk4\Ui\LoremIpsum::addTo($tab);
// set the default active tab
$tabs->addTab('Default Active Tab', function ($tab) {
- \atk4\ui\Message::addTo($tab, ['This is the active tab by default']);
+ \Atk4\Ui\Message::addTo($tab, ['This is the active tab by default']);
})->setActive();
// dynamic tab
$tabs->addTab('Dynamic Lorem Ipsum', function ($tab) {
- \atk4\ui\Message::addTo($tab, ['Every time you come to this tab, you will see a different text']);
- \atk4\ui\LoremIpsum::addTo($tab, ['size' => (int) $_GET['size'] ?? 1]);
+ \Atk4\Ui\Message::addTo($tab, ['Every time you come to this tab, you will see a different text']);
+ \Atk4\Ui\LoremIpsum::addTo($tab, ['size' => (int) $_GET['size'] ?? 1]);
}, ['apiSettings' => ['data' => ['size' => random_int(1, 4)]]]);
// modal tab
$tabs->addTab('Modal popup', function ($tab) {
- \atk4\ui\Button::addTo($tab, ['Load Lorem'])->on('click', \atk4\ui\Modal::addTo($tab)->set(function ($p) {
- \atk4\ui\LoremIpsum::addTo($p, ['size' => 2]);
+ \Atk4\Ui\Button::addTo($tab, ['Load Lorem'])->on('click', \Atk4\Ui\Modal::addTo($tab)->set(function ($p) {
+ \Atk4\Ui\LoremIpsum::addTo($p, ['size' => 2]);
})->show());
});
// dynamic tab
$tabs->addTab('Dynamic Form', function ($tab) {
- \atk4\ui\Message::addTo($tab, ['It takes 2 seconds for this tab to load', 'warning']);
+ \Atk4\Ui\Message::addTo($tab, ['It takes 2 seconds for this tab to load', 'warning']);
sleep(2);
- $modelRegister = new \atk4\data\Model(new \atk4\data\Persistence\Array_());
+ $modelRegister = new \Atk4\Data\Model(new \Atk4\Data\Persistence\Array_());
$modelRegister->addField('name', ['caption' => 'Please enter your name (John)']);
- $form = \atk4\ui\Form::addTo($tab, ['segment' => true]);
+ $form = \Atk4\Ui\Form::addTo($tab, ['segment' => true]);
$form->setModel($modelRegister);
- $form->onSubmit(function (\atk4\ui\Form $form) {
+ $form->onSubmit(function (\Atk4\Ui\Form $form) {
if ($form->model->get('name') !== 'John') {
return $form->error('name', 'Your name is not John! It is "' . $form->model->get('name') . '". It should be John. Pleeease!');
}
diff --git a/demos/interactive/toast.php b/demos/interactive/toast.php
index f534baef56..3940943423 100644
--- a/demos/interactive/toast.php
+++ b/demos/interactive/toast.php
@@ -2,89 +2,89 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
-\atk4\ui\Header::addTo($app, ['Toast']);
+\Atk4\Ui\Header::addTo($app, ['Toast']);
-$btn = \atk4\ui\Button::addTo($app)->set('Minimal');
+$btn = \Atk4\Ui\Button::addTo($app)->set('Minimal');
-$btn->on('click', new \atk4\ui\JsToast('Hi there!'));
+$btn->on('click', new \Atk4\Ui\JsToast('Hi there!'));
-$btn = \atk4\ui\Button::addTo($app)->set('Using a title');
+$btn = \Atk4\Ui\Button::addTo($app)->set('Using a title');
-$btn->on('click', new \atk4\ui\JsToast([
+$btn->on('click', new \Atk4\Ui\JsToast([
'title' => 'Title',
'message' => 'See I have a title',
]));
-\atk4\ui\Header::addTo($app, ['Using class name']);
+\Atk4\Ui\Header::addTo($app, ['Using class name']);
-$btn = \atk4\ui\Button::addTo($app)->set('Success');
-$btn->on('click', new \atk4\ui\JsToast([
+$btn = \Atk4\Ui\Button::addTo($app)->set('Success');
+$btn->on('click', new \Atk4\Ui\JsToast([
'title' => 'Success',
'message' => 'Well done',
'class' => 'success',
]));
-$btn = \atk4\ui\Button::addTo($app)->set('Error');
-$btn->on('click', new \atk4\ui\JsToast([
+$btn = \Atk4\Ui\Button::addTo($app)->set('Error');
+$btn->on('click', new \Atk4\Ui\JsToast([
'title' => 'Error',
'message' => 'An error occured',
'class' => 'error',
]));
-$btn = \atk4\ui\Button::addTo($app)->set('Warning');
-$btn->on('click', new \atk4\ui\JsToast([
+$btn = \Atk4\Ui\Button::addTo($app)->set('Warning');
+$btn->on('click', new \Atk4\Ui\JsToast([
'title' => 'Warning',
'message' => 'Behind you!',
'class' => 'warning',
]));
-\atk4\ui\Header::addTo($app, ['Using different position']);
+\Atk4\Ui\Header::addTo($app, ['Using different position']);
-$btn = \atk4\ui\Button::addTo($app)->set('Bottom Right');
-$btn->on('click', new \atk4\ui\JsToast([
+$btn = \Atk4\Ui\Button::addTo($app)->set('Bottom Right');
+$btn->on('click', new \Atk4\Ui\JsToast([
'title' => 'Bottom Right',
'message' => 'Should appear at the bottom on your right',
'position' => 'bottom right',
]));
-$btn = \atk4\ui\Button::addTo($app)->set('Top Center');
-$btn->on('click', new \atk4\ui\JsToast([
+$btn = \Atk4\Ui\Button::addTo($app)->set('Top Center');
+$btn->on('click', new \Atk4\Ui\JsToast([
'title' => 'Top Center',
'message' => 'Should appear at the top center',
'position' => 'top center',
]));
-\atk4\ui\Header::addTo($app, ['Other Options']);
+\Atk4\Ui\Header::addTo($app, ['Other Options']);
-$btn = \atk4\ui\Button::addTo($app)->set('5 seconds');
-$btn->on('click', new \atk4\ui\JsToast([
+$btn = \Atk4\Ui\Button::addTo($app)->set('5 seconds');
+$btn->on('click', new \Atk4\Ui\JsToast([
'title' => 'Timeout',
'message' => 'I will stay here for 5 sec.',
'displayTime' => 5000,
]));
-$btn = \atk4\ui\Button::addTo($app)->set('For ever');
-$btn->on('click', new \atk4\ui\JsToast([
+$btn = \Atk4\Ui\Button::addTo($app)->set('For ever');
+$btn->on('click', new \Atk4\Ui\JsToast([
'title' => 'No Timeout',
'message' => 'I will stay until you click me',
'displayTime' => 0,
]));
-$btn = \atk4\ui\Button::addTo($app)->set('Using Message style');
-$btn->on('click', new \atk4\ui\JsToast([
+$btn = \Atk4\Ui\Button::addTo($app)->set('Using Message style');
+$btn->on('click', new \Atk4\Ui\JsToast([
'title' => 'Awesome',
'message' => 'I got my style from the message class',
'class' => 'purple',
'className' => ['toast' => 'ui message', 'title' => 'ui header'],
]));
-$btn = \atk4\ui\Button::addTo($app)->set('With progress bar');
-$btn->on('click', new \atk4\ui\JsToast([
+$btn = \Atk4\Ui\Button::addTo($app)->set('With progress bar');
+$btn->on('click', new \Atk4\Ui\JsToast([
'title' => 'Awesome',
'message' => 'See how long I will last',
'showProgress' => 'bottom',
diff --git a/demos/interactive/virtual.php b/demos/interactive/virtual.php
index 6260559598..4ea9683fa9 100644
--- a/demos/interactive/virtual.php
+++ b/demos/interactive/virtual.php
@@ -2,73 +2,73 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
// Demonstrate the use of Virtual Page.
// define virtual page.
-$virtualPage = \atk4\ui\VirtualPage::addTo($app->layout, ['urlTrigger' => 'in']);
+$virtualPage = \Atk4\Ui\VirtualPage::addTo($app->layout, ['urlTrigger' => 'in']);
// Add content to virtual page.
if (isset($_GET['p_id'])) {
- \atk4\ui\Header::addTo($virtualPage, [$_GET['p_id']]);
+ \Atk4\Ui\Header::addTo($virtualPage, [$_GET['p_id']]);
}
-\atk4\ui\LoremIpsum::addTo($virtualPage, ['size' => 1]);
-$virtualPageButton = \atk4\ui\Button::addTo($virtualPage, ['Back', 'icon' => 'left arrow']);
+\Atk4\Ui\LoremIpsum::addTo($virtualPage, ['size' => 1]);
+$virtualPageButton = \Atk4\Ui\Button::addTo($virtualPage, ['Back', 'icon' => 'left arrow']);
$virtualPageButton->link('virtual.php');
$virtualPage->ui = 'grey inverted segment';
-$msg = \atk4\ui\Message::addTo($app, ['Virtual Page']);
+$msg = \Atk4\Ui\Message::addTo($app, ['Virtual Page']);
$msg->text->addParagraph('Virtual page content are not rendered on page load. They will ouptput their content when trigger.');
$msg->text->addParagraph('Click button below to trigger it.');
// button that trigger virtual page.
-$btn = \atk4\ui\Button::addTo($app, ['More info on Car']);
+$btn = \Atk4\Ui\Button::addTo($app, ['More info on Car']);
$btn->link($virtualPage->cb->getUrl() . '&p_id=Car');
-$btn = \atk4\ui\Button::addTo($app, ['More info on Bike']);
+$btn = \Atk4\Ui\Button::addTo($app, ['More info on Bike']);
$btn->link($virtualPage->cb->getUrl() . '&p_id=Bike');
// Test 1 - Basic reloading
-\atk4\ui\Header::addTo($app, ['Virtual Page Logic']);
+\Atk4\Ui\Header::addTo($app, ['Virtual Page Logic']);
-$virtualPage = \atk4\ui\VirtualPage::addTo($app); // this page will not be visible unless you trigger it specifically
-\atk4\ui\Header::addTo($virtualPage, ['Contens of your pop-up here']);
-\atk4\ui\LoremIpsum::addTo($virtualPage, ['size' => 2]);
+$virtualPage = \Atk4\Ui\VirtualPage::addTo($app); // this page will not be visible unless you trigger it specifically
+\Atk4\Ui\Header::addTo($virtualPage, ['Contens of your pop-up here']);
+\Atk4\Ui\LoremIpsum::addTo($virtualPage, ['size' => 2]);
Counter::addTo($virtualPage);
-\atk4\ui\View::addTo($virtualPage, ['ui' => 'hidden divider']);
-\atk4\ui\Button::addTo($virtualPage, ['Back', 'icon' => 'left arrow'])->link('virtual.php');
+\Atk4\Ui\View::addTo($virtualPage, ['ui' => 'hidden divider']);
+\Atk4\Ui\Button::addTo($virtualPage, ['Back', 'icon' => 'left arrow'])->link('virtual.php');
-$bar = \atk4\ui\View::addTo($app, ['ui' => 'buttons']);
-\atk4\ui\Button::addTo($bar)->set('Inside current layout')->link($virtualPage->getUrl());
-\atk4\ui\Button::addTo($bar)->set('On a blank page')->link($virtualPage->getUrl('popup'));
-\atk4\ui\Button::addTo($bar)->set('No layout at all')->link($virtualPage->getUrl('cut'));
+$bar = \Atk4\Ui\View::addTo($app, ['ui' => 'buttons']);
+\Atk4\Ui\Button::addTo($bar)->set('Inside current layout')->link($virtualPage->getUrl());
+\Atk4\Ui\Button::addTo($bar)->set('On a blank page')->link($virtualPage->getUrl('popup'));
+\Atk4\Ui\Button::addTo($bar)->set('No layout at all')->link($virtualPage->getUrl('cut'));
-\atk4\ui\Header::addTo($app, ['Inside Modal', 'subHeader' => 'Virtual page content can be display using JsModal Class.']);
+\Atk4\Ui\Header::addTo($app, ['Inside Modal', 'subHeader' => 'Virtual page content can be display using JsModal Class.']);
-$bar = \atk4\ui\View::addTo($app, ['ui' => 'buttons']);
-\atk4\ui\Button::addTo($bar)->set('Load in Modal')->on('click', new \atk4\ui\JsModal('My Popup Title', $virtualPage->getJsUrl('cut')));
+$bar = \Atk4\Ui\View::addTo($app, ['ui' => 'buttons']);
+\Atk4\Ui\Button::addTo($bar)->set('Load in Modal')->on('click', new \Atk4\Ui\JsModal('My Popup Title', $virtualPage->getJsUrl('cut')));
-\atk4\ui\Button::addTo($bar)->set('Simulate slow load')->on('click', new \atk4\ui\JsModal('My Popup Title', $virtualPage->getJsUrl('cut') . '&slow=true'));
+\Atk4\Ui\Button::addTo($bar)->set('Simulate slow load')->on('click', new \Atk4\Ui\JsModal('My Popup Title', $virtualPage->getJsUrl('cut') . '&slow=true'));
if (isset($_GET['slow'])) {
sleep(1);
}
-\atk4\ui\Button::addTo($bar)->set('No title')->on('click', new \atk4\ui\JsModal(null, $virtualPage->getJsUrl('cut')));
+\Atk4\Ui\Button::addTo($bar)->set('No title')->on('click', new \Atk4\Ui\JsModal(null, $virtualPage->getJsUrl('cut')));
-\atk4\ui\View::addTo($app, ['ui' => 'hidden divider']);
-$text = \atk4\ui\Text::addTo($app);
+\Atk4\Ui\View::addTo($app, ['ui' => 'hidden divider']);
+$text = \Atk4\Ui\Text::addTo($app);
$text->addParagraph('Can also be trigger from a js event, like clicking on a table row.');
-$table = \atk4\ui\Table::addTo($app, ['celled' => true]);
+$table = \Atk4\Ui\Table::addTo($app, ['celled' => true]);
$table->setModel(new SomeData());
-$frame = \atk4\ui\VirtualPage::addTo($app);
+$frame = \Atk4\Ui\VirtualPage::addTo($app);
$frame->set(function ($frame) {
- \atk4\ui\Header::addTo($frame, ['Clicked row with ID = ' . $_GET['id']]);
+ \Atk4\Ui\Header::addTo($frame, ['Clicked row with ID = ' . $_GET['id']]);
});
-$table->onRowClick(new \atk4\ui\JsModal('Row Clicked', $frame, ['id' => $table->jsRow()->data('id')]));
+$table->onRowClick(new \Atk4\Ui\JsModal('Row Clicked', $frame, ['id' => $table->jsRow()->data('id')]));
diff --git a/demos/interactive/wizard.php b/demos/interactive/wizard.php
index 427ff78757..26192eadef 100644
--- a/demos/interactive/wizard.php
+++ b/demos/interactive/wizard.php
@@ -2,12 +2,12 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-use atk4\ui\Callback;
-use atk4\ui\Wizard;
+use Atk4\Ui\Callback;
+use Atk4\Ui\Wizard;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
/**
@@ -17,7 +17,7 @@
// First step will automatcally be active when you open page first. It
// will contain the 'Next' button with a link.
$wizard->addStep('Welcome', function (Wizard $wizard) {
- \atk4\ui\Message::addTo($wizard, ['Welcome to wizard demonstration'])->text
+ \Atk4\Ui\Message::addTo($wizard, ['Welcome to wizard demonstration'])->text
->addParagraph('Use button "Next" to advance')
->addParagraph('You can specify your existing database connection string which will be used
to create a table for model of your choice');
@@ -28,12 +28,12 @@
// to return any action from form's onSubmit callback. You may also use memorize()
// to store wizard-specific variables
$wizard->addStep(['Set DSN', 'icon' => 'configure', 'description' => 'Database Connection String'], function (Wizard $wizard) {
- $form = \atk4\ui\Form::addTo($wizard);
+ $form = \Atk4\Ui\Form::addTo($wizard);
// IMPORTANT - needed for php_unit Wizard test.
$form->cb->setUrlTrigger('w_form_submit');
$form->addControl('dsn', 'Connect DSN', ['required' => true])->placeholder = 'mysql://user:pass@db-host.example.com/mydb';
- $form->onSubmit(function (\atk4\ui\Form $form) use ($wizard) {
+ $form->onSubmit(function (\Atk4\Ui\Form $form) use ($wizard) {
$wizard->memorize('dsn', $form->model->get('dsn'));
return $wizard->jsNext();
@@ -49,18 +49,18 @@
$wizard->getApp()->redirect($wizard->urlNext());
}
- $columns = \atk4\ui\Columns::addTo($wizard);
+ $columns = \Atk4\Ui\Columns::addTo($wizard);
- $grid = \atk4\ui\Grid::addTo($columns->addColumn(), ['paginator' => false, 'menu' => false]);
- \atk4\ui\Message::addTo($columns->addColumn(), ['Information', 'info'])->text
+ $grid = \Atk4\Ui\Grid::addTo($columns->addColumn(), ['paginator' => false, 'menu' => false]);
+ \Atk4\Ui\Message::addTo($columns->addColumn(), ['Information', 'info'])->text
->addParagraph('Selecting which model you would like to import into your DSN. If corresponding table already exist, we might add extra fields into it. No tables, columns or rows will be deleted.');
$grid->setSource(['Country', 'Stat']);
// should work after url() fix
- $grid->addDecorator('name', [\atk4\ui\Table\Column\Link::class, [], ['name']]);
+ $grid->addDecorator('name', [\Atk4\Ui\Table\Column\Link::class, [], ['name']]);
- //$t->addDecorator('name', [\atk4\ui\Table\Column\Link::class, [$wizard->stepCallback->name=>$wizard->currentStep], ['name']]);
+ //$t->addDecorator('name', [\Atk4\Ui\Table\Column\Link::class, [$wizard->stepCallback->name=>$wizard->currentStep], ['name']]);
$wizard->buttonNext->addClass('disabled');
});
@@ -69,7 +69,7 @@
// and enable them as you see fit. Use handy js method to trigger advancement to
// the next step.
$wizard->addStep(['Migration', 'description' => 'Create or update table', 'icon' => 'database'], function (Wizard $wizard) {
- $console = \atk4\ui\Console::addTo($wizard);
+ $console = \Atk4\Ui\Console::addTo($wizard);
$wizard->buttonFinish->addClass('disabled');
$console->set(function ($console) use ($wizard) {
@@ -93,5 +93,5 @@
// because you shouldn't be able to navigate wizard back without restarting it.
// Only one finish can be added.
$wizard->addFinish(function (Wizard $wizard) {
- \atk4\ui\Header::addTo($wizard, ['You are DONE', 'huge centered']);
+ \Atk4\Ui\Header::addTo($wizard, ['You are DONE', 'huge centered']);
});
diff --git a/demos/javascript/js.php b/demos/javascript/js.php
index dc416cef10..c8eaa06af5 100644
--- a/demos/javascript/js.php
+++ b/demos/javascript/js.php
@@ -2,12 +2,12 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-use atk4\ui\Button;
-use atk4\ui\Header;
+use Atk4\Ui\Button;
+use Atk4\Ui\Header;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
// Demonstrates how to use interractive buttons.
@@ -54,13 +54,13 @@
$b = Button::addTo($app, ['failure']);
$b->on('click', function ($b) {
- throw new \atk4\data\ValidationException(['Everything is bad']);
+ throw new \Atk4\Data\ValidationException(['Everything is bad']);
});
Header::addTo($app, ['Callbacks on HTML element', 'subHeader' => 'Click on label below.']);
-$label = \atk4\ui\Label::addTo($app->layout, ['Test']);
+$label = \Atk4\Ui\Label::addTo($app->layout, ['Test']);
$label->on('click', function ($j, $arg1) {
return 'width is ' . $arg1;
-}, [new \atk4\ui\JsExpression('$(window).width()')]);
+}, [new \Atk4\Ui\JsExpression('$(window).width()')]);
diff --git a/demos/javascript/reloading.php b/demos/javascript/reloading.php
index 734e0bc31c..d63e23ebfb 100644
--- a/demos/javascript/reloading.php
+++ b/demos/javascript/reloading.php
@@ -2,32 +2,32 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
// Test 1 - Basic reloading
-\atk4\ui\Header::addTo($app, ['Button reloading segment']);
-$v = \atk4\ui\View::addTo($app, ['ui' => 'segment'])->set((string) random_int(1, 100));
-\atk4\ui\Button::addTo($app, ['Reload random number'])->js('click', new \atk4\ui\JsReload($v, [], new \atk4\ui\JsExpression('console.log("Output with afterSuccess");')));
+\Atk4\Ui\Header::addTo($app, ['Button reloading segment']);
+$v = \Atk4\Ui\View::addTo($app, ['ui' => 'segment'])->set((string) random_int(1, 100));
+\Atk4\Ui\Button::addTo($app, ['Reload random number'])->js('click', new \Atk4\Ui\JsReload($v, [], new \Atk4\Ui\JsExpression('console.log("Output with afterSuccess");')));
// Test 2 - Reloading self
-\atk4\ui\Header::addTo($app, ['JS-actions will be re-applied']);
-$b2 = \atk4\ui\Button::addTo($app, ['Reload Myself']);
-$b2->js('click', new \atk4\ui\JsReload($b2));
+\Atk4\Ui\Header::addTo($app, ['JS-actions will be re-applied']);
+$b2 = \Atk4\Ui\Button::addTo($app, ['Reload Myself']);
+$b2->js('click', new \Atk4\Ui\JsReload($b2));
// Test 3 - avoid duplicate
-\atk4\ui\Header::addTo($app, ['No duplicate JS bindings']);
-$b3 = \atk4\ui\Button::addTo($app, ['Reload other button']);
-$b4 = \atk4\ui\Button::addTo($app, ['Add one dot']);
+\Atk4\Ui\Header::addTo($app, ['No duplicate JS bindings']);
+$b3 = \Atk4\Ui\Button::addTo($app, ['Reload other button']);
+$b4 = \Atk4\Ui\Button::addTo($app, ['Add one dot']);
-$b4->js('click', $b4->js()->text(new \atk4\ui\JsExpression('[]+"."', [$b4->js()->text()])));
-$b3->js('click', new \atk4\ui\JsReload($b4));
+$b4->js('click', $b4->js()->text(new \Atk4\Ui\JsExpression('[]+"."', [$b4->js()->text()])));
+$b3->js('click', new \Atk4\Ui\JsReload($b4));
// Test 3 - avoid duplicate
-\atk4\ui\Header::addTo($app, ['Make sure nested JS bindings are applied too']);
-$seg = \atk4\ui\View::addTo($app, ['ui' => 'segment']);
+\Atk4\Ui\Header::addTo($app, ['Make sure nested JS bindings are applied too']);
+$seg = \Atk4\Ui\View::addTo($app, ['ui' => 'segment']);
// add 3 counters
Counter::addTo($seg);
@@ -35,16 +35,16 @@
Counter::addTo($seg, ['-20']);
// Add button to reload all counters
-$bar = \atk4\ui\View::addTo($app, ['ui' => 'buttons']);
-$b = \atk4\ui\Button::addTo($bar, ['Reload counter'])->js('click', new \atk4\ui\JsReload($seg));
+$bar = \Atk4\Ui\View::addTo($app, ['ui' => 'buttons']);
+$b = \Atk4\Ui\Button::addTo($bar, ['Reload counter'])->js('click', new \Atk4\Ui\JsReload($seg));
// Relading with argument
-\atk4\ui\Header::addTo($app, ['We can pass argument to reloader']);
+\Atk4\Ui\Header::addTo($app, ['We can pass argument to reloader']);
-$v = \atk4\ui\View::addTo($app, ['ui' => 'segment'])->set($_GET['val'] ?? 'No value');
+$v = \Atk4\Ui\View::addTo($app, ['ui' => 'segment'])->set($_GET['val'] ?? 'No value');
-\atk4\ui\Button::addTo($app, ['Set value to "hello"'])->js('click', new \atk4\ui\JsReload($v, ['val' => 'hello']));
-\atk4\ui\Button::addTo($app, ['Set value to "world"'])->js('click', new \atk4\ui\JsReload($v, ['val' => 'world']));
+\Atk4\Ui\Button::addTo($app, ['Set value to "hello"'])->js('click', new \Atk4\Ui\JsReload($v, ['val' => 'hello']));
+\Atk4\Ui\Button::addTo($app, ['Set value to "world"'])->js('click', new \Atk4\Ui\JsReload($v, ['val' => 'world']));
-$val = \atk4\ui\Form\Control\Line::addTo($app, ['']);
-$val->addAction('Set Custom Value')->js('click', new \atk4\ui\JsReload($v, ['val' => $val->jsInput()->val()], $val->jsInput()->focus()));
+$val = \Atk4\Ui\Form\Control\Line::addTo($app, ['']);
+$val->addAction('Set Custom Value')->js('click', new \Atk4\Ui\JsReload($v, ['val' => $val->jsInput()->val()], $val->jsInput()->focus()));
diff --git a/demos/javascript/vue-component.php b/demos/javascript/vue-component.php
index 8fb1ef99bd..8e396a1d3b 100644
--- a/demos/javascript/vue-component.php
+++ b/demos/javascript/vue-component.php
@@ -2,15 +2,15 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-use atk4\ui\HtmlTemplate;
+use Atk4\Ui\HtmlTemplate;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
-\atk4\ui\Header::addTo($app, ['Component', 'size' => 2, 'icon' => 'vuejs', 'subHeader' => 'UI view handle by Vue.js']);
-\atk4\ui\View::addTo($app, ['ui' => 'divider']);
+\Atk4\Ui\Header::addTo($app, ['Component', 'size' => 2, 'icon' => 'vuejs', 'subHeader' => 'UI view handle by Vue.js']);
+\Atk4\Ui\View::addTo($app, ['ui' => 'divider']);
// ****** Inline Edit *****************************
@@ -18,36 +18,36 @@
$model->loadAny();
$subHeader = 'Try me. I will restore value on "Escape" or save it on "Enter" or when field get blur after it has been changed.';
-\atk4\ui\Header::addTo($app, ['Inline editing.', 'size' => 3, 'subHeader' => $subHeader]);
+\Atk4\Ui\Header::addTo($app, ['Inline editing.', 'size' => 3, 'subHeader' => $subHeader]);
-$inline_edit = \atk4\ui\Component\InlineEdit::addTo($app);
+$inline_edit = \Atk4\Ui\Component\InlineEdit::addTo($app);
$inline_edit->setModel($model);
$inline_edit->onChange(function ($value) {
- $view = new \atk4\ui\Message();
+ $view = new \Atk4\Ui\Message();
$view->invokeInit();
$view->text->addParagraph('new value: ' . $value);
return $view;
});
-\atk4\ui\View::addTo($app, ['ui' => 'divider']);
+\Atk4\Ui\View::addTo($app, ['ui' => 'divider']);
// ****** ITEM SEARCH *****************************
$subHeader = 'Searching will reload the list of countries below with matching result.';
-\atk4\ui\Header::addTo($app, ['Search using a Vue component', 'subHeader' => $subHeader]);
+\Atk4\Ui\Header::addTo($app, ['Search using a Vue component', 'subHeader' => $subHeader]);
$model = new Country($app->db);
$lister_template = new HtmlTemplate('
{List}
{$name}
{$end}{/}
');
-$view = \atk4\ui\View::addTo($app);
+$view = \Atk4\Ui\View::addTo($app);
-$search = \atk4\ui\Component\ItemSearch::addTo($view, ['ui' => 'ui compact segment']);
-$lister_container = \atk4\ui\View::addTo($view, ['template' => $lister_template]);
-$lister = \atk4\ui\Lister::addTo($lister_container, [], ['List']);
-$lister->onHook(\atk4\ui\Lister::HOOK_BEFORE_ROW, function (\atk4\ui\Lister $lister) {
+$search = \Atk4\Ui\Component\ItemSearch::addTo($view, ['ui' => 'ui compact segment']);
+$lister_container = \Atk4\Ui\View::addTo($view, ['template' => $lister_template]);
+$lister = \Atk4\Ui\Lister::addTo($lister_container, [], ['List']);
+$lister->onHook(\Atk4\Ui\Lister::HOOK_BEFORE_ROW, function (\Atk4\Ui\Lister $lister) {
++$lister->ipp;
$lister->current_row->set('iso', mb_strtolower($lister->current_row->get('iso')));
if ($lister->ipp === $lister->model->limit[0]) {
@@ -58,10 +58,10 @@
$search->reload = $lister_container;
$lister->setModel($search->setModelCondition($model))->setLimit(50);
-\atk4\ui\View::addTo($app, ['ui' => 'divider']);
+\Atk4\Ui\View::addTo($app, ['ui' => 'divider']);
// ****** CREATING CUSTOM VUE USING EXTERNAL COMPONENT *****************************
-\atk4\ui\Header::addTo($app, ['External Component', 'subHeader' => 'Creating component using an external component definition.']);
+\Atk4\Ui\Header::addTo($app, ['External Component', 'subHeader' => 'Creating component using an external component definition.']);
$app->requireJs('https://unpkg.com/vue-clock2@1.1.5/dist/vue-clock.min.js');
@@ -119,7 +119,7 @@
";
// Creating the clock view and injecting js.
-$clock = \atk4\ui\View::addTo($app, ['template' => $clock_template]);
+$clock = \Atk4\Ui\View::addTo($app, ['template' => $clock_template]);
$clock->template->tryDangerouslySetHtml('script', $clock_script);
// passing some style to my-clock component.
@@ -132,6 +132,6 @@
// creating vue using an external definition.
$clock->vue('my-clock', ['clock' => $clock_style], 'myClock');
-$btn = \atk4\ui\Button::addTo($app, ['Change Style']);
+$btn = \Atk4\Ui\Button::addTo($app, ['Change Style']);
$btn->on('click', $clock->jsEmitEvent($clock->name . '-clock-change-style'));
-\atk4\ui\View::addTo($app, ['element' => 'p', 'I am not part of the component but I can still change style using the eventBus.']);
+\Atk4\Ui\View::addTo($app, ['element' => 'p', 'I am not part of the component but I can still change style using the eventBus.']);
diff --git a/demos/layout/layout-panel.php b/demos/layout/layout-panel.php
index 06ddbb494b..dcde856b0f 100644
--- a/demos/layout/layout-panel.php
+++ b/demos/layout/layout-panel.php
@@ -2,116 +2,116 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
$country = new CountryLock($app->db);
DemoActionsUtil::setupDemoActions($country);
-\atk4\ui\Header::addTo($app, ['Right Panel', 'subHeader' => 'Content on the fly!']);
+\Atk4\Ui\Header::addTo($app, ['Right Panel', 'subHeader' => 'Content on the fly!']);
// PANEL
-\atk4\ui\Header::addTo($app, ['Static', 'size' => 4, 'subHeader' => 'Panel may have static content only.']);
-$panel = $app->layout->addRightPanel(new \atk4\ui\Panel\Right(['dynamic' => false]));
-\atk4\ui\Message::addTo($panel, ['This panel contains only static content.']);
-$btn = \atk4\ui\Button::addTo($app, ['Open Static']);
+\Atk4\Ui\Header::addTo($app, ['Static', 'size' => 4, 'subHeader' => 'Panel may have static content only.']);
+$panel = $app->layout->addRightPanel(new \Atk4\Ui\Panel\Right(['dynamic' => false]));
+\Atk4\Ui\Message::addTo($panel, ['This panel contains only static content.']);
+$btn = \Atk4\Ui\Button::addTo($app, ['Open Static']);
$btn->on('click', $panel->jsOpen());
-\atk4\ui\View::addTo($app, ['ui' => 'divider']);
+\Atk4\Ui\View::addTo($app, ['ui' => 'divider']);
// PANEL_1
-\atk4\ui\Header::addTo($app, ['Dynamic', 'size' => 4, 'subHeader' => 'Panel can load content dynamically']);
-$panel1 = $app->layout->addRightPanel(new \atk4\ui\Panel\Right());
-\atk4\ui\Message::addTo($panel1, ['This panel will load content dynamically below according to button select on the right.']);
-$btn = \atk4\ui\Button::addTo($app, ['Button 1']);
+\Atk4\Ui\Header::addTo($app, ['Dynamic', 'size' => 4, 'subHeader' => 'Panel can load content dynamically']);
+$panel1 = $app->layout->addRightPanel(new \Atk4\Ui\Panel\Right());
+\Atk4\Ui\Message::addTo($panel1, ['This panel will load content dynamically below according to button select on the right.']);
+$btn = \Atk4\Ui\Button::addTo($app, ['Button 1']);
$btn->js(true)->data('btn', '1');
$btn->on('click', $panel1->jsOpen(['btn'], 'orange'));
-$btn = \atk4\ui\Button::addTo($app, ['Button 2']);
+$btn = \Atk4\Ui\Button::addTo($app, ['Button 2']);
$btn->js(true)->data('btn', '2');
$btn->on('click', $panel1->jsOpen(['btn'], 'orange'));
-$view = \atk4\ui\View::addTo($app, ['ui' => 'segment']);
-$text = \atk4\ui\Text::addTo($view);
+$view = \Atk4\Ui\View::addTo($app, ['ui' => 'segment']);
+$text = \Atk4\Ui\Text::addTo($view);
$text->set($_GET['txt'] ?? 'Not Complete');
$panel1->onOpen(function ($p) use ($view) {
- $panel = \atk4\ui\View::addTo($p, ['ui' => 'basic segment']);
+ $panel = \Atk4\Ui\View::addTo($p, ['ui' => 'basic segment']);
$buttonNumber = $panel->stickyGet('btn');
$panelText = 'You loaded panel content using button #' . $buttonNumber;
- \atk4\ui\Message::addTo($panel, ['Panel 1', 'text' => $panelText]);
+ \Atk4\Ui\Message::addTo($panel, ['Panel 1', 'text' => $panelText]);
- $reloadPanelButton = \atk4\ui\Button::addTo($panel, ['Reload Myself']);
- $reloadPanelButton->on('click', new \atk4\ui\JsReload($panel));
+ $reloadPanelButton = \Atk4\Ui\Button::addTo($panel, ['Reload Myself']);
+ $reloadPanelButton->on('click', new \Atk4\Ui\JsReload($panel));
- \atk4\ui\View::addTo($panel, ['ui' => 'divider']);
- $panelButton = \atk4\ui\Button::addTo($panel, ['Complete']);
+ \Atk4\Ui\View::addTo($panel, ['ui' => 'divider']);
+ $panelButton = \Atk4\Ui\Button::addTo($panel, ['Complete']);
$panelButton->on('click', [
$p->getOwner()->jsClose(),
- new \atk4\ui\JsReload($view, ['txt' => 'Complete using button #' . $buttonNumber]),
+ new \Atk4\Ui\JsReload($view, ['txt' => 'Complete using button #' . $buttonNumber]),
]);
});
-\atk4\ui\View::addTo($app, ['ui' => 'divider']);
+\Atk4\Ui\View::addTo($app, ['ui' => 'divider']);
// PANEL_2
-\atk4\ui\Header::addTo($app, ['Closing option', 'size' => 4, 'subHeader' => 'Panel can prevent from closing.']);
+\Atk4\Ui\Header::addTo($app, ['Closing option', 'size' => 4, 'subHeader' => 'Panel can prevent from closing.']);
-$panel2 = $app->layout->addRightPanel(new \atk4\ui\Panel\Right(['hasClickAway' => false]));
-$icon = \atk4\ui\Icon::addTo($app, ['big cog'])->addStyle('cursor', 'pointer');
+$panel2 = $app->layout->addRightPanel(new \Atk4\Ui\Panel\Right(['hasClickAway' => false]));
+$icon = \Atk4\Ui\Icon::addTo($app, ['big cog'])->addStyle('cursor', 'pointer');
$icon->on('click', $panel2->jsOpen());
$panel2->addConfirmation('Changes will be lost. Are you sure?');
-$msg = \atk4\ui\Message::addTo($panel2, ['Prevent close.']);
+$msg = \Atk4\Ui\Message::addTo($panel2, ['Prevent close.']);
-$txt = \atk4\ui\Text::addTo($msg);
+$txt = \Atk4\Ui\Text::addTo($msg);
$txt->addParagraph('This panel can only be closed via it\'s close icon at top right.');
$txt->addParagraph('Try to change dropdown value and close without saving!');
$panel2->onOpen(function ($p) {
- $form = \atk4\ui\Form::addTo($p);
+ $form = \Atk4\Ui\Form::addTo($p);
$form->addHeader('Settings');
- $form->addControl('name', [\atk4\ui\Form\Control\Dropdown::class, 'values' => ['1' => 'Option 1', '2' => 'Option 2']])
+ $form->addControl('name', [\Atk4\Ui\Form\Control\Dropdown::class, 'values' => ['1' => 'Option 1', '2' => 'Option 2']])
->set('1')
->onChange($p->getOwner()->jsDisplayWarning(true));
- $form->onSubmit(function (\atk4\ui\Form $form) use ($p) {
+ $form->onSubmit(function (\Atk4\Ui\Form $form) use ($p) {
return [
- new \atk4\ui\JsToast('Saved, closing panel.'),
+ new \Atk4\Ui\JsToast('Saved, closing panel.'),
$p->getOwner()->jsDisplayWarning(false),
$p->getOwner()->jsClose(),
];
});
});
-\atk4\ui\View::addTo($app, ['ui' => 'divider']);
+\Atk4\Ui\View::addTo($app, ['ui' => 'divider']);
// PANEL_3
$countryId = $app->stickyGet('id');
-\atk4\ui\Header::addTo($app, ['UserAction Friendly', 'size' => 4, 'subHeader' => 'Panel can run model action.']);
-$panel3 = $app->layout->addRightPanel(new \atk4\ui\Panel\Right());
-$msg = \atk4\ui\Message::addTo($panel3, ['Run Country model action below.']);
+\Atk4\Ui\Header::addTo($app, ['UserAction Friendly', 'size' => 4, 'subHeader' => 'Panel can run model action.']);
+$panel3 = $app->layout->addRightPanel(new \Atk4\Ui\Panel\Right());
+$msg = \Atk4\Ui\Message::addTo($panel3, ['Run Country model action below.']);
-$deck = \atk4\ui\View::addTo($app, ['ui' => 'cards']);
+$deck = \Atk4\Ui\View::addTo($app, ['ui' => 'cards']);
$country->setLimit(3);
foreach ($country as $ct) {
- $c = \atk4\ui\Card::addTo($deck, ['useLabel' => true])->addStyle('cursor', 'pointer');
+ $c = \Atk4\Ui\Card::addTo($deck, ['useLabel' => true])->addStyle('cursor', 'pointer');
$c->setModel($ct);
$c->on('click', $panel3->jsOpen(['id'], 'orange'));
}
$panel3->onOpen(function ($p) use ($country, $countryId) {
- $seg = \atk4\ui\View::addTo($p, ['ui' => 'basic segment center aligned']);
- \atk4\ui\Header::addTo($seg, [$country->load($countryId)->getTitle()]);
- $buttons = \atk4\ui\View::addTo($seg, ['ui' => 'vertical basic buttons']);
+ $seg = \Atk4\Ui\View::addTo($p, ['ui' => 'basic segment center aligned']);
+ \Atk4\Ui\Header::addTo($seg, [$country->load($countryId)->getTitle()]);
+ $buttons = \Atk4\Ui\View::addTo($seg, ['ui' => 'vertical basic buttons']);
foreach ($country->getUserActions() as $action) {
- $button = \atk4\ui\Button::addTo($buttons, [$action->getCaption()]);
+ $button = \Atk4\Ui\Button::addTo($buttons, [$action->getCaption()]);
$button->on('click', $action, ['args' => ['id' => $countryId]]);
}
});
diff --git a/demos/layout/layouts.php b/demos/layout/layouts.php
index ba17ed32b4..81a12cf549 100644
--- a/demos/layout/layouts.php
+++ b/demos/layout/layouts.php
@@ -2,33 +2,33 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
// buttons configuration: [page, title]
$buttons = [
['page' => ['layouts_nolayout'], 'title' => 'HTML without layout'],
['page' => ['layouts_manual'], 'title' => 'Manual layout'],
- ['page' => ['../basic/header', 'layout' => \atk4\ui\Layout\Centered::class], 'title' => 'Centered layout'],
+ ['page' => ['../basic/header', 'layout' => \Atk4\Ui\Layout\Centered::class], 'title' => 'Centered layout'],
['page' => ['layouts_admin'], 'title' => 'Admin Layout'],
['page' => ['layouts_error'], 'title' => 'Exception Error'],
];
// layout
-\atk4\ui\Text::addTo(\atk4\ui\View::addTo($app, ['red' => true, 'ui' => 'segment']))
+\Atk4\Ui\Text::addTo(\Atk4\Ui\View::addTo($app, ['red' => true, 'ui' => 'segment']))
->addParagraph('Layouts can be used to wrap your UI elements into HTML / Boilerplate');
// toolbar
-$tb = \atk4\ui\View::addTo($app);
+$tb = \Atk4\Ui\View::addTo($app);
// iframe
-$i = \atk4\ui\View::addTo($app, ['green' => true, 'ui' => 'segment'])->setElement('iframe')->setStyle(['width' => '100%', 'height' => '500px']);
+$i = \Atk4\Ui\View::addTo($app, ['green' => true, 'ui' => 'segment'])->setElement('iframe')->setStyle(['width' => '100%', 'height' => '500px']);
// add buttons in toolbar
foreach ($buttons as $k => $args) {
- \atk4\ui\Button::addTo($tb)
+ \Atk4\Ui\Button::addTo($tb)
->set([$args['title'], 'iconRight' => 'down arrow'])
->js('click', $i->js()->attr('src', $app->url($args['page'])));
}
diff --git a/demos/layout/layouts_admin.php b/demos/layout/layouts_admin.php
index 56729ee5eb..d793542c06 100644
--- a/demos/layout/layouts_admin.php
+++ b/demos/layout/layouts_admin.php
@@ -2,16 +2,16 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
-$layout = \atk4\ui\Layout\Admin::addTo($app);
+$layout = \Atk4\Ui\Layout\Admin::addTo($app);
$menu = $layout->menu->addMenu(['Layouts', 'icon' => 'puzzle']);
-$menu->addItem(\atk4\ui\Layout\Centered::class);
-$menu->addItem(\atk4\ui\Layout\Admin::class);
+$menu->addItem(\Atk4\Ui\Layout\Centered::class);
+$menu->addItem(\Atk4\Ui\Layout\Admin::class);
$menuRight = $layout->menuRight;
$menuRight->addItem(['Warning', 'red', 'icon' => 'red warning']);
@@ -34,10 +34,10 @@
$layout->template->set('Footer', 'ATK is awesome');
-\atk4\ui\Header::addTo($layout, ['Basic Form Example']);
+\Atk4\Ui\Header::addTo($layout, ['Basic Form Example']);
-$form = \atk4\ui\Form::addTo($layout, ['segment']);
-$form->setModel(new \atk4\data\Model());
+$form = \Atk4\Ui\Form::addTo($layout, ['segment']);
+$form->setModel(new \Atk4\Data\Model());
$formGroup = $form->addGroup('Name');
$formGroup->addControl('first_name', ['width' => 'eight']);
@@ -48,7 +48,7 @@
$formGroup->addControl('address', ['width' => 'twelve']);
$formGroup->addControl('zip', ['width' => 'four']);
-$form->onSubmit(function (\atk4\ui\Form $form) {
+$form->onSubmit(function (\Atk4\Ui\Form $form) {
$errors = [];
foreach (['first_name', 'last_name', 'address'] as $field) {
diff --git a/demos/layout/layouts_error.php b/demos/layout/layouts_error.php
index ef6fbd985e..78dc0719f2 100644
--- a/demos/layout/layouts_error.php
+++ b/demos/layout/layouts_error.php
@@ -2,10 +2,10 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
// Next line produces exception, which Agile UI will catch and display nicely.
-\atk4\ui\View::addTo($app, ['foo' => 'bar']);
+\Atk4\Ui\View::addTo($app, ['foo' => 'bar']);
diff --git a/demos/layout/layouts_manual.php b/demos/layout/layouts_manual.php
index f6ae2af9d7..bfa268a043 100644
--- a/demos/layout/layouts_manual.php
+++ b/demos/layout/layouts_manual.php
@@ -2,17 +2,17 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
-$layout = new \atk4\ui\Layout(['defaultTemplate' => __DIR__ . '/templates/layout1.html']);
+$layout = new \Atk4\Ui\Layout(['defaultTemplate' => __DIR__ . '/templates/layout1.html']);
-\atk4\ui\Lister::addTo($layout, [], ['Report'])
+\Atk4\Ui\Lister::addTo($layout, [], ['Report'])
->setModel(new SomeData());
$app->html = null;
-$app->initLayout([\atk4\ui\Layout::class]);
+$app->initLayout([\Atk4\Ui\Layout::class]);
-\atk4\ui\Text::addTo($app->layout)->addHtml($layout->render());
+\Atk4\Ui\Text::addTo($app->layout)->addHtml($layout->render());
diff --git a/demos/layout/layouts_nolayout.php b/demos/layout/layouts_nolayout.php
index cd7c9ba4c2..9f06911344 100644
--- a/demos/layout/layouts_nolayout.php
+++ b/demos/layout/layouts_nolayout.php
@@ -2,16 +2,16 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
// nothing to do with Agile UI - will not use any Layout
-$a = new \atk4\ui\LoremIpsum();
+$a = new \Atk4\Ui\LoremIpsum();
$text = $a->generateLorem(150);
$app->html = null;
-$app->initLayout([\atk4\ui\Layout::class]);
+$app->initLayout([\Atk4\Ui\Layout::class]);
-\atk4\ui\Text::addTo($app->layout)->addParagraph($text);
+\Atk4\Ui\Text::addTo($app->layout)->addParagraph($text);
diff --git a/demos/obsolete/crud2.php b/demos/obsolete/crud2.php
index bae9425fc5..549eff877c 100644
--- a/demos/obsolete/crud2.php
+++ b/demos/obsolete/crud2.php
@@ -2,9 +2,9 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
$model = new Stat($app->db);
@@ -12,6 +12,6 @@
$model->getUserAction('edit')->system = true;
$model->getUserAction('delete')->system = true;
-$grid = \atk4\ui\Crud::addTo($app, ['paginator' => false]);
+$grid = \Atk4\Ui\Crud::addTo($app, ['paginator' => false]);
$grid->setModel($model);
-$grid->addDecorator('project_code', [\atk4\ui\Table\Column\Link::class]);
+$grid->addDecorator('project_code', [\Atk4\Ui\Table\Column\Link::class]);
diff --git a/demos/obsolete/notify.php b/demos/obsolete/notify.php
index c7749752ba..402f3912be 100644
--- a/demos/obsolete/notify.php
+++ b/demos/obsolete/notify.php
@@ -2,32 +2,32 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
-\atk4\ui\Button::addTo($app, ['Notify Examples - Page 2', 'small right floated basic blue', 'iconRight' => 'right arrow'])
+\Atk4\Ui\Button::addTo($app, ['Notify Examples - Page 2', 'small right floated basic blue', 'iconRight' => 'right arrow'])
->link(['notify2']);
-\atk4\ui\Button::addTo($app, ['Test'])->on('click', (new \atk4\ui\JsNotify('Not yet implemented'))->setColor('red'));
+\Atk4\Ui\Button::addTo($app, ['Test'])->on('click', (new \Atk4\Ui\JsNotify('Not yet implemented'))->setColor('red'));
-$modal = \atk4\ui\Modal::addTo($app, ['Modal Title']);
+$modal = \Atk4\Ui\Modal::addTo($app, ['Modal Title']);
$modal->set(function ($p) use ($modal) {
- $form = \atk4\ui\Form::addTo($p);
+ $form = \Atk4\Ui\Form::addTo($p);
$form->addControl('name', null, ['caption' => 'Add your name']);
- $form->onSubmit(function (\atk4\ui\Form $form) use ($modal) {
+ $form->onSubmit(function (\Atk4\Ui\Form $form) use ($modal) {
if (empty($form->model->get('name'))) {
return $form->error('name', 'Please add a name!');
}
return [
$modal->hide(),
- new \atk4\ui\JsNotify('Thank you ' . $form->model->get('name')),
+ new \Atk4\Ui\JsNotify('Thank you ' . $form->model->get('name')),
];
});
});
-\atk4\ui\Button::addTo($app, ['Open Modal'])->on('click', $modal->show());
+\Atk4\Ui\Button::addTo($app, ['Open Modal'])->on('click', $modal->show());
diff --git a/demos/obsolete/notify2.php b/demos/obsolete/notify2.php
index 4a7bf50aa5..c15bbaac54 100644
--- a/demos/obsolete/notify2.php
+++ b/demos/obsolete/notify2.php
@@ -2,13 +2,13 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
-/** @var \atk4\data\Model $notifierClass */
-$notifierClass = get_class(new class() extends \atk4\data\Model {
+/** @var \Atk4\Data\Model $notifierClass */
+$notifierClass = get_class(new class() extends \Atk4\Data\Model {
public $table = 'notifier';
protected function init(): void
@@ -26,13 +26,13 @@ protected function init(): void
});
// Notification type form
-$head = \atk4\ui\Header::addTo($app, ['Notification Types']);
+$head = \Atk4\Ui\Header::addTo($app, ['Notification Types']);
-$form = \atk4\ui\Form::addTo($app, ['segment']);
+$form = \Atk4\Ui\Form::addTo($app, ['segment']);
// Unit test only.
$form->cb->setUrlTrigger('test_notify');
-\atk4\ui\Label::addTo($form, ['Some of notification options that can be set.', 'top attached'], ['AboveControls']);
+\Atk4\Ui\Label::addTo($form, ['Some of notification options that can be set.', 'top attached'], ['AboveControls']);
$form->buttonSave->set('Show');
$form->setModel(new $notifierClass($app->db), false);
@@ -49,8 +49,8 @@ protected function init(): void
$formGroup2->addControl('position', ['width' => 'four']);
$formGroup2->addControl('attach', ['width' => 'four']);
-$form->onSubmit(function (\atk4\ui\Form $form) {
- $notifier = new \atk4\ui\JsNotify();
+$form->onSubmit(function (\Atk4\Ui\Form $form) {
+ $notifier = new \Atk4\Ui\JsNotify();
$notifier->setColor($form->model->get('color'))
->setPosition($form->model->get('position'))
->setWidth(rtrim($form->model->get('width'), '%'))
diff --git a/demos/others/recursive.php b/demos/others/recursive.php
index 802710732a..ed75b9b13c 100644
--- a/demos/others/recursive.php
+++ b/demos/others/recursive.php
@@ -2,43 +2,43 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
-/** @var \atk4\ui\View $mySwitcherClass */
-$mySwitcherClass = get_class(new class() extends \atk4\ui\View {
+/** @var \Atk4\Ui\View $mySwitcherClass */
+$mySwitcherClass = get_class(new class() extends \Atk4\Ui\View {
protected function init(): void
{
parent::init();
- \atk4\ui\Header::addTo($this, ['My name is ' . $this->name, 'red']);
+ \Atk4\Ui\Header::addTo($this, ['My name is ' . $this->name, 'red']);
- $buttons = \atk4\ui\View::addTo($this, ['ui' => 'basic buttons']);
- \atk4\ui\Button::addTo($buttons, ['Yellow'])->setAttr('data-id', 'yellow');
- \atk4\ui\Button::addTo($buttons, ['Blue'])->setAttr('data-id', 'blue');
- \atk4\ui\Button::addTo($buttons, ['Button'])->setAttr('data-id', 'button');
+ $buttons = \Atk4\Ui\View::addTo($this, ['ui' => 'basic buttons']);
+ \Atk4\Ui\Button::addTo($buttons, ['Yellow'])->setAttr('data-id', 'yellow');
+ \Atk4\Ui\Button::addTo($buttons, ['Blue'])->setAttr('data-id', 'blue');
+ \Atk4\Ui\Button::addTo($buttons, ['Button'])->setAttr('data-id', 'button');
- $buttons->on('click', '.button', new \atk4\ui\JsReload($this, [$this->name => (new \atk4\ui\Jquery())->data('id')]));
+ $buttons->on('click', '.button', new \Atk4\Ui\JsReload($this, [$this->name => (new \Atk4\Ui\Jquery())->data('id')]));
switch ($this->getApp()->stickyGet($this->name)) {
case 'yellow':
- self::addTo(\atk4\ui\View::addTo($this, ['ui' => 'yellow segment']));
+ self::addTo(\Atk4\Ui\View::addTo($this, ['ui' => 'yellow segment']));
break;
case 'blue':
- self::addTo(\atk4\ui\View::addTo($this, ['ui' => 'blue segment']));
+ self::addTo(\Atk4\Ui\View::addTo($this, ['ui' => 'blue segment']));
break;
case 'button':
- \atk4\ui\Button::addTo(\atk4\ui\View::addTo($this, ['ui' => 'green segment']), ['Refresh page'])->link([]);
+ \Atk4\Ui\Button::addTo(\Atk4\Ui\View::addTo($this, ['ui' => 'green segment']), ['Refresh page'])->link([]);
break;
}
}
});
-$view = \atk4\ui\View::addTo($app, ['ui' => 'segment']);
+$view = \Atk4\Ui\View::addTo($app, ['ui' => 'segment']);
$mySwitcherClass::addTo($view);
diff --git a/demos/others/sticky.php b/demos/others/sticky.php
index 1f2db3cb41..a29ffc6213 100644
--- a/demos/others/sticky.php
+++ b/demos/others/sticky.php
@@ -2,20 +2,20 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-use atk4\ui\Button;
+use Atk4\Ui\Button;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
-\atk4\ui\View::addTo($app, [
+\Atk4\Ui\View::addTo($app, [
'Sticky GET allows us to preserve some GET arguments',
'ui' => 'ignored info message',
]);
-/** @var \atk4\ui\Button $myButtonClass */
-$myButtonClass = get_class(new class() extends \atk4\ui\Button {
+/** @var \Atk4\Ui\Button $myButtonClass */
+$myButtonClass = get_class(new class() extends \Atk4\Ui\Button {
protected function renderView(): void
{
$this->link($this->content);
@@ -32,7 +32,7 @@ protected function renderView(): void
$myButtonClass::addTo($app, [$app->url(['xx' => 'YEY', 'c' => 'OHO'])]);
// URLs presented by a blank app
-\atk4\ui\Header::addTo($app, ['URLs presented by a blank app']);
+\Atk4\Ui\Header::addTo($app, ['URLs presented by a blank app']);
Button::addTo($app, [$app->url()]);
Button::addTo($app, [$app->url(['b' => 2])]);
Button::addTo($app, [$app->url(['b' => 2, 'c' => false])]);
@@ -40,7 +40,7 @@ protected function renderView(): void
Button::addTo($app, [$app->url(['b' => 2, 'c' => 'abc'])]);
// Sticky for xx=
-\atk4\ui\Header::addTo($app, ['Now add sticky for xx=' . $app->stickyGET('xx')]);
+\Atk4\Ui\Header::addTo($app, ['Now add sticky for xx=' . $app->stickyGET('xx')]);
Button::addTo($app, [$app->url()]);
Button::addTo($app, [$app->url(['b' => 2])]);
Button::addTo($app, [$app->url(['b' => 2, 'c' => false])]);
@@ -48,7 +48,7 @@ protected function renderView(): void
Button::addTo($app, [$app->url(['b' => 2, 'c' => 'abc'])]);
// Sticky for c=
-\atk4\ui\Header::addTo($app, ['Now also add sticky for c=' . $app->stickyGET('c')]);
+\Atk4\Ui\Header::addTo($app, ['Now also add sticky for c=' . $app->stickyGET('c')]);
Button::addTo($app, [$app->url()]);
Button::addTo($app, [$app->url(['b' => 2])]);
Button::addTo($app, [$app->url(['b' => 2, 'c' => false])]);
@@ -56,7 +56,7 @@ protected function renderView(): void
Button::addTo($app, [$app->url(['b' => 2, 'c' => 'abc'])]);
// Various ways to build links
-\atk4\ui\Header::addTo($app, ['Various ways to build links']);
+\Atk4\Ui\Header::addTo($app, ['Various ways to build links']);
Button::addTo($app, [$app->url()]);
Button::addTo($app, [$app->url('other.php')]);
Button::addTo($app, [$app->url('other')]);
diff --git a/demos/others/sticky2.php b/demos/others/sticky2.php
index df92cce45b..6291e917f2 100644
--- a/demos/others/sticky2.php
+++ b/demos/others/sticky2.php
@@ -2,9 +2,9 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
// This demo shows a local impact of a sticky parameters.
@@ -12,49 +12,49 @@
if (isset($_GET['name'])) {
// IMPORTANT: because this is an optional frame, I have to specify it's unique short_name explicitly, othrewise
// the name for a second frame will be affected by presence of GET['name'] parameter
- $frame = \atk4\ui\View::addTo($app, ['ui' => 'red segment', 'short_name' => 'fr1']);
+ $frame = \Atk4\Ui\View::addTo($app, ['ui' => 'red segment', 'short_name' => 'fr1']);
$frame->stickyGet('name');
// frame will generate URL with sticky parameter
- \atk4\ui\Label::addTo($frame, ['Name:', 'detail' => $_GET['name'], 'black'])->link($frame->url());
+ \Atk4\Ui\Label::addTo($frame, ['Name:', 'detail' => $_GET['name'], 'black'])->link($frame->url());
// app still generates URL without localized sticky
- \atk4\ui\Label::addTo($frame, ['Reset', 'iconRight' => 'close', 'black'])->link($app->url());
- \atk4\ui\View::addTo($frame, ['ui' => 'hidden divider']);
+ \Atk4\Ui\Label::addTo($frame, ['Reset', 'iconRight' => 'close', 'black'])->link($app->url());
+ \Atk4\Ui\View::addTo($frame, ['ui' => 'hidden divider']);
// nested interractive elemetns will respect lockal sticky get
- \atk4\ui\Button::addTo($frame, ['Triggering callback here will inherit color'])->on('click', function () {
- return new \atk4\ui\JsNotify('Color was = ' . $_GET['name']);
+ \Atk4\Ui\Button::addTo($frame, ['Triggering callback here will inherit color'])->on('click', function () {
+ return new \Atk4\Ui\JsNotify('Color was = ' . $_GET['name']);
});
// Next we have loader, which will dynamically load console which will dynamically output "success" message.
- \atk4\ui\Loader::addTo($frame)->set(function ($page) {
- \atk4\ui\Console::addTo($page)->set(function ($console) {
+ \Atk4\Ui\Loader::addTo($frame)->set(function ($page) {
+ \Atk4\Ui\Console::addTo($page)->set(function ($console) {
$console->output('success!, color is still ' . $_GET['name']);
});
});
}
-$t = \atk4\ui\Table::addTo($app);
+$t = \Atk4\Ui\Table::addTo($app);
$t->setSource(['Red', 'Green', 'Blue']);
-$t->addDecorator('name', [\atk4\ui\Table\Column\Link::class, [], ['name']]);
+$t->addDecorator('name', [\Atk4\Ui\Table\Column\Link::class, [], ['name']]);
-$frame = \atk4\ui\View::addTo($app, ['ui' => 'green segment']);
-\atk4\ui\Button::addTo($frame, ['does not inherit sticky get'])->on('click', function () use ($app) {
- return new \atk4\ui\JsNotify('$_GET = ' . $app->encodeJson($_GET));
+$frame = \Atk4\Ui\View::addTo($app, ['ui' => 'green segment']);
+\Atk4\Ui\Button::addTo($frame, ['does not inherit sticky get'])->on('click', function () use ($app) {
+ return new \Atk4\Ui\JsNotify('$_GET = ' . $app->encodeJson($_GET));
});
-\atk4\ui\Header::addTo($app, ['Use of View::url()']);
+\Atk4\Ui\Header::addTo($app, ['Use of View::url()']);
-$b1 = \atk4\ui\Button::addTo($app);
+$b1 = \Atk4\Ui\Button::addTo($app);
$b1->set($b1->url());
-\atk4\ui\Loader::addTo($app)->set(function ($page) use ($b1) {
- $b2 = \atk4\ui\Button::addTo($page);
+\Atk4\Ui\Loader::addTo($app)->set(function ($page) use ($b1) {
+ $b2 = \Atk4\Ui\Button::addTo($page);
$b2->set($b2->url());
- $b2->on('click', new \atk4\ui\JsReload($b1));
+ $b2->on('click', new \Atk4\Ui\JsReload($b1));
});
-$b3 = \atk4\ui\Button::addTo($app);
+$b3 = \Atk4\Ui\Button::addTo($app);
$b3->set($b3->url());
diff --git a/demos/special/multiline-containsmany.php b/demos/special/multiline-containsmany.php
index fe05f9ac90..ac1db23f87 100644
--- a/demos/special/multiline-containsmany.php
+++ b/demos/special/multiline-containsmany.php
@@ -2,14 +2,14 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
// This demo require specific Database setup.
-class Client extends \atk4\data\Model
+class Client extends \Atk4\Data\Model
{
public $table = 'client';
public $caption = 'Client';
@@ -25,7 +25,7 @@ protected function init(): void
}
}
-class Account extends \atk4\data\Model
+class Account extends \Atk4\Data\Model
{
public $caption = ' ';
@@ -40,4 +40,4 @@ protected function init(): void
}
}
-\atk4\ui\Crud::addTo($app)->setModel(new Client($app->db));
+\Atk4\Ui\Crud::addTo($app)->setModel(new Client($app->db));
diff --git a/demos/tutorial/actions.php b/demos/tutorial/actions.php
index 3948e464bc..5220f7dc08 100644
--- a/demos/tutorial/actions.php
+++ b/demos/tutorial/actions.php
@@ -2,20 +2,20 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-use atk4\ui\View;
+use Atk4\Ui\View;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
-$wizard = \atk4\ui\Wizard::addTo($app);
+$wizard = \Atk4\Ui\Wizard::addTo($app);
$app->stickyGet($wizard->name);
$wizard->addStep('Define User Action', function ($page) {
- \atk4\ui\Header::addTo($page, ['What are User Actions?']);
+ \Atk4\Ui\Header::addTo($page, ['What are User Actions?']);
- $t = \atk4\ui\Text::addTo($page);
+ $t = \Atk4\Ui\Text::addTo($page);
$t->addParagraph(
<<< 'EOF'
Since the early version ATK UI was about building generic UI capable of automatically read information about
@@ -35,12 +35,12 @@
);
$page->add(new Demo())->setCodeAndCall(function (View $owner) {
- $country = new \atk4\ui\demo\CountryLock($owner->getApp()->db);
+ $country = new \Atk4\Ui\Demos\CountryLock($owner->getApp()->db);
$country->addUserAction('send_message');
});
- $t = \atk4\ui\Text::addTo($page);
+ $t = \Atk4\Ui\Text::addTo($page);
$t->addParagraph(
<<< 'EOF'
Once defied - actions will be visualised in the Form, Grid, Crud and CardDeck. Additionally add-ons will recognise
@@ -58,21 +58,21 @@
);
$page->add(new Demo())->setCodeAndCall(function (View $owner) {
- $country = new \atk4\ui\demo\CountryLock($owner->getApp()->db);
+ $country = new \Atk4\Ui\Demos\CountryLock($owner->getApp()->db);
$country->addUserAction('send_message', function () {
return 'sent';
});
$country->tryLoadAny();
- $card = \atk4\ui\Card::addTo($owner);
+ $card = \Atk4\Ui\Card::addTo($owner);
$card->setModel($country, ['iso']);
$card->addClickAction($country->getUserAction('send_message'));
});
});
$wizard->addStep('UI Integration', function ($page) {
- $t = \atk4\ui\Text::addTo($page);
+ $t = \Atk4\Ui\Text::addTo($page);
$t->addParagraph(
<<< 'EOF'
Agile UI introduces a new set of views called "User Action Executors". Their job is to recognise all that meta-information
@@ -82,14 +82,14 @@
);
$page->add(new Demo())->setCodeAndCall(function (View $owner) {
- $country = new \atk4\ui\demo\CountryLock($owner->getApp()->db);
+ $country = new \Atk4\Ui\Demos\CountryLock($owner->getApp()->db);
$country->loadAny();
- \atk4\ui\Button::addTo($owner, ['Edit some country'])
+ \Atk4\Ui\Button::addTo($owner, ['Edit some country'])
->on('click', $country->getUserAction('edit'));
});
- $t = \atk4\ui\Text::addTo($page);
+ $t = \Atk4\Ui\Text::addTo($page);
$t->addParagraph(
<<< 'EOF'
It is not only the button, but any view can have "User Action" passed as a second step of the on() call. Here the user action
@@ -98,17 +98,17 @@
);
$page->add(new Demo())->setCodeAndCall(function (View $owner) {
- $country = new \atk4\ui\demo\CountryLock($owner->getApp()->db);
+ $country = new \Atk4\Ui\Demos\CountryLock($owner->getApp()->db);
$country->loadAny();
- $menu = \atk4\ui\Menu::addTo($owner);
+ $menu = \Atk4\Ui\Menu::addTo($owner);
$menu->addItem('Hello');
$menu->addItem('World', $country->getUserAction('edit'));
});
});
$wizard->addStep('Arguments', function ($page) {
- $t = \atk4\ui\Text::addTo($page);
+ $t = \Atk4\Ui\Text::addTo($page);
$t->addParagraph(
<<< 'EOF'
Next demo defines an user action that requires arguments. You can specify arguments when the user action is invoked, but if not
@@ -118,10 +118,10 @@
);
$page->add(new Demo())->setCodeAndCall(function (View $owner) {
- $model = new \atk4\data\Model($owner->getApp()->db, 'test');
+ $model = new \Atk4\Data\Model($owner->getApp()->db, 'test');
$model->addUserAction('greet', [
- 'appliesTo' => \atk4\data\Model\UserAction::APPLIES_TO_NO_RECORDS,
+ 'appliesTo' => \Atk4\Data\Model\UserAction::APPLIES_TO_NO_RECORDS,
'args' => [
'age' => [
'type' => 'string',
@@ -130,11 +130,11 @@
'callback' => function ($model, $name) {
return 'Hi ' . $name;
},
- 'ui' => ['executor' => [\atk4\ui\UserAction\JsCallbackExecutor::class]],
+ 'ui' => ['executor' => [\Atk4\Ui\UserAction\JsCallbackExecutor::class]],
]);
$model->addUserAction('ask_age', [
- 'appliesTo' => \atk4\data\Model\UserAction::APPLIES_TO_NO_RECORDS,
+ 'appliesTo' => \Atk4\Data\Model\UserAction::APPLIES_TO_NO_RECORDS,
'args' => [
'age' => [
'type' => 'integer',
@@ -146,13 +146,13 @@
},
]);
- $owner->add(new \atk4\ui\Form\Control\Line([
+ $owner->add(new \Atk4\Ui\Form\Control\Line([
'action' => $model->getUserAction('greet'),
]));
- \atk4\ui\View::addTo($owner, ['ui' => 'divider']);
+ \Atk4\Ui\View::addTo($owner, ['ui' => 'divider']);
- \atk4\ui\Button::addTo($owner, ['Ask Age'])
+ \Atk4\Ui\Button::addTo($owner, ['Ask Age'])
->on('click', $model->getUserAction('ask_age'));
});
});
@@ -163,7 +163,7 @@
$model = new Stat($owner->getApp()->db);
$model->addUserAction('mail', [
'fields' => ['currency_field'],
- 'appliesTo' => \atk4\data\Model\UserAction::APPLIES_TO_SINGLE_RECORD,
+ 'appliesTo' => \Atk4\Data\Model\UserAction::APPLIES_TO_SINGLE_RECORD,
'callback' => function() { return 'testing'; },
'description' => 'Email testing',
]);
@@ -177,7 +177,7 @@
*/
$wizard->addStep('Crud integration', function ($page) {
- $t = \atk4\ui\Text::addTo($page);
+ $t = \Atk4\Ui\Text::addTo($page);
$t->addParagraph(
<<< 'EOF'
Compared to 1.x versions Crud implementation has became much more lightweight, however you retain all the same
@@ -187,23 +187,23 @@ functionality and more. Next example shows how you can disable user action (add)
);
$page->add(new Demo())->setCodeAndCall(function (View $owner) {
- $country = new \atk4\ui\demo\CountryLock($owner->getApp()->db);
+ $country = new \Atk4\Ui\Demos\CountryLock($owner->getApp()->db);
$country->getUserAction('add')->enabled = false;
$country->getUserAction('delete')->enabled = function () { return random_int(1, 2) > 1; };
$country->addUserAction('mail', [
- 'appliesTo' => \atk4\data\Model\UserAction::APPLIES_TO_SINGLE_RECORD,
+ 'appliesTo' => \Atk4\Data\Model\UserAction::APPLIES_TO_SINGLE_RECORD,
'preview' => function ($model) { return 'here is email preview for ' . $model->get('name'); },
'callback' => function ($model) { return 'email sent to ' . $model->get('name'); },
'description' => 'Email testing',
'ui' => ['icon' => 'mail', 'button' => [null, 'icon' => 'green mail']],
]);
- \atk4\ui\Crud::addTo($owner, ['ipp' => 5])->setModel($country, ['name', 'iso']);
+ \Atk4\Ui\Crud::addTo($owner, ['ipp' => 5])->setModel($country, ['name', 'iso']);
});
});
$wizard->addFinish(function ($page) use ($wizard) {
PromotionText::addTo($page);
- \atk4\ui\Button::addTo($wizard, ['Exit demo', 'primary', 'icon' => 'left arrow'], ['Left'])
+ \Atk4\Ui\Button::addTo($wizard, ['Exit demo', 'primary', 'icon' => 'left arrow'], ['Left'])
->link('/demos/index.php');
});
diff --git a/demos/tutorial/intro.php b/demos/tutorial/intro.php
index 333faa49e9..e08d1384cf 100644
--- a/demos/tutorial/intro.php
+++ b/demos/tutorial/intro.php
@@ -2,20 +2,20 @@
declare(strict_types=1);
-namespace atk4\ui\demo;
+namespace Atk4\Ui\Demos;
-use atk4\ui\Header;
-use atk4\ui\JsToast;
-use atk4\ui\Message;
-use atk4\ui\View;
+use Atk4\Ui\Header;
+use Atk4\Ui\JsToast;
+use Atk4\Ui\Message;
+use Atk4\Ui\View;
-/** @var \atk4\ui\App $app */
+/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
-$wizard = \atk4\ui\Wizard::addTo($app);
+$wizard = \Atk4\Ui\Wizard::addTo($app);
$wizard->addStep('User Interface', function ($page) {
- $t = \atk4\ui\Text::addTo($page);
+ $t = \Atk4\Ui\Text::addTo($page);
$t->addParagraph(
<<< 'EOF'
Agile Toolkit is a "Low Code Framework" written in PHP. It is designed to simplify all aspects of web application creation:
@@ -57,12 +57,12 @@
$t->addParagraph('It all has started with a "Button" though:');
Demo::addTo($page)->setCodeAndCall(function (View $owner) {
- \atk4\ui\Button::addTo($owner, ['Hello from the button!']);
+ \Atk4\Ui\Button::addTo($owner, ['Hello from the button!']);
});
});
$wizard->addStep('Interactivity', function ($page) {
- $t = \atk4\ui\Text::addTo($page);
+ $t = \Atk4\Ui\Text::addTo($page);
$t->addParagraph(
<<< 'EOF'
PHP is a server-side language. That prompted us to implement server-side UI actions. They are very easy to define -
@@ -71,13 +71,13 @@
);
Demo::addTo($page)->setCodeAndCall(function (View $owner) {
- $button = \atk4\ui\Button::addTo($owner, ['Click for the greeting!']);
+ $button = \Atk4\Ui\Button::addTo($owner, ['Click for the greeting!']);
$button->on('click', function () {
return 'Hello World!';
});
});
- $t = \atk4\ui\Text::addTo($page);
+ $t = \Atk4\Ui\Text::addTo($page);
$t->addParagraph(
<<< 'EOF'
A component of Agile Toolkit (callback) enables seamless communication between the frontend components (which are often
@@ -86,24 +86,24 @@
);
Demo::addTo($page)->setCodeAndCall(function (View $owner) {
- $seg = \atk4\ui\View::addTo($owner, ['ui' => 'segment']);
+ $seg = \Atk4\Ui\View::addTo($owner, ['ui' => 'segment']);
- \atk4\ui\Text::addTo($seg)->set('Number of buttons: ');
+ \Atk4\Ui\Text::addTo($seg)->set('Number of buttons: ');
- $paginator = \atk4\ui\Paginator::addTo($seg, [
+ $paginator = \Atk4\Ui\Paginator::addTo($seg, [
'total' => 5,
'reload' => $seg,
'urlTrigger' => 'count',
]);
- \atk4\ui\View::addTo($seg, ['ui' => 'divider']);
+ \Atk4\Ui\View::addTo($seg, ['ui' => 'divider']);
for ($i = 1; $i <= ($_GET['count'] ?? 1); ++$i) {
- \atk4\ui\Button::addTo($seg, [$i]);
+ \Atk4\Ui\Button::addTo($seg, [$i]);
}
});
- $t = \atk4\ui\Text::addTo($page);
+ $t = \Atk4\Ui\Text::addTo($page);
$t->addParagraph(
<<< 'EOF'
This demo also shows you how to create composite views. The '$seg' above contains text, paginator, divider and some
@@ -113,7 +113,7 @@
});
$wizard->addStep('Business Model', function ($page) {
- $t = \atk4\ui\Text::addTo($page);
+ $t = \Atk4\Ui\Text::addTo($page);
$t->addParagraph(
<<< 'EOF'
One major benefit of Server Side Rendered applications is ability to directly interact with data. In other applications
@@ -123,7 +123,7 @@
Demo::addTo($page)->setCodeAndCall(function (View $owner) {
/* Showing Class definition.
- class DemoInvoice extends \atk4\data\Model
+ class DemoInvoice extends \Atk4\Data\Model
{
public $title_field = 'reference';
@@ -138,13 +138,13 @@ protected function init(): void
*/
session_start();
- $model = new \atk4\ui\demo\DemoInvoice(new \atk4\data\Persistence\Array_($_SESSION['x'] ?? []), ['dateFormat' => $owner->getApp()->ui_persistence->date_format]);
- $model->onHook(\atk4\data\Model::HOOK_AFTER_SAVE, function ($model) {
+ $model = new \Atk4\Ui\Demos\DemoInvoice(new \Atk4\Data\Persistence\Array_($_SESSION['x'] ?? []), ['dateFormat' => $owner->getApp()->ui_persistence->date_format]);
+ $model->onHook(\Atk4\Data\Model::HOOK_AFTER_SAVE, function ($model) {
$_SESSION['x'][$model->getId()] = $model->get();
});
Header::addTo($owner, ['Set invoice data:']);
- $form = \atk4\ui\Form::addTo($owner);
+ $form = \Atk4\Ui\Form::addTo($owner);
$form->setModel($model)->tryLoad(1);
if (!$model->loaded()) {
@@ -163,10 +163,10 @@ protected function init(): void
return new JsToast('Saved!');
});
- \atk4\ui\View::addTo($owner, ['ui' => 'divider']);
+ \Atk4\Ui\View::addTo($owner, ['ui' => 'divider']);
});
- $t = \atk4\ui\Text::addTo($page);
+ $t = \Atk4\Ui\Text::addTo($page);
$t->addParagraph(
<<< 'EOF'
This code shows you a combination of 3 objects:
@@ -189,7 +189,7 @@ protected function init(): void
});
$wizard->addStep('Persistence', function ($page) {
- $t = \atk4\ui\Text::addTo($page);
+ $t = \Atk4\Ui\Text::addTo($page);
$t->addParagraph(
<<< 'EOF'
Once your model is defined, it can be re-used later with any generic view:
@@ -199,21 +199,21 @@ protected function init(): void
Demo::addTo($page)->setCodeAndCall(function (View $owner) {
session_start();
- $model = new \atk4\ui\demo\DemoInvoice(new \atk4\data\Persistence\Array_($_SESSION['x'] ?? []), ['dateFormat' => $owner->getApp()->ui_persistence->date_format]);
- $model->onHook(\atk4\data\Model::HOOK_AFTER_SAVE, function ($model) {
+ $model = new \Atk4\Ui\Demos\DemoInvoice(new \Atk4\Data\Persistence\Array_($_SESSION['x'] ?? []), ['dateFormat' => $owner->getApp()->ui_persistence->date_format]);
+ $model->onHook(\Atk4\Data\Model::HOOK_AFTER_SAVE, function ($model) {
$_SESSION['x'][$model->getId()] = $model->get();
});
Header::addTo($owner, ['Record display in Card View using model data.']);
$model->tryLoad(1);
if ($model->loaded()) {
- \atk4\ui\Card::addTo($owner, ['useLabel' => true])->setModel($model);
+ \Atk4\Ui\Card::addTo($owner, ['useLabel' => true])->setModel($model);
} else {
Message::addTo($owner, ['Empty record.']);
}
});
- $t = \atk4\ui\Text::addTo($page);
+ $t = \Atk4\Ui\Text::addTo($page);
$t->addParagraph(
<<< 'EOF'
Re-use of your Business Model code, generic and interactive views and principles of composition and a simple PHP
@@ -224,6 +224,6 @@ protected function init(): void
$wizard->addFinish(function ($page) use ($wizard) {
PromotionText::addTo($page);
- \atk4\ui\Button::addTo($wizard, ['Exit demo', 'primary', 'icon' => 'left arrow'], ['Left'])
+ \Atk4\Ui\Button::addTo($wizard, ['Exit demo', 'primary', 'icon' => 'left arrow'], ['Left'])
->link('/demos/index.php');
});
diff --git a/docs/accordion.rst b/docs/accordion.rst
index e64494fb3e..7e0b23cbf5 100644
--- a/docs/accordion.rst
+++ b/docs/accordion.rst
@@ -1,5 +1,5 @@
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Accordion
diff --git a/docs/app.rst b/docs/app.rst
index 96cd48d162..a337087f8b 100644
--- a/docs/app.rst
+++ b/docs/app.rst
@@ -6,7 +6,7 @@
Purpose of App class
====================
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: App
App is a mandatory object that's essential for Agile UI to operate. If you don't create App object explicitly, it
@@ -14,8 +14,8 @@ will be automatically created if you execute `$component->invokeInit()` or `$com
In most use-scenarios, however, you would create instance of an App class yourself before other components::
- $app = new \atk4\ui\App('My App');
- $app->initLayout([\atk4\ui\Layout\Centered::class]);
+ $app = new \Atk4\Ui\App('My App');
+ $app->initLayout([\Atk4\Ui\Layout\Centered::class]);
LoremIpsum::addTo($app);
As you add one component into another, they will automatically inherit reference to App class. App
@@ -35,7 +35,7 @@ Using App for Injecting Dependencies
Since App class becomes available for all objects and components of Agile Toolkit, you may add
properties into the App class::
- $app->db = new \atk4\ui\Persistence_SQL($dsn);
+ $app->db = new \Atk4\Ui\Persistence_SQL($dsn);
// later anywhere in the code:
@@ -61,7 +61,7 @@ App class may initialize some resources for you including user authentication an
My next example defines property `$user` and `$system` for the app class to indicate a system which is currently
active. (See :ref:`system_pattern`)::
- class Warehouse extends \atk4\ui\App
+ class Warehouse extends \Atk4\Ui\App
{
public $user;
public $company;
@@ -70,7 +70,7 @@ active. (See :ref:`system_pattern`)::
parent::__construct('Warehouse App v0.4');
// My App class will establish database connection
- $this->db = new \atk4\data\Persistence_SQL($_CLEARDB_DATABASE_URL['DSN']);
+ $this->db = new \Atk4\Data\Persistence_SQL($_CLEARDB_DATABASE_URL['DSN']);
$this->db->setApp($this);
     // My App class provides access to a currently logged user and currently selected system.
@@ -80,7 +80,7 @@ active. (See :ref:`system_pattern`)::
// App class may be used for pages that do not require authentication
if (!$auth) {
- $this->initLayout([\atk4\ui\Layout\Centered::class]);
+ $this->initLayout([\Atk4\Ui\Layout\Centered::class]);
return;
}
@@ -91,7 +91,7 @@ active. (See :ref:`system_pattern`)::
     // Make sure user is valid
if(!$this->user->loaded()) {
- $this->initLayout([\atk4\ui\Layout\Centered::class]);
+ $this->initLayout([\Atk4\Ui\Layout\Centered::class]);
Message::addTo($this, ['Login Required', 'error']);
Button::addTo($this, ['Login', 'primary'])->link('index.php');
exit;
@@ -100,7 +100,7 @@ active. (See :ref:`system_pattern`)::
// Load company data (System) for present user
$this->company = $this->user->ref('company_id');
- $this->initLayout([\atk4\ui\Layout\Admin::class]);
+ $this->initLayout([\Atk4\Ui\Layout\Admin::class]);
     // Add more initialization here, such as a populating menu.
}
@@ -265,7 +265,7 @@ If your `App` needs a DB connection, set this property to an instance of `Persis
Example:
- $app->db = \atk4\data\Persistence::connect('mysql://user:pass@localhost/atk');
+ $app->db = \Atk4\Data\Persistence::connect('mysql://user:pass@localhost/atk');
See `Persistence::connect `
@@ -353,7 +353,7 @@ at some point initialize internal 'App' class that will assist with various task
Having composition of multiple components will allow them to share the app object::
- $grid = new \atk4\ui\Grid();
+ $grid = new \Atk4\Ui\Grid();
$grid->setModel($user);
$grid->addPaginator(); // initialize and populate paginator
$grid->addButton('Test'); // initialize and populate toolbar
@@ -386,7 +386,7 @@ Adding the Layout
Layout can be initialized through the app like this::
- $app->initLayout([\atk4\ui\Layout\Centered::class]);
+ $app->initLayout([\Atk4\Ui\Layout\Centered::class]);
This will initialize two new views inside the app::
@@ -403,7 +403,7 @@ Each layout, depending on it's content, may come with several views that you can
Admin Layout
------------
-.. php:namespace:: atk4\ui\Layout
+.. php:namespace:: Atk4\Ui\Layout
.. php:class:: Admin
Agile Toolkit comes with a ready to use admin layout for your application. The layout is built
@@ -413,7 +413,7 @@ with top, left and right menu objects.
Populating the left menu object is simply a matter of adding the right menu items to the layout menu::
- $app->initLayout([\atk4\ui\Layout\Admin::class]);
+ $app->initLayout([\Atk4\Ui\Layout\Admin::class]);
$layout = $app->layout;
// Add item into menu
@@ -428,7 +428,7 @@ Populating the left menu object is simply a matter of adding the right menu item
This is the top menu of the admin layout. You can add other item to the top menu using::
Button::addTo($layout->menu->addItem(), ['View Source', 'teal', 'icon' => 'github'])
- ->setAttr('target', '_blank')->on('click', new \atk4\ui\JsExpression('document.location=[];', [$url.$f]));
+ ->setAttr('target', '_blank')->on('click', new \Atk4\Ui\JsExpression('document.location=[];', [$url.$f]));
.. php:attr:: menuRight
diff --git a/docs/autocomplete.rst b/docs/autocomplete.rst
index e5762d864e..c02ea93036 100644
--- a/docs/autocomplete.rst
+++ b/docs/autocomplete.rst
@@ -5,7 +5,7 @@
AutoComplete Form Control
=========================
-.. php:namespace:: atk4\ui\Form\Control
+.. php:namespace:: Atk4\Ui\Form\Control
.. php:class:: AutoComplete
Agile UI uses "Form\\Control\\Dropdown" by default on the form, but there is also implementation
@@ -31,14 +31,14 @@ form where you can enter new record details.
The form save will re-use the model of your auto-complete, so be sure to set() defaults and
addCondition()s::
- $form->addControl('test', [\atk4\ui\Form\Control\AutoComplete::class, 'plus'=>true])->setModel(new Country($db));
+ $form->addControl('test', [\Atk4\Ui\Form\Control\AutoComplete::class, 'plus'=>true])->setModel(new Country($db));
Specifying in Model
-------------------
You can also specify that you prefer to use AutoComplete inside your model definition::
- $model->hasOne('country_id', [new Country($db), 'ui'=>['form'=>[\atk4\ui\Form\Control\AutoComplete::class]]]);
+ $model->hasOne('country_id', [new Country($db), 'ui'=>['form'=>[\Atk4\Ui\Form\Control\AutoComplete::class]]]);
Advanced Usage
--------------
@@ -46,11 +46,11 @@ Advanced Usage
You can do much more with AutoComplete form control by passing dropdown settings::
$form->addControl('test', [
- \atk4\ui\Form\Control\AutoComplete::class,
+ \Atk4\Ui\Form\Control\AutoComplete::class,
'settings'=>[
'allowReselection' => true,
'selectOnKeydown' => false,
- 'onChange' => new \atk4\ui\JsExpression('function(value,t,c){
+ 'onChange' => new \Atk4\Ui\JsExpression('function(value,t,c){
if ($(this).data("value") !== value) {
$(this).parents(".form").form("submit");
$(this).data("value", value);
@@ -66,10 +66,10 @@ In 1.6 we have introduced Lookup form control, which is identical to AutoComplet
use of Filters::
- $form = \atk4\ui\Form::addTo($app, ['segment']);
- \atk4\ui\Label::addTo($form, ['Add city', 'top attached'], ['AboveControls']);
+ $form = \Atk4\Ui\Form::addTo($app, ['segment']);
+ \Atk4\Ui\Label::addTo($form, ['Add city', 'top attached'], ['AboveControls']);
- $l = $form->addControl('city',[\atk4\ui\Form\Control\Lookup::class]);
+ $l = $form->addControl('city',[\Atk4\Ui\Form\Control\Lookup::class]);
// will restraint possible city value in droddown base on country and/or language.
$l->addFilter('country', 'Country');
diff --git a/docs/breadcrumb.rst b/docs/breadcrumb.rst
index d4bb0a975b..e9ba3dde76 100644
--- a/docs/breadcrumb.rst
+++ b/docs/breadcrumb.rst
@@ -5,7 +5,7 @@
Breadcrumb
==========
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Breadcrumb
Implement navigational Breadcrumb, by using https://fomantic-ui.com/collections/breadcrumb.html
@@ -72,7 +72,7 @@ For example the next code will use some logic::
// display list of users
$table = Table::addTo($app);
$table->setModel($model);
- $table->addDecorator(['name', [\atk4\ui\Table\Column\Link::class, [], ['user_id'=>'id']);
+ $table->addDecorator(['name', [\Atk4\Ui\Table\Column\Link::class, [], ['user_id'=>'id']);
}
$crumb->popTitle();
diff --git a/docs/button.rst b/docs/button.rst
index a962422009..506ccd9b1a 100644
--- a/docs/button.rst
+++ b/docs/button.rst
@@ -5,7 +5,7 @@
Button
======
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Button
diff --git a/docs/callbacks.rst b/docs/callbacks.rst
index 2223986cdd..31e5c7243e 100644
--- a/docs/callbacks.rst
+++ b/docs/callbacks.rst
@@ -37,7 +37,7 @@ traits:
To create a new callback, do this::
- $c = new \atk4\ui\Callback();
+ $c = new \Atk4\Ui\Callback();
$app->add($c);
Because 'Callback' is not a View, it won't be rendered. The reason we are adding into :ref:`render_tree`
@@ -49,8 +49,8 @@ is for it to establish a unique name which will be used to generate callback URL
The following example code generates unique URL::
- $label = \atk4\ui\Label::addTo($app, ['Callback URL:']);
- $cb = \atk4\ui\Callback::addTo($label);
+ $label = \Atk4\Ui\Label::addTo($app, ['Callback URL:']);
+ $cb = \Atk4\Ui\Callback::addTo($label);
$label->detail = $cb->getUrl();
$label->link($cb->getUrl());
@@ -87,8 +87,8 @@ Return value of set()
The callback verifies trigger condition when you call :php:meth:`Callback::set()`. If your callback
returns any value, the set() will return it too::
- $label = \atk4\ui\Label::addTo($app, ['Callback URL:']);
- $cb = \atk4\ui\Callback::addTo($label);
+ $label = \Atk4\Ui\Label::addTo($app, ['Callback URL:']);
+ $cb = \Atk4\Ui\Callback::addTo($label);
$label->detail = $cb->getUrl();
$label->link($cb->getUrl());
@@ -106,8 +106,8 @@ execution with set() and terminate(). This can be helpful sometimes when you nee
rendering of the page through a special call-back link. The next example will change color of
the label regardless of the callback function::
- $label = \atk4\ui\Label::addTo($app, ['Callback URL:']);
- $cb = \atk4\ui\Callback::addTo($label);
+ $label = \Atk4\Ui\Label::addTo($app, ['Callback URL:']);
+ $cb = \Atk4\Ui\Callback::addTo($label);
$label->detail = $cb->getUrl();
$label->link($cb->getUrl());
@@ -141,8 +141,8 @@ either at the end at beforeRender or beforeOutput hook from inside App, whicheve
In other words this won't break the flow of your code logic, it simply won't render it. In the next example
the $label->detail is assigned at the very end, yet callback is able to access the property::
- $label = \atk4\ui\Label::addTo($app, ['Callback URL:']);
- $cb = \atk4\ui\CallbackLater::addTo($label);
+ $label = \Atk4\Ui\Label::addTo($app, ['Callback URL:']);
+ $cb = \Atk4\Ui\CallbackLater::addTo($label);
$cb->set(function() use($app, $label) {
$app->terminate('Label detail is '.$label->detail);
@@ -163,12 +163,12 @@ know about :php:class:`JsReload` already?
Here is example of JsReload::
- $view = \atk4\ui\View::addTo($app, ['ui'=>'tertiary green inverted segment']);
- $button = \atk4\ui\Button::addTo($app, ['Reload Lorem']);
+ $view = \Atk4\Ui\View::addTo($app, ['ui'=>'tertiary green inverted segment']);
+ $button = \Atk4\Ui\Button::addTo($app, ['Reload Lorem']);
- $button->on('click', new \atk4\ui\JsReload($view));
+ $button->on('click', new \Atk4\Ui\JsReload($view));
- \atk4\ui\LoremIpsum::addTo($view);
+ \Atk4\Ui\LoremIpsum::addTo($view);
NOTE: that we can't perform JsReload on LoremIpsum directly, because it's a text, it needs to be inside
@@ -193,8 +193,8 @@ JsCallback implements exactly that. When you specify a handler for JsCallback, i
which will be rendered into JavaScript in response to triggering callback's URL. Let's bring up our older example, but will
use JsCallback class now::
- $label = \atk4\ui\Label::addTo($app, ['Callback URL:']);
- $cb = \atk4\ui\JsCallback::addTo($label);
+ $label = \Atk4\Ui\Label::addTo($app, ['Callback URL:']);
+ $cb = \Atk4\Ui\JsCallback::addTo($label);
$cb->set(function() {
return 'ok';
@@ -215,8 +215,8 @@ execute PHP method returning one or more :ref:`js_action` which will be received
To fully use jsAction above, here is a modified code::
- $label = \atk4\ui\Label::addTo($app, ['Callback URL:']);
- $cb = \atk4\ui\JsCallback::addTo($label);
+ $label = \Atk4\Ui\Label::addTo($app, ['Callback URL:']);
+ $cb = \Atk4\Ui\JsCallback::addTo($label);
$cb->set(function() {
return 'ok';
@@ -227,7 +227,7 @@ To fully use jsAction above, here is a modified code::
Now, that is pretty long. For your convenience, there is a shorter mechanism::
- $label = \atk4\ui\Label::addTo($app, ['Callback test']);
+ $label = \Atk4\Ui\Label::addTo($app, ['Callback test']);
$label->on('click', function() {
return 'ok';
@@ -243,8 +243,8 @@ is based on 'Callback' therefore code after :php:meth:`View::on()` will not be e
If you set `confirm` property action will ask for user's confirmation before sending a callback::
- $label = \atk4\ui\Label::addTo($app, ['Callback URL:']);
- $cb = \atk4\ui\JsCallback::addTo($label);
+ $label = \Atk4\Ui\Label::addTo($app, ['Callback URL:']);
+ $cb = \Atk4\Ui\JsCallback::addTo($label);
$cb->confirm = 'sure?';
@@ -258,7 +258,7 @@ If you set `confirm` property action will ask for user's confirmation before sen
This is used with delete operations. When using :php:meth:`View::on()` you can pass extra argument to set the 'confirm'
property::
- $label = \atk4\ui\Label::addTo($app, ['Callback test']);
+ $label = \Atk4\Ui\Label::addTo($app, ['Callback test']);
$label->on('click', function() {
return 'ok';
@@ -272,12 +272,12 @@ JavaScript arguments
It is possible to modify expression of JsCallback to pass additional arguments to it's callback. The next example
will send browser screen width back to the callback::
- $label = \atk4\ui\Label::addTo($app);
- $cb = \atk4\ui\JsCallback::addTo($label);
+ $label = \Atk4\Ui\Label::addTo($app);
+ $cb = \Atk4\Ui\JsCallback::addTo($label);
$cb->set(function($j, $arg1){
return 'width is '.$arg1;
- }, [new \atk4\ui\JsExpression( '$(window).width()' )]);
+ }, [new \Atk4\Ui\JsExpression( '$(window).width()' )]);
$label->detail = $cb->getUrl();
$label->js('click', $cb);
@@ -286,19 +286,19 @@ In here you see that I'm using a 2nd argument to $cb->set() to specify arguments
browser. Those arguments are passed to the callback and eventually arrive as $arg1 inside my callback. The :php:meth:`View::on()`
also supports argument passing::
- $label = \atk4\ui\Label::addTo($app, ['Callback test']);
+ $label = \Atk4\Ui\Label::addTo($app, ['Callback test']);
$label->on('click', function($j, $arg1) {
return 'width is '.$arg1;
- }, ['confirm'=>'sure?', 'args'=>[new \atk4\ui\JsExpression( '$(window).width()' )]]);
+ }, ['confirm'=>'sure?', 'args'=>[new \Atk4\Ui\JsExpression( '$(window).width()' )]]);
If you do not need to specify confirm, you can actually pass arguments in a key-less array too::
- $label = \atk4\ui\Label::addTo($app, ['Callback test']);
+ $label = \Atk4\Ui\Label::addTo($app, ['Callback test']);
$label->on('click', function($j, $arg1) {
return 'width is '.$arg1;
- }, [new \atk4\ui\JsExpression( '$(window).width()' )]);
+ }, [new \Atk4\Ui\JsExpression( '$(window).width()' )]);
Refering to event origin
diff --git a/docs/console.rst b/docs/console.rst
index 3e01932b24..4ad4ef7733 100644
--- a/docs/console.rst
+++ b/docs/console.rst
@@ -1,4 +1,4 @@
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Console
@@ -36,7 +36,7 @@ After adding a console to your :ref:`render_tree`, you just need to set a call-b
sleep(2);
- $console->send(new \atk4\ui\JsExpression('alert([])', ['The wait is over']));
+ $console->send(new \Atk4\Ui\JsExpression('alert([])', ['The wait is over']));
});
Console uses :ref:`sse` which works pretty much out-of-the-box with the modern browsers and unlike websockets
@@ -64,7 +64,7 @@ your site is slow and is unable to load page quick. Alternative is to run it thr
This will display console to the user and will even output information from inside the model::
- use \atk4\core\DebugTrait();
+ use \Atk4\Core\DebugTrait();
function generateReport($pages) {
$this->info('converting report to PDF');
diff --git a/docs/core.rst b/docs/core.rst
index 680531ceb2..d3b812bc50 100644
--- a/docs/core.rst
+++ b/docs/core.rst
@@ -2,7 +2,7 @@
Core Concepts
=============
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
Agile Toolkit and Agile UI are built upon specific core concepts. Understanding those
concepts is very important especially if you plan to write and distribute your own
@@ -15,8 +15,8 @@ In any Agile UI application you will always need to have an App class. Even if y
create this class explicitly, components generally will do it for you. The common pattern
is::
- $app = new \atk4\ui\App('My App');
- $app->initLayout([\atk4\ui\Layout\Centered::class]);
+ $app = new \Atk4\Ui\App('My App');
+ $app->initLayout([\Atk4\Ui\Layout\Centered::class]);
LoremIpsum::addTo($app);
.. toctree::
@@ -55,7 +55,7 @@ hierarchy will render itself and will present HTML output that would appear to u
You can create and link multiple UI objects together before linking them with other chunks of your UI::
- $msg = new \atk4\ui\Message('Hey There');
+ $msg = new \Atk4\Ui\Message('Hey There');
Button::addTo($msg, ['Button']);
$app->add($msg);
diff --git a/docs/crud.rst b/docs/crud.rst
index 41d306b976..356e9d9532 100644
--- a/docs/crud.rst
+++ b/docs/crud.rst
@@ -5,7 +5,7 @@
Crud
====
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Crud
Crud class offers a very usable extension to :php:class:`Grid` class, which automatically adds actions for deleting,
@@ -88,7 +88,7 @@ specify your own form behavior using a callback for action::
// callback for both model action edit and add.
$g->onFormAddEdit(function ($form, $ex) {
$form->onSubmit(function ($form) use ($ex) {
- return [$ex->hide(), new \atk4\ui\JsToast('Submit all right! This demo does not saved data.')];
+ return [$ex->hide(), new \Atk4\Ui\JsToast('Submit all right! This demo does not saved data.')];
});
});
diff --git a/docs/dataexecutor.rst b/docs/dataexecutor.rst
index 30557a04c2..872677b539 100644
--- a/docs/dataexecutor.rst
+++ b/docs/dataexecutor.rst
@@ -19,7 +19,7 @@ Demo: https://ui.agiletoolkit.org/demos/data-action/actions.php
Executor Interface
==================
-.. php:namespace:: atk4\ui\UserAction
+.. php:namespace:: Atk4\Ui\UserAction
All executors must implement the Executor or JsExecutor interface.
@@ -108,7 +108,7 @@ Here is an example of an user action returning specific record information in th
[
'caption' => 'Delete',
'description' => 'Delete Country',
- 'ui' => ['executor' => [\atk4\ui\UserAction\ConfirmationExecutor::class]],
+ 'ui' => ['executor' => [\Atk4\Ui\UserAction\ConfirmationExecutor::class]],
'confirmation' => function ($action) {
return 'Are you sure you want to delete this country: $action->getModel()->getTitle();
},
diff --git a/docs/filestructure.rst b/docs/filestructure.rst
index 1603d7bac1..9f9995f799 100644
--- a/docs/filestructure.rst
+++ b/docs/filestructure.rst
@@ -135,7 +135,7 @@ We initialize a reusable database connection in db.php through a mysql persisten
Create a file called "db.php" in the directory "config"::
db = $db; // defines our database for reuse in other classes
Create index.php and admin.php
@@ -172,14 +172,14 @@ If you want to write an app with a backend, create a file called "admin.php"::
initLayout([\atk4\ui\Layout\Admin::class]);
+ $app->initLayout([\Atk4\Ui\Layout\Admin::class]);
If you want to write an app with a frontend, create a file called "index.php"::
initLayout([\atk4\ui\Layout\Centered::class]);
+ $app->initLayout([\Atk4\Ui\Layout\Centered::class]);
Create your own classes
@@ -202,11 +202,11 @@ Open the created file "View1.php" in your editor and add the following lines::
getApp(), ['here goes some text']);
+ $text = \Atk4\Ui\Text::addTo($this->getApp(), ['here goes some text']);
}
}
diff --git a/docs/fileupload.rst b/docs/fileupload.rst
index a0c1d4978a..ee7bc53791 100644
--- a/docs/fileupload.rst
+++ b/docs/fileupload.rst
@@ -16,14 +16,14 @@ in steps:
4. PHP upload callback :php:meth:`Upload::onUpload` is called, returns "file_id"
5. "file_id" is placed inside form.
6. User submits the form
- 7. :php:meth:`\atk4\ui\Form::onSubmit()` receives "file_id"
+ 7. :php:meth:`\Atk4\Ui\Form::onSubmit()` receives "file_id"
Currently only one file can be uploaded at a time. If file is uploaded incorrectly,
it can be removed. Both Upload and UploadImage controls contain an upload button which would
open a File Selection dialog. UploadImage also implements image preview icon.
During upload, a progress bar will appear.
-.. php:namespace:: atk4\ui\Form\Control
+.. php:namespace:: Atk4\Ui\Form\Control
.. php:class:: Upload
@@ -51,7 +51,7 @@ Callbacks
When adding an Upload or UploadImage field to a form, onUpload and onDelete callback must be defined::
- $img = $form->addControl('img', [\atk4\ui\Form\Control\UploadImage::class, ['defaultSrc' => './images/default.png', 'placeholder' => 'Click to add an image.']]);
+ $img = $form->addControl('img', [\Atk4\Ui\Form\Control\UploadImage::class, ['defaultSrc' => './images/default.png', 'placeholder' => 'Click to add an image.']]);
$img->onUpload(function ($postFile) {
// callback action here...
@@ -90,7 +90,7 @@ Example showing the onUpload callback on the UploadImage field::
$img->setFileId('123456');
// can also return a notifier.
- return new \atk4\ui\JsNotify(['content' => 'File is uploaded!', 'color' => 'green']);
+ return new \Atk4\Ui\JsNotify(['content' => 'File is uploaded!', 'color' => 'green']);
});
When user submit the form, the form control data value that will be submitted is the fileId set during the onUpload callback.
@@ -121,7 +121,7 @@ Example showing the onDelete callback on the UploadImage field::
// reset thumbanil
$img->clearThumbnail('./images/default.png');
- return new \atk4\ui\JsNotify(['content' => $fileId.' has been removed!', 'color' => 'green']);
+ return new \Atk4\Ui\JsNotify(['content' => $fileId.' has been removed!', 'color' => 'green']);
});
diff --git a/docs/form-control.rst b/docs/form-control.rst
index 2869e5dc9a..ebf8fa60b4 100644
--- a/docs/form-control.rst
+++ b/docs/form-control.rst
@@ -5,7 +5,7 @@
Form Controls
=============
-.. php:namespace:: atk4\ui\Form
+.. php:namespace:: Atk4\Ui\Form
.. php:class:: Control
@@ -15,7 +15,7 @@ quite simple components that present themselves as input controls: line, select,
Relationship with Form
======================
-All Form Control Decorators can be integrated with :php:class:`atk4\\ui\\Form` which will
+All Form Control Decorators can be integrated with :php:class:`Atk4\\Ui\\Form` which will
facilitate collection and processing of data in a form. Form Control decorators can also
be used as stand-alone controls.
@@ -34,8 +34,8 @@ You can set default value and interact with a form control using JavaScript::
$control->set('hello world');
- $button = \atk4\ui\Button::addTo($app, ['check value']);
- $button->on('click', new \atk4\ui\JsExpression('alert("control value is: "+[])', [$control->jsInput()->val()]));
+ $button = \Atk4\Ui\Button::addTo($app, ['check value']);
+ $button->on('click', new \Atk4\Ui\JsExpression('alert("control value is: "+[])', [$control->jsInput()->val()]));
When used stand-alone, Form\Controls will produce a basic HTML (I have omitted id=)::
@@ -50,8 +50,8 @@ Using in-form
Form Control can also be used inside a form like this::
- $form = \atk4\ui\Form::addTo($app);
- $control = $form->addControl('name', new \atk4\ui\Form\Control\Line());
+ $form = \Atk4\Ui\Form::addTo($app);
+ $control = $form->addControl('name', new \Atk4\Ui\Form\Control\Line());
If you execute this exmple, you'll notice that Feld now has a label, it uses full width of the
page and the following HTML is now produced::
@@ -64,7 +64,7 @@ page and the following HTML is now produced::
The markup that surronds the button which includes Label and formatting is produced by
-:php:class:`atk4\\ui\\Form\\Layout`, which does draw some of the information from the Form Control
+:php:class:`Atk4\\Ui\\Form\\Layout`, which does draw some of the information from the Form Control
itself.
Using in Form Layouts
@@ -73,19 +73,19 @@ Using in Form Layouts
Form may have multiple Form Layouts and that's very useful if you need to split up form
into multiple Tabs or detach form control groups or even create nested layouts::
- $form = \atk4\ui\Form::addTo($app);
- $tabs = \atk4\ui\Tabs::addTo($form, [], ['AboveControls']);
- \atk4\ui\View::addTo($form, ['ui'=>'divider'], ['AboveControls']);
+ $form = \Atk4\Ui\Form::addTo($app);
+ $tabs = \Atk4\Ui\Tabs::addTo($form, [], ['AboveControls']);
+ \Atk4\Ui\View::addTo($form, ['ui'=>'divider'], ['AboveControls']);
$form_page = Form\Layout::addTo($tabs->addTab('Basic Info'), ['form'=>$form]);
- $form_page->addControl('name', new \atk4\ui\Form\Control\Line());
+ $form_page->addControl('name', new \Atk4\Ui\Form\Control\Line());
$form_page = Form\Layout::addTo($tabs->addTab('Other Info'), ['form'=>$form]);
- $form_page->addControl('age', new \atk4\ui\Form\Control\Line());
+ $form_page->addControl('age', new \Atk4\Ui\Form\Control\Line());
$form->onSubmit(function($form) { return $form->model->get('name').' has age '.$form->model->get('age'); });
-This is further explained in documentation for :php:class:`atk4\\ui\\Form\\Layout` class,
+This is further explained in documentation for :php:class:`Atk4\\Ui\\Form\\Layout` class,
however if you do plan on adding your own form control types, it's important that you extend it
properly:
@@ -112,13 +112,13 @@ Hint can be specified either inside Form Control decorator seed or inside the Fi
Text will have HTML characters escaped. You may also specify hint value as an object::
- $form->addControl('name', ['hint'=>new \atk4\ui\Text(
+ $form->addControl('name', ['hint'=>new \Atk4\Ui\Text(
'Click here'
)]);
or you can inject a view with a custom template::
- $form->addControl('name', ['hint'=>['template'=>new \atk4\ui\Template(
+ $form->addControl('name', ['hint'=>['template'=>new \Atk4\Ui\Template(
'Click here'
)]]);
@@ -144,7 +144,7 @@ The most common use-case in large application is the use with Models. You would
`Country` model as well as
`Persistence $db `_::
- class Country extends \atk4\data\Model
+ class Country extends \Atk4\Data\Model
{
public $table = 'country';
@@ -163,14 +163,14 @@ The most common use-case in large application is the use with Models. You would
To create a form, the following is sufficient::
- $form = \atk4\ui\Form::addTo($app);
+ $form = \Atk4\Ui\Form::addTo($app);
$form->setModel(new Country($db);
The above will populate fields from model into the form automatically. You can use second
-argument to :php:meth:`\atk4\ui\Form::setModel()` to indicate which fields to display
+argument to :php:meth:`\Atk4\Ui\Form::setModel()` to indicate which fields to display
or rely on :ref:`field_visibility`.
-When Form controls are populated, then :php:meth:`\atk4\ui\Form::controlFactory` is
+When Form controls are populated, then :php:meth:`\Atk4\Ui\Form::controlFactory` is
consulted to make a decision on how to translate
`Model Field `_ into
Form Control Decorator.
@@ -178,12 +178,12 @@ Form Control Decorator.
The rules are rather straightforward but may change in future versions of Agile UI:
- if `enum `_ is defined, use :php:class:`Dropdown`
- - consult :php:attr:`\atk4\ui\Form::$typeToDecorator` property for type-to-seed association
+ - consult :php:attr:`\Atk4\Ui\Form::$typeToDecorator` property for type-to-seed association
- type=password will use :php:class:`Password`
You always have an option to explicitly specify which field you would like to use::
- $model->addField('long_text', ['ui'=>['rorm'=>\atk4\ui\Form\Control\TextArea::class]]);
+ $model->addField('long_text', ['ui'=>['rorm'=>\Atk4\Ui\Form\Control\TextArea::class]]);
It is recommended however, that you use type when possible, because types will be universally supported
by all components::
@@ -202,7 +202,7 @@ Link to Model Field
Form decorator defines $field property which will be pointing to a field object of a model, so technically
the value of the field would be read from `$decorator->field->get()`.
-.. php:namespace:: atk4\ui\Form\Control
+.. php:namespace:: Atk4\Ui\Form\Control
Line Input Form control
=======================
@@ -227,7 +227,7 @@ Here are few ways to specify `icon` to an Input::
Line::addTo($page, ['icon'=>'search']);
// Type-hinting friendly
- $line = new \atk4\ui\Form\Control\Line();
+ $line = new \Atk4\Ui\Form\Control\Line();
$line->icon='search';
$page->add($line);
@@ -301,10 +301,10 @@ $expression argument can be string, JsExpression, array of JsExpressions or even
// callback
$f2 = $form->addControl('f2');
- $f2->onChange(function(){return new \atk4\ui\JsExpression('console.log("f2 changed")');});
+ $f2->onChange(function(){return new \Atk4\Ui\JsExpression('console.log("f2 changed")');});
// Calendar form control - wraps in function call with arguments date, text and mode
- $c1 = $form->addControl('c1', new \atk4\ui\Form\Control\Calendar(['type'=>'date']));
+ $c1 = $form->addControl('c1', new \Atk4\Ui\Form\Control\Calendar(['type'=>'date']));
$c1->onChange('console.log("c1 changed: "+date+","+text+","+mode)');
@@ -326,7 +326,7 @@ of records to display. Dropdown renders all records when the paged is rendered,
To render a model field as Dropdown, use the ui property of the field::
- $model->addField('someField', ['ui' => ['form' =>[\atk4\ui\Form\Control\Dropdown::class]]]);
+ $model->addField('someField', ['ui' => ['form' =>[\Atk4\Ui\Form\Control\Dropdown::class]]]);
.. Customizing how a Model's records are displayed in Dropdown
As default, Dropdown will use the `$model->id_field` as value, and `$model->title_field` as title for each menu item.
@@ -352,7 +352,7 @@ You can also use this function to add an Icon to a record::
If you'd like to even further adjust How each item is displayed (e.g. complex HTML and more model fields), you can extend the Dropdown class and create your own template with the complex HTML::
- class MyDropdown extends \atk4\ui\Dropdown {
+ class MyDropdown extends \Atk4\Ui\Dropdown {
public $defaultTemplate = 'my_dropdown.html';
@@ -450,7 +450,7 @@ See this example from Model class init method::
'serialize' => 'json',
'ui' => [
'form' => [
- \atk4\ui\Form\Control\Dropdown::class,
+ \Atk4\Ui\Form\Control\Dropdown::class,
'isMultiple' => true,
'model' => $expr_model,
],
@@ -485,7 +485,7 @@ input model.
Assume that each data model are defined and model Category has many Sub-Category and Sub-Category has many Product::
- $form = \atk4\ui\Form::addTo($app);
+ $form = \Atk4\Ui\Form::addTo($app);
$form->addControl('category_id', [Dropdown::class, 'model' => new Category($db)]);
$form->addControl('sub_category_id', [DropdownCascade::class, 'cascadeFrom' => 'category_id', 'reference' => 'SubCategories']);
$form->addControl('product_id', [DropdownCascade::class, 'cascadeFrom' => 'sub_category_id', 'reference' => 'Products']);
diff --git a/docs/form.rst b/docs/form.rst
index fb955952d1..f338857f58 100644
--- a/docs/form.rst
+++ b/docs/form.rst
@@ -6,7 +6,7 @@
Forms
=====
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Form
@@ -69,15 +69,15 @@ Even if model not explicitly set (see section below) each form has an underlying
'email' => 'some@email.com'
]);
-Form also relies on a ``\atk4\ui\Form::Layout`` class and displays form controls through
-decorators defined at ``\atk4\ui\Form::Control``. See dedicated documentation for:
+Form also relies on a ``\Atk4\Ui\Form::Layout`` class and displays form controls through
+decorators defined at ``\Atk4\Ui\Form::Control``. See dedicated documentation for:
- :php:class:`Form::Layout`
- :php:class:`Form::Control`
To tweak the UI properties of an form control input use ``setInputAttr()`` (and not the surrounding
as ``setAttr()`` would do). Here is how to set the HTML "maxlength" attribute on the generated input field::
- $form = $this->add(new \atk4\ui\Form);
+ $form = $this->add(new \Atk4\Ui\Form);
$form->setModel($model);
$form->getControl('name')->setInputAttr('maxlength', 20);
@@ -161,7 +161,7 @@ Create a new control on a form::
$form = Form::addTo($app);
$form->addControl('email');
- $form->addControl('gender', [\atk4\ui\Form\Control\Dropdown::class, 'values'=>['Female', 'Male']]);
+ $form->addControl('gender', [\Atk4\Ui\Form\Control\Dropdown::class, 'values'=>['Female', 'Male']]);
$form->addControl('terms', null, ['type'=>'boolean', 'caption'=>'Agree to Terms & Conditions']);
Create a new control on a form using Model does not require you to describe each control.
@@ -184,7 +184,7 @@ Similar to :php:meth:`Form::addControl()`, but allows to add multiple form contr
$form = Form::addTo($app);
$form->addControls([
'email',
- ['gender', [\atk4\ui\Form\Control\Dropdown::class, 'values'=>['Female', 'Male']]],
+ ['gender', [\Atk4\Ui\Form\Control\Dropdown::class, 'values'=>['Female', 'Male']]],
['terms', null, ['type'=>'boolean', 'caption'=>'Agree to Terms & Conditions']],
]);
@@ -206,7 +206,7 @@ field.
Form Control
------------
-To avoid term miss-use, we use "Field" to refer to ``\atk4\data\Field``. This class
+To avoid term miss-use, we use "Field" to refer to ``\Atk4\Data\Field``. This class
is documented here: https://agile-data.readthedocs.io/en/develop/fields.html
Form uses a small UI component to visualize HTML input fields associated with
@@ -227,10 +227,10 @@ For some examples see: https://ui.agiletoolkit.org/demos/form3.php
Field Decorator can be passed to ``addControl`` using 'string', :php:ref:`seed` or 'object'::
- $form->addControl('accept_terms', [\atk4\ui\Form\Control\Checkbox::class]);
- $form->addControl('gender', [\atk4\ui\Form\Control\Dropdown::class, 'values'=>['Female', 'Male']]);
+ $form->addControl('accept_terms', [\Atk4\Ui\Form\Control\Checkbox::class]);
+ $form->addControl('gender', [\Atk4\Ui\Form\Control\Dropdown::class, 'values'=>['Female', 'Male']]);
- $calendar = new \atk4\ui\Form\Control\Calendar();
+ $calendar = new \Atk4\Ui\Form\Control\Calendar();
$calendar->type = 'tyme';
$calendar->options['ampm'] = true;
$form->addControl('time', $calendar);
@@ -238,7 +238,7 @@ Field Decorator can be passed to ``addControl`` using 'string', :php:ref:`seed`
For more information on default form controls as well as examples on how to create
your own see documentation on :php:class:`Form::Control`.
-.. php:method:: controlFactory(\\atk4\\data\\Field $field, $defaults = [])
+.. php:method:: controlFactory(\\Atk4\\Data\\Field $field, $defaults = [])
If form control class is not specified (``null``) then it will be determined from
the type of the Data control with ``controlFactory`` method.
@@ -250,10 +250,10 @@ Data field is the 3rd argument to ``Form::addControl()``.
There are 3 ways to define Data form control using 'string', 'array' or 'object'::
- $form->addControl('accept_terms', [\atk4\ui\Form\Control\Checkbox::class], 'Accept Terms & Conditions');
+ $form->addControl('accept_terms', [\Atk4\Ui\Form\Control\Checkbox::class], 'Accept Terms & Conditions');
$form->addControl('gender', null, ['enum'=>['Female', 'Male']]);
- class MyBoolean extends \atk4\data\Field {
+ class MyBoolean extends \Atk4\Data\Field {
public $type = 'boolean';
public $enum = ['N', 'Y'];
}
@@ -264,7 +264,7 @@ field a custom label. Without a custom label, Form will clean up the name (1st
argument) by replacing '_' with spaces and uppercasing words (accept_terms
becomes "Accept Terms")
-Specifying array will use the same syntax as the 2nd argument for ``\atk4\data\Model::addField()``.
+Specifying array will use the same syntax as the 2nd argument for ``\Atk4\Data\Model::addField()``.
(https://agile-data.readthedocs.io/en/develop/model.html#Model::addField)
If field already exist inside model, then values of $field will be merged into
@@ -284,7 +284,7 @@ be set as "never_persist" (https://agile-data.readthedocs.io/en/develop/fields.h
This is to make sure that data from custom form controls wouldn't go directly into the database. Next
example displays a registration form for a User::
- class User extends \atk4\data\Model {
+ class User extends \Atk4\Data\Model {
public $table = 'user';
function init(): void {
parent::init();
@@ -298,7 +298,7 @@ example displays a registration form for a User::
$form->setModel(new User($db));
// add password verification field
- $form->addControl('password_verify', [\atk4\ui\Form\Control\Password::class], 'Type password again');
+ $form->addControl('password_verify', [\Atk4\Ui\Form\Control\Password::class], 'Type password again');
$form->addControl('accept_terms', null, ['type'=>'boolean']);
// submit event
@@ -326,7 +326,7 @@ for you. Here is an example with date::
$form = Form::addTo($app);
$form->addControl('date1', null, ['type'=>'date']);
- $form->addControl('date2', [\atk4\ui\Form\Control\Calendar::class, 'type'=>'date']);
+ $form->addControl('date2', [\Atk4\Ui\Form\Control\Calendar::class, 'type'=>'date']);
$form->onSubmit(function($form) {
echo 'date1 = '.print_r($form->model->get('date1'), true).' and date2 = '.print_r($form->model->get('date2'), true);
@@ -354,7 +354,7 @@ This is where ``$field->ui`` comes in (https://agile-data.readthedocs.io/en/deve
You can specify ``'ui'=>['form' => $decorator_seed]`` when defining your model field inside your Model::
- class User extends \atk4\data\Model {
+ class User extends \Atk4\Data\Model {
public $table = 'user';
function init(): void {
@@ -371,7 +371,7 @@ The seed for the UI will be combined with the default overriding :php:attr:`Form
to allow month/year entry by the Calendar extension, which will then be saved and
stored as a regular date. Obviously you can also specify decorator class::
- $this->addField('birth_year', ['ui'=>[\atk4\ui\Form\Control\Calendar::class, 'type'=>'month']);
+ $this->addField('birth_year', ['ui'=>[\Atk4\Ui\Form\Control\Calendar::class, 'type'=>'month']);
Without the data 'type' property, now the calendar selection will be stored as text.
@@ -481,7 +481,7 @@ As far as form is concerned:
Example use of Model's validate() method::
- class Person extends \atk4\data\Model
+ class Person extends \Atk4\Data\Model
{
public $table = 'person';
@@ -592,10 +592,10 @@ with a message about failure to accept of terms and conditions::
So far Agile UI / Agile Data does not come with a validation library but
it supports usage of 3rd party validation libraries.
-Callback function may raise exception. If Exception is based on ``\atk4\core\Exception``,
+Callback function may raise exception. If Exception is based on ``\Atk4\Core\Exception``,
then the parameter "field" can be used to associate error with specific field::
- throw (new \atk4\core\Exception('Sample Exception'))
+ throw (new \Atk4\Core\Exception('Sample Exception'))
->addMoreInfo('field', 'surname');
If 'field' parameter is not set or any other exception is generated, then error will not be
@@ -688,12 +688,12 @@ The following example will show how to organize fields using regular sub layout
$form = Form::addTo($app);
$form->setModel($model, false);
- $sub_layout = $form->layout->addSubLayout([\atk4\ui\Form\Layout\Section::class]);
+ $sub_layout = $form->layout->addSubLayout([\Atk4\Ui\Form\Layout\Section::class]);
Header::addTo($sub_layout, ['Accordion Section in Form']);
$sub_layout->setModel($model, ['name']);
- $accordion_layout = $form->layout->addSubLayout([\atk4\ui\Form\Layout\Section\Accordion::class]);
+ $accordion_layout = $form->layout->addSubLayout([\Atk4\Ui\Form\Layout\Section\Accordion::class]);
$a1 = $accordion_layout->addSection('Section 1');
$a1->setModel($model, ['iso', 'iso3']);
@@ -719,7 +719,7 @@ Fomantic UI Modifiers
There are many other classes Fomantic UI allow you to use on a form. The next code will produce
form inside a segment (outline) and will make form controls appear smaller::
- $form = new \atk4\ui\Form(['small segment']));
+ $form = new \Atk4\Ui\Form(['small segment']));
For further styling see documentation on :php:class:`View`.
@@ -772,11 +772,11 @@ Here is a more advanced example::
$f_sub = Form::addTo($app);
$f_sub->addControl('name');
- $f_sub->addControl('subscribe', [\atk4\ui\Form\Control\Checkbox::class, 'Subscribe to weekly newsletter', 'toggle']);
+ $f_sub->addControl('subscribe', [\Atk4\Ui\Form\Control\Checkbox::class, 'Subscribe to weekly newsletter', 'toggle']);
$f_sub->addControl('email');
- $f_sub->addControl('gender', [\atk4\ui\Form\Control\Radio::class], ['enum'=>['Female', 'Male']])->set('Female');
- $f_sub->addControl('m_gift', [\atk4\ui\Form\Control\Dropdown::class, 'caption'=>'Gift for Men', 'values' => ['Beer Glass', 'Swiss Knife']]);
- $f_sub->addControl('f_gift', [\atk4\ui\Form\Control\Dropdown::class, 'caption'=>'Gift for Women', 'values' => ['Wine Glass', 'Lipstick']]);
+ $f_sub->addControl('gender', [\Atk4\Ui\Form\Control\Radio::class], ['enum'=>['Female', 'Male']])->set('Female');
+ $f_sub->addControl('m_gift', [\Atk4\Ui\Form\Control\Dropdown::class, 'caption'=>'Gift for Men', 'values' => ['Beer Glass', 'Swiss Knife']]);
+ $f_sub->addControl('f_gift', [\Atk4\Ui\Form\Control\Dropdown::class, 'caption'=>'Gift for Women', 'values' => ['Wine Glass', 'Lipstick']]);
// Show email and gender when subscribe is checked.
@@ -794,9 +794,9 @@ You may also define multiple conditions for the form control to be visible if yo
$f_sub = Form::addTo($app);
- $f_dog->addControl('race', [\atk4\ui\Form\Control\Line::class]);
+ $f_dog->addControl('race', [\Atk4\Ui\Form\Control\Line::class]);
$f_dog->addControl('age');
- $f_dog->addControl('hair_cut', [\atk4\ui\Form\Control\Dropdown::class, 'values' => ['Short', 'Long']]);
+ $f_dog->addControl('hair_cut', [\Atk4\Ui\Form\Control\Dropdown::class, 'values' => ['Short', 'Long']]);
// Show 'hair_cut' when race contains the word 'poodle' AND age is between 1 and 5
// OR
@@ -818,13 +818,13 @@ Instead of defining rules for form controls individually you can hide/show entir
$g_basic->addControl('middle_name', ['width' => 'three']);
$g_basic->addControl('last_name', ['width' => 'five']);
- $f_group->addControl('dev', [\atk4\ui\Form\Control\Checkbox::class, 'caption' => 'I am a developper']);
+ $f_group->addControl('dev', [\Atk4\Ui\Form\Control\Checkbox::class, 'caption' => 'I am a developper']);
$g_code = $f_group->addGroup(['Check all language that apply']);
- $g_code->addControl('php', [\atk4\ui\Form\Control\Checkbox::class]);
- $g_code->addControl('js', [\atk4\ui\Form\Control\Checkbox::class]);
- $g_code->addControl('html', [\atk4\ui\Form\Control\Checkbox::class]);
- $g_code->addControl('css', [\atk4\ui\Form\Control\Checkbox::class]);
+ $g_code->addControl('php', [\Atk4\Ui\Form\Control\Checkbox::class]);
+ $g_code->addControl('js', [\Atk4\Ui\Form\Control\Checkbox::class]);
+ $g_code->addControl('html', [\Atk4\Ui\Form\Control\Checkbox::class]);
+ $g_code->addControl('css', [\Atk4\Ui\Form\Control\Checkbox::class]);
$g_other = $f_group->addGroup(['Others']);
$g_other->addControl('language', ['width' => 'eight']);
diff --git a/docs/grid.rst b/docs/grid.rst
index ed758e1296..c538526b19 100644
--- a/docs/grid.rst
+++ b/docs/grid.rst
@@ -5,7 +5,7 @@
Grid
====
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Grid
If you didn't read documentation on :ref:`table` you should start with that. While table implements the actual
@@ -25,7 +25,7 @@ To make your grid look nicer, you might want to add some buttons and enable quic
$grid->setModel(new Country($db));
$grid->addQuickSearch();
- $grid->menu->addItem('Reload Grid', new \atk4\ui\JsReload($grid));
+ $grid->menu->addItem('Reload Grid', new \Atk4\Ui\JsReload($grid));
Adding Menu Items
=================
@@ -134,7 +134,7 @@ to populate a content::
Calling this method multiple times will add button into same action column.
-See :php:meth:`atk4\\ui\\Table\\Column\\Actions::addModal`
+See :php:meth:`Atk4\\Ui\\Table\\Column\\Actions::addModal`
Column Menus
@@ -144,8 +144,8 @@ Column Menus
.. php:method:: addPopup($columnName, $popup = null, $icon = 'caret square down')
-Methods addDropdown and addPopup provide a wrapper for :php:meth:`atk4\\ui\\Table\\Column::addDropdown` and
-:php:meth:`atk4\\ui\\\Table\\Column::addPopup` methods.
+Methods addDropdown and addPopup provide a wrapper for :php:meth:`Atk4\\Ui\\Table\\Column::addDropdown` and
+:php:meth:`Atk4\\Ui\\\Table\\Column::addPopup` methods.
Selection
=========
@@ -155,7 +155,7 @@ additionally place this column before any other column inside a grid. You can us
method to reference value of selected checkboxes inside any :ref:`js_action`::
$sel = $grid->addSelection();
- $grid->menu->addItem('show selection')->on('click', new \atk4\ui\JsExpression(
+ $grid->menu->addItem('show selection')->on('click', new \Atk4\Ui\JsExpression(
'alert("Selected: "+[])', [$sel->jsChecked()]
));
diff --git a/docs/header.rst b/docs/header.rst
index 36cf0c595f..66883e2155 100644
--- a/docs/header.rst
+++ b/docs/header.rst
@@ -1,4 +1,4 @@
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
======
Header
diff --git a/docs/helloworld.rst b/docs/helloworld.rst
index e7a865dd8a..05423ef720 100644
--- a/docs/helloworld.rst
+++ b/docs/helloworld.rst
@@ -6,7 +6,7 @@
HelloWorld
==========
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: HelloWorld
diff --git a/docs/icon.rst b/docs/icon.rst
index 98cbab838a..57fa37610a 100644
--- a/docs/icon.rst
+++ b/docs/icon.rst
@@ -5,7 +5,7 @@
Icon
====
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Icon
@@ -20,12 +20,12 @@ Alternatively::
Most commonly icon class is used for embedded icons on a :php:class:`Button`
or inside other components (see :ref:`icon_other_comp`)::
- $b1 = new \atk4\ui\Button(['Click Me', 'icon'=>'book']);
+ $b1 = new \Atk4\Ui\Button(['Click Me', 'icon'=>'book']);
You can, of course, create instance of an Icon yourself::
- $icon = new \atk4\ui\Icon('book');
- $b1 = new \atk4\ui\Button(['Click Me', 'icon'=>$icon]);
+ $icon = new \Atk4\Ui\Icon('book');
+ $b1 = new \Atk4\Ui\Button(['Click Me', 'icon'=>$icon]);
You do not need to add an icon into the render tree when specifying like that. The icon is selected
through class. To find out what icons are available, refer to Fomantic-UI icon documentation:
@@ -65,7 +65,7 @@ Groups
Fomantic UI support icon groups. The best way to implement is to supply :php:class:`Template` to an
icon::
- Icon::addTo($app, ['template'=>new \atk4\ui\Template('
+ Icon::addTo($app, ['template'=>new \Atk4\Ui\Template(''), false]);
@@ -75,7 +75,7 @@ exclusive to Icon, but I'm adding a few examples here, just for your convenience
Let's start with a View that contains your custom HTML loaded from file or embedded like this::
- $view = View::addTo($app, ['template'=>new \atk4\ui\Template('
Hello my {Icon}
+ $view = View::addTo($app, ['template'=>new \Atk4\Ui\Template('
Hello my {Icon}{/}, It is me
')]);
@@ -95,7 +95,7 @@ Composing
Composing offers you another way to deal with Group icons::
- $no_users = new \atk4\ui\View([null, 'huge icons', 'element'=>'i']);
+ $no_users = new \Atk4\Ui\View([null, 'huge icons', 'element'=>'i']);
Icon::addTo($no_users, ['big red dont']);
Icon::addTo($no_users, ['black user icon']);
@@ -123,7 +123,7 @@ Here is the code with comments::
* For convenience use this with link(), which will automatically open a new window
* too.
*/
- class SocialAdd extends \atk4\ui\View {
+ class SocialAdd extends \Atk4\Ui\View {
public $social = null;
public $icon = null;
public $defaultTemplate = null;
@@ -147,7 +147,7 @@ Here is the code with comments::
if (!$this->template) {
// TODO: Place template into file and set defaultTemplate instead
- $this->template = new \atk4\ui\Template(
+ $this->template = new \Atk4\Ui\Template(
'<{_element}button{/} class="ui '.$this->social.' button" {$attributes}>
{$Icon}
@@ -159,7 +159,7 @@ Here is the code with comments::
// Initialize icon
if (!is_object($this->icon)) {
- $this->icon = new \atk4\ui\Icon($this->icon);
+ $this->icon = new \Atk4\Ui\Icon($this->icon);
}
// Add icon into render tree
diff --git a/docs/image.rst b/docs/image.rst
index 313fc754ec..b698c519c8 100644
--- a/docs/image.rst
+++ b/docs/image.rst
@@ -5,7 +5,7 @@
Image
=====
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Image
diff --git a/docs/js.rst b/docs/js.rst
index 00c841bb81..914ed5e465 100644
--- a/docs/js.rst
+++ b/docs/js.rst
@@ -1,4 +1,4 @@
-.. php:namespace: atk4\ui
+.. php:namespace: Atk4\Ui
.. _js:
@@ -92,9 +92,9 @@ multiple elements::
$buttons = View::addTo($app, ['ui' => 'basic buttons']);
- \atk4\ui\Button::addTo($buttons, ['One']);
- \atk4\ui\Button::addTo($buttons, ['Two']);
- \atk4\ui\Button::addTo($buttons, ['Three']);
+ \Atk4\Ui\Button::addTo($buttons, ['One']);
+ \Atk4\Ui\Button::addTo($buttons, ['Two']);
+ \Atk4\Ui\Button::addTo($buttons, ['Three']);
$buttons->on('click', '.button')->hide();
@@ -241,9 +241,9 @@ The following code will show three buttons and clicking any one will hide it. On
$buttons = View::addTo($app, ['ui' => 'basic buttons']);
- \atk4\ui\Button::addTo($buttons, ['One']);
- \atk4\ui\Button::addTo($buttons, ['Two']);
- \atk4\ui\Button::addTo($buttons, ['Three']);
+ \Atk4\Ui\Button::addTo($buttons, ['One']);
+ \Atk4\Ui\Button::addTo($buttons, ['Two']);
+ \Atk4\Ui\Button::addTo($buttons, ['Three']);
$buttons->on('click', '.button')->hide();
@@ -261,9 +261,9 @@ You can use both actions together. The next example will allow only one button t
$buttons = View::addTo($app, ['ui' => 'basic buttons']);
- \atk4\ui\Button::addTo($buttons, ['One']);
- \atk4\ui\Button::addTo($buttons, ['Two']);
- \atk4\ui\Button::addTo($buttons, ['Three']);
+ \Atk4\Ui\Button::addTo($buttons, ['One']);
+ \Atk4\Ui\Button::addTo($buttons, ['Two']);
+ \Atk4\Ui\Button::addTo($buttons, ['Three']);
$buttons->on('click', '.button', $b3->js()->hide());
@@ -419,21 +419,21 @@ This class allows you to open modal dialogs and close them easily. It's based ar
`.modal(), `_ but integrates PHP callback for dynamically
producing content of your dialog::
- $modal = \atk4\ui\Modal::addTo($app, ['Modal Title']);
+ $modal = \Atk4\Ui\Modal::addTo($app, ['Modal Title']);
$modal->set(function ($p) use ($modal) {
- \atk4\ui\LoremIpsum::addTo($p);
- \atk4\ui\Button::addTo($p, ['Hide'])->on('click', $modal->hide());
+ \Atk4\Ui\LoremIpsum::addTo($p);
+ \Atk4\Ui\Button::addTo($p, ['Hide'])->on('click', $modal->hide());
});
- \atk4\ui\Button::addTo($app, ['Show'])->on('click', $modal->show());
+ \Atk4\Ui\Button::addTo($app, ['Show'])->on('click', $modal->show());
Modal will render as a HTML `
` block but will be hidden. Alternatively you can use Modal without loadable content::
- $modal = \atk4\ui\Modal::addTo($app, ['Modal Title']);
- \atk4\ui\LoremIpsum::addTo($modal);
- \atk4\ui\Button::addTo($modal, ['Hide'])->on('click', $modal->hide());
+ $modal = \Atk4\Ui\Modal::addTo($app, ['Modal Title']);
+ \Atk4\Ui\LoremIpsum::addTo($modal);
+ \Atk4\Ui\Button::addTo($modal, ['Hide'])->on('click', $modal->hide());
- \atk4\ui\Button::addTo($app, ['Show'])->on('click', $modal->show());
+ \Atk4\Ui\Button::addTo($app, ['Show'])->on('click', $modal->show());
The second way is more convenient for creating static content, such as Terms of Service.
@@ -450,11 +450,11 @@ when the need to open a dialog box is not known in advance. This class is not
a component, but rather an Action so you **must not** add it to the Render Tree.
To accomplish that, use a :ref:`virtualpage`::
- $vp = \atk4\ui\VirtualPage::addTo($app);
- \atk4\ui\LoremIpsum::addTo($vp, ['size' => 2]);
+ $vp = \Atk4\Ui\VirtualPage::addTo($app);
+ \Atk4\Ui\LoremIpsum::addTo($vp, ['size' => 2]);
- \atk4\ui\Button::addTo($app, ['Dynamic Modal'])
- ->on('click', new \atk4\ui\JsModal('My Popup Title', $vp->getUrl('cut')));
+ \Atk4\Ui\Button::addTo($app, ['Dynamic Modal'])
+ ->on('click', new \Atk4\Ui\JsModal('My Popup Title', $vp->getUrl('cut')));
Note that this element is always destroyed as opposed to :php:class:`Modal`,
where it is only hidden.
@@ -471,19 +471,19 @@ JsNotify
Dynamic notifier used to display operation status::
- \atk4\ui\Button::addTo($app, ['Test'])->on(
+ \Atk4\Ui\Button::addTo($app, ['Test'])->on(
'click',
- (new \atk4\ui\JsNotify('Not yet implemented'))->setColor('red')
+ (new \Atk4\Ui\JsNotify('Not yet implemented'))->setColor('red')
);
A typical use case would be to provide visual feedback of an action after used performs operation inside
a Modal window with a Form. When user submits a form, its Submit handler will close modal in order to leave
some feedback to the user. JsNotify can display a bar on top of the screen for some time::
- $modal = \atk4\ui\Modal::addTo($app, ['Modal Title']);
+ $modal = \Atk4\Ui\Modal::addTo($app, ['Modal Title']);
$modal->set(function ($p) use ($modal) {
- $form = \atk4\ui\Form::addTo($p);
+ $form = \Atk4\Ui\Form::addTo($p);
$form->addControl('name', null, ['caption'=>'Add your name']);
$form->onSubmit(function ($form) use ($modal) {
@@ -492,13 +492,13 @@ some feedback to the user. JsNotify can display a bar on top of the screen for s
} else {
return [
$modal->hide(),
- new \atk4\ui\JsNotify('Thank you '.$form->model->get('name'))
+ new \Atk4\Ui\JsNotify('Thank you '.$form->model->get('name'))
];
}
});
});
- \atk4\ui\Button::addTo($app, ['Open Modal'])->on('click', $modal->show());
+ \Atk4\Ui\Button::addTo($app, ['Open Modal'])->on('click', $modal->show());
.. php:method:: setIcon(color)
.. php:method:: setTransition(openTransition, closeTransition)
@@ -530,14 +530,14 @@ other view::
$m_book = new Book($db);
- $form = \atk4\ui\Form::addTo($app);
- $table = \atk4\ui\Table::addTo($app);
+ $form = \Atk4\Ui\Form::addTo($app);
+ $table = \Atk4\Ui\Table::addTo($app);
$form->setModel($m_book);
$form->onSubmit(function($form) use($table) {
$form->model->save();
- return new \atk4\ui\JsReload($table);
+ return new \Atk4\Ui\JsReload($table);
});
$t->setModel($m_book);
@@ -566,15 +566,15 @@ The following will **not** work::
$model = new myModel;
// JsModal requires its contents to be put into a Virtual Page
- $vp = \atk4\ui\VirtualPage::addTo($app);
- $form = \atk4\ui\Form::addTo($vp);
+ $vp = \Atk4\Ui\VirtualPage::addTo($app);
+ $form = \Atk4\Ui\Form::addTo($vp);
$form->setModel(clone $model);
- $table = \atk4\ui\Table::addTo($app);
+ $table = \Atk4\Ui\Table::addTo($app);
$table->setModel(clone $model));
- $button = \atk4\ui\Button::addTo($app, ['Add Item', 'icon'=>'plus']);
- $button->on('click', new \atk4\ui\JsModal('JSModal Title', $vp));
+ $button = \Atk4\Ui\Button::addTo($app, ['Add Item', 'icon'=>'plus']);
+ $button->on('click', new \Atk4\Ui\JsModal('JSModal Title', $vp));
$form->onSubmit(function($form) use($table) {
$form->model->save();
@@ -590,15 +590,15 @@ Table needs to be first! The following works::
$model = new myModel;
// This needs to be first
- $table = \atk4\ui\Table::addTo($app);
+ $table = \Atk4\Ui\Table::addTo($app);
$table->setModel(clone $model));
- $vp = \atk4\ui\VirtualPage::addTo($app);
- $form = \atk4\ui\Form::addTo($vp);
+ $vp = \Atk4\Ui\VirtualPage::addTo($app);
+ $form = \Atk4\Ui\Form::addTo($vp);
$form->setModel(clone $model);
- $button = \atk4\ui\Button::addTo($app, ['Add Item', 'icon'=>'plus']);
- $button->on('click', new \atk4\ui\JsModal('JSModal Title', $vp));
+ $button = \Atk4\Ui\Button::addTo($app, ['Add Item', 'icon'=>'plus']);
+ $button->on('click', new \Atk4\Ui\JsModal('JSModal Title', $vp));
$form->onSubmit(function($form) use($table) {
$form->model->save();
@@ -613,12 +613,12 @@ While rendering, if a reload is caught, the rendering process stops and only ren
Since VirtualPage is special, when asked to be rendered and it gets triggered, rendering stops and only the
VirtualPage content is rendered. To force yourself to put things in order you can write the above like this::
- $table = \atk4\ui\Table::addTo($app);
+ $table = \Atk4\Ui\Table::addTo($app);
$table->setModel($model);
- $vp = \atk4\ui\VirtualPage::addTo($app);
+ $vp = \Atk4\Ui\VirtualPage::addTo($app);
$vp->set(function($p) use ($table, $model) {
- $form = \atk4\ui\Form::addTo($p);
+ $form = \Atk4\Ui\Form::addTo($p);
$form->setModel(clone $model);
$form->onSubmit(function($form) use($table) {
$form->model->save();
@@ -629,8 +629,8 @@ VirtualPage content is rendered. To force yourself to put things in order you ca
});
});
- $button = \atk4\ui\Button::addTo($app, ['Add Item', 'icon'=>'plus']);
- $button->on('click', new \atk4\ui\JsModal('JSModal Title', $vp));
+ $button = \Atk4\Ui\Button::addTo($app, ['Add Item', 'icon'=>'plus']);
+ $button->on('click', new \Atk4\Ui\JsModal('JSModal Title', $vp));
Note that in no case you will be able to render the button *above* the table (because the button needs a
reference to `$vp` which references `$table` for reload), so `$button` must be last.
@@ -647,7 +647,7 @@ average of 5-10 seconds, so you'd like to user updated about the process. There
The most basic approach is::
- $button = \atk4\ui\Button::addTo($app, ['Process Image']);
+ $button = \Atk4\Ui\Button::addTo($app, ['Process Image']);
$button->on('click', function() use($button, $image) {
sleep(1); // $image->resize();
@@ -673,9 +673,9 @@ Server Sent Event (JsSse)
This class implements ability for your PHP code to send messages to the browser during process execution::
- $button = \atk4\ui\Button::addTo($app, ['Process Image']);
+ $button = \Atk4\Ui\Button::addTo($app, ['Process Image']);
- $sse = \atk4\ui\JsSse::addTo($app);
+ $sse = \Atk4\Ui\JsSse::addTo($app);
$button->on('click', $sse->set(function() use($sse, $button, $image) {
diff --git a/docs/label.rst b/docs/label.rst
index 2405d8b144..487b7cef01 100644
--- a/docs/label.rst
+++ b/docs/label.rst
@@ -6,7 +6,7 @@
Label
=====
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Label
@@ -27,7 +27,7 @@ appear on the label::
// or
- $label = new \atk4\ui\Label('hello world');
+ $label = new \Atk4\Ui\Label('hello world');
$app->add($label);
@@ -55,7 +55,7 @@ There are two properties (icon, iconRight) but you can set only one at a time::
You can also specify icon as an object::
- Label::addTo($app, ['new', 'iconRight'=>new \atk4\ui\Icon('delete')]);
+ Label::addTo($app, ['new', 'iconRight'=>new \Atk4\Ui\Icon('delete')]);
For more information, see: :php:class:`Icon`
@@ -122,7 +122,7 @@ Added labels into Table
You can even use label inside a table, but because table renders itself by repeating periodically, then
the following code is needed::
- $table->onHook(\atk4\ui\Table\Column::HOOK_GET_HTML_TAGS, function ($table, Model $row) {
+ $table->onHook(\Atk4\Ui\Table\Column::HOOK_GET_HTML_TAGS, function ($table, Model $row) {
if ($row->getId() == 1) {
return [
'name'=> $table->getApp()->getTag('div', ['class'=>'ui ribbon label'], $row->get('name')),
diff --git a/docs/lister.rst b/docs/lister.rst
index d41562e6db..6aacdfddf6 100644
--- a/docs/lister.rst
+++ b/docs/lister.rst
@@ -5,7 +5,7 @@
Lister
======
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Lister
@@ -96,7 +96,7 @@ Tweaking the output
Output is formatted using the standard :ref:`ui_persistence` routine, but you can also fine-tune the content
of your tags like this::
- $lister->onHook(\atk4\ui\Lister::HOOK_BEFORE_ROW, function(\atk4\ui\Lister $lister){
+ $lister->onHook(\Atk4\Ui\Lister::HOOK_BEFORE_ROW, function(\Atk4\Ui\Lister $lister){
$lister->current_row->set('iso', mb_strtolower($lister->current_row->get('iso')));
})
diff --git a/docs/loremipsum.rst b/docs/loremipsum.rst
index 61ab4f9bbf..a4d0e592f5 100644
--- a/docs/loremipsum.rst
+++ b/docs/loremipsum.rst
@@ -5,7 +5,7 @@
LoremIpsum
==========
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: LoremIpsum
diff --git a/docs/menu.rst b/docs/menu.rst
index 736d417f65..4d8b47e6a0 100644
--- a/docs/menu.rst
+++ b/docs/menu.rst
@@ -5,7 +5,7 @@
Menu
====
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Menu
Menu implements horizontal or vertical multi-level menu by using Fomantic UI's 'menu'.
diff --git a/docs/message.rst b/docs/message.rst
index 4ece4c2dc7..45b4362e22 100644
--- a/docs/message.rst
+++ b/docs/message.rst
@@ -5,7 +5,7 @@
Message
=======
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Message
@@ -18,12 +18,12 @@ Basic Usage
Implements basic image::
- $message = new \atk4\ui\Message('Message Title');
+ $message = new \Atk4\Ui\Message('Message Title');
$app->add($message);
Although typically you would want to specify what type of message is that::
- $message = new \atk4\ui\Message(['Warning Message Title', 'warning']);
+ $message = new \Atk4\Ui\Message(['Warning Message Title', 'warning']);
$app->add($message);
Here is the alternative syntax::
diff --git a/docs/misc.rst b/docs/misc.rst
index d40a6132df..1a68ddab46 100644
--- a/docs/misc.rst
+++ b/docs/misc.rst
@@ -1,6 +1,6 @@
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
Columns
diff --git a/docs/multiline.rst b/docs/multiline.rst
index 103085265d..b287589d95 100644
--- a/docs/multiline.rst
+++ b/docs/multiline.rst
@@ -1,5 +1,5 @@
-.. php:namespace:: atk4\ui\Form\Control
+.. php:namespace:: Atk4\Ui\Form\Control
.. php:class:: Multiline
@@ -16,7 +16,7 @@ This means that the addresses are not stored into a separate database table but
/**
* User model
*/
- class User extends \atk4\data\Model
+ class User extends \Atk4\Data\Model
{
public $table = 'user';
@@ -35,7 +35,7 @@ This means that the addresses are not stored into a separate database table but
/**
* Address Model
*/
- class Address extends \atk4\data\Model
+ class Address extends \Atk4\Data\Model
{
public $table = 'addresses';
@@ -51,14 +51,14 @@ This means that the addresses are not stored into a separate database table but
}
// Create some sample record of user Model
- $user = new User(new \atk4\data\Persistence\Array_());
+ $user = new User(new \Atk4\Data\Persistence\Array_());
$user->set('firstname', 'Hans');
$user->set('lastname', 'Test');
$user->save();
// Add a Form to the UI and set User as Model
- $user_form = \atk4\ui\Form::addTo($app);
+ $user_form = \Atk4\Ui\Form::addTo($app);
$user_form->setModel($user);
This leads to a Multiline component automatically rendered for adding, editing and deleting Addresses of the user:
@@ -81,7 +81,7 @@ but you want to store them in a separate table. Uncomment the line `//$this->has
/**
* Email Model
*/
- class Email extends \atk4\data\Model
+ class Email extends \Atk4\Data\Model
{
public $table = 'email';
@@ -99,16 +99,16 @@ Now when we use a Form for User records, it won't automatically add a Multiline
If you want to edit them along with the user, Multiline is set up in a few lines::
// Create some sample record of user Model
- $user = new User(new \atk4\data\Persistence\Array_());
+ $user = new User(new \Atk4\Data\Persistence\Array_());
$user->setId(1);
$user->set('firstname', 'Hans');
$user->set('lastname', 'Test');
$user->save();
// Add a form to UI to edit User record
- $user_form = \atk4\ui\Form::addTo($app);
+ $user_form = \Atk4\Ui\Form::addTo($app);
$user_form->setModel($user);
- $ml = $user_form->addField('email_addresses', [\atk4\ui\Form\Control\Multiline::class]);
+ $ml = $user_form->addField('email_addresses', [\Atk4\Ui\Form\Control\Multiline::class]);
$ml->setModel($user->ref('Email'));
// set up saving of Email on Form submit
@@ -130,7 +130,7 @@ Multiline and Expressions
If a Model has Expressions, they automatically get updated when a form control value is changed. A loading icon on the ``+`` sign indicates that the expression values are updated.
Lets use the example of demos/multiline.php::
- class InventoryItem extends \atk4\data\Model
+ class InventoryItem extends \Atk4\Data\Model
{
protected function init(): void
{
@@ -200,10 +200,10 @@ Footer
------
You can add a footer to Multiline form control by adding a sublayout to it. In this example, we add a footer containing a read-only input which could get the value from ``onLineChange`` callback (see above)::
- $ml = $form->addControl('ml', [\atk4\ui\FormField\Multiline::class, 'options' => ['color' => 'blue']]);
+ $ml = $form->addControl('ml', [\Atk4\Ui\FormField\Multiline::class, 'options' => ['color' => 'blue']]);
$ml->setModel($inventory);
// Add sublayout with total form control.
- $sub_layout = $form->layout->addSublayout([\atk4\ui\Form\Layout\Section\Columns::class]);
+ $sub_layout = $form->layout->addSublayout([\Atk4\Ui\Form\Layout\Section\Columns::class]);
$sub_layout->addColumn(12);
$c = $sub_layout->addColumn(4);
$f_total = $c->addControl('total', ['readonly' => true])->set($total);
diff --git a/docs/overview.rst b/docs/overview.rst
index 00c09ce777..ae2e4593f8 100644
--- a/docs/overview.rst
+++ b/docs/overview.rst
@@ -99,7 +99,7 @@ clarifications::
require_once __DIR__ . '/vendor/autoload.php';
// Define your data structure
- class Offer extends \atk4\data\Model {
+ class Offer extends \Atk4\Data\Model {
public $table = 'offer';
@@ -116,12 +116,12 @@ clarifications::
}
// Create Application object and initialize Admin Layout
- $app = new \atk4\ui\App('Offer tracking system');
- $app->initLayout([\atk4\ui\Layout\Admin::class]);
+ $app = new \Atk4\Ui\App('Offer tracking system');
+ $app->initLayout([\Atk4\Ui\Layout\Admin::class]);
// Connect to database and place a fully-interactive Crud
- $db = new \atk4\data\Persistence_SQL($dsn);
- \atk4\ui\Crud::addTo($app)
+ $db = new \Atk4\Data\Persistence_SQL($dsn);
+ \Atk4\Ui\Crud::addTo($app)
->setModel(new Offer($db));
Through the course of this example, We are performing several core actions:
@@ -204,9 +204,9 @@ That means that components may rely on each other and even though some may appea
very basic to you, they are relied on by some other components for maximum
flexibility. The next example adds a "Cancel" button to a form::
- $button = \atk4\ui\Button::addTo($form, [
+ $button = \Atk4\Ui\Button::addTo($form, [
'Cancel',
- 'icon'=>new \atk4\ui\Icon('pencil')
+ 'icon'=>new \Atk4\Ui\Icon('pencil')
])->link('dashboard.php');
:php:class:`Button` and :php:class:`Icon` are some of the most basic components in
@@ -220,7 +220,7 @@ Using Components
Look above at the :ref:`overview_example`, component `GRID` was made part
of application layout with a line::
- \atk4\ui\Crud::addTo($app);
+ \Atk4\Ui\Crud::addTo($app);
To render a component individually and get the HTML and JavaScript use this format::
@@ -252,11 +252,11 @@ Factory is a mechanism which allow you to use shorter syntax for creating object
The goal of Agile UI is to be simple to read and use; so taking advantage of loose types
in PHP language allows us to use an alternative shorter syntax::
- \atk4\ui\Button::addTo($form, ['Cancel', 'icon'=>'pencil'])
+ \Atk4\Ui\Button::addTo($form, ['Cancel', 'icon'=>'pencil'])
->link('dashboard.php');
By default, class names specified as the first array elements passed to the add() method are
-resolved to namespace `atk4\\ui`; however the application class can fine-tune the
+resolved to namespace `Atk4\\Ui`; however the application class can fine-tune the
search.
Using a factory is optional. For more information see:
diff --git a/docs/paginator.rst b/docs/paginator.rst
index c8c6fe698a..b1a5f5face 100644
--- a/docs/paginator.rst
+++ b/docs/paginator.rst
@@ -5,7 +5,7 @@
Paginator
=========
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Paginator
Paginator displays a horizontal UI menu providing links to pages when all of the content does not fit
diff --git a/docs/popup.rst b/docs/popup.rst
index 776bb7469a..cc48a535ce 100644
--- a/docs/popup.rst
+++ b/docs/popup.rst
@@ -5,7 +5,7 @@
Popup
=====
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Popup
diff --git a/docs/progressbar.rst b/docs/progressbar.rst
index 02cf99d0b9..11a3110776 100644
--- a/docs/progressbar.rst
+++ b/docs/progressbar.rst
@@ -1,5 +1,5 @@
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: ProgressBar
diff --git a/docs/quickstart.rst b/docs/quickstart.rst
index 5857df0d27..96f2ec113f 100644
--- a/docs/quickstart.rst
+++ b/docs/quickstart.rst
@@ -37,10 +37,10 @@ Open a new file `index.php` and enter the following code::
initLayout([\atk4\ui\Layout\Centered::class]); // 4
+ $app = new \Atk4\Ui\App('My First App'); // 3
+ $app->initLayout([\Atk4\Ui\Layout\Centered::class]); // 4
- \atk4\ui\HelloWorld::addTo($app); // 5
+ \Atk4\Ui\HelloWorld::addTo($app); // 5
.. rubric:: Clarifications
@@ -75,12 +75,12 @@ writing clearer code.
By using namespaces you will make out of this::
initLayout([\atk4\ui\Layout\Centered::class]);
+ $app = new \Atk4\Ui\App('ToDo List');
+ $app->initLayout([\Atk4\Ui\Layout\Centered::class]);
All components of Agile Data are database-agnostic and will not concern themselves with the way how you store data.
I will start the session and connect `persistence `_
@@ -113,14 +113,14 @@ with it::
db class::
pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));
- use atk4\data\Persistence;
- use atk4\ui\App;
+ use Atk4\Data\Persistence;
+ use Atk4\Ui\App;
$db = Persistence::connect("mysql://localhost:3306/database_name", "user", "password");
$app = new App([
@@ -193,10 +193,10 @@ Form and Crud Components
Next we need to add Components that are capable of manipulating the data::
- $col = \atk4\ui\Columns::addTo($app, ['divided']); // 10
- $col_reload = new \atk4\ui\JsReload($col); // 11
+ $col = \Atk4\Ui\Columns::addTo($app, ['divided']); // 10
+ $col_reload = new \Atk4\Ui\JsReload($col); // 11
- $form = \atk4\ui\Form::addTo($col->addColumn()); // 12
+ $form = \Atk4\Ui\Form::addTo($col->addColumn()); // 12
$form->setModel(new ToDoItem($s)); // 13
$form->onSubmit(function($form) use($col_reload) { // 14
$form->model->save(); // 15
@@ -204,12 +204,12 @@ Next we need to add Components that are capable of manipulating the data::
return $col_reload; // 16
});
- \atk4\ui\Table::addTo($col->addColumn()) // 17
+ \Atk4\Ui\Table::addTo($col->addColumn()) // 17
->setModel(new ToDoItem($s));
.. rubric:: Clarifications
-.. [#] We wish to position Form and Table side-by-side, so we use `\atk4\ui\Columns` component and
+.. [#] We wish to position Form and Table side-by-side, so we use `\Atk4\Ui\Columns` component and
inject a Fomantic UI CSS class "divided" that will appear as a vertical separation line.
.. [#] $col_reload is a special object which we call :ref:`js_action`. It represents a Browser-event
@@ -241,13 +241,13 @@ Grid and Crud
As mentioned before, UI Components in Agile Toolkit are often interchangeable, you can swap one for
another. In our example replace right column (label 17) with the following code::
- $grid = \atk4\ui\Crud::addTo($col->addColumn(), ['paginator'=>false, // 18
+ $grid = \Atk4\Ui\Crud::addTo($col->addColumn(), ['paginator'=>false, // 18
'canCreate'=>false, 'canDelete'=>false // 19
]);
$grid->setModel(new ToDoItem($s));
$grid->menu->addItem('Complete Selected', // 20
- new \atk4\ui\JsReload($grid->table, [ // 21
+ new \Atk4\Ui\JsReload($grid->table, [ // 21
'delete'=>$grid->addSelection()->jsChecked() // 22
])
);
diff --git a/docs/render.rst b/docs/render.rst
index f6cea014a2..cf92672478 100644
--- a/docs/render.rst
+++ b/docs/render.rst
@@ -5,9 +5,9 @@ Introduction
Agile UI allows you to create and combine various objects into a single Render Tree for unified rendering. Tree represents
all the UI components that will contribute to the HTML generation. Render tree is automatically created and maintained::
- $view = new \atk4\ui\View();
+ $view = new \Atk4\Ui\View();
- \atk4\ui\Button::addTo($view, ['test']);
+ \Atk4\Ui\Button::addTo($view, ['test']);
echo $view->render();
@@ -52,14 +52,14 @@ Late initialization
When you create an application and select a Layout, the layout is automatically initialized::
- $app = new \atk4\ui\App();
- $app->initLayout([\atk4\ui\Layout\Centered::class]);
+ $app = new \Atk4\Ui\App();
+ $app->initLayout([\Atk4\Ui\Layout\Centered::class]);
echo $app->layout->name; // present, because layout is initialized!
After that, adding any objects into app (into layout) will initialize those objects too::
- $b = \atk4\ui\Button::addTo($app, ['Test1']);
+ $b = \Atk4\Ui\Button::addTo($app, ['Test1']);
echo $b->name; // present, because button was added into initialized object.
@@ -67,7 +67,7 @@ If object cannot determine the path to the application, then it will remain unin
"Late initialization"::
$v = new Buttons();
- $b2 = \atk4\ui\Button::addTo($v, ['Test2']);
+ $b2 = \Atk4\Ui\Button::addTo($v, ['Test2']);
echo $b2->name; // not set!! Not part of render tree
@@ -113,7 +113,7 @@ Unique Name
Through adding objects into render tree (even if those are not Views) objects can assume unique names. When you create
your application, then any object you add into your app will have a unique `name` property::
- $b = \atk4\ui\Button::addTo($app);
+ $b = \Atk4\Ui\Button::addTo($app);
echo $b->name;
The other property of the name is that it's also "permanent". Refreshing the page guarantees your object to have the same
@@ -124,10 +124,10 @@ name. Ultimately, you can create a View that uses it's name to store some inform
parent::init();
if ($_GET[$this->name]) {
- \atk4\ui\Label::addTo($this, ['Secret info is', 'big red', 'detail'=>$_GET[$this->name]]);
+ \Atk4\Ui\Label::addTo($this, ['Secret info is', 'big red', 'detail'=>$_GET[$this->name]]);
}
- \atk4\ui\Button::addTo($this, ['Send info to ourselves'])
+ \Atk4\Ui\Button::addTo($this, ['Send info to ourselves'])
->link([$this->name => 'secret_info']);
}
}
diff --git a/docs/rightpanel.rst b/docs/rightpanel.rst
index 738586ed07..a2461052f3 100644
--- a/docs/rightpanel.rst
+++ b/docs/rightpanel.rst
@@ -5,7 +5,7 @@
Right Panel
===========
-.. php:namespace:: atk4\ui\Panel
+.. php:namespace:: Atk4\Ui\Panel
.. php:class:: Right
@@ -19,7 +19,7 @@ Basic Usage
Adding a right panel to the app layout and adding content to it::
- $panel = $app->layout->addRightPanel(new \atk4\ui\Panel\Right(['dynamic' => false]));
+ $panel = $app->layout->addRightPanel(new \Atk4\Ui\Panel\Right(['dynamic' => false]));
Message::addTo($panel, ['This panel contains only static content.']);
By default, panel content are loaded dynamically. If you want to only add static content, you need to specify
@@ -40,7 +40,7 @@ Loading dynamic content within panel is done via the onOpen method
Initializing a panel with onOpen callback::
- $panel_1 = $app->layout->addRightPanel(new \atk4\ui\Panel\Right());
+ $panel_1 = $app->layout->addRightPanel(new \Atk4\Ui\Panel\Right());
Message::addTo($panel_1, ['This panel will load content dynamically below according to button select on the right.']);
$btn = Button::addTo($app, ['Button 1']);
$btn->js(true)->data('btn', '1');
diff --git a/docs/seed.rst b/docs/seed.rst
index 71f499edc4..7a3290e1e8 100644
--- a/docs/seed.rst
+++ b/docs/seed.rst
@@ -2,7 +2,7 @@
Purpose of the Seed
===================
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
Agile UI relies on wide variety of objects. For example :php:class:`Button` relies on
:php:class:`Icon` object for its rendering. As a developer can create Icon object first,
@@ -42,7 +42,7 @@ In most cases you don't need to call factory yourself, methods which accept obje
will do it for you::
Button::addTo($app);
- // app will create instance of class \atk4\ui\Button
+ // app will create instance of class \Atk4\Ui\Button
Seed, Object and Render Tree
----------------------------
@@ -61,7 +61,7 @@ The most important points of a seed such as this one::
are:
- - Element with index 0 is name of the class mapped into namespace \atk4\ui (by default).
+ - Element with index 0 is name of the class mapped into namespace \Atk4\Ui (by default).
- Elements with numeric indexes 'hello' and 'big red' are passed to constructor of Button
- Elements with named arguments are assigned to properties after invocation of constructor
@@ -83,23 +83,23 @@ Additional cases
----------------
An individual object may add more ways to deal with seed. For example, when adding columns
-to your Table you can specify seed for the decorator: :php:class:`atk4\\ui\\\Table\\Column`::
+to your Table you can specify seed for the decorator: :php:class:`Atk4\\Ui\\\Table\\Column`::
- $table->addColumn('salary', [\atk4\ui\Table\Column\Money::class]);
+ $table->addColumn('salary', [\Atk4\Ui\Table\Column\Money::class]);
// or
- $table->addColumn('salary', [\atk4\ui\Table\Column\Money::class]);
+ $table->addColumn('salary', [\Atk4\Ui\Table\Column\Money::class]);
// or
- $table->addColumn('salary', new \atk4\ui\Table\Column\Money());
+ $table->addColumn('salary', new \Atk4\Ui\Table\Column\Money());
// or
- $table->addColumn('salary', [new \atk4\ui\Table\Column\Money()]);
+ $table->addColumn('salary', [new \Atk4\Ui\Table\Column\Money()]);
-Note that addColumn uses default namespace of `\\atk4\\ui\\Table\\Column` when seeding objects. Some
+Note that addColumn uses default namespace of `\\Atk4\\Ui\\Table\\Column` when seeding objects. Some
other methods that use seeds are:
- :php:meth:`Table::addColumn()`
diff --git a/docs/sticky.rst b/docs/sticky.rst
index 23e5614ae8..3ecb9c14cd 100644
--- a/docs/sticky.rst
+++ b/docs/sticky.rst
@@ -68,15 +68,15 @@ defined as sticky globally.
Consider this code::
- $b1 = \atk4\ui\Button::addTo($app);
+ $b1 = \Atk4\Ui\Button::addTo($app);
$b1->set($b1->url());
Loader::addTo($app)->set(function($page) {
- $b2 = \atk4\ui\Button::addTo($page);
+ $b2 = \Atk4\Ui\Button::addTo($page);
$b2->set($b2->url());
});
- $b3 = \atk4\ui\Button::addTo($app);
+ $b3 = \Atk4\Ui\Button::addTo($app);
$b3->set($b3->url());
This will display 3 buttons and each button will contain a URL which needs to be opened in order for
diff --git a/docs/table.rst b/docs/table.rst
index 9faaa22839..4e9d131229 100644
--- a/docs/table.rst
+++ b/docs/table.rst
@@ -5,7 +5,7 @@
Table
=====
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
.. php:class:: Table
@@ -55,7 +55,7 @@ You can also use Table with Array data source like this::
$table->setSource($my_array);
$table->addColumn('name');
- $table->addColumn('surname', [\atk4\ui\Table\Column\Link::class, 'url'=>'details.php?surname={$surname}']);
+ $table->addColumn('surname', [\Atk4\Ui\Table\Column\Link::class, 'url'=>'details.php?surname={$surname}']);
$table->addColumn('birthdate', null, ['type'=>'date']);
.. warning:: I encourage you to seek appropriate Agile Data persistence instead of
@@ -65,7 +65,7 @@ You can also use Table with Array data source like this::
Adding Columns
--------------
-.. php:method:: setModel(\atk4\data\Model $model, $fields = null)
+.. php:method:: setModel(\Atk4\Data\Model $model, $fields = null)
.. php:method:: addColumn($name, $columnDecorator = null, $field = null)
@@ -138,7 +138,7 @@ Advanced Column Denifitions
Table defines a method `columnFactory`, which returns Column object which is to be used to
display values of specific model Field.
-.. php:method:: columnFactory(\atk4\data\Field $field)
+.. php:method:: columnFactory(\Atk4\Data\Field $field)
If the value of the field can be displayed by :php:class:`Table\\Column` then :php:class:`Table` will
respord with object of this class. Since the default column does not contain any customization,
@@ -183,7 +183,7 @@ the "total" column value (as above) but using PHP math instead of doing it insid
$order = new Order($db);
$table->setModel($order, ['name', 'price', 'amount', 'status']);
- $table->addColumn('total', new \atk4\data\Field\Calculated(
+ $table->addColumn('total', new \Atk4\Data\Field\Calculated(
function(Model $row) {
return $row->get('price') * $row->get('amount');
}));
@@ -195,7 +195,7 @@ wish to position it before status, you can use the final format of addColumn()::
$order = new Order($db);
$table->setModel($order, ['name', 'price', 'amount']);
- $table->addColumn('total', new \atk4\data\Field\Calculated(
+ $table->addColumn('total', new \Atk4\Data\Field\Calculated(
function(Model $row) {
return $row->get('price') * $row->get('amount');
}));
@@ -212,7 +212,7 @@ your convenience there is a way to add multiple columns efficiently.
As a final note in this section - you can re-use column objects multiple times::
- $c_gap = new \atk4\ui\Table\Column\Template('
...
');
+ $c_gap = new \Atk4\Ui\Table\Column\Template('
...
');
$table->addColumn($c_gap);
$table->setModel(new Order($db), ['name', 'price', 'amount']);
@@ -260,13 +260,13 @@ Injecting HTML
The tag will override model value. Here is example usage of :php:meth:`Table\\Column::getHtmlTags`::
- class ExpiredColumn extends \atk4\ui\Table\Column
+ class ExpiredColumn extends \Atk4\Ui\Table\Column
public function getDataCellHtml()
{
return '{$_expired}';
}
- function getHtmlTags(\atk4\data\Model $row)
+ function getHtmlTags(\Atk4\Data\Model $row)
{
return ['_expired'=>
$row->get('date') < new \DateTime() ?
@@ -291,15 +291,15 @@ examples will show you how to display list of "files" inside your Dropbox folder
of issues from your Github repository::
// Show contents of dropbox
- $dropbox = \atk4\dropbox\Persistence($db_config);
- $files = new \atk4\dropbox\Model\File($dropbox);
+ $dropbox = \Atk4\Dropbox\Persistence($db_config);
+ $files = new \Atk4\Dropbox\Model\File($dropbox);
Table::addTo($app)->setModel($files);
// Show contents of dropbox
- $github = \atk4\github\Persistence_Issues($github_api_config);
- $issues = new \atk4\github\Model\Issue($github);
+ $github = \Atk4\Github\Persistence_Issues($github_api_config);
+ $issues = new \Atk4\Github\Model\Issue($github);
Table::addTo($app)->setModel($issues);
@@ -359,8 +359,8 @@ nicer especially inside a table.
One column may have several decorators::
- $table->addColumn('salary', new \atk4\ui\Table\Column\Money());
- $table->addDecorator('salary', new \atk4\ui\Table\Column\Link(['page2']));
+ $table->addColumn('salary', new \Atk4\Ui\Table\Column\Money());
+ $table->addDecorator('salary', new \Atk4\Ui\Table\Column\Link(['page2']));
In this case the first decorator will take care of tr/td tags but second decorator will compliment
it. Result is that table will output 'salary' as a currency (align and red ink) and also decorate
@@ -376,7 +376,7 @@ There are a few things to note:
2. formatting is always applied in same order as defined - in example above Money first, Link after.
-3. output of the \atk4\ui\\Table\\Column\Money decorator is used into Link decorator as if it would be value of cell, however
+3. output of the \Atk4\Ui\\Table\\Column\Money decorator is used into Link decorator as if it would be value of cell, however
decorators have access to original value also. Decorator implementation is usually aware of combinations.
:php:meth:`Table\\Column\\\Money::getDataCellTemplate` is called, which returns ONLY the HTML value,
@@ -496,25 +496,25 @@ Static Attributes and classes
The following code will make sure that contents of the column appear on a single line by
adding class "single line" to all body cells::
- $table->addColumn('name', (new \atk4\ui\Table\Column()->addClass('single line')));
+ $table->addColumn('name', (new \Atk4\Ui\Table\Column()->addClass('single line')));
If you wish to add a class to 'head' or 'foot' or 'all' cells, you can pass 2nd argument to addClass::
- $table->addColumn('name', (new \atk4\ui\Table\Column()->addClass('right aligned', 'all')));
+ $table->addColumn('name', (new \Atk4\Ui\Table\Column()->addClass('right aligned', 'all')));
There are several ways to make your code more readable::
- $table->addColumn('name', new \atk4\ui\Table\Column())
+ $table->addColumn('name', new \Atk4\Ui\Table\Column())
->addClass('right aligned', 'all');
Or if you wish to use factory, the syntax is::
- $table->addColumn('name', [\atk4\ui\Table\Column::class])
+ $table->addColumn('name', [\Atk4\Ui\Table\Column::class])
->addClass('right aligned', 'all');
For setting an attribute you can use setAttr() method::
- $table->addColumn('name', [\atk4\ui\Table\Column::class])
+ $table->addColumn('name', [\Atk4\Ui\Table\Column::class])
->setAttr('colspan', 2, 'all');
Setting a new value to the attribute will override previous value.
diff --git a/docs/tablecolumn.rst b/docs/tablecolumn.rst
index dfdbb06912..f4b3e0662e 100644
--- a/docs/tablecolumn.rst
+++ b/docs/tablecolumn.rst
@@ -1,7 +1,7 @@
.. _tablecolumn:
-.. php:namespace:: atk4\ui
+.. php:namespace:: Atk4\Ui
=======================
Table Column Decorators
@@ -33,9 +33,9 @@ Generic Column Decorator
.. php:class:: Table\\Column
- Generic description of a column for :php:class:`atk4\\ui\\Table`
+ Generic description of a column for :php:class:`Atk4\\Ui\\Table`
-Table object relies on a separate class: `\\atk4\\ui\\Table\\Column` to present most of the values. The goals
+Table object relies on a separate class: `\\Atk4\\Ui\\Table\\Column` to present most of the values. The goals
of the column object is to format anything around the actual values. The type = 'money' will result in
a custom formatting of the value, but will also require column to be right-aligned. To simplify this,
type = 'money' will use a different column class - :php:class:`Table\\Column\\Money`. There are several others,
@@ -44,17 +44,17 @@ but first we need to look at the generic column and understand it's base capabil
A class resposnible for cell formatting. This class defines 3 main methods that is used by the Table
when constructing HTML:
-.. php:method:: getHeaderCellHtml(\atk4\data\Field $field)
+.. php:method:: getHeaderCellHtml(\Atk4\Data\Field $field)
Must respond with HTML for the header cell (`