diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index 45b26b1f7b..5022d5b867 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -78,7 +78,7 @@ jobs: - name: Check Coding Style (only for CodingStyle) if: matrix.type == 'CodingStyle' run: | - if [ "$(find demos/ -name '*.php' -print0 | xargs -0 grep -L "namespace atk4\\\\ui\\\\demo;" | tee /dev/fd/2)" ]; then echo 'All demos/ files must have namespace declared' && (exit 1); fi + if [ "$(find demos/ -name '*.php' -print0 | xargs -0 grep -L "namespace Atk4\\\\Ui\\\\Demos;" | tee /dev/fd/2)" ]; then echo 'All demos/ files must have namespace declared' && (exit 1); fi vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --diff --diff-format=udiff --verbose --show-progress=dots - name: Run Static Analysis (only for StaticAnalysis) diff --git a/README.md b/README.md index 87ce5b8446..6a2b0eabc5 100644 --- a/README.md +++ b/README.md @@ -56,10 +56,10 @@ Create "index.php" file with: initLayout([\atk4\ui\Layout\Centered::class]); +$app = new \Atk4\Ui\App(); // That's your UI application +$app->initLayout([\Atk4\Ui\Layout\Centered::class]); -$form = \atk4\ui\Form::addTo($app); // Yeah, that's a form! +$form = \Atk4\Ui\Form::addTo($app); // Yeah, that's a form! $form->addField('email'); // adds field $form->onSubmit(function ($form) { @@ -88,11 +88,11 @@ To get most of ATK UI, use [ATK Data](https://github.com/atk4/data) to describe [Crud](https://ui.agiletoolkit.org/demos/crud.php) is a fully-interractive component that supports pagination, reloading, conditions, data formatting, sorting, quick-search, ordering, custom actions and modals, but at the same time is very easy to use: ``` php -$app = new \atk4\ui\App('hello world'); -$app->initLayout([\atk4\ui\Layout\Admin::class]); -$app->db = \atk4\data\Persistence::connect('mysql://user:pass@localhost/atk'); +$app = new \Atk4\Ui\App('hello world'); +$app->initLayout([\Atk4\Ui\Layout\Admin::class]); +$app->db = \Atk4\Data\Persistence::connect('mysql://user:pass@localhost/atk'); -\atk4\ui\Crud::addTo($app)->setModel(new User($app->db)); +\Atk4\Ui\Crud::addTo($app)->setModel(new User($app->db)); ``` ATK Data allows you to set up relations between models: @@ -112,7 +112,7 @@ class User extends Model { Conventional Crud works only with a single model, but with add-on you can take advantage this relationship information: https://github.com/atk4/mastercrud ``` php -use \atk4\mastercrud\MasterCrud; +use \Atk4\Mastercrud\MasterCrud; // set up $app here @@ -149,13 +149,13 @@ Agile UI has some unique features: One of the fundamental features of ATK is Callback - ability to dynamically generate a route then have JS part of the component invoke it. Thanks to this approach, code can be fluid, simple and readable: ``` php -$tabs = \atk4\ui\Tabs::addTo($app); -\atk4\ui\Message::addTo($tabs->addTab('Intro'), ['Other tabs are loaded dynamically!']); +$tabs = \Atk4\Ui\Tabs::addTo($app); +\Atk4\Ui\Message::addTo($tabs->addTab('Intro'), ['Other tabs are loaded dynamically!']); $tabs->addTab('Users', function($p) use($app) { // This tab is loaded dynamically, but also contains dynamic component - \atk4\ui\Crud::addTo($p)->setModel(new User($app->db)); + \Atk4\Ui\Crud::addTo($p)->setModel(new User($app->db)); }); $tabs->addTab('Settings', function($p) use($app) { @@ -163,7 +163,7 @@ $tabs->addTab('Settings', function($p) use($app) { // Second tab contains an AJAX form that stores itself back to DB. $m = new Settings($app->db); $m->load(2); - \atk4\ui\Form::addTo($p)->setModel($m); + \Atk4\Ui\Form::addTo($p)->setModel($m); }); ``` @@ -190,11 +190,11 @@ It's really easy to put together a complex Admin system. Add this code to a new ``` php initLayout([\atk4\ui\Layout\Admin::class]); -$app->db = \atk4\data\Persistence::connect('mysql://user:pass@localhost/yourdb'); +$app = new \Atk4\Ui\App('My App'); +$app->initLayout([\Atk4\Ui\Layout\Admin::class]); +$app->db = \Atk4\Data\Persistence::connect('mysql://user:pass@localhost/yourdb'); -class User extends \atk4\data\Model { +class User extends \Atk4\Data\Model { public $table = 'user'; function init(): void { parent::init(); @@ -205,7 +205,7 @@ class User extends \atk4\data\Model { } } -\atk4\ui\Crud::addTo($app)->setModel(new User($app->db)); +\Atk4\Ui\Crud::addTo($app)->setModel(new User($app->db)); ``` The result is here: diff --git a/behat.yml.dist b/behat.yml.dist index f50f52fbfb..c3e243efb3 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -4,7 +4,7 @@ default: paths: features: '%paths.base%/tests-behat' contexts: - - atk4\ui\behat\Context + - Atk4\Ui\Behat\Context - Behat\MinkExtension\Context\MinkContext extensions: Behat\MinkExtension: diff --git a/composer.json b/composer.json index ae2a4ab9f8..9cac1f4f5c 100644 --- a/composer.json +++ b/composer.json @@ -85,13 +85,13 @@ }, "autoload": { "psr-4": { - "atk4\\ui\\": "src/" + "Atk4\\Ui\\": "src/" } }, "autoload-dev": { "psr-4": { - "atk4\\ui\\tests\\": "tests/", - "atk4\\ui\\behat\\": "tests-behat/bootstrap/" + "Atk4\\Ui\\Tests\\": "tests/", + "Atk4\\Ui\\Behat\\": "tests-behat/bootstrap/" } } } diff --git a/demos/_demo-data/create-sqlite-db.php b/demos/_demo-data/create-sqlite-db.php index 5ea1e00eb1..f72d80886f 100644 --- a/demos/_demo-data/create-sqlite-db.php +++ b/demos/_demo-data/create-sqlite-db.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\data\Model; +use Atk4\Data\Model; require_once __DIR__ . '/../init-autoloader.php'; @@ -13,13 +13,13 @@ unlink($sqliteFile); } -$persistence = new \atk4\data\Persistence\Sql('sqlite:' . $sqliteFile); +$persistence = new \Atk4\Data\Persistence\Sql('sqlite:' . $sqliteFile); $model = new Model($persistence, 'client'); $model->addField('name', ['type' => 'string']); $model->addField('addresses', ['type' => 'text']); $model->addField('accounts', ['type' => 'text']); -(new \atk4\schema\Migration($model))->dropIfExists()->create(); +(new \Atk4\Schema\Migration($model))->dropIfExists()->create(); $model->import([ ['id' => 1, 'name' => 'John', 'addresses' => null, 'accounts' => null], ['id' => 2, 'name' => 'Jane', 'addresses' => null, 'accounts' => null], @@ -32,7 +32,7 @@ $model->addField('iso3', ['type' => 'string']); // should be CHAR(3) NOT NULL $model->addField('numcode', ['type' => 'smallint']); $model->addField('phonecode', ['type' => 'integer']); -(new \atk4\schema\Migration($model))->dropIfExists()->create(); +(new \Atk4\Schema\Migration($model))->dropIfExists()->create(); $model->import([ ['id' => 1, 'iso' => 'AF', 'name' => 'AFGHANISTAN', 'nicename' => 'Afghanistan', 'iso3' => 'AFG', 'numcode' => 4, 'phonecode' => 93], ['id' => 2, 'iso' => 'AL', 'name' => 'ALBANIA', 'nicename' => 'Albania', 'iso3' => 'ALB', 'numcode' => 8, 'phonecode' => 355], @@ -294,7 +294,7 @@ $model->addField('is_folder', ['type' => 'boolean']); $model->addField('parent_folder_id', ['type' => 'bigint']); // KEY `fk_file_file_idx` (`parent_folder_id`) -(new \atk4\schema\Migration($model))->dropIfExists()->create(); +(new \Atk4\Schema\Migration($model))->dropIfExists()->create(); $model->import([ ['id' => 1, 'name' => 'phpunit.xml', 'type' => 'xml', 'is_folder' => 0, 'parent_folder_id' => null], ['id' => 2, 'name' => 'LICENSE', 'type' => '', 'is_folder' => 0, 'parent_folder_id' => null], @@ -384,7 +384,7 @@ $model->addField('finish_time', ['type' => 'time']); $model->addField('created', ['type' => 'datetime']); $model->addField('updated', ['type' => 'datetime']); -(new \atk4\schema\Migration($model))->dropIfExists()->create(); +(new \Atk4\Schema\Migration($model))->dropIfExists()->create(); $model->import([ ['id' => 1, 'project_name' => 'Agile DSQL', 'project_code' => 'at01', 'description' => 'DSQL is a composable SQL query builder. You can write multi-vendor queries in PHP profiting from better security, clean syntax and avoid human errors.', 'client_name' => 'Agile Toolkit', 'client_address' => 'Some Street,\nGarden City\nUK', 'client_country_iso' => 'GB', 'is_commercial' => 0, 'currency' => 'GBP', 'is_completed' => 1, 'project_budget' => 7000, 'project_invoiced' => 0, 'project_paid' => 0, 'project_hour_cost' => 0, 'project_hours_est' => 150, 'project_hours_reported' => 125, 'project_expenses_est' => 50, 'project_expenses' => 0, 'project_mgmt_cost_pct' => 0.1, 'project_qa_cost_pct' => 0.2, 'start_date' => '2016-01-26', 'finish_date' => '2016-06-23', 'finish_time' => '12:50:00', 'created' => '2017-04-06 10:34:34', 'updated' => '2017-04-06 10:35:04'], ['id' => 2, 'project_name' => 'Agile Core', 'project_code' => 'at02', 'description' => 'Collection of PHP Traits for designing object-oriented frameworks.', 'client_name' => 'Agile Toolkit', 'client_address' => 'Some Street,\nGarden City\nUK', 'client_country_iso' => 'GB', 'is_commercial' => 0, 'currency' => 'GBP', 'is_completed' => 1, 'project_budget' => 3000, 'project_invoiced' => 0, 'project_paid' => 0, 'project_hour_cost' => 0, 'project_hours_est' => 70, 'project_hours_reported' => 56, 'project_expenses_est' => 50, 'project_expenses' => 0, 'project_mgmt_cost_pct' => 0.1, 'project_qa_cost_pct' => 0.2, 'start_date' => '2016-04-27', 'finish_date' => '2016-05-21', 'finish_time' => '18:41:00', 'created' => '2017-04-06 10:21:50', 'updated' => '2017-04-06 10:35:04'], @@ -394,7 +394,7 @@ $model = new Model($persistence, 'product_category'); $model->addField('name', ['type' => 'string']); -(new \atk4\schema\Migration($model))->dropIfExists()->create(); +(new \Atk4\Schema\Migration($model))->dropIfExists()->create(); $model->import([ ['id' => 1, 'name' => 'Condiments and Gravies'], ['id' => 2, 'name' => 'Beverages'], @@ -404,7 +404,7 @@ $model = new Model($persistence, 'product_sub_category'); $model->addField('name', ['type' => 'string']); $model->addField('product_category_id', ['type' => 'bigint']); -(new \atk4\schema\Migration($model))->dropIfExists()->create(); +(new \Atk4\Schema\Migration($model))->dropIfExists()->create(); $model->import([ ['id' => 1, 'name' => 'Gravie', 'product_category_id' => 1], ['id' => 2, 'name' => 'Spread', 'product_category_id' => 1], @@ -422,7 +422,7 @@ $model->addField('brand', ['type' => 'string']); $model->addField('product_category_id', ['type' => 'bigint']); $model->addField('product_sub_category_id', ['type' => 'bigint']); -(new \atk4\schema\Migration($model))->dropIfExists()->create(); +(new \Atk4\Schema\Migration($model))->dropIfExists()->create(); $model->import([ ['id' => 1, 'name' => 'Mustard', 'brand' => 'Condiment Corp.', 'product_category_id' => 1, 'product_sub_category_id' => 2], ['id' => 2, 'name' => 'Ketchup', 'brand' => 'Condiment Corp.', 'product_category_id' => 1, 'product_sub_category_id' => 2], diff --git a/demos/_includes/Counter.php b/demos/_includes/Counter.php index 9024dd8e44..1ad886b8b7 100644 --- a/demos/_includes/Counter.php +++ b/demos/_includes/Counter.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; /** * Counter for certain demos file. */ -class Counter extends \atk4\ui\Form\Control\Line +class Counter extends \Atk4\Ui\Form\Control\Line { public $content = 20; // default @@ -15,10 +15,10 @@ protected function init(): void { parent::init(); - $this->actionLeft = new \atk4\ui\Button(['icon' => 'minus']); - $this->action = new \atk4\ui\Button(['icon' => 'plus']); + $this->actionLeft = new \Atk4\Ui\Button(['icon' => 'minus']); + $this->action = new \Atk4\Ui\Button(['icon' => 'plus']); - $this->actionLeft->js('click', $this->jsInput()->val(new \atk4\ui\JsExpression('parseInt([])-1', [$this->jsInput()->val()]))); - $this->action->js('click', $this->jsInput()->val(new \atk4\ui\JsExpression('parseInt([])+1', [$this->jsInput()->val()]))); + $this->actionLeft->js('click', $this->jsInput()->val(new \Atk4\Ui\JsExpression('parseInt([])-1', [$this->jsInput()->val()]))); + $this->action->js('click', $this->jsInput()->val(new \Atk4\Ui\JsExpression('parseInt([])+1', [$this->jsInput()->val()]))); } } diff --git a/demos/_includes/Demo.php b/demos/_includes/Demo.php index 991b2b5c10..f0e48c430e 100644 --- a/demos/_includes/Demo.php +++ b/demos/_includes/Demo.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -class Demo extends \atk4\ui\Columns +class Demo extends \Atk4\Ui\Columns { public $left; public $right; @@ -26,7 +26,7 @@ protected function extractCodeFromClosure(\Closure $fx): string { $funcRefl = new \ReflectionFunction($fx); if ($funcRefl->getEndLine() === $funcRefl->getStartLine()) { - throw new \atk4\ui\Exception('Closure body to extract must be on separate lines'); + throw new \Atk4\Ui\Exception('Closure body to extract must be on separate lines'); } $codeArr = array_slice( @@ -49,7 +49,7 @@ public function setCodeAndCall(\Closure $fx, $lang = 'php') $code = $this->extractCodeFromClosure($fx); $this->highLightCode(); - \atk4\ui\View::addTo(\atk4\ui\View::addTo($this->left, ['element' => 'pre']), ['element' => 'code'])->addClass($lang)->set($code); + \Atk4\Ui\View::addTo(\Atk4\Ui\View::addTo($this->left, ['element' => 'pre']), ['element' => 'code'])->addClass($lang)->set($code); $fx($this->right); } @@ -59,7 +59,7 @@ public function highLightCode() if (!self::$isInitialized) { $this->getApp()->requireCss('https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.16.2/styles/' . $this->highlightDefaultStyle . '.min.css'); $this->getApp()->requireJs('https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.16.2/highlight.min.js'); - $this->js(true, (new \atk4\ui\JsChain('hljs'))->initHighlighting()); + $this->js(true, (new \Atk4\Ui\JsChain('hljs'))->initHighlighting()); self::$isInitialized = true; } } diff --git a/demos/_includes/DemoActionsUtil.php b/demos/_includes/DemoActionsUtil.php index 43d975b08c..ce1c6ba065 100644 --- a/demos/_includes/DemoActionsUtil.php +++ b/demos/_includes/DemoActionsUtil.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; class DemoActionsUtil { @@ -101,7 +101,7 @@ public static function setupDemoActions(CountryLock $country): void return 'Be careful with this action.'; }, 'callback' => function () { - throw new \atk4\ui\Exception('Told you, didn\'t I?'); + throw new \Atk4\Ui\Exception('Told you, didn\'t I?'); }, ] ); @@ -111,7 +111,7 @@ public static function setupDemoActions(CountryLock $country): void [ 'caption' => 'User Confirmation', 'description' => 'Confirm the action using a ConfirmationExecutor', - 'ui' => ['executor' => [\atk4\ui\UserAction\ConfirmationExecutor::class]], + 'ui' => ['executor' => [\Atk4\Ui\UserAction\ConfirmationExecutor::class]], 'confirmation' => function ($a) { return 'Are you sure you want to perform this action on: ' . $a->getModel()->getTitle() . ' (' . $a->getModel()->get('iso3') . ')'; }, diff --git a/demos/_includes/DemoInvoice.php b/demos/_includes/DemoInvoice.php index ab08288840..d1e40ba6bd 100644 --- a/demos/_includes/DemoInvoice.php +++ b/demos/_includes/DemoInvoice.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; /** * Invoice class for tutorial intro. */ -class DemoInvoice extends \atk4\data\Model +class DemoInvoice extends \Atk4\Data\Model { public $dateFormat; diff --git a/demos/_includes/DemoLookup.php b/demos/_includes/DemoLookup.php index b5232b8829..aedb1657cc 100644 --- a/demos/_includes/DemoLookup.php +++ b/demos/_includes/DemoLookup.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\core\Factory; +use Atk4\Core\Factory; /** * Setup file - do not test. * Lookup that can not saved data. */ -class DemoLookup extends \atk4\ui\Form\Control\Lookup +class DemoLookup extends \Atk4\Ui\Form\Control\Lookup { /** * Add button for new record. @@ -29,34 +29,34 @@ protected function initQuickNewRecord() $buttonSeed = is_string($buttonSeed) ? ['content' => $buttonSeed] : $buttonSeed; - $defaultSeed = [\atk4\ui\Button::class, 'disabled' => ($this->disabled || $this->readonly)]; + $defaultSeed = [\Atk4\Ui\Button::class, 'disabled' => ($this->disabled || $this->readonly)]; $this->action = Factory::factory(array_merge($defaultSeed, (array) $buttonSeed)); if ($this->form) { - $vp = \atk4\ui\VirtualPage::addTo($this->form); + $vp = \Atk4\Ui\VirtualPage::addTo($this->form); } else { - $vp = \atk4\ui\VirtualPage::addTo($this->getOwner()); + $vp = \Atk4\Ui\VirtualPage::addTo($this->getOwner()); } $vp->set(function ($page) { - $form = \atk4\ui\Form::addTo($page); + $form = \Atk4\Ui\Form::addTo($page); $model = clone $this->model; $form->setModel($model->onlyFields($this->plus['fields'] ?? [])); - $form->onSubmit(function (\atk4\ui\Form $form) { + $form->onSubmit(function (\Atk4\Ui\Form $form) { // Prevent from saving // $form->model->save(); $ret = [ - new \atk4\ui\JsToast('Form submit!. Demo can not saved data.'), - (new \atk4\ui\Jquery('.atk-modal'))->modal('hide'), + new \Atk4\Ui\JsToast('Form submit!. Demo can not saved data.'), + (new \Atk4\Ui\Jquery('.atk-modal'))->modal('hide'), ]; if ($row = $this->renderRow($form->model)) { - $chain = new \atk4\ui\Jquery('#' . $this->name . '-ac'); + $chain = new \Atk4\Ui\Jquery('#' . $this->name . '-ac'); $chain->dropdown('set value', $row['value'])->dropdown('set text', $row['title']); $ret[] = $chain; @@ -68,6 +68,6 @@ protected function initQuickNewRecord() $caption = $this->plus['caption'] ?? 'Add New ' . $this->model->getModelCaption(); - $this->action->js('click', new \atk4\ui\JsModal($caption, $vp)); + $this->action->js('click', new \Atk4\Ui\JsModal($caption, $vp)); } } diff --git a/demos/_includes/Flyers.php b/demos/_includes/Flyers.php index bf558b1e34..da946e6c50 100644 --- a/demos/_includes/Flyers.php +++ b/demos/_includes/Flyers.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -class Flyers extends \atk4\data\Model +class Flyers extends \Atk4\Data\Model { protected function init(): void { diff --git a/demos/_includes/FlyersForm.php b/demos/_includes/FlyersForm.php index 7152b148f4..511139d85b 100644 --- a/demos/_includes/FlyersForm.php +++ b/demos/_includes/FlyersForm.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; +use Atk4\Ui\Form; class FlyersForm extends Form { @@ -35,7 +35,7 @@ protected function init(): void $this->addControl('country', [ Form\Control\Lookup::class, - 'model' => new \atk4\ui\demo\Country($this->getApp()->db), + 'model' => new \Atk4\Ui\Demos\Country($this->getApp()->db), 'dependency' => function ($model, $data) { isset($data['contains']) ? $model->addCondition('name', 'like', '%' . $data['contains'] . '%') : null; }, @@ -45,13 +45,13 @@ protected function init(): void ], ['required' => true]); $ml = $this->addControl('multi', [Form\Control\Multiline::class, 'rowLimit' => 4, 'addOnTab' => true, 'caption' => 'Additional passengers:', 'renderLabel' => false]); - $ml->setModel(new Flyers(new \atk4\data\Persistence\Array_($this->flyers))); + $ml->setModel(new Flyers(new \Atk4\Data\Persistence\Array_($this->flyers))); $cards = $this->addControl('cards', [Form\Control\TreeItemSelector::class, 'treeItems' => $this->cards, 'caption' => 'Flyers program:'], ['type' => 'array', 'serialize' => 'json']); $cards->set($this->getApp()->encodeJson([])); $this->onSubmit(function ($form) { - return new \atk4\ui\JsToast('Thank you!'); + return new \Atk4\Ui\JsToast('Thank you!'); }); } } diff --git a/demos/_includes/Persistence_Faker.php b/demos/_includes/Persistence_Faker.php index b77e3a9a39..5ae88d66bd 100644 --- a/demos/_includes/Persistence_Faker.php +++ b/demos/_includes/Persistence_Faker.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -class Persistence_Faker extends \atk4\data\Persistence +class Persistence_Faker extends \Atk4\Data\Persistence { /** @var \Faker\Generator */ public $faker; diff --git a/demos/_includes/PromotionText.php b/demos/_includes/PromotionText.php index d1b718a661..8a8f3ec788 100644 --- a/demos/_includes/PromotionText.php +++ b/demos/_includes/PromotionText.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -class PromotionText extends \atk4\ui\View +class PromotionText extends \Atk4\Ui\View { protected function init(): void { parent::init(); - $t = \atk4\ui\Text::addTo($this); + $t = \Atk4\Ui\Text::addTo($this); $t->addParagraph( <<< 'EOF' Agile Toolkit base package includes: @@ -28,19 +28,19 @@ protected function init(): void HTML ); - $gl = \atk4\ui\GridLayout::addTo($this, [null, 'stackable divided', 'columns' => 4]); - \atk4\ui\Button::addTo($gl, ['Explore UI components', 'primary basic fluid', 'iconRight' => 'right arrow'], ['r1c1']) + $gl = \Atk4\Ui\GridLayout::addTo($this, [null, 'stackable divided', 'columns' => 4]); + \Atk4\Ui\Button::addTo($gl, ['Explore UI components', 'primary basic fluid', 'iconRight' => 'right arrow'], ['r1c1']) ->link('https://github.com/atk4/ui/#bundled-and-planned-components'); - \atk4\ui\Button::addTo($gl, ['Try out interactive features', 'primary basic fluid', 'iconRight' => 'right arrow'], ['r1c2']) + \Atk4\Ui\Button::addTo($gl, ['Try out interactive features', 'primary basic fluid', 'iconRight' => 'right arrow'], ['r1c2']) ->link(['interactive/tabs']); - \atk4\ui\Button::addTo($gl, ['Dive into Agile Data', 'primary basic fluid', 'iconRight' => 'right arrow'], ['r1c3']) + \Atk4\Ui\Button::addTo($gl, ['Dive into Agile Data', 'primary basic fluid', 'iconRight' => 'right arrow'], ['r1c3']) ->link('https://git.io/ad'); - \atk4\ui\Button::addTo($gl, ['More ATK Add-ons', 'primary basic fluid', 'iconRight' => 'right arrow'], ['r1c4']) + \Atk4\Ui\Button::addTo($gl, ['More ATK Add-ons', 'primary basic fluid', 'iconRight' => 'right arrow'], ['r1c4']) ->link('https://github.com/atk4/ui/#add-ons-and-integrations'); - \atk4\ui\View::addTo($this, ['ui' => 'divider']); + \Atk4\Ui\View::addTo($this, ['ui' => 'divider']); - \atk4\ui\Message::addTo($this, ['Cool fact!', 'info', 'icon' => 'book'])->text + \Atk4\Ui\Message::addTo($this, ['Cool fact!', 'info', 'icon' => 'book'])->text ->addParagraph('This entire demo is coded in Agile Toolkit and takes up less than 300 lines of very simple code!'); } } diff --git a/demos/_includes/Session.php b/demos/_includes/Session.php index 421f00ce64..8fa9ad2605 100644 --- a/demos/_includes/Session.php +++ b/demos/_includes/Session.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\core\NameTrait; -use atk4\core\SessionTrait; +use Atk4\Core\NameTrait; +use Atk4\Core\SessionTrait; class Session { diff --git a/demos/_includes/SomeData.php b/demos/_includes/SomeData.php index ac49604f62..c941fd61ce 100644 --- a/demos/_includes/SomeData.php +++ b/demos/_includes/SomeData.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -class SomeData extends \atk4\data\Model +class SomeData extends \Atk4\Data\Model { public function __construct() { diff --git a/demos/_includes/ViewTester.php b/demos/_includes/ViewTester.php index 515ff1b62c..dccec89b9b 100644 --- a/demos/_includes/ViewTester.php +++ b/demos/_includes/ViewTester.php @@ -2,27 +2,27 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; /** * This view is designed to verify various things about it's positioning, e.g. * can its callbacks reach itself and potentially more. */ -class ViewTester extends \atk4\ui\View +class ViewTester extends \Atk4\Ui\View { protected function init(): void { parent::init(); - $label = \atk4\ui\Label::addTo($this, ['CallBack', 'detail' => 'fail', 'red']); - $reload = new \atk4\ui\JsReload($this, [$this->name => 'ok']); + $label = \Atk4\Ui\Label::addTo($this, ['CallBack', 'detail' => 'fail', 'red']); + $reload = new \Atk4\Ui\JsReload($this, [$this->name => 'ok']); if (isset($_GET[$this->name])) { $label->class[] = 'green'; $label->detail = 'success'; } else { $this->js(true, $reload); - $this->js(true, new \atk4\ui\JsExpression('var s = Date.now(); var i=setInterval(function() { var p = Date.now()-s; var el=$[]; el.find(".detail").text(p+"ms"); if(el.is(".green")) { clearInterval(i); }}, 100)', [$label])); + $this->js(true, new \Atk4\Ui\JsExpression('var s = Date.now(); var i=setInterval(function() { var p = Date.now()-s; var el=$[]; el.find(".detail").text(p+"ms"); if(el.is(".green")) { clearInterval(i); }}, 100)', [$label])); } } } diff --git a/demos/_unit-test/calendar-input.php b/demos/_unit-test/calendar-input.php index bc5c03366e..c175ca0558 100644 --- a/demos/_unit-test/calendar-input.php +++ b/demos/_unit-test/calendar-input.php @@ -2,23 +2,23 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; -use atk4\ui\View; +use Atk4\Ui\Form; +use Atk4\Ui\View; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $output = function (string $date) { - $view = new \atk4\ui\Message(); + $view = new \Atk4\Ui\Message(); $view->invokeInit(); $view->text->addHTML($date); return $view; }; -\atk4\ui\Header::addTo($app, ['Testing flatpickr using Behat']); +\Atk4\Ui\Header::addTo($app, ['Testing flatpickr using Behat']); $form = Form::addTo($app); $c = $form->addControl('field', null, ['type' => 'date']); $form->buttonSave->set($c->short_name); diff --git a/demos/_unit-test/callback.php b/demos/_unit-test/callback.php index 7169d73db3..bf4b0acb97 100644 --- a/demos/_unit-test/callback.php +++ b/demos/_unit-test/callback.php @@ -6,30 +6,30 @@ * Test for triggerOnReload = false for Callback. */ -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Button; -use atk4\ui\Form; -use atk4\ui\Jquery; -use atk4\ui\JsToast; +use Atk4\Ui\Button; +use Atk4\Ui\Form; +use Atk4\Ui\Jquery; +use Atk4\Ui\JsToast; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $m = (new CountryLock($app->db))->setLimit(5); -$vp = $app->add(new \atk4\ui\VirtualPage()); +$vp = $app->add(new \Atk4\Ui\VirtualPage()); $vp->cb->triggerOnReload = false; $form = Form::addTo($vp); $form->setModel((clone $m)->tryLoadAny(), ['name']); $form->getControl('name')->caption = 'TestName'; -$table = $app->add(new \atk4\ui\Table()); +$table = $app->add(new \Atk4\Ui\Table()); $table->setModel($m); $button = Button::addTo($app, ['First', ['ui' => 'atk-test']]); -$button->on('click', new \atk4\ui\JsModal('Edit First Record', $vp)); +$button->on('click', new \Atk4\Ui\JsModal('Edit First Record', $vp)); $form->onSubmit(function ($form) use ($table) { $form->model->save(); diff --git a/demos/_unit-test/callback_2.php b/demos/_unit-test/callback_2.php index d72b533947..8a27a30868 100644 --- a/demos/_unit-test/callback_2.php +++ b/demos/_unit-test/callback_2.php @@ -6,14 +6,14 @@ * Test for callback in callback. */ -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Button; -use atk4\ui\Crud; -use atk4\ui\Header; -use atk4\ui\Loader; +use Atk4\Ui\Button; +use Atk4\Ui\Crud; +use Atk4\Ui\Header; +use Atk4\Ui\Loader; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $m = (new CountryLock($app->db))->setLimit(5); @@ -39,7 +39,7 @@ $c->setModel($m, ['name']); }); }); - \atk4\ui\Button::addTo($p, ['Load2'])->js('click', $loader_1->jsLoad()); + \Atk4\Ui\Button::addTo($p, ['Load2'])->js('click', $loader_1->jsLoad()); }); -\atk4\ui\Button::addTo($app, ['Load1'])->js('click', $loader->jsLoad()); +\Atk4\Ui\Button::addTo($app, ['Load1'])->js('click', $loader->jsLoad()); diff --git a/demos/_unit-test/console.php b/demos/_unit-test/console.php index 821da16504..cf2d55bc5e 100644 --- a/demos/_unit-test/console.php +++ b/demos/_unit-test/console.php @@ -2,22 +2,22 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\JsSse; +use Atk4\Ui\JsSse; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $sse = JsSse::addTo($app); $sse->setUrlTrigger('console_test'); -$console = \atk4\ui\Console::addTo($app, ['sse' => $sse]); +$console = \Atk4\Ui\Console::addTo($app, ['sse' => $sse]); $console->set(function ($console) { $console->output('Executing test process...'); $console->output('Now trying something dangerous..'); echo 'direct output is captured'; - throw new \atk4\core\Exception('BOOM - exceptions are caught'); + throw new \Atk4\Core\Exception('BOOM - exceptions are caught'); }); diff --git a/demos/_unit-test/console_exec.php b/demos/_unit-test/console_exec.php index 958c2ce806..84abb1be73 100644 --- a/demos/_unit-test/console_exec.php +++ b/demos/_unit-test/console_exec.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\JsSse; +use Atk4\Ui\JsSse; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $sse = JsSse::addTo($app); $sse->setUrlTrigger('console_test'); -$console = \atk4\ui\Console::addTo($app, ['sse' => $sse]); +$console = \Atk4\Ui\Console::addTo($app, ['sse' => $sse]); $console->exec('/bin/pwd'); diff --git a/demos/_unit-test/console_run.php b/demos/_unit-test/console_run.php index 685df938fc..c567dc581c 100644 --- a/demos/_unit-test/console_run.php +++ b/demos/_unit-test/console_run.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\JsSse; +use Atk4\Ui\JsSse; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; -/** @var \atk4\ui\View $testRunClass */ -$testRunClass = get_class(new class() extends \atk4\ui\View { - use \atk4\core\DebugTrait; +/** @var \Atk4\Ui\View $testRunClass */ +$testRunClass = get_class(new class() extends \Atk4\Ui\View { + use \Atk4\Core\DebugTrait; public function test() { @@ -32,5 +32,5 @@ public function test() $sse = JsSse::addTo($app); $sse->setUrlTrigger('console_test'); -$console = \atk4\ui\Console::addTo($app, ['sse' => $sse]); +$console = \Atk4\Ui\Console::addTo($app, ['sse' => $sse]); $console->runMethod($testRunClass::addTo($app), 'test'); diff --git a/demos/_unit-test/crud.php b/demos/_unit-test/crud.php index fae3a4502a..725a33e612 100644 --- a/demos/_unit-test/crud.php +++ b/demos/_unit-test/crud.php @@ -7,16 +7,16 @@ * see crud.feature. */ -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 CountryLock($app->db); $model->getUserAction('edit')->ui = []; $model->getUserAction('delete')->ui = []; -$crud = \atk4\ui\Crud::addTo($app, ['ipp' => 10, 'menu' => ['class' => ['atk-grid-menu']]]); +$crud = \Atk4\Ui\Crud::addTo($app, ['ipp' => 10, 'menu' => ['class' => ['atk-grid-menu']]]); $crud->setModel($model); $crud->addQuickSearch(['name'], true); diff --git a/demos/_unit-test/exception.php b/demos/_unit-test/exception.php index a29b822c60..db8d0aa035 100644 --- a/demos/_unit-test/exception.php +++ b/demos/_unit-test/exception.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\CallbackLater; +use Atk4\Ui\CallbackLater; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; // JUST TO TEST Exceptions and Error throws @@ -14,22 +14,22 @@ $cb = CallbackLater::addTo($app); $cb->setUrlTrigger('m_cb'); -$modal = \atk4\ui\Modal::addTo($app, ['cb' => $cb]); +$modal = \Atk4\Ui\Modal::addTo($app, ['cb' => $cb]); $modal->name = 'm_test'; $modal->set(function ($m) { throw new \Exception('TEST!'); }); -$button = \atk4\ui\Button::addTo($app, ['Test modal exception']); +$button = \Atk4\Ui\Button::addTo($app, ['Test modal exception']); $button->on('click', $modal->show()); $cb1 = CallbackLater::addTo($app, ['urlTrigger' => 'm2_cb']); -$modal2 = \atk4\ui\Modal::addTo($app, ['cb' => $cb1]); +$modal2 = \Atk4\Ui\Modal::addTo($app, ['cb' => $cb1]); $modal2->set(function ($m) { trigger_error('error triggered'); }); -$button2 = \atk4\ui\Button::addTo($app, ['Test modal error']); +$button2 = \Atk4\Ui\Button::addTo($app, ['Test modal error']); $button2->on('click', $modal2->show()); diff --git a/demos/_unit-test/lookup.php b/demos/_unit-test/lookup.php index 90673625d2..80da906aeb 100644 --- a/demos/_unit-test/lookup.php +++ b/demos/_unit-test/lookup.php @@ -2,20 +2,20 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Crud; +use Atk4\Ui\Crud; // Test for hasOne Lookup as dropdown control. -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $model = new ProductLock($app->db); $model->addCondition('name', '=', 'Mustard'); $edit = $model->getUserAction('edit'); -$edit->ui = ['execButton' => [\atk4\ui\Button::class, 'EditMe', 'blue']]; +$edit->ui = ['execButton' => [\Atk4\Ui\Button::class, 'EditMe', 'blue']]; $edit->description = 'edit'; $edit->callback = function ($model) { return $model->ref('product_category_id')->getTitle() . ' - ' . $model->ref('product_sub_category_id')->getTitle(); diff --git a/demos/_unit-test/modal-reload.php b/demos/_unit-test/modal-reload.php index 61f32bd161..11c3cad781 100644 --- a/demos/_unit-test/modal-reload.php +++ b/demos/_unit-test/modal-reload.php @@ -2,23 +2,23 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Button; -use atk4\ui\Header; -use atk4\ui\Modal; +use Atk4\Ui\Button; +use Atk4\Ui\Header; +use Atk4\Ui\Modal; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; -class ReloadTest extends \atk4\ui\View +class ReloadTest extends \Atk4\Ui\View { protected function init(): void { parent::init(); - $label = \atk4\ui\Label::addTo($this, ['Testing...', 'detail' => '', 'red']); - $reload = new \atk4\ui\JsReload($this, [$this->name => 'ok']); + $label = \Atk4\Ui\Label::addTo($this, ['Testing...', 'detail' => '', 'red']); + $reload = new \Atk4\Ui\JsReload($this, [$this->name => 'ok']); if (isset($_GET[$this->name])) { $label->class[] = 'green'; diff --git a/demos/_unit-test/post.php b/demos/_unit-test/post.php index 1703c29488..8f89a68bba 100644 --- a/demos/_unit-test/post.php +++ b/demos/_unit-test/post.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; -use atk4\ui\JsToast; +use Atk4\Ui\Form; +use Atk4\Ui\JsToast; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $form = Form::addTo($app); diff --git a/demos/_unit-test/reload.php b/demos/_unit-test/reload.php index 83ffaf79f9..bcb30dbdc2 100644 --- a/demos/_unit-test/reload.php +++ b/demos/_unit-test/reload.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Button; -use atk4\ui\Callback; -use atk4\ui\JsReload; -use atk4\ui\View; +use Atk4\Ui\Button; +use Atk4\Ui\Callback; +use Atk4\Ui\JsReload; +use Atk4\Ui\View; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $v = View::addTo($app, ['ui' => 'segment']); @@ -22,6 +22,6 @@ $cb = Callback::addTo($app); $cb->setUrlTrigger('c_reload'); -\atk4\ui\Loader::addTo($app, ['cb' => $cb])->set(function ($page) { +\Atk4\Ui\Loader::addTo($app, ['cb' => $cb])->set(function ($page) { $v = View::addTo($page, ['ui' => 'segment'])->set('loaded'); }); diff --git a/demos/_unit-test/scope-builder-to-query.php b/demos/_unit-test/scope-builder-to-query.php index 1efcff8242..edf2cba3ed 100644 --- a/demos/_unit-test/scope-builder-to-query.php +++ b/demos/_unit-test/scope-builder-to-query.php @@ -6,12 +6,12 @@ * Test query output by ScopeBuilder into model scope definition. */ -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form\Control\ScopeBuilder; -use atk4\ui\Grid; +use Atk4\Ui\Form\Control\ScopeBuilder; +use Atk4\Ui\Grid; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $query = <<<'EOF' diff --git a/demos/_unit-test/scope-builder.php b/demos/_unit-test/scope-builder.php index 760b300072..385405f7f8 100644 --- a/demos/_unit-test/scope-builder.php +++ b/demos/_unit-test/scope-builder.php @@ -6,14 +6,14 @@ * Test Model condition rendering into ScopeBuilder component. */ -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\data\Model\Scope; -use atk4\data\Model\Scope\Condition; -use atk4\ui\Header; -use atk4\ui\View; +use Atk4\Data\Model\Scope; +use Atk4\Data\Model\Scope\Condition; +use Atk4\Ui\Header; +use Atk4\Ui\View; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $model = new Stat($app->db, ['caption' => 'Demo Stat']); @@ -33,13 +33,13 @@ $model->scope()->add($scope); $model->scope()->add($orScope); -$form = \atk4\ui\Form::addTo($app); +$form = \Atk4\Ui\Form::addTo($app); -$form->addControl('qb', [\atk4\ui\Form\Control\ScopeBuilder::class, 'model' => $model]); +$form->addControl('qb', [\Atk4\Ui\Form\Control\ScopeBuilder::class, 'model' => $model]); $form->onSubmit(function ($form) use ($model) { $message = $form->model->get('qb')->toWords($model); - $view = new \atk4\ui\Message(''); + $view = new \Atk4\Ui\Message(''); $view->invokeInit(); $view->text->addHTML($message); diff --git a/demos/_unit-test/sse.php b/demos/_unit-test/sse.php index 9688d7edba..299226940e 100644 --- a/demos/_unit-test/sse.php +++ b/demos/_unit-test/sse.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\JsExpression; -use atk4\ui\View; +use Atk4\Ui\JsExpression; +use Atk4\Ui\View; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $v = View::addTo($app)->set('This will trigger a network request for testing sse...'); -$sse = \atk4\ui\JsSse::addTo($app); +$sse = \Atk4\Ui\JsSse::addTo($app); // url trigger must match php_unit test in sse provider. $sse->setUrlTrigger('see_test'); diff --git a/demos/basic/breadcrumb.php b/demos/basic/breadcrumb.php index f6c16da46f..fd62974dab 100644 --- a/demos/basic/breadcrumb.php +++ b/demos/basic/breadcrumb.php @@ -2,19 +2,19 @@ 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'; /** * Demonstrates how to use Breadcrumb. */ -$crumb = \atk4\ui\Breadcrumb::addTo($app); +$crumb = \Atk4\Ui\Breadcrumb::addTo($app); $crumb->addCrumb('UI Demo', ['index']); $crumb->addCrumb('Breadcrumb Demo', ['breadcrumb']); -\atk4\ui\View::addTo($app, ['ui' => 'divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'divider']); $crumb->addCrumb('Countries', []); @@ -28,16 +28,16 @@ // here we can check for additional criteria and display a deeper level on the crumb - $form = \atk4\ui\Form::addTo($app); + $form = \Atk4\Ui\Form::addTo($app); $form->setModel($model); - $form->onSubmit(function (\atk4\ui\Form $form) { - return new \atk4\ui\JsToast('Form Submitted! Data saving is not possible in demo!'); + $form->onSubmit(function (\Atk4\Ui\Form $form) { + return new \Atk4\Ui\JsToast('Form Submitted! Data saving is not possible in demo!'); }); } else { // display list of countries - $table = \atk4\ui\Table::addTo($app); + $table = \Atk4\Ui\Table::addTo($app); $table->setModel($model); - $table->addDecorator('name', [\atk4\ui\Table\Column\Link::class, [], ['country_id' => 'id']]); + $table->addDecorator('name', [\Atk4\Ui\Table\Column\Link::class, [], ['country_id' => 'id']]); } $crumb->popTitle(); diff --git a/demos/basic/button.php b/demos/basic/button.php index 836adc7647..1cc9c62a5e 100644 --- a/demos/basic/button.php +++ b/demos/basic/button.php @@ -2,19 +2,19 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Button; -use atk4\ui\HtmlTemplate; -use atk4\ui\Icon; -use atk4\ui\Label; +use Atk4\Ui\Button; +use Atk4\Ui\HtmlTemplate; +use Atk4\Ui\Icon; +use Atk4\Ui\Label; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; // Demonstrates how to use buttons. -\atk4\ui\Header::addTo($app, ['Basic Button', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Basic Button', 'size' => 2]); // With Seed Button::addTo($app, ['Click me'])->link(['index']); @@ -25,33 +25,33 @@ // must be added first $b1->link(['index']); -\atk4\ui\Header::addTo($app, ['Properties', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Properties', 'size' => 2]); Button::addTo($app, ['Primary button', 'primary']); Button::addTo($app, ['Load', 'labeled', 'icon' => 'pause']); Button::addTo($app, ['Next', 'iconRight' => 'right arrow']); Button::addTo($app, [null, 'circular', 'icon' => 'settings']); -\atk4\ui\Header::addTo($app, ['Big Button', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Big Button', 'size' => 2]); Button::addTo($app, ['Click me', 'big primary', 'icon' => 'check']); -\atk4\ui\Header::addTo($app, ['Button Intent', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Button Intent', 'size' => 2]); Button::addTo($app, ['Yes', 'positive basic']); Button::addTo($app, ['No', 'negative basic']); -\atk4\ui\Header::addTo($app, ['Combining Buttons', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Combining Buttons', 'size' => 2]); -$bar = \atk4\ui\View::addTo($app, ['ui' => 'vertical buttons']); +$bar = \Atk4\Ui\View::addTo($app, ['ui' => 'vertical buttons']); Button::addTo($bar, ['Play', 'icon' => 'play']); Button::addTo($bar, ['Pause', 'icon' => 'pause']); Button::addTo($bar, ['Shuffle', 'icon' => 'shuffle']); -\atk4\ui\Header::addTo($app, ['Icon Bar', 'size' => 2]); -$bar = \atk4\ui\View::addTo($app, ['ui' => 'big blue buttons']); +\Atk4\Ui\Header::addTo($app, ['Icon Bar', 'size' => 2]); +$bar = \Atk4\Ui\View::addTo($app, ['ui' => 'big blue buttons']); Button::addTo($bar, ['icon' => 'file']); Button::addTo($bar, ['icon' => 'yellow save']); Button::addTo($bar, ['icon' => 'upload', 'disabled' => true]); -\atk4\ui\Header::addTo($app, ['Forks Button Component', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Forks Button Component', 'size' => 2]); // Creating your own button component example @@ -68,16 +68,16 @@ public function __construct($n) $forkButton = new $forkButtonClass(1234 + random_int(1, 100)); $app->add($forkButton); -\atk4\ui\Header::addTo($app, ['Custom Template', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Custom Template', 'size' => 2]); -$view = \atk4\ui\View::addTo($app, ['template' => new HtmlTemplate('Hello, {$tag1}, my name is {$tag2}')]); +$view = \Atk4\Ui\View::addTo($app, ['template' => new HtmlTemplate('Hello, {$tag1}, my name is {$tag2}')]); Button::addTo($view, ['World'], ['tag1']); Button::addTo($view, ['Agile UI', 'blue'], ['tag2']); -\atk4\ui\Header::addTo($app, ['Attaching', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Attaching', 'size' => 2]); Button::addTo($app, ['Previous', 'top attached']); -\atk4\ui\Table::addTo($app, ['attached', 'header' => false]) +\Atk4\Ui\Table::addTo($app, ['attached', 'header' => false]) ->setSource(['One', 'Two', 'Three', 'Four']); Button::addTo($app, ['Next', 'bottom attached']); diff --git a/demos/basic/columns.php b/demos/basic/columns.php index 14c2194244..848f9fa093 100644 --- a/demos/basic/columns.php +++ b/demos/basic/columns.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; /** * Testing Columns. */ -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; // some custom style needed for our "highlight" to work. You don't need this on @@ -23,19 +23,19 @@ } '); -$page = \atk4\ui\View::addTo($app, ['id' => 'example']); +$page = \Atk4\Ui\View::addTo($app, ['id' => 'example']); -\atk4\ui\Header::addTo($page, ['Basic Usage']); +\Atk4\Ui\Header::addTo($page, ['Basic Usage']); -$c = \atk4\ui\Columns::addTo($page); -\atk4\ui\LoremIpsum::addTo($c->addColumn(), [1]); -\atk4\ui\LoremIpsum::addTo($c->addColumn(), [1]); -\atk4\ui\LoremIpsum::addTo($c->addColumn(), [1]); +$c = \Atk4\Ui\Columns::addTo($page); +\Atk4\Ui\LoremIpsum::addTo($c->addColumn(), [1]); +\Atk4\Ui\LoremIpsum::addTo($c->addColumn(), [1]); +\Atk4\Ui\LoremIpsum::addTo($c->addColumn(), [1]); -\atk4\ui\Header::addTo($page, ['Specifying widths, using rows or automatic flow']); +\Atk4\Ui\Header::addTo($page, ['Specifying widths, using rows or automatic flow']); // highlight class will show cells as boxes, even though they contain nothing -$c = \atk4\ui\Columns::addTo($page, [null, 'highlight']); +$c = \Atk4\Ui\Columns::addTo($page, [null, 'highlight']); $c->addColumn(3); $c->addColumn(5); $c->addColumn(2); @@ -50,38 +50,38 @@ $r->addColumn(); $r->addColumn(); -\atk4\ui\Header::addTo($page, ['Content Outline']); -$c = \atk4\ui\Columns::addTo($page, ['internally celled']); +\Atk4\Ui\Header::addTo($page, ['Content Outline']); +$c = \Atk4\Ui\Columns::addTo($page, ['internally celled']); $r = $c->addRow(); -\atk4\ui\Icon::addTo($r->addColumn([2, 'right aligned']), ['huge home']); -\atk4\ui\LoremIpsum::addTo($r->addColumn(12), [1]); -\atk4\ui\Icon::addTo($r->addColumn(2), ['huge trash']); +\Atk4\Ui\Icon::addTo($r->addColumn([2, 'right aligned']), ['huge home']); +\Atk4\Ui\LoremIpsum::addTo($r->addColumn(12), [1]); +\Atk4\Ui\Icon::addTo($r->addColumn(2), ['huge trash']); $r = $c->addRow(); -\atk4\ui\Icon::addTo($r->addColumn([2, 'right aligned']), ['huge home']); -\atk4\ui\LoremIpsum::addTo($r->addColumn(12), [1]); -\atk4\ui\Icon::addTo($r->addColumn(2), ['huge trash']); +\Atk4\Ui\Icon::addTo($r->addColumn([2, 'right aligned']), ['huge home']); +\Atk4\Ui\LoremIpsum::addTo($r->addColumn(12), [1]); +\Atk4\Ui\Icon::addTo($r->addColumn(2), ['huge trash']); -\atk4\ui\Header::addTo($page, ['Add elements into columns and using classes']); +\Atk4\Ui\Header::addTo($page, ['Add elements into columns and using classes']); /** * Example box component with some content, good for putting into columns. */ -/** @var \atk4\ui\View $boxClass */ -$boxClass = get_class(new class() extends \atk4\ui\View { +/** @var \Atk4\Ui\View $boxClass */ +$boxClass = get_class(new class() extends \Atk4\Ui\View { public $ui = 'segment'; public $content = false; protected function init(): void { parent::init(); - \atk4\ui\Table::addTo($this, ['header' => false]) + \Atk4\Ui\Table::addTo($this, ['header' => false]) ->setSource(['One', 'Two', 'Three', 'Four']); } }); -$c = \atk4\ui\Columns::addTo($page, ['width' => 4]); +$c = \Atk4\Ui\Columns::addTo($page, ['width' => 4]); $boxClass::addTo($c->addColumn(), [null, 'red']); $boxClass::addTo($c->addColumn([null, null, 'right floated']), [null, 'blue']); diff --git a/demos/basic/grid-layout.php b/demos/basic/grid-layout.php index 4857eaf339..5c11ac980c 100644 --- a/demos/basic/grid-layout.php +++ b/demos/basic/grid-layout.php @@ -2,15 +2,15 @@ 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'; // create layout -$gridLayout = \atk4\ui\GridLayout::addTo($app, ['columns' => 4, 'rows' => 2]); +$gridLayout = \Atk4\Ui\GridLayout::addTo($app, ['columns' => 4, 'rows' => 2]); // add other views in layout spots -\atk4\ui\LoremIpsum::addTo($gridLayout, ['words' => 4], ['r1c1']); // row 1, col 1 -\atk4\ui\LoremIpsum::addTo($gridLayout, ['words' => 4], ['r1c4']); // row 1, col 4 -\atk4\ui\LoremIpsum::addTo($gridLayout, ['words' => 4], ['r2c2']); // row 2, col 2 +\Atk4\Ui\LoremIpsum::addTo($gridLayout, ['words' => 4], ['r1c1']); // row 1, col 1 +\Atk4\Ui\LoremIpsum::addTo($gridLayout, ['words' => 4], ['r1c4']); // row 1, col 4 +\Atk4\Ui\LoremIpsum::addTo($gridLayout, ['words' => 4], ['r2c2']); // row 2, col 2 diff --git a/demos/basic/header.php b/demos/basic/header.php index 59893ecc88..11dbdf529c 100644 --- a/demos/basic/header.php +++ b/demos/basic/header.php @@ -2,46 +2,46 @@ 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'; $img = 'https://raw.githubusercontent.com/atk4/ui/2.0.4/public/logo.png'; -$seg = \atk4\ui\View::addTo($app, ['ui' => 'segment']); -\atk4\ui\Header::addTo($seg, ['H1 Header', 'size' => 1]); -\atk4\ui\Header::addTo($seg, ['H2 Header', 'size' => 2]); -\atk4\ui\Header::addTo($seg, ['H3 Header', 'size' => 3]); -\atk4\ui\Header::addTo($seg, ['H4 Header', 'size' => 4]); -\atk4\ui\Header::addTo($seg, ['H5 Header', 'size' => 5, 'dividing']); -\atk4\ui\View::addTo($seg, ['element' => 'P'])->set('This is a following paragraph of text'); +$seg = \Atk4\Ui\View::addTo($app, ['ui' => 'segment']); +\Atk4\Ui\Header::addTo($seg, ['H1 Header', 'size' => 1]); +\Atk4\Ui\Header::addTo($seg, ['H2 Header', 'size' => 2]); +\Atk4\Ui\Header::addTo($seg, ['H3 Header', 'size' => 3]); +\Atk4\Ui\Header::addTo($seg, ['H4 Header', 'size' => 4]); +\Atk4\Ui\Header::addTo($seg, ['H5 Header', 'size' => 5, 'dividing']); +\Atk4\Ui\View::addTo($seg, ['element' => 'P'])->set('This is a following paragraph of text'); -\atk4\ui\Header::addTo($seg, ['H1', 'size' => 1, 'subHeader' => 'H1 subheader']); -\atk4\ui\Header::addTo($seg, ['H5', 'size' => 5, 'subHeader' => 'H5 subheader']); +\Atk4\Ui\Header::addTo($seg, ['H1', 'size' => 1, 'subHeader' => 'H1 subheader']); +\Atk4\Ui\Header::addTo($seg, ['H5', 'size' => 5, 'subHeader' => 'H5 subheader']); -$seg = \atk4\ui\View::addTo($app, ['ui' => 'segment']); -\atk4\ui\Header::addTo($seg, ['Huge Header', 'size' => 'huge']); -\atk4\ui\Header::addTo($seg, ['Large Header', 'size' => 'large']); -\atk4\ui\Header::addTo($seg, ['Medium Header', 'size' => 'medium']); -\atk4\ui\Header::addTo($seg, ['Small Header', 'size' => 'small']); -\atk4\ui\Header::addTo($seg, ['Tiny Header', 'size' => 'tiny']); +$seg = \Atk4\Ui\View::addTo($app, ['ui' => 'segment']); +\Atk4\Ui\Header::addTo($seg, ['Huge Header', 'size' => 'huge']); +\Atk4\Ui\Header::addTo($seg, ['Large Header', 'size' => 'large']); +\Atk4\Ui\Header::addTo($seg, ['Medium Header', 'size' => 'medium']); +\Atk4\Ui\Header::addTo($seg, ['Small Header', 'size' => 'small']); +\Atk4\Ui\Header::addTo($seg, ['Tiny Header', 'size' => 'tiny']); -\atk4\ui\Header::addTo($seg, ['Sub Header', 'sub']); +\Atk4\Ui\Header::addTo($seg, ['Sub Header', 'sub']); -$seg = \atk4\ui\View::addTo($app, ['ui' => 'segment']); -\atk4\ui\Header::addTo($seg, ['Header with icon', 'icon' => 'settings']); -\atk4\ui\Header::addTo($seg, ['Header with icon', 'icon' => 'settings', 'subHeader' => 'and with sub-header']); -\atk4\ui\Header::addTo($seg, ['Header with image', 'image' => $img, 'subHeader' => 'and with sub-header']); +$seg = \Atk4\Ui\View::addTo($app, ['ui' => 'segment']); +\Atk4\Ui\Header::addTo($seg, ['Header with icon', 'icon' => 'settings']); +\Atk4\Ui\Header::addTo($seg, ['Header with icon', 'icon' => 'settings', 'subHeader' => 'and with sub-header']); +\Atk4\Ui\Header::addTo($seg, ['Header with image', 'image' => $img, 'subHeader' => 'and with sub-header']); -$seg = \atk4\ui\View::addTo($app, ['ui' => 'segment']); -\atk4\ui\Header::addTo($seg, ['Center-aligned', 'aligned' => 'center', 'icon' => 'settings', 'subHeader' => 'header with icon']); +$seg = \Atk4\Ui\View::addTo($app, ['ui' => 'segment']); +\Atk4\Ui\Header::addTo($seg, ['Center-aligned', 'aligned' => 'center', 'icon' => 'settings', 'subHeader' => 'header with icon']); -$seg = \atk4\ui\View::addTo($app, ['ui' => 'segment']); -\atk4\ui\Header::addTo($seg, ['Center-aligned', 'aligned' => 'center', 'icon' => 'circular users', 'subHeader' => 'header with icon']); +$seg = \Atk4\Ui\View::addTo($app, ['ui' => 'segment']); +\Atk4\Ui\Header::addTo($seg, ['Center-aligned', 'aligned' => 'center', 'icon' => 'circular users', 'subHeader' => 'header with icon']); -$seg = \atk4\ui\View::addTo($app, ['ui' => 'segment']); -\atk4\ui\Header::addTo($seg, ['Center-aligned', 'aligned' => 'center', 'image' => $img, 'subHeader' => 'header with image']); +$seg = \Atk4\Ui\View::addTo($app, ['ui' => 'segment']); +\Atk4\Ui\Header::addTo($seg, ['Center-aligned', 'aligned' => 'center', 'image' => $img, 'subHeader' => 'header with image']); -$seg = \atk4\ui\View::addTo($app, ['ui' => 'segment']); -\atk4\ui\Header::addTo($seg, ['Center-aligned', 'aligned' => 'center', 'image' => [$img, 'disabled'], 'subHeader' => 'header with image']); +$seg = \Atk4\Ui\View::addTo($app, ['ui' => 'segment']); +\Atk4\Ui\Header::addTo($seg, ['Center-aligned', 'aligned' => 'center', 'image' => [$img, 'disabled'], 'subHeader' => 'header with image']); diff --git a/demos/basic/label.php b/demos/basic/label.php index 3fe8791c6f..03dfd6bd83 100644 --- a/demos/basic/label.php +++ b/demos/basic/label.php @@ -2,50 +2,50 @@ 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'; $img = 'https://raw.githubusercontent.com/atk4/ui/2.0.4/public/logo.png'; -\atk4\ui\Header::addTo($app, ['Labels']); -\atk4\ui\Label::addTo($app, ['Hot!']); -\atk4\ui\Label::addTo($app, ['23', 'icon' => 'mail']); -\atk4\ui\Label::addTo($app, ['new', 'iconRight' => 'delete']); +\Atk4\Ui\Header::addTo($app, ['Labels']); +\Atk4\Ui\Label::addTo($app, ['Hot!']); +\Atk4\Ui\Label::addTo($app, ['23', 'icon' => 'mail']); +\Atk4\Ui\Label::addTo($app, ['new', 'iconRight' => 'delete']); -\atk4\ui\Label::addTo($app, ['Coded in PHP', 'image' => $img]); -\atk4\ui\Label::addTo($app, ['Number of lines', 'detail' => '33']); +\Atk4\Ui\Label::addTo($app, ['Coded in PHP', 'image' => $img]); +\Atk4\Ui\Label::addTo($app, ['Number of lines', 'detail' => '33']); -\atk4\ui\Header::addTo($app, ['Combinations and Interraction']); -$del = \atk4\ui\Label::addTo($app, ['Zoe', 'image' => 'https://semantic-ui.com/images/avatar/small/ade.jpg', 'iconRight' => 'delete']); +\Atk4\Ui\Header::addTo($app, ['Combinations and Interraction']); +$del = \Atk4\Ui\Label::addTo($app, ['Zoe', 'image' => 'https://semantic-ui.com/images/avatar/small/ade.jpg', 'iconRight' => 'delete']); $del->on('click', '.delete', $del->js()->fadeOut()); $val = isset($_GET['toggle']) && $_GET['toggle']; -$toggle = \atk4\ui\Label::addTo($app, ['icon' => 'toggle ' . ($val ? 'on' : 'off')])->set('Value: ' . $val); -$toggle->on('click', new \atk4\ui\JsReload($toggle, ['toggle' => $val ? null : 1])); +$toggle = \Atk4\Ui\Label::addTo($app, ['icon' => 'toggle ' . ($val ? 'on' : 'off')])->set('Value: ' . $val); +$toggle->on('click', new \Atk4\Ui\JsReload($toggle, ['toggle' => $val ? null : 1])); -$menu = \atk4\ui\Menu::addTo($app); -\atk4\ui\Label::addTo($menu->addItem('Inbox'), ['20', 'floating red']); -\atk4\ui\Label::addTo($menu->addMenu('Others')->addItem('Draft'), ['10', 'floating blue']); +$menu = \Atk4\Ui\Menu::addTo($app); +\Atk4\Ui\Label::addTo($menu->addItem('Inbox'), ['20', 'floating red']); +\Atk4\Ui\Label::addTo($menu->addMenu('Others')->addItem('Draft'), ['10', 'floating blue']); -$seg = \atk4\ui\View::addTo($app, ['ui' => 'segment']); -\atk4\ui\Header::addTo($seg, ['Label Group']); -$labels = \atk4\ui\View::addTo($seg, [false, 'tag', 'ui' => 'labels']); -\atk4\ui\Label::addTo($seg, ['$9.99']); -\atk4\ui\Label::addTo($seg, ['$19.99']); -\atk4\ui\Label::addTo($seg, ['$24.99']); +$seg = \Atk4\Ui\View::addTo($app, ['ui' => 'segment']); +\Atk4\Ui\Header::addTo($seg, ['Label Group']); +$labels = \Atk4\Ui\View::addTo($seg, [false, 'tag', 'ui' => 'labels']); +\Atk4\Ui\Label::addTo($seg, ['$9.99']); +\Atk4\Ui\Label::addTo($seg, ['$19.99']); +\Atk4\Ui\Label::addTo($seg, ['$24.99']); -$columns = \atk4\ui\Columns::addTo($app); +$columns = \Atk4\Ui\Columns::addTo($app); $c = $columns->addColumn(); -$seg = \atk4\ui\View::addTo($c, ['ui' => 'raised segment']); -\atk4\ui\Label::addTo($seg, ['Left Column', 'top attached', 'icon' => 'book']); -\atk4\ui\Label::addTo($seg, ['Lorem', 'red ribbon', 'icon' => 'cut']); -\atk4\ui\LoremIpsum::addTo($seg, ['size' => 1]); +$seg = \Atk4\Ui\View::addTo($c, ['ui' => 'raised segment']); +\Atk4\Ui\Label::addTo($seg, ['Left Column', 'top attached', 'icon' => 'book']); +\Atk4\Ui\Label::addTo($seg, ['Lorem', 'red ribbon', 'icon' => 'cut']); +\Atk4\Ui\LoremIpsum::addTo($seg, ['size' => 1]); $c = $columns->addColumn(); -$seg = \atk4\ui\View::addTo($c, ['ui' => 'raised segment']); -\atk4\ui\Label::addTo($seg, ['Right Column', 'top attached', 'icon' => 'book']); -\atk4\ui\LoremIpsum::addTo($seg, ['size' => 1]); -\atk4\ui\Label::addTo($seg, ['Ipsum', 'orange bottom right attached', 'icon' => 'cut']); +$seg = \Atk4\Ui\View::addTo($c, ['ui' => 'raised segment']); +\Atk4\Ui\Label::addTo($seg, ['Right Column', 'top attached', 'icon' => 'book']); +\Atk4\Ui\LoremIpsum::addTo($seg, ['size' => 1]); +\Atk4\Ui\Label::addTo($seg, ['Ipsum', 'orange bottom right attached', 'icon' => 'cut']); diff --git a/demos/basic/menu.php b/demos/basic/menu.php index 4800170e5b..64c4fe7875 100644 --- a/demos/basic/menu.php +++ b/demos/basic/menu.php @@ -2,19 +2,19 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; /** * Demonstrates how to use menu. */ -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; -$menu = \atk4\ui\Menu::addTo($app); +$menu = \Atk4\Ui\Menu::addTo($app); $menu->addItem('foo', 'foo.php'); $menu->addItem('bar'); $menu->addItem('baz'); -$dropdown = \atk4\ui\Dropdown::addTo($menu, ['With Callback', 'dropdownOptions' => ['on' => 'hover']]); +$dropdown = \Atk4\Ui\Dropdown::addTo($menu, ['With Callback', 'dropdownOptions' => ['on' => 'hover']]); $dropdown->setSource(['a', 'b', 'c']); $dropdown->onChange(function ($itemId) { return 'New seleced item id: ' . $itemId; @@ -28,16 +28,16 @@ $submenu->addItem('one'); $submenu->addItem('two'); -$menu = \atk4\ui\Menu::addTo($app, ['vertical pointing']); +$menu = \Atk4\Ui\Menu::addTo($app, ['vertical pointing']); $menu->addItem(['Inbox', 'label' => ['123', 'teal left pointing']]); $menu->addItem('Spam'); -\atk4\ui\Form\Control\Input::addTo($menu->addItem(), ['placeholder' => 'Search', 'icon' => 'search'])->addClass('transparent'); +\Atk4\Ui\Form\Control\Input::addTo($menu->addItem(), ['placeholder' => 'Search', 'icon' => 'search'])->addClass('transparent'); -$menu = \atk4\ui\Menu::addTo($app, ['secondary vertical pointing']); +$menu = \Atk4\Ui\Menu::addTo($app, ['secondary vertical pointing']); $menu->addItem(['Inbox', 'label' => ['123', 'teal left pointing']]); $menu->addItem('Spam'); -\atk4\ui\Form\Control\Input::addTo($menu->addItem(), ['placeholder' => 'Search', 'icon' => 'search'])->addClass('transparent'); -$menu = \atk4\ui\Menu::addTo($app, ['vertical']); +\Atk4\Ui\Form\Control\Input::addTo($menu->addItem(), ['placeholder' => 'Search', 'icon' => 'search'])->addClass('transparent'); +$menu = \Atk4\Ui\Menu::addTo($app, ['vertical']); $group = $menu->addGroup('Products'); $group->addItem('Enterprise'); $group->addItem('Consumer'); @@ -46,10 +46,10 @@ $group->addItem('Shared'); $group->addItem('Dedicated'); -$menu = \atk4\ui\Menu::addTo($app, ['vertical']); +$menu = \Atk4\Ui\Menu::addTo($app, ['vertical']); $i = $menu->addItem(); -\atk4\ui\Header::addTo($i, ['size' => 4])->set('Promotions'); -\atk4\ui\View::addTo($i, ['element' => 'P'])->set('Check out our promotions'); +\Atk4\Ui\Header::addTo($i, ['size' => 4])->set('Promotions'); +\Atk4\Ui\View::addTo($i, ['element' => 'P'])->set('Check out our promotions'); // menu without any item should not show -\atk4\ui\Menu::addTo($app); +\Atk4\Ui\Menu::addTo($app); diff --git a/demos/basic/message.php b/demos/basic/message.php index dc60e1dec4..39cb87faf4 100644 --- a/demos/basic/message.php +++ b/demos/basic/message.php @@ -2,36 +2,36 @@ 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'; $img = 'https://github.com/atk4/ui/raw/07208a0af84109f0d6e3553e242720d8aeedb784/public/logo.png'; -\atk4\ui\Header::addTo($app, ['Message Types']); +\Atk4\Ui\Header::addTo($app, ['Message Types']); -$seg = \atk4\ui\View::addTo($app, ['ui' => 'raised segment']); +$seg = \Atk4\Ui\View::addTo($app, ['ui' => 'raised segment']); -$barType = \atk4\ui\View::addTo($seg, ['ui' => ' basic buttons']); +$barType = \Atk4\Ui\View::addTo($seg, ['ui' => ' basic buttons']); -$msg = \atk4\ui\Message::addTo($seg, [ +$msg = \Atk4\Ui\Message::addTo($seg, [ 'This is a title of your message', 'type' => $app->stickyGet('type'), 'icon' => $app->stickyGet('icon'), ]); $msg->text->addParagraph('You can add some more text here for your messages'); -$barType->on('click', '.button', new \atk4\ui\JsReload($seg, ['type' => (new \atk4\ui\Jquery())->text()])); -\atk4\ui\Button::addTo($barType, ['success']); -\atk4\ui\Button::addTo($barType, ['error']); -\atk4\ui\Button::addTo($barType, ['info']); -\atk4\ui\Button::addTo($barType, ['warning']); - -$barIcon = \atk4\ui\View::addTo($seg, ['ui' => ' basic buttons']); -$barIcon->on('click', '.button', new \atk4\ui\JsReload($seg, ['icon' => (new \atk4\ui\Jquery())->find('i')->attr('class')])); -\atk4\ui\Button::addTo($barIcon, ['icon' => 'book']); -\atk4\ui\Button::addTo($barIcon, ['icon' => 'check circle outline']); -\atk4\ui\Button::addTo($barIcon, ['icon' => 'pointing right']); -\atk4\ui\Button::addTo($barIcon, ['icon' => 'asterisk loading']); -\atk4\ui\Button::addTo($barIcon, ['icon' => 'vertically flipped cloud']); +$barType->on('click', '.button', new \Atk4\Ui\JsReload($seg, ['type' => (new \Atk4\Ui\Jquery())->text()])); +\Atk4\Ui\Button::addTo($barType, ['success']); +\Atk4\Ui\Button::addTo($barType, ['error']); +\Atk4\Ui\Button::addTo($barType, ['info']); +\Atk4\Ui\Button::addTo($barType, ['warning']); + +$barIcon = \Atk4\Ui\View::addTo($seg, ['ui' => ' basic buttons']); +$barIcon->on('click', '.button', new \Atk4\Ui\JsReload($seg, ['icon' => (new \Atk4\Ui\Jquery())->find('i')->attr('class')])); +\Atk4\Ui\Button::addTo($barIcon, ['icon' => 'book']); +\Atk4\Ui\Button::addTo($barIcon, ['icon' => 'check circle outline']); +\Atk4\Ui\Button::addTo($barIcon, ['icon' => 'pointing right']); +\Atk4\Ui\Button::addTo($barIcon, ['icon' => 'asterisk loading']); +\Atk4\Ui\Button::addTo($barIcon, ['icon' => 'vertically flipped cloud']); diff --git a/demos/basic/view.php b/demos/basic/view.php index 42cf80e840..f74351e612 100644 --- a/demos/basic/view.php +++ b/demos/basic/view.php @@ -2,39 +2,39 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\HtmlTemplate; -use atk4\ui\View; +use Atk4\Ui\HtmlTemplate; +use Atk4\Ui\View; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $img = 'https://github.com/atk4/ui/raw/07208a0af84109f0d6e3553e242720d8aeedb784/public/logo.png'; -\atk4\ui\Header::addTo($app, ['Default view has no styling']); -\atk4\ui\View::addTo($app)->set('just a
element'); +\Atk4\Ui\Header::addTo($app, ['Default view has no styling']); +\Atk4\Ui\View::addTo($app)->set('just a
element'); -\atk4\ui\Header::addTo($app, ['View can specify CSS class']); -\atk4\ui\View::addTo($app, ['ui' => 'segment', 'raised'])->set('Segment'); +\Atk4\Ui\Header::addTo($app, ['View can specify CSS class']); +\Atk4\Ui\View::addTo($app, ['ui' => 'segment', 'raised'])->set('Segment'); -\atk4\ui\Header::addTo($app, ['View can contain stuff']); -\atk4\ui\Header::addTo(\atk4\ui\View::addTo($app, ['ui' => 'segment']) +\Atk4\Ui\Header::addTo($app, ['View can contain stuff']); +\Atk4\Ui\Header::addTo(\Atk4\Ui\View::addTo($app, ['ui' => 'segment']) ->addClass('inverted red circular'), ['Buy', 'inverted', 'subHeader' => '$' . (random_int(100, 1000) / 100)]); -\atk4\ui\Header::addTo($app, ['View can use JavaScript']); -\atk4\ui\View::addTo($app, ['ui' => 'heart rating']) +\Atk4\Ui\Header::addTo($app, ['View can use JavaScript']); +\Atk4\Ui\View::addTo($app, ['ui' => 'heart rating']) ->js(true)->rating(['maxRating' => 5, 'initialRating' => random_int(1, 5)]); -\atk4\ui\Header::addTo($app, ['View can have events']); -$bb = \atk4\ui\View::addTo($app, ['ui' => 'large blue buttons']); +\Atk4\Ui\Header::addTo($app, ['View can have events']); +$bb = \Atk4\Ui\View::addTo($app, ['ui' => 'large blue buttons']); $bb->on('click', '.button')->transition('fly up'); foreach (str_split('Click me!!') as $letter) { - \atk4\ui\Button::addTo($bb, [$letter]); + \Atk4\Ui\Button::addTo($bb, [$letter]); } -\atk4\ui\Header::addTo($app, ['View load HTML from string or file']); +\Atk4\Ui\Header::addTo($app, ['View load HTML from string or file']); $planeTemplate = new HtmlTemplate('
{$num} @@ -45,36 +45,36 @@
'); $planeTemplate->set('num', random_int(100, 999)); -$plane = \atk4\ui\View::addTo($app, ['template' => $planeTemplate]); +$plane = \Atk4\Ui\View::addTo($app, ['template' => $planeTemplate]); -\atk4\ui\Header::addTo($app, ['Can be rendered into HTML']); -\atk4\ui\View::addTo($app, ['ui' => 'segment', 'raised', 'element' => 'pre'])->set($plane->render()); +\Atk4\Ui\Header::addTo($app, ['Can be rendered into HTML']); +\Atk4\Ui\View::addTo($app, ['ui' => 'segment', 'raised', 'element' => 'pre'])->set($plane->render()); -\atk4\ui\Header::addTo($app, ['Has a unique global identifier']); -\atk4\ui\Label::addTo($app, ['Plane ID: ', 'detail' => $plane->name]); +\Atk4\Ui\Header::addTo($app, ['Has a unique global identifier']); +\Atk4\Ui\Label::addTo($app, ['Plane ID: ', 'detail' => $plane->name]); -\atk4\ui\Header::addTo($app, ['Can interract with JavaScript actions']); -\atk4\ui\Button::addTo($app, ['Hide plane', 'icon' => 'down arrow'])->on('click', $plane->js()->hide()); -\atk4\ui\Button::addTo($app, ['Show plane', 'icon' => 'up arrow'])->on('click', $plane->js()->show()); -\atk4\ui\Button::addTo($app, ['Jiggle plane', 'icon' => 'expand'])->on('click', $plane->js()->transition('jiggle')); -\atk4\ui\Button::addTo($app, ['Reload plane', 'icon' => 'refresh'])->on('click', new \atk4\ui\JsReload($plane)); +\Atk4\Ui\Header::addTo($app, ['Can interract with JavaScript actions']); +\Atk4\Ui\Button::addTo($app, ['Hide plane', 'icon' => 'down arrow'])->on('click', $plane->js()->hide()); +\Atk4\Ui\Button::addTo($app, ['Show plane', 'icon' => 'up arrow'])->on('click', $plane->js()->show()); +\Atk4\Ui\Button::addTo($app, ['Jiggle plane', 'icon' => 'expand'])->on('click', $plane->js()->transition('jiggle')); +\Atk4\Ui\Button::addTo($app, ['Reload plane', 'icon' => 'refresh'])->on('click', new \Atk4\Ui\JsReload($plane)); -\atk4\ui\Header::addTo($app, ['Can be on a Virtual Page']); -$vp = \atk4\ui\VirtualPage::addTo($app)->set(function ($page) use ($planeTemplate) { +\Atk4\Ui\Header::addTo($app, ['Can be on a Virtual Page']); +$vp = \Atk4\Ui\VirtualPage::addTo($app)->set(function ($page) use ($planeTemplate) { $plane = View::addTo($page, ['template' => $planeTemplate]); - \atk4\ui\Label::addTo($page, ['Plane ID: ', 'bottom attached', 'detail' => $plane->name]); + \Atk4\Ui\Label::addTo($page, ['Plane ID: ', 'bottom attached', 'detail' => $plane->name]); }); -\atk4\ui\Button::addTo($app, ['Show $plane in a dialog', 'icon' => 'clone'])->on('click', new \atk4\ui\JsModal('Plane Box', $vp)); +\Atk4\Ui\Button::addTo($app, ['Show $plane in a dialog', 'icon' => 'clone'])->on('click', new \Atk4\Ui\JsModal('Plane Box', $vp)); -\atk4\ui\Header::addTo($app, ['All components extend View (even paginator)']); -$columns = \atk4\ui\Columns::addTo($app); +\Atk4\Ui\Header::addTo($app, ['All components extend View (even paginator)']); +$columns = \Atk4\Ui\Columns::addTo($app); -\atk4\ui\Button::addTo($columns->addColumn(), ['Button'])->addClass('green'); -\atk4\ui\Header::addTo($columns->addColumn(), ['Header'])->addClass('green'); -\atk4\ui\Label::addTo($columns->addColumn(), ['Label'])->addClass('green'); -\atk4\ui\Message::addTo($columns->addColumn(), ['Message'])->addClass('green'); -\atk4\ui\Paginator::addTo($columns->addColumn(), ['total' => 3, 'reload' => $columns])->addClass('green'); +\Atk4\Ui\Button::addTo($columns->addColumn(), ['Button'])->addClass('green'); +\Atk4\Ui\Header::addTo($columns->addColumn(), ['Header'])->addClass('green'); +\Atk4\Ui\Label::addTo($columns->addColumn(), ['Label'])->addClass('green'); +\Atk4\Ui\Message::addTo($columns->addColumn(), ['Message'])->addClass('green'); +\Atk4\Ui\Paginator::addTo($columns->addColumn(), ['total' => 3, 'reload' => $columns])->addClass('green'); -\atk4\ui\Header::addTo($app, ['Can have a custom render logic']); -\atk4\ui\Table::addTo($app)->addclass('green')->setSource(['One', 'Two', 'Three']); +\Atk4\Ui\Header::addTo($app, ['Can have a custom render logic']); +\Atk4\Ui\Table::addTo($app)->addclass('green')->setSource(['One', 'Two', 'Three']); diff --git a/demos/collection/crud.php b/demos/collection/crud.php index 313abebae9..19de3cda7e 100644 --- a/demos/collection/crud.php +++ b/demos/collection/crud.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'; $model = new CountryLock($app->db); -$crud = \atk4\ui\Crud::addTo($app, ['ipp' => 10]); +$crud = \Atk4\Ui\Crud::addTo($app, ['ipp' => 10]); // callback for model action add form. $crud->onFormAdd(function ($form, $t) { @@ -23,23 +23,23 @@ // callback for both model action edit and add. $crud->onFormAddEdit(function ($form, $ex) { - $form->onSubmit(function (\atk4\ui\Form $form) use ($ex) { - return [$ex->hide(), new \atk4\ui\JsToast('Submit all right! This demo does not saved data.')]; + $form->onSubmit(function (\Atk4\Ui\Form $form) use ($ex) { + return [$ex->hide(), new \Atk4\Ui\JsToast('Submit all right! This demo does not saved data.')]; }); }); $crud->setModel($model); -$crud->addDecorator($model->title_field, [\atk4\ui\Table\Column\Link::class, ['test' => false, 'path' => 'interfaces/page'], ['_id' => 'id']]); +$crud->addDecorator($model->title_field, [\Atk4\Ui\Table\Column\Link::class, ['test' => false, 'path' => 'interfaces/page'], ['_id' => 'id']]); -\atk4\ui\View::addTo($app, ['ui' => 'divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'divider']); -$columns = \atk4\ui\Columns::addTo($app); +$columns = \Atk4\Ui\Columns::addTo($app); $column = $columns->addColumn(0, 'ui blue segment'); // Crud can operate with various fields -\atk4\ui\Header::addTo($column, ['Configured Crud']); -$crud = \atk4\ui\Crud::addTo($column, [ +\Atk4\Ui\Header::addTo($column, ['Configured Crud']); +$crud = \Atk4\Ui\Crud::addTo($column, [ //'fieldsCreate' => ['name', 'iso', 'iso3', 'numcode', 'phonecode'], // when creating then show more fields 'displayFields' => ['name'], // when updating then only allow to update name 'editFields' => ['name', 'iso', 'iso3'], @@ -51,7 +51,7 @@ // Condition on the model can be applied on a model $model = new CountryLock($app->db); $model->addCondition('numcode', '<', 200); -$model->onHook(\atk4\data\Model::HOOK_VALIDATE, function ($model, $intent) { +$model->onHook(\Atk4\Data\Model::HOOK_VALIDATE, function ($model, $intent) { $err = []; if ($model->get('numcode') >= 200) { $err['numcode'] = 'Should be less than 200'; @@ -62,28 +62,28 @@ $crud->setModel($model); // Because Crud inherits Grid, you can also define custom actions -$crud->addModalAction(['icon' => [\atk4\ui\Icon::class, 'cogs']], 'Details', function ($p, $id) use ($crud) { - \atk4\ui\Message::addTo($p, ['Details for: ' . $crud->model->load($id)->get('name') . ' (id: ' . $id . ')']); +$crud->addModalAction(['icon' => [\Atk4\Ui\Icon::class, 'cogs']], 'Details', function ($p, $id) use ($crud) { + \Atk4\Ui\Message::addTo($p, ['Details for: ' . $crud->model->load($id)->get('name') . ' (id: ' . $id . ')']); }); $column = $columns->addColumn(); -\atk4\ui\Header::addTo($column, ['Cutomizations']); +\Atk4\Ui\Header::addTo($column, ['Cutomizations']); -/** @var \atk4\ui\UserAction\ModalExecutor $myExecutorClass */ -$myExecutorClass = get_class(new class() extends \atk4\ui\UserAction\ModalExecutor { - public function addFormTo(\atk4\ui\View $view): \atk4\ui\Form +/** @var \Atk4\Ui\UserAction\ModalExecutor $myExecutorClass */ +$myExecutorClass = get_class(new class() extends \Atk4\Ui\UserAction\ModalExecutor { + public function addFormTo(\Atk4\Ui\View $view): \Atk4\Ui\Form { - $columns = \atk4\ui\Columns::addTo($view); + $columns = \Atk4\Ui\Columns::addTo($view); $left = $columns->addColumn(); $right = $columns->addColumn(); $result = parent::addFormTo($left); // TODO: Change the autogenerated stub if ($this->action->getOwner()->get('is_folder')) { - \atk4\ui\Grid::addTo($right, ['menu' => false, 'ipp' => 5]) + \Atk4\Ui\Grid::addTo($right, ['menu' => false, 'ipp' => 5]) ->setModel($this->action->getOwner()->ref('SubFolder')); } else { - \atk4\ui\Message::addTo($right, ['Not a folder', 'warning']); + \Atk4\Ui\Message::addTo($right, ['Not a folder', 'warning']); } return $result; @@ -93,7 +93,7 @@ public function addFormTo(\atk4\ui\View $view): \atk4\ui\Form $file = new FileLock($app->db); $file->getUserAction('edit')->ui['executor'] = [$myExecutorClass]; -$crud = \atk4\ui\Crud::addTo($column, [ +$crud = \Atk4\Ui\Crud::addTo($column, [ 'ipp' => 5, ]); diff --git a/demos/collection/crud3.php b/demos/collection/crud3.php index cb130a8dd2..29817370bc 100644 --- a/demos/collection/crud3.php +++ b/demos/collection/crud3.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 $modelClass */ -$modelClass = get_class(new class() extends \atk4\data\Model { +/** @var \Atk4\Data\Model $modelClass */ +$modelClass = get_class(new class() extends \Atk4\Data\Model { use ModelLockTrait; public $table = 'test'; @@ -39,10 +39,10 @@ protected function init(): void 8 => ['id' => 8, 'name' => 'ABC2', 'code' => 18, 'country' => 'Russia'], 9 => ['id' => 9, 'name' => 'ABC1', 'code' => 19, 'country' => 'Latvia'], ]]; -$p = new \atk4\data\Persistence\Array_($data); +$p = new \Atk4\Data\Persistence\Array_($data); $model = new $modelClass($p); // add Crud -\atk4\ui\Header::addTo($app, ['Crud with Array Persistence']); -$c = \atk4\ui\Crud::addTo($app, ['ipp' => 5]); +\Atk4\Ui\Header::addTo($app, ['Crud with Array Persistence']); +$c = \Atk4\Ui\Crud::addTo($app, ['ipp' => 5]); $c->setModel($model); diff --git a/demos/collection/grid.php b/demos/collection/grid.php index 72cd92b21d..137abf9252 100644 --- a/demos/collection/grid.php +++ b/demos/collection/grid.php @@ -2,23 +2,23 @@ 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'; -$grid = \atk4\ui\Grid::addTo($app); +$grid = \Atk4\Ui\Grid::addTo($app); $model = new CountryLock($app->db); $model->addUserAction('test', function ($model) { return 'test from ' . $model->getTitle() . ' was successful!'; }); // Delete is already prevent by our lock Model, just simulating it. -$ex = new \atk4\ui\UserAction\JsCallbackExecutor(); -$ex->onHook(\atk4\ui\UserAction\BasicExecutor::HOOK_AFTER_EXECUTE, function () { +$ex = new \Atk4\Ui\UserAction\JsCallbackExecutor(); +$ex->onHook(\Atk4\Ui\UserAction\BasicExecutor::HOOK_AFTER_EXECUTE, function () { return [ - (new \atk4\ui\Jquery())->closest('tr')->transition('fade left'), - new \atk4\ui\JsToast('Simulating delete in demo mode.'), + (new \Atk4\Ui\Jquery())->closest('tr')->transition('fade left'), + new \Atk4\Ui\JsToast('Simulating delete in demo mode.'), ]; }); $model->getUserAction('delete')->ui['executor'] = $ex; @@ -28,11 +28,11 @@ // Adding Quicksearch on Name field using auto query. $grid->addQuickSearch(['name'], true); -$grid->menu->addItem(['Add Country', 'icon' => 'add square'], new \atk4\ui\JsExpression('alert(123)')); -$grid->menu->addItem(['Re-Import', 'icon' => 'power'], new \atk4\ui\JsReload($grid)); +$grid->menu->addItem(['Add Country', 'icon' => 'add square'], new \Atk4\Ui\JsExpression('alert(123)')); +$grid->menu->addItem(['Re-Import', 'icon' => 'power'], new \Atk4\Ui\JsReload($grid)); $grid->menu->addItem(['Delete All', 'icon' => 'trash', 'red active']); -$grid->addColumn(null, [\atk4\ui\Table\Column\Template::class, 'helloworld']); +$grid->addColumn(null, [\Atk4\Ui\Table\Column\Template::class, 'helloworld']); $grid->addActionButton('test'); @@ -40,14 +40,14 @@ return 'Loaded "' . $grid->model->load($id)->get('name') . '" from ID=' . $id; }); -$grid->addModalAction(['icon' => [\atk4\ui\Icon::class, 'external']], 'Modal Test', function ($p, $id) { - \atk4\ui\Message::addTo($p, ['Clicked on ID=' . $id]); +$grid->addModalAction(['icon' => [\Atk4\Ui\Icon::class, 'external']], 'Modal Test', function ($p, $id) { + \Atk4\Ui\Message::addTo($p, ['Clicked on ID=' . $id]); }); $grid->addActionButton(['icon' => 'delete'], $model->getUserAction('delete')); $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/demos/collection/jssortable.php b/demos/collection/jssortable.php index 5976b0b67e..ef18f7b8f6 100644 --- a/demos/collection/jssortable.php +++ b/demos/collection/jssortable.php @@ -2,14 +2,14 @@ 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'; -$view = \atk4\ui\View::addTo($app, ['template' => new HtmlTemplate( +$view = \Atk4\Ui\View::addTo($app, ['template' => new HtmlTemplate( '
Click and drag country to reorder
    @@ -18,34 +18,34 @@
' )]); -$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)) ->setLimit(20); -$sortable = \atk4\ui\JsSortable::addTo($view, ['container' => 'ul', 'draggable' => 'li', 'dataLabel' => 'name']); +$sortable = \Atk4\Ui\JsSortable::addTo($view, ['container' => 'ul', 'draggable' => 'li', 'dataLabel' => 'name']); $sortable->onReorder(function ($order, $src, $pos, $oldPos) { if ($_GET['btn'] ?? null) { - return new \atk4\ui\JsToast(implode(' - ', $order)); + return new \Atk4\Ui\JsToast(implode(' - ', $order)); } - return new \atk4\ui\JsToast($src . ' moved from position ' . $oldPos . ' to ' . $pos); + return new \Atk4\Ui\JsToast($src . ' moved from position ' . $oldPos . ' to ' . $pos); }); -$button = \atk4\ui\Button::addTo($app)->set('Get countries order'); +$button = \Atk4\Ui\Button::addTo($app)->set('Get countries order'); $button->js('click', $sortable->jsGetOrders(['btn' => '1'])); ////////////////////////////////////////////////////////////////////////////////////////// -\atk4\ui\View::addTo($app, ['ui' => 'divider']); -\atk4\ui\Header::addTo($app, ['Add Drag n drop to Grid']); +\Atk4\Ui\View::addTo($app, ['ui' => 'divider']); +\Atk4\Ui\Header::addTo($app, ['Add Drag n drop to Grid']); -$grid = \atk4\ui\Grid::addTo($app, ['paginator' => false]); +$grid = \Atk4\Ui\Grid::addTo($app, ['paginator' => false]); $grid->setModel((new Country($app->db))->setLimit(6)); $dragHandler = $grid->addDragHandler(); $dragHandler->onReorder(function ($order) { - return new \atk4\ui\JsToast('New order: ' . implode(' - ', $order)); + return new \Atk4\Ui\JsToast('New order: ' . implode(' - ', $order)); }); diff --git a/demos/collection/lister-ipp.php b/demos/collection/lister-ipp.php index 44adbd5409..f439997a14 100644 --- a/demos/collection/lister-ipp.php +++ b/demos/collection/lister-ipp.php @@ -2,72 +2,72 @@ 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'; // default lister -\atk4\ui\Header::addTo($app)->set('Default lister'); -\atk4\ui\Lister::addTo($app, ['defaultTemplate' => 'lister.html'])->setSource([ +\Atk4\Ui\Header::addTo($app)->set('Default lister'); +\Atk4\Ui\Lister::addTo($app, ['defaultTemplate' => 'lister.html'])->setSource([ ['icon' => 'map marker', 'title' => 'Krolewskie Jadlo', 'descr' => 'An excellent polish restaurant, quick delivery and hearty, filling meals'], ['icon' => 'map marker', 'title' => 'Xian Famous Foods', 'descr' => 'A taste of Shaanxi\'s delicious culinary traditions, with delights like spicy cold noodles and lamb burgers.'], ['icon' => 'check', 'title' => 'Sapporo Haru', 'descr' => 'Greenpoint\'s best choice for quick and delicious sushi'], ]); -\atk4\ui\View::addTo($app, ['ui' => 'clearing divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'clearing divider']); // lister with custom template -$view = \atk4\ui\View::addTo($app, ['template' => new HtmlTemplate('
+$view = \Atk4\Ui\View::addTo($app, ['template' => new HtmlTemplate('
Top 20 countries (alphabetically)
{List}
{$name}
{/}
')]); -$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)) ->setLimit(20); -\atk4\ui\View::addTo($app, ['ui' => 'clearing divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'clearing divider']); // empty lister with default template -\atk4\ui\Header::addTo($app)->set('Empty default lister'); -\atk4\ui\Lister::addTo($app, ['defaultTemplate' => 'lister.html'])->setSource([]); -\atk4\ui\View::addTo($app, ['ui' => 'clearing divider']); +\Atk4\Ui\Header::addTo($app)->set('Empty default lister'); +\Atk4\Ui\Lister::addTo($app, ['defaultTemplate' => 'lister.html'])->setSource([]); +\Atk4\Ui\View::addTo($app, ['ui' => 'clearing divider']); // empty lister with custom template -$view = \atk4\ui\View::addTo($app, ['template' => new HtmlTemplate('
+$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') . ')'); } elseif ($table->current_row->get('action') === 'Tax') { @@ -46,13 +46,13 @@ $table->template->dangerouslyAppendHtml('Foot', 'This will appear above totals'); $table->addTotals(['action' => 'Totals:', 'amount' => ['sum']]); -\atk4\ui\Header::addTo($app, ['Columns with multiple formats', 'subHeader' => 'Single column can use logic to swap out formatters', 'icon' => 'table']); +\Atk4\Ui\Header::addTo($app, ['Columns with multiple formats', 'subHeader' => 'Single column can use logic to swap out formatters', 'icon' => 'table']); -$table = \atk4\ui\Table::addTo($app); +$table = \Atk4\Ui\Table::addTo($app); $table->setModel($model, ['action']); // copy of amount through a PHP callback -$model->addExpression('amount_copy', [function (\atk4\data\Model $model) { +$model->addExpression('amount_copy', [function (\Atk4\Data\Model $model) { return $model->get('amount'); }, 'type' => 'money']); @@ -78,8 +78,8 @@ return Table\Column\Money::class; }, 'attr' => ['all' => ['class' => ['right aligned singel line']]]]); -\atk4\ui\Header::addTo($app, ['Table with resizable columns', 'subHeader' => 'Just drag column header to resize', 'icon' => 'table']); +\Atk4\Ui\Header::addTo($app, ['Table with resizable columns', 'subHeader' => 'Just drag column header to resize', 'icon' => 'table']); -$table = \atk4\ui\Table::addTo($app); +$table = \Atk4\Ui\Table::addTo($app); $table->setModel($model); $table->addClass('celled')->resizableColumn(); diff --git a/demos/collection/tablecolumnmenu.php b/demos/collection/tablecolumnmenu.php index d03a227692..6ebe46112e 100644 --- a/demos/collection/tablecolumnmenu.php +++ b/demos/collection/tablecolumnmenu.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'; -\atk4\ui\Header::addTo($app, ['Table column may contains popup or dropdown menu.']); +\Atk4\Ui\Header::addTo($app, ['Table column may contains popup or dropdown menu.']); // Better Popup positionning when Popup are inside a container. -$container = \atk4\ui\View::addTo($app, ['ui' => 'vertical segment']); -$table = \atk4\ui\Table::addTo($container, ['celled' => true]); +$container = \Atk4\Ui\View::addTo($app, ['ui' => 'vertical segment']); +$table = \Atk4\Ui\Table::addTo($container, ['celled' => true]); $table->setModel(new SomeData(), false); // will add popup to this column. @@ -23,15 +23,15 @@ $colTitle = $table->addColumn('title'); $table->addColumn('date'); -$table->addColumn('salary', new \atk4\ui\Table\Column\Money()); +$table->addColumn('salary', new \Atk4\Ui\Table\Column\Money()); // regular popup setup -\atk4\ui\Text::addTo($colName->addPopup())->set('Name popup'); +\Atk4\Ui\Text::addTo($colName->addPopup())->set('Name popup'); // dynamic popup setup // This popup will add content using the callback function. $colSurname->addPopup()->set(function ($pop) { - \atk4\ui\Text::addTo($pop)->set('This popup is loaded dynamically'); + \Atk4\Ui\Text::addTo($pop)->set('This popup is loaded dynamically'); }); // Another dropdown menu. @@ -41,10 +41,10 @@ //////////////////////////////////////////////// -\atk4\ui\Header::addTo($app, ['Grid column may contains popup or dropdown menu.']); +\Atk4\Ui\Header::addTo($app, ['Grid column may contains popup or dropdown menu.']); // Table in Grid are already inside a container. -$grid = \atk4\ui\Grid::addTo($app); +$grid = \Atk4\Ui\Grid::addTo($app); $grid->setModel(new Country($app->db)); $grid->ipp = 5; @@ -55,4 +55,4 @@ // Adding a popup view to the column 'iso' $pop = $grid->addPopup('iso'); -\atk4\ui\Text::addTo($pop)->set('Grid column popup'); +\Atk4\Ui\Text::addTo($pop)->set('Grid column popup'); diff --git a/demos/collection/tablecolumns.php b/demos/collection/tablecolumns.php index e763ee27cd..05ef3c1252 100644 --- a/demos/collection/tablecolumns.php +++ b/demos/collection/tablecolumns.php @@ -2,15 +2,15 @@ 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'; -/** @var \atk4\data\Model $modelColorClass */ -$modelColorClass = get_class(new class() extends \atk4\data\Model { +/** @var \Atk4\Data\Model $modelColorClass */ +$modelColorClass = get_class(new class() extends \Atk4\Data\Model { protected function init(): void { parent::init(); @@ -109,9 +109,9 @@ protected function init(): void 'four', ]; -\atk4\ui\Header::addTo($app, ['Table column', 'subHeader' => 'Table column decorator can be set from your model.']); +\Atk4\Ui\Header::addTo($app, ['Table column', 'subHeader' => 'Table column decorator can be set from your model.']); -$model = new $modelColorClass(new \atk4\data\Persistence\Static_([])); +$model = new $modelColorClass(new \Atk4\Data\Persistence\Static_([])); foreach (range(1, 10) as $id) { $key_value = random_int(1, 4); @@ -128,5 +128,5 @@ protected function init(): void ]); } -$table = \atk4\ui\Table::addTo($app); +$table = \Atk4\Ui\Table::addTo($app); $table->setModel($model); diff --git a/demos/collection/tablefilter.php b/demos/collection/tablefilter.php index 6ec02bdbff..a42243006e 100644 --- a/demos/collection/tablefilter.php +++ b/demos/collection/tablefilter.php @@ -2,15 +2,15 @@ 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'; // For popup positioning to work correctly, table need to be inside a view segment. -$view = \atk4\ui\View::addTo($app, ['ui' => 'basic segment']); +$view = \Atk4\Ui\View::addTo($app, ['ui' => 'basic segment']); // Important: menu class added for Behat testing. -$grid = \atk4\ui\Grid::addTo($view, ['menu' => ['class' => ['atk-grid-menu']]]); +$grid = \Atk4\Ui\Grid::addTo($view, ['menu' => ['class' => ['atk-grid-menu']]]); $model = new CountryLock($app->db); $model->addExpression('is_uk', $model->expr('case when [iso] = [country] THEN 1 ELSE 0 END', ['country' => 'GB']))->type = 'boolean'; diff --git a/demos/data-action/actions.php b/demos/data-action/actions.php index 84ea2b1ef7..062913818c 100644 --- a/demos/data-action/actions.php +++ b/demos/data-action/actions.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Button; -use atk4\ui\Columns; -use atk4\ui\Header; -use atk4\ui\UserAction; -use atk4\ui\View; +use Atk4\Ui\Button; +use Atk4\Ui\Columns; +use Atk4\Ui\Header; +use Atk4\Ui\UserAction; +use Atk4\Ui\View; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $files = new FileLock($app->db); @@ -38,13 +38,13 @@ 'args' => [ 'path' => ['type' => 'string', 'required' => true], ], - 'appliesTo' => \atk4\data\Model\UserAction::APPLIES_TO_NO_RECORDS, + 'appliesTo' => \Atk4\Data\Model\UserAction::APPLIES_TO_NO_RECORDS, ] ); Header::addTo($app, [ 'Extensions to ATK Data Actions', - 'subHeader' => 'Showing different UserAction executors that can execute atk4\data model action.', + 'subHeader' => 'Showing different UserAction executors that can execute Atk4\Data model action.', ]); View::addTo($app, ['ui' => 'hidden divider']); @@ -63,10 +63,10 @@ $executor->setAction($action, ['path' => '.']); // Setting user response after model action get execute. $executor->onHook(UserAction\BasicExecutor::HOOK_AFTER_EXECUTE, function ($t, $m) { - return new \atk4\ui\JsToast('Files imported'); + return new \Atk4\Ui\JsToast('Files imported'); }); -$btn = \atk4\ui\Button::addTo($rightColumn, ['Import File']); +$btn = \Atk4\Ui\Button::addTo($rightColumn, ['Import File']); $btn->on('click', $executor, ['confirm' => 'This will import a lot of file. Are you sure?']); Header::addTo($rightColumn, ['BasicExecutor']); @@ -76,7 +76,7 @@ $executor->description = 'Execute Import action using "BasicExecutor" with argument "path" equal to "."'; $executor->setArguments(['path' => '.']); $executor->onHook(UserAction\BasicExecutor::HOOK_AFTER_EXECUTE, function ($x) { - return new \atk4\ui\JsToast('Done!'); + return new \Atk4\Ui\JsToast('Done!'); }); View::addTo($rightColumn, ['ui' => 'hidden divider']); @@ -89,7 +89,7 @@ $executor->description = 'Displays preview in console prior to executing'; $executor->setArguments(['path' => '.']); $executor->onHook(UserAction\BasicExecutor::HOOK_AFTER_EXECUTE, function ($x, $ret) { - return new \atk4\ui\JsToast('Confirm!'); + return new \Atk4\Ui\JsToast('Confirm!'); }); Header::addTo($leftColumn, ['FormExecutor']); @@ -99,7 +99,7 @@ $executor->description = 'Only fields set in $action[field] array will be added in form.'; $executor->setArguments(['path' => '.']); $executor->onHook(UserAction\BasicExecutor::HOOK_AFTER_EXECUTE, function ($x, $ret) { - return new \atk4\ui\JsToast('Confirm! ' . $x->action->getModel()->get('name')); + return new \Atk4\Ui\JsToast('Confirm! ' . $x->action->getModel()->get('name')); }); View::addTo($leftColumn, ['ui' => 'hidden divider']); @@ -110,5 +110,5 @@ $executor->description = 'ArgumentFormExecutor will ask user about arguments set in actions.'; $executor->ui = 'segment'; $executor->onHook(UserAction\BasicExecutor::HOOK_AFTER_EXECUTE, function ($x, $ret) { - return new \atk4\ui\JsToast('Imported!'); + return new \Atk4\Ui\JsToast('Imported!'); }); diff --git a/demos/data-action/jsactions.php b/demos/data-action/jsactions.php index 361593712b..0963a89b75 100644 --- a/demos/data-action/jsactions.php +++ b/demos/data-action/jsactions.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form\Control\Line; -use atk4\ui\UserAction; -use atk4\ui\UserAction\JsCallbackExecutor; +use Atk4\Ui\Form\Control\Line; +use Atk4\Ui\UserAction; +use Atk4\Ui\UserAction\JsCallbackExecutor; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; -\atk4\ui\Header::addTo($app, [ +\Atk4\Ui\Header::addTo($app, [ 'Extensions to ATK Data Actions', 'subHeader' => 'Model action can be trigger in various ways.', ]); @@ -28,9 +28,9 @@ /////////////////////////////////////////// -\atk4\ui\View::addTo($app, ['ui' => 'ui clearing divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'ui clearing divider']); -\atk4\ui\Header::addTo($app, [ +\Atk4\Ui\Header::addTo($app, [ 'Using Input button', 'size' => 4, 'subHeader' => 'Action can be triggered via a button attached to an input. The data action argument value is set to the input value.', @@ -55,20 +55,20 @@ /////////////////////////////////////////// -\atk4\ui\View::addTo($app, ['ui' => 'ui clearing divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'ui clearing divider']); -\atk4\ui\Header::addTo($app, [ +\Atk4\Ui\Header::addTo($app, [ 'Using buttons in a Card component', 'size' => 4, 'subHeader' => 'Easily trigger a data action using a Card component.', ]); // Card component. -$card = \atk4\ui\Card::addTo($app); -$content = new \atk4\ui\View(['class' => ['content']]); -$content->add($img = new \atk4\ui\Image(['../images/kristy.png'])); +$card = \Atk4\Ui\Card::addTo($app); +$content = new \Atk4\Ui\View(['class' => ['content']]); +$content->add($img = new \Atk4\Ui\Image(['../images/kristy.png'])); $img->addClass('right floated mini ui image'); -$content->add(new \atk4\ui\Header(['Kristy'])); +$content->add(new \Atk4\Ui\Header(['Kristy'])); $card->addContent($content); $card->addDescription('Kristy is a friend of Mully.'); diff --git a/demos/data-action/jsactions2.php b/demos/data-action/jsactions2.php index 39d1b58d05..b924529598 100644 --- a/demos/data-action/jsactions2.php +++ b/demos/data-action/jsactions2.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Message; +use Atk4\Ui\Message; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; // Demo for Model action @@ -18,25 +18,25 @@ // Model actions for this file are setup in DemoActionUtil. DemoActionsUtil::setupDemoActions($country); -\atk4\ui\Header::addTo($app, ['Assign Model action to button event', 'subHeader' => 'Execute model action on this country record by clicking on the appropriate button on the right.']); +\Atk4\Ui\Header::addTo($app, ['Assign Model action to button event', 'subHeader' => 'Execute model action on this country record by clicking on the appropriate button on the right.']); $msg = Message::addTo($app, ['Notes', 'type' => 'info']); $msg->text->addParagraph('When passing an action to a button event, Ui will determine what executor is required base on the action properties.'); $msg->text->addParagraph('If action require arguments, fields and/or preview, then a ModalExecutor will be use.'); -\atk4\ui\View::addTo($app, ['ui' => 'ui clearing divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'ui clearing divider']); -$gl = \atk4\ui\GridLayout::addTo($app, ['rows' => 1, 'columns' => 2]); -$c = \atk4\ui\Card::addTo($gl, ['useLabel' => true], ['r1c1']); -$c->addContent(new \atk4\ui\Header(['Using country: '])); +$gl = \Atk4\Ui\GridLayout::addTo($app, ['rows' => 1, 'columns' => 2]); +$c = \Atk4\Ui\Card::addTo($gl, ['useLabel' => true], ['r1c1']); +$c->addContent(new \Atk4\Ui\Header(['Using country: '])); $c->setModel($country, ['iso', 'iso3', 'phonecode']); -$buttons = \atk4\ui\View::addTo($gl, ['ui' => 'vertical basic buttons'], ['r1c2']); +$buttons = \Atk4\Ui\View::addTo($gl, ['ui' => 'vertical basic buttons'], ['r1c2']); $country->unload(); // Create a button for every action in Country model. foreach ($country->getUserActions() as $action) { - $b = \atk4\ui\Button::addTo($buttons, [$action->getCaption()]); + $b = \Atk4\Ui\Button::addTo($buttons, [$action->getCaption()]); // Assign action to button using current model id as url arguments. $b->on('click', $action, ['args' => ['id' => $countryId]]); } diff --git a/demos/data-action/jsactionscrud.php b/demos/data-action/jsactionscrud.php index a2a56f82e4..2fb4406bc1 100644 --- a/demos/data-action/jsactionscrud.php +++ b/demos/data-action/jsactionscrud.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Header; +use Atk4\Ui\Header; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; Header::addTo($app, ['Actions in Crud', 'subHeader' => 'Crud will automatically setup Menu items based on actions defined in model.']); @@ -28,12 +28,12 @@ 'args' => [ 'path' => ['type' => 'string', 'required' => true], ], - 'appliesTo' => \atk4\data\Model\UserAction::APPLIES_TO_NO_RECORDS, + 'appliesTo' => \Atk4\Data\Model\UserAction::APPLIES_TO_NO_RECORDS, ] ); -$files->addUserAction('download', function (\atk4\data\Model $model) { +$files->addUserAction('download', function (\Atk4\Data\Model $model) { return 'File has been download!'; }); -\atk4\ui\Crud::addTo($app, ['ipp' => 10])->setModel($files); +\Atk4\Ui\Crud::addTo($app, ['ipp' => 10])->setModel($files); diff --git a/demos/data-action/jsactionsgrid.php b/demos/data-action/jsactionsgrid.php index a4ada611dc..88b9a783b7 100644 --- a/demos/data-action/jsactionsgrid.php +++ b/demos/data-action/jsactionsgrid.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\core\Factory; +use Atk4\Core\Factory; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; // Demo for Model action in Grid @@ -15,23 +15,23 @@ // Model actions for this file are setup in DemoActionUtil. DemoActionsUtil::setupDemoActions($country); -\atk4\ui\Header::addTo($app, ['Execute model action from Grid menu items', 'subHeader' => 'Setting grid menu items in order to execute model actions or javascript.']); +\Atk4\Ui\Header::addTo($app, ['Execute model action from Grid menu items', 'subHeader' => 'Setting grid menu items in order to execute model actions or javascript.']); -$grid = \atk4\ui\Grid::addTo($app, ['menu' => false]); +$grid = \Atk4\Ui\Grid::addTo($app, ['menu' => false]); $grid->setModel($country); -$divider = Factory::factory([\atk4\ui\View::class], ['id' => false, 'class' => ['divider'], 'content' => '']); +$divider = Factory::factory([\Atk4\Ui\View::class], ['id' => false, 'class' => ['divider'], 'content' => '']); -$modelHeader = Factory::factory([\atk4\ui\View::class], ['id' => false, 'class' => ['header'], 'content' => 'Model Actions']); -\atk4\ui\Icon::addTo($modelHeader, ['content' => 'database']); +$modelHeader = Factory::factory([\Atk4\Ui\View::class], ['id' => false, 'class' => ['header'], 'content' => 'Model Actions']); +\Atk4\Ui\Icon::addTo($modelHeader, ['content' => 'database']); -$jsHeader = Factory::factory([\atk4\ui\View::class], ['id' => false, 'class' => ['header'], 'content' => 'Js Actions']); -\atk4\ui\Icon::addTo($jsHeader, ['content' => 'file code']); +$jsHeader = Factory::factory([\Atk4\Ui\View::class], ['id' => false, 'class' => ['header'], 'content' => 'Js Actions']); +\Atk4\Ui\Icon::addTo($jsHeader, ['content' => 'file code']); $grid->addActionMenuItem($jsHeader); // Beside model user action, grid menu items can also execute javascript. $grid->addActionMenuItem('Js Callback', function () { - return (new \atk4\ui\View())->set('Js Callback done!'); + return (new \Atk4\Ui\View())->set('Js Callback done!'); }, 'Are you sure?'); $grid->addActionMenuItem($divider); @@ -52,7 +52,7 @@ ] ); -$specialItem = Factory::factory([\atk4\ui\View::class], ['id' => false, 'class' => ['item'], 'content' => 'Multi Step']); -\atk4\ui\Icon::addTo($specialItem, ['content' => 'window maximize outline']); +$specialItem = Factory::factory([\Atk4\Ui\View::class], ['id' => false, 'class' => ['item'], 'content' => 'Multi Step']); +\Atk4\Ui\Icon::addTo($specialItem, ['content' => 'window maximize outline']); $grid->ipp = 10; diff --git a/demos/db.default.php b/demos/db.default.php index 8658f836fd..e64ebf681d 100644 --- a/demos/db.default.php +++ b/demos/db.default.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; // to use MySQL database: // 1. copy this file to "db.php" // 2. uncomment the line below (and update the configuration if needed) // 3. remove the Sqlite code from the new file -// $db = new \atk4\data\Persistence\Sql('mysql:dbname=atk4_test__ui;host=mysql', 'atk4_test', 'atk4_pass'); +// $db = new \Atk4\Data\Persistence\Sql('mysql:dbname=atk4_test__ui;host=mysql', 'atk4_test', 'atk4_pass'); $sqliteFile = __DIR__ . '/_demo-data/db.sqlite'; if (!file_exists($sqliteFile)) { throw new \Exception('Sqlite database does not exist, create it first.'); } -$db = new \atk4\data\Persistence\Sql('sqlite:' . $sqliteFile); +$db = new \Atk4\Data\Persistence\Sql('sqlite:' . $sqliteFile); unset($sqliteFile); diff --git a/demos/form-control/calendar.php b/demos/form-control/calendar.php index 74711da686..72c587f557 100644 --- a/demos/form-control/calendar.php +++ b/demos/form-control/calendar.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; -use atk4\ui\GridLayout; -use atk4\ui\JsExpression; -use atk4\ui\JsFunction; -use atk4\ui\JsToast; +use Atk4\Ui\Form; +use Atk4\Ui\GridLayout; +use Atk4\Ui\JsExpression; +use Atk4\Ui\JsFunction; +use Atk4\Ui\JsToast; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $layout = GridLayout::addTo($app, ['rows' => 1, 'columns' => 2]); diff --git a/demos/form-control/checkbox.php b/demos/form-control/checkbox.php index 705d503e09..035ea08b9e 100644 --- a/demos/form-control/checkbox.php +++ b/demos/form-control/checkbox.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; -use atk4\ui\View; +use Atk4\Ui\Form; +use Atk4\Ui\View; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; // Testing fields. -\atk4\ui\Header::addTo($app, ['CheckBoxes', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['CheckBoxes', 'size' => 2]); Form\Control\Checkbox::addTo($app, ['Make my profile visible']); Form\Control\Checkbox::addTo($app, ['Make my profile visible ticked'])->set(true); @@ -28,14 +28,14 @@ View::addTo($app, ['ui' => 'divider']); Form\Control\Checkbox::addTo($app, ['Custom setting?'])->js(true)->checkbox('set indeterminate'); -\atk4\ui\Header::addTo($app, ['CheckBoxes in a form', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['CheckBoxes in a form', 'size' => 2]); $form = Form::addTo($app); $form->addControl('test', [Form\Control\Checkbox::class]); $form->addControl('test_checked', [Form\Control\Checkbox::class])->set(true); $form->addControl('also_checked', 'Hello World', 'boolean')->set(true); $form->onSubmit(function ($f) use ($app) { - return new \atk4\ui\JsToast($app->encodeJson($f->model->get())); + return new \Atk4\Ui\JsToast($app->encodeJson($f->model->get())); }); View::addTo($app, ['ui' => 'divider']); diff --git a/demos/form-control/dropdown-plus.php b/demos/form-control/dropdown-plus.php index 2602707174..ad1d077901 100644 --- a/demos/form-control/dropdown-plus.php +++ b/demos/form-control/dropdown-plus.php @@ -2,20 +2,20 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\data\Model; -use atk4\ui\Form; +use Atk4\Data\Model; +use Atk4\Ui\Form; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $demo = Demo::addTo($app); -\atk4\ui\Header::addTo($demo->left, ['Dropdown sample:']); -\atk4\ui\Header::addTo($demo->right, ['Cascading Dropdown']); +\Atk4\Ui\Header::addTo($demo->left, ['Dropdown sample:']); +\Atk4\Ui\Header::addTo($demo->right, ['Cascading Dropdown']); -$txt = \atk4\ui\Text::addTo($demo->right); +$txt = \Atk4\Ui\Text::addTo($demo->right); $txt->addParagraph('Dropdown may also be used in a cascade manner.'); $form = Form::addTo($demo->right); @@ -26,7 +26,7 @@ $form->onSubmit(function (Form $form) use ($app) { $message = $app->encodeJson($form->model->get()); - $view = new \atk4\ui\Message('Values: '); + $view = new \Atk4\Ui\Message('Values: '); $view->invokeInit(); $view->text->addParagraph($message); @@ -114,7 +114,7 @@ $form->onSubmit(function (Form $form) use ($app) { $message = $app->encodeJson($form->model->get()); - $view = new \atk4\ui\Message('Values: '); + $view = new \Atk4\Ui\Message('Values: '); $view->invokeInit(); $view->text->addParagraph($message); diff --git a/demos/form-control/form6.php b/demos/form-control/form6.php index 87d2ac5525..222a53f557 100644 --- a/demos/form-control/form6.php +++ b/demos/form-control/form6.php @@ -2,20 +2,20 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; -use atk4\ui\JsToast; +use Atk4\Ui\Form; +use Atk4\Ui\JsToast; -/** @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, [ 'Forms below demonstrate how to work with multi-value selectors', 'ui' => 'ignored warning message', ]); -$cc = \atk4\ui\Columns::addTo($app); +$cc = \Atk4\Ui\Columns::addTo($app); $form = Form::addTo($cc->addColumn()); $form->addControl('one', null, ['enum' => ['female', 'male']])->set('male'); diff --git a/demos/form-control/input.php b/demos/form-control/input.php index bee2be6085..bdc6290842 100644 --- a/demos/form-control/input.php +++ b/demos/form-control/input.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; +use Atk4\Ui\Form; /** * Testing fields. */ -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; -\atk4\ui\Header::addTo($app, ['Types', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Types', 'size' => 2]); Form\Control\Line::addTo($app)->setDefaults(['placeholder' => 'Search']); Form\Control\Line::addTo($app, ['placeholder' => 'Search', 'loading' => true]); @@ -20,84 +20,84 @@ Form\Control\Line::addTo($app, ['placeholder' => 'Search', 'icon' => 'search', 'disabled' => true]); Form\Control\Line::addTo($app, ['placeholder' => 'Search', 'error' => true]); -\atk4\ui\Header::addTo($app, ['Icon Variations', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Icon Variations', 'size' => 2]); Form\Control\Line::addTo($app, ['placeholder' => 'Search users', 'left' => true, 'icon' => 'users']); Form\Control\Line::addTo($app, ['placeholder' => 'Search users', 'icon' => 'circular search link']); Form\Control\Line::addTo($app, ['placeholder' => 'Search users', 'icon' => 'inverted circular search link']); -\atk4\ui\Header::addTo($app, ['Labels', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Labels', 'size' => 2]); Form\Control\Line::addTo($app, ['placeholder' => 'Search users', 'label' => 'http://']); // dropdown example -$dd = new \atk4\ui\Dropdown('.com'); +$dd = new \Atk4\Ui\Dropdown('.com'); $dd->setSource(['.com', '.net', '.org']); Form\Control\Line::addTo($app, [ 'placeholder' => 'Find Domain', 'labelRight' => $dd, ]); -Form\Control\Line::addTo($app, ['placeholder' => 'Weight', 'labelRight' => new \atk4\ui\Label(['kg', 'basic'])]); -Form\Control\Line::addTo($app, ['label' => '$', 'labelRight' => new \atk4\ui\Label(['.00', 'basic'])]); +Form\Control\Line::addTo($app, ['placeholder' => 'Weight', 'labelRight' => new \Atk4\Ui\Label(['kg', 'basic'])]); +Form\Control\Line::addTo($app, ['label' => '$', 'labelRight' => new \Atk4\Ui\Label(['.00', 'basic'])]); Form\Control\Line::addTo($app, [ 'iconLeft' => 'tags', - 'labelRight' => new \atk4\ui\Label(['Add Tag', 'tag']), + 'labelRight' => new \Atk4\Ui\Label(['Add Tag', 'tag']), ]); // left/right corner is not supported, but here is work-around: -$label = new \atk4\ui\Label(); +$label = new \Atk4\Ui\Label(); $label->addClass('left corner'); -\atk4\ui\Icon::addTo($label, ['asterisk']); +\Atk4\Ui\Icon::addTo($label, ['asterisk']); Form\Control\Line::addTo($app, [ 'label' => $label, ])->addClass('left corner'); -$label = new \atk4\ui\Label(); +$label = new \Atk4\Ui\Label(); $label->addClass('corner'); -\atk4\ui\Icon::addTo($label, ['asterisk']); +\Atk4\Ui\Icon::addTo($label, ['asterisk']); Form\Control\Line::addTo($app, [ 'label' => $label, ])->addClass('corner'); -\atk4\ui\Header::addTo($app, ['Actions', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Actions', 'size' => 2]); Form\Control\Line::addTo($app, ['action' => 'Search']); -Form\Control\Line::addTo($app, ['actionLeft' => new \atk4\ui\Button([ +Form\Control\Line::addTo($app, ['actionLeft' => new \Atk4\Ui\Button([ 'Checkout', 'icon' => 'cart', 'teal', ])]); Form\Control\Line::addTo($app, ['iconLeft' => 'search', 'action' => 'Search']); -$dd = new \atk4\ui\DropdownButton(['This Page', 'basic']); +$dd = new \Atk4\Ui\DropdownButton(['This Page', 'basic']); $dd->setSource(['This Organisation', 'Entire Site']); Form\Control\Line::addTo($app, ['iconLeft' => 'search', 'action' => $dd]); // double actions are not supported but you can add them yourself -$dd = new \atk4\ui\Dropdown(['Articles', 'compact selection']); +$dd = new \Atk4\Ui\Dropdown(['Articles', 'compact selection']); $dd->setSource(['All', 'Services', 'Products']); -\atk4\ui\Button::addTo(Form\Control\Line::addTo($app, ['iconLeft' => 'search', 'action' => $dd]), ['Search'], ['AfterAfterInput']); +\Atk4\Ui\Button::addTo(Form\Control\Line::addTo($app, ['iconLeft' => 'search', 'action' => $dd]), ['Search'], ['AfterAfterInput']); -Form\Control\Line::addTo($app, ['action' => new \atk4\ui\Button([ +Form\Control\Line::addTo($app, ['action' => new \Atk4\Ui\Button([ 'Copy', 'iconRight' => 'copy', 'teal', ])]); -Form\Control\Line::addTo($app, ['action' => new \atk4\ui\Button([ +Form\Control\Line::addTo($app, ['action' => new \Atk4\Ui\Button([ 'icon' => 'search', ])]); -\atk4\ui\Header::addTo($app, ['Modifiers', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Modifiers', 'size' => 2]); Form\Control\Line::addTo($app, ['icon' => 'search', 'transparent' => true, 'placeholder' => 'transparent']); Form\Control\Line::addTo($app, ['icon' => 'search', 'fluid' => true, 'placeholder' => 'fluid']); Form\Control\Line::addTo($app, ['icon' => 'search', 'mini' => true, 'placeholder' => 'mini']); -\atk4\ui\Header::addTo($app, ['Custom HTML attributes for tag', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Custom HTML attributes for tag', 'size' => 2]); $l = Form\Control\Line::addTo($app, ['placeholder' => 'maxlength attribute set to 10']); $l->setInputAttr('maxlength', '10'); $l = Form\Control\Line::addTo($app, ['fluid' => true, 'placeholder' => 'overwrite existing attribute (type="number")']); diff --git a/demos/form-control/input2.php b/demos/form-control/input2.php index d824b29323..af2e907398 100644 --- a/demos/form-control/input2.php +++ b/demos/form-control/input2.php @@ -2,19 +2,19 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Button; -use atk4\ui\Form; -use atk4\ui\HtmlTemplate; +use Atk4\Ui\Button; +use Atk4\Ui\Form; +use Atk4\Ui\HtmlTemplate; /** * Demonstrates how to use fields with form. */ -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; -\atk4\ui\Header::addTo($app, ['Disabled and read only form controls (normal / readonly / disabled)']); +\Atk4\Ui\Header::addTo($app, ['Disabled and read only form controls (normal / readonly / disabled)']); $form = Form::addTo($app); @@ -103,16 +103,16 @@ $form->onSubmit(function (Form $form) { }); -\atk4\ui\Header::addTo($app, ['Stand Alone Line']); +\Atk4\Ui\Header::addTo($app, ['Stand Alone Line']); // you can pass values to button $control = Form\Control\Line::addTo($app); $control->set('hello world'); $button = $control->addAction('check value'); -$button->on('click', new \atk4\ui\JsExpression('alert("field value is: "+[])', [$control->jsInput()->val()])); +$button->on('click', new \Atk4\Ui\JsExpression('alert("field value is: "+[])', [$control->jsInput()->val()])); -\atk4\ui\Header::addTo($app, ['Line in a Form']); +\Atk4\Ui\Header::addTo($app, ['Line in a Form']); $form = Form::addTo($app); $control = $form->addControl('Title', null, ['values' => ['Mr', 'Mrs', 'Miss'], 'ui' => ['hint' => 'select one']]); @@ -121,7 +121,7 @@ $control->set('value in a form'); $control = $form->addControl('surname', new Form\Control\Line([ - 'hint' => [\atk4\ui\View::class, 'template' => new HtmlTemplate( + 'hint' => [\Atk4\Ui\View::class, 'template' => new HtmlTemplate( 'Click here' )], ])); @@ -130,11 +130,11 @@ return $form->model->get('name'); }); -\atk4\ui\Header::addTo($app, ['Multiple Form Layouts']); +\Atk4\Ui\Header::addTo($app, ['Multiple Form Layouts']); $form = Form::addTo($app); -$tabs = \atk4\ui\Tabs::addTo($form, [], ['AboveControls']); -\atk4\ui\View::addTo($form, ['ui' => 'divider'], ['AboveControls']); +$tabs = \Atk4\Ui\Tabs::addTo($form, [], ['AboveControls']); +\Atk4\Ui\View::addTo($form, ['ui' => 'divider'], ['AboveControls']); $formPage = Form\Layout::addTo($tabs->addTab('Basic Info'), ['form' => $form]); $formPage->addControl('name', new Form\Control\Line()); @@ -146,7 +146,7 @@ return $form->model->get('name') . ' has age ' . $form->model->get('age'); }); -\atk4\ui\Header::addTo($app, ['onChange event', 'subHeader' => 'see in browser console']); +\Atk4\Ui\Header::addTo($app, ['onChange event', 'subHeader' => 'see in browser console']); $form = Form::addTo($app); @@ -156,10 +156,10 @@ $c3 = $group->addControl('c3', new Form\Control\Calendar(['type' => 'date'])); $c1->onChange('console.log("c1 changed: "+date+","+text+","+mode)'); -$c2->onChange(new \atk4\ui\JsExpression('console.log("c2 changed: "+date+","+text+","+mode)')); +$c2->onChange(new \Atk4\Ui\JsExpression('console.log("c2 changed: "+date+","+text+","+mode)')); $c3->onChange([ - new \atk4\ui\JsExpression('console.log("c3 changed: "+date+","+text+","+mode)'), - new \atk4\ui\JsExpression('console.log("c3 really changed: "+date+","+text+","+mode)'), + new \Atk4\Ui\JsExpression('console.log("c3 changed: "+date+","+text+","+mode)'), + new \Atk4\Ui\JsExpression('console.log("c3 really changed: "+date+","+text+","+mode)'), ]); $group = $form->addGroup('Line'); @@ -169,13 +169,13 @@ $f4 = $group->addControl('f4'); $f1->onChange('console.log("f1 changed")'); -$f2->onChange(new \atk4\ui\JsExpression('console.log("f2 changed")')); +$f2->onChange(new \Atk4\Ui\JsExpression('console.log("f2 changed")')); $f3->onChange([ - new \atk4\ui\JsExpression('console.log("f3 changed")'), - new \atk4\ui\JsExpression('console.log("f3 really changed")'), + new \Atk4\Ui\JsExpression('console.log("f3 changed")'), + new \Atk4\Ui\JsExpression('console.log("f3 really changed")'), ]); $f4->onChange(function () { - return new \atk4\ui\JsExpression('console.log("f4 changed")'); + return new \Atk4\Ui\JsExpression('console.log("f4 changed")'); }); $group = $form->addGroup('CheckBox'); @@ -202,7 +202,7 @@ ])); $r1->onChange('console.log("radio changed")'); -\atk4\ui\Header::addTo($app, ['Line ends of Textarea']); +\Atk4\Ui\Header::addTo($app, ['Line ends of Textarea']); $form = Form::addTo($app); $group = $form->addGroup('Without model'); diff --git a/demos/form-control/lookup-dep.php b/demos/form-control/lookup-dep.php index 0fd9feb311..09d52f69cc 100644 --- a/demos/form-control/lookup-dep.php +++ b/demos/form-control/lookup-dep.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; +use Atk4\Ui\Form; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; -\atk4\ui\Header::addTo($app, ['Lookup dependency']); +\Atk4\Ui\Header::addTo($app, ['Lookup dependency']); $form = Form::addTo($app, ['segment']); -\atk4\ui\Label::addTo($form, ['Input information here', 'top attached'], ['AboveControls']); +\Atk4\Ui\Label::addTo($form, ['Input information here', 'top attached'], ['AboveControls']); $form->addControl('starts_with', [ Form\Control\Dropdown::class, @@ -50,10 +50,10 @@ return 'Submitted: ' . print_r($form->model->get(), true); }); -\atk4\ui\Header::addTo($app, ['Lookup multiple values']); +\Atk4\Ui\Header::addTo($app, ['Lookup multiple values']); $form = Form::addTo($app, ['segment']); -\atk4\ui\Label::addTo($form, ['Input information here', 'top attached'], ['AboveControls']); +\Atk4\Ui\Label::addTo($form, ['Input information here', 'top attached'], ['AboveControls']); $form->addControl('ends_with', [ Form\Control\Dropdown::class, diff --git a/demos/form-control/lookup.php b/demos/form-control/lookup.php index 4f25e6d306..d3460851ac 100644 --- a/demos/form-control/lookup.php +++ b/demos/form-control/lookup.php @@ -2,23 +2,23 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; +use Atk4\Ui\Form; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; // create header -\atk4\ui\Header::addTo($app, ['Lookup Input']); +\Atk4\Ui\Header::addTo($app, ['Lookup Input']); Form\Control\Lookup::addTo($app, ['placeholder' => 'Search country', 'label' => 'Country: '])->setModel(new Country($app->db)); // create form $form = Form::addTo($app, ['segment']); -\atk4\ui\Label::addTo($form, ['Lookup countries', 'top attached'], ['AboveControls']); +\Atk4\Ui\Label::addTo($form, ['Lookup countries', 'top attached'], ['AboveControls']); -$model = new \atk4\data\Model($app->db, 'test'); +$model = new \Atk4\Data\Model($app->db, 'test'); // Without Lookup $model->hasOne('country1', new Country()); @@ -40,40 +40,40 @@ $form->onSubmit(function (Form $form) { $str = $form->model->ref('country1')->get('name') . ' ' . $form->model->ref('country2')->get('name') . ' ' . (new Country($form->getApp()->db))->tryLoad($form->model->get('country3'))->get('name'); - $view = new \atk4\ui\Message('Select:'); // need in behat test. + $view = new \Atk4\Ui\Message('Select:'); // need in behat test. $view->invokeInit(); $view->text->addParagraph($str); return $view; }); -\atk4\ui\Header::addTo($app, ['Lookup input using label']); +\Atk4\Ui\Header::addTo($app, ['Lookup input using label']); // from seed Form\Control\Lookup::addTo($app, ['placeholder' => 'Search country', 'label' => 'Country: '])->setModel(new Country($app->db)); // through constructor -Form\Control\Lookup::addTo($app, ['placeholder' => 'Weight', 'labelRight' => new \atk4\ui\Label(['kg', 'basic'])]); -Form\Control\Lookup::addTo($app, ['label' => '$', 'labelRight' => new \atk4\ui\Label(['.00', 'basic'])]); +Form\Control\Lookup::addTo($app, ['placeholder' => 'Weight', 'labelRight' => new \Atk4\Ui\Label(['kg', 'basic'])]); +Form\Control\Lookup::addTo($app, ['label' => '$', 'labelRight' => new \Atk4\Ui\Label(['.00', 'basic'])]); Form\Control\Lookup::addTo($app, [ 'iconLeft' => 'tags', - 'labelRight' => new \atk4\ui\Label(['Add Tag', 'tag']), + 'labelRight' => new \Atk4\Ui\Label(['Add Tag', 'tag']), ]); // left/right corner is not supported, but here is work-around: -$label = new \atk4\ui\Label(); +$label = new \Atk4\Ui\Label(); $label->addClass('left corner'); -\atk4\ui\Icon::addTo($label, ['asterisk']); +\Atk4\Ui\Icon::addTo($label, ['asterisk']); Form\Control\Lookup::addTo($app, [ 'label' => $label, ])->addClass('left corner'); -\atk4\ui\Header::addTo($app, ['Lookup input inside modal']); +\Atk4\Ui\Header::addTo($app, ['Lookup input inside modal']); -$modal = \atk4\ui\Modal::addTo($app)->set(function ($p) { +$modal = \Atk4\Ui\Modal::addTo($app)->set(function ($p) { $a = Form\Control\Lookup::addTo($p, ['placeholder' => 'Search country', 'label' => 'Country: ']); $a->setModel(new Country($p->getApp()->db)); }); -\atk4\ui\Button::addTo($app, ['Open Lookup on a Modal window'])->on('click', $modal->show()); +\Atk4\Ui\Button::addTo($app, ['Open Lookup on a Modal window'])->on('click', $modal->show()); diff --git a/demos/form-control/multiline.php b/demos/form-control/multiline.php index ccb85c9e55..6547932330 100644 --- a/demos/form-control/multiline.php +++ b/demos/form-control/multiline.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\data\Model; -use atk4\data\Persistence; -use atk4\ui\Form; -use atk4\ui\Header; -use atk4\ui\JsExpression; -use atk4\ui\JsFunction; +use Atk4\Data\Model; +use Atk4\Data\Persistence; +use Atk4\Ui\Form; +use Atk4\Ui\Header; +use Atk4\Ui\JsExpression; +use Atk4\Ui\JsFunction; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; Header::addTo($app, ['Multiline form control', 'icon' => 'database', 'subHeader' => 'Collect/Edit multiple rows of table record.']); @@ -103,5 +103,5 @@ function ($v) { $form->onSubmit(function (Form $form) use ($multiline) { $rows = $multiline->saveRows()->getModel()->export(); - return new \atk4\ui\JsToast($form->getApp()->encodeJson(array_values($rows))); + return new \Atk4\Ui\JsToast($form->getApp()->encodeJson(array_values($rows))); }); diff --git a/demos/form-control/scope-builder.php b/demos/form-control/scope-builder.php index e9236db6dd..8e678ea02a 100644 --- a/demos/form-control/scope-builder.php +++ b/demos/form-control/scope-builder.php @@ -2,18 +2,18 @@ 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, ['caption' => 'Demo Stat']); $model->addCondition('finish_time', '=', '22:12:00'); $model->addCondition('start_date', '=', '2020-10-22'); -$form = \atk4\ui\Form::addTo($app); +$form = \Atk4\Ui\Form::addTo($app); -$form->addControl('qb', [\atk4\ui\Form\Control\ScopeBuilder::class, 'model' => $model, 'options' => ['debug' => true]]); +$form->addControl('qb', [\Atk4\Ui\Form\Control\ScopeBuilder::class, 'model' => $model, 'options' => ['debug' => true]]); $form->onSubmit(function ($form) use ($model) { return "Scope selected:\n\n" . $form->model->get('qb')->toWords($model); diff --git a/demos/form-control/tree-item-selector.php b/demos/form-control/tree-item-selector.php index 228b2a9d58..9a456aa4cb 100644 --- a/demos/form-control/tree-item-selector.php +++ b/demos/form-control/tree-item-selector.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; -use atk4\ui\JsToast; +use Atk4\Ui\Form; +use Atk4\Ui\JsToast; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $items = [ @@ -35,14 +35,14 @@ ['name' => 'Appliances', 'id' => 301, 'nodes' => []], ]; -\atk4\ui\Header::addTo($app, ['Tree item selector']); +\Atk4\Ui\Header::addTo($app, ['Tree item selector']); $form = Form::addTo($app); $control = $form->addControl('tree', [Form\Control\TreeItemSelector::class, 'treeItems' => $items, 'caption' => 'Multiple selection:'], ['type' => 'array', 'serialize' => 'json']); $control->set($app->encodeJson([201, 301, 503])); //$control->onItem(function($value) use ($app) { -// return new \atk4\ui\JsToast($app->encodeJson($value)); +// return new \Atk4\Ui\JsToast($app->encodeJson($value)); //}); $control = $form->addControl('tree1', [Form\Control\TreeItemSelector::class, 'treeItems' => $items, 'allowMultiple' => false, 'caption' => 'Single selection:']); @@ -58,7 +58,7 @@ 'single' => $form->model->get('tree1'), ]; - $view = new \atk4\ui\Message('Items: '); + $view = new \Atk4\Ui\Message('Items: '); $view->invokeInit(); $view->text->addParagraph($app->encodeJson($response)); diff --git a/demos/form-control/upload.php b/demos/form-control/upload.php index a3ff1f153f..e83b9d474f 100644 --- a/demos/form-control/upload.php +++ b/demos/form-control/upload.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; +use Atk4\Ui\Form; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; $form = Form::addTo($app); @@ -23,7 +23,7 @@ $img->onDelete(function ($fileId) use ($img) { $img->clearThumbnail('./images/default.png'); - return new \atk4\ui\JsToast([ + return new \Atk4\Ui\JsToast([ 'title' => 'Delete successfully', 'message' => $fileId . ' has been removed', 'class' => 'success', @@ -48,7 +48,7 @@ // return $form->error('file', 'Unable to upload file.'); // can also return a notifier. - return new \atk4\ui\JsToast([ + return new \Atk4\Ui\JsToast([ 'title' => 'Upload success', 'message' => 'Image is uploaded!', 'class' => 'success', @@ -56,7 +56,7 @@ }); $control->onDelete(function ($fileId) { - return new \atk4\ui\JsToast([ + return new \Atk4\Ui\JsToast([ 'title' => 'Delete successfully', 'message' => $fileId . ' has been removed', 'class' => 'success', @@ -69,7 +69,7 @@ } $control->setFileId('a_token'); - return new \atk4\ui\JsToast([ + return new \Atk4\Ui\JsToast([ 'title' => 'Upload success', 'message' => 'File is uploaded!', 'class' => 'success', diff --git a/demos/form/form-section-accordion.php b/demos/form/form-section-accordion.php index b7d87dc390..3e051d1cd8 100644 --- a/demos/form/form-section-accordion.php +++ b/demos/form/form-section-accordion.php @@ -2,22 +2,22 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; +use Atk4\Ui\Form; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; -\atk4\ui\Button::addTo($app, ['Form Sections', 'small left floated basic blue', 'icon' => 'left arrow']) +\Atk4\Ui\Button::addTo($app, ['Form Sections', 'small left floated basic blue', 'icon' => 'left arrow']) ->link(['form-section']); -\atk4\ui\View::addTo($app, ['ui' => 'ui clearing divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'ui clearing divider']); $form = Form::addTo($app); -$sublayout = $form->layout->addSubLayout([\atk4\ui\Form\Layout\Section::class]); +$sublayout = $form->layout->addSubLayout([\Atk4\Ui\Form\Layout\Section::class]); -\atk4\ui\Header::addTo($sublayout, ['Please fill all form sections!', 'size' => 4]); +\Atk4\Ui\Header::addTo($sublayout, ['Please fill all form sections!', 'size' => 4]); $sublayout->addControl('company_name'); diff --git a/demos/form/form-section.php b/demos/form/form-section.php index e1321713ce..1ccf630ea3 100644 --- a/demos/form/form-section.php +++ b/demos/form/form-section.php @@ -2,23 +2,23 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; +use Atk4\Ui\Form; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; -\atk4\ui\Button::addTo($app, ['Accordion in Form', 'small right floated basic blue', 'iconRight' => 'right arrow']) +\Atk4\Ui\Button::addTo($app, ['Accordion in Form', 'small right floated basic blue', 'iconRight' => 'right arrow']) ->link(['form-section-accordion']); -\atk4\ui\View::addTo($app, ['ui' => 'ui clearing divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'ui clearing divider']); $model = new CountryLock($app->db); $model->loadAny(); // Prevent form from saving $noSave = function (Form $form) { - return new \atk4\ui\JsToast([ + return new \Atk4\Ui\JsToast([ 'title' => 'POSTed field values', 'message' => '
' . $form->getApp()->encodeJson($form->model->get()) . '
', 'class' => 'success', @@ -33,7 +33,7 @@ $sublayout = $form->layout->addSubLayout([Form\Layout\Section::class]); -\atk4\ui\Header::addTo($sublayout, ['Column Section in Form']); +\Atk4\Ui\Header::addTo($sublayout, ['Column Section in Form']); $sublayout->setModel($model, ['name']); $colsLayout = $form->layout->addSubLayout([Form\Layout\Section\Columns::class]); @@ -48,7 +48,7 @@ $form->onSubmit($noSave); -\atk4\ui\View::addTo($app, ['ui' => 'divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'divider']); //////////////////////////////// @@ -57,7 +57,7 @@ $sublayout = $form->layout->addSubLayout([Form\Layout\Section::class]); -\atk4\ui\Header::addTo($sublayout, ['Accordion Section in Form']); +\Atk4\Ui\Header::addTo($sublayout, ['Accordion Section in Form']); $sublayout->setModel($model, ['name']); $accordionLayout = $form->layout->addSubLayout([Form\Layout\Section\Accordion::class]); @@ -70,7 +70,7 @@ $form->onSubmit($noSave); -\atk4\ui\View::addTo($app, ['ui' => 'divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'divider']); //////////////////////////////// @@ -79,7 +79,7 @@ $sublayout = $form->layout->addSubLayout([Form\Layout\Section::class]); -\atk4\ui\Header::addTo($sublayout, ['Tabs in Form']); +\Atk4\Ui\Header::addTo($sublayout, ['Tabs in Form']); $sublayout->setModel($model, ['name']); $tabsLayout = $form->layout->addSubLayout([Form\Layout\Section\Tabs::class]); @@ -92,18 +92,18 @@ $form->onSubmit($noSave); -\atk4\ui\View::addTo($app, ['ui' => 'divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'divider']); ///////////////////////////////////////// -\atk4\ui\Header::addTo($app, ['Color in form']); +\Atk4\Ui\Header::addTo($app, ['Color in form']); $form = Form::addTo($app); $form->setModel($model, false); $sublayout = $form->layout->addSubLayout([Form\Layout\Section::class, 'ui' => 'segment red inverted'], false); -\atk4\ui\Header::addTo($sublayout, ['This section in Red', 'ui' => 'dividing header', 'element' => 'h2']); +\Atk4\Ui\Header::addTo($sublayout, ['This section in Red', 'ui' => 'dividing header', 'element' => 'h2']); $sublayout->setModel($model, ['name']); $sublayout = $form->layout->addSubLayout([Form\Layout\Section::class, 'ui' => 'segment teal inverted']); @@ -117,4 +117,4 @@ $form->onSubmit($noSave); -\atk4\ui\View::addTo($app, ['ui' => 'divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'divider']); diff --git a/demos/form/form.php b/demos/form/form.php index 3602d8a438..ee2fa284c7 100644 --- a/demos/form/form.php +++ b/demos/form/form.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; +use Atk4\Ui\Form; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; /** @@ -20,12 +20,12 @@ * This approach will also prevent your application from registering shutdown handler or catching error, * so we will need to do a bit of work about that too. */ -$tabs = \atk4\ui\Tabs::addTo($app); +$tabs = \Atk4\Ui\Tabs::addTo($app); //////////////////////////////////////////// $tab = $tabs->addTab('Basic Use'); -\atk4\ui\Header::addTo($tab, ['Very simple form']); +\Atk4\Ui\Header::addTo($tab, ['Very simple form']); $form = Form::addTo($tab); $form->addControl('email'); @@ -38,7 +38,7 @@ $form->buttonSave->set('Subscribe'); $form->buttonSave->icon = 'mail'; -\atk4\ui\Header::addTo($tab, ['But very flexible']); +\Atk4\Ui\Header::addTo($tab, ['But very flexible']); $form = Form::addTo($tab); $group = $form->addGroup(['width' => 'three']); @@ -57,10 +57,10 @@ $form->addControl('status_integer_mandatory', [Form\Control\Dropdown::class], ['type' => 'integer', 'values' => $values, 'mandatory' => true]); $form->onSubmit(function (Form $form) use ($app) { - return new \atk4\ui\JsToast($app->encodeJson($form->model->get())); + return new \Atk4\Ui\JsToast($app->encodeJson($form->model->get())); }); -\atk4\ui\Header::addTo($tab, ['Comparing Field type vs Form control class']); +\Atk4\Ui\Header::addTo($tab, ['Comparing Field type vs Form control class']); $form = Form::addTo($tab); $form->addControl('field', null, ['type' => 'date', 'caption' => 'Date using model field:']); $form->addControl('control', [Form\Control\Calendar::class, 'type' => 'date', 'caption' => 'Date using form control: ']); @@ -68,7 +68,7 @@ $form->onSubmit(function (Form $form) { $message = 'field = ' . print_r($form->model->get('field'), true) . ';
control = ' . print_r($form->model->get('control'), true); - $view = new \atk4\ui\Message('Date field vs control:'); + $view = new \Atk4\Ui\Message('Date field vs control:'); $view->invokeInit(); $view->text->addHTML($message); @@ -78,7 +78,7 @@ //////////////////////////////////////////////////////////// $tab = $tabs->addTab('Handler Output'); -\atk4\ui\Header::addTo($tab, ['Form can respond with manually generated error']); +\Atk4\Ui\Header::addTo($tab, ['Form can respond with manually generated error']); $form = Form::addTo($tab); $form->addControl('email1'); $form->buttonSave->set('Save1'); @@ -86,7 +86,7 @@ return $form->error('email1', 'some error action ' . random_int(1, 100)); }); -\atk4\ui\Header::addTo($tab, ['..or success message']); +\Atk4\Ui\Header::addTo($tab, ['..or success message']); $form = Form::addTo($tab); $form->addControl('email2'); $form->buttonSave->set('Save2'); @@ -94,34 +94,34 @@ return $form->success('form was successful'); }); -\atk4\ui\Header::addTo($tab, ['Any other view can be output']); +\Atk4\Ui\Header::addTo($tab, ['Any other view can be output']); $form = Form::addTo($tab); $form->addControl('email3'); $form->buttonSave->set('Save3'); $form->onSubmit(function (Form $form) { - $view = new \atk4\ui\Message('some header'); + $view = new \Atk4\Ui\Message('some header'); $view->invokeInit(); $view->text->addParagraph('some text ' . random_int(1, 100)); return $view; }); -\atk4\ui\Header::addTo($tab, ['Modal can be output directly']); +\Atk4\Ui\Header::addTo($tab, ['Modal can be output directly']); $form = Form::addTo($tab); $form->addControl('email4'); $form->buttonSave->set('Save4'); $form->onSubmit(function (Form $form) { - $view = new \atk4\ui\Message('some header'); + $view = new \Atk4\Ui\Message('some header'); $view->invokeInit(); $view->text->addParagraph('some text ' . random_int(1, 100)); - $modal = new \atk4\ui\Modal(['title' => 'Something happen', 'ui' => 'ui modal tiny']); + $modal = new \Atk4\Ui\Modal(['title' => 'Something happen', 'ui' => 'ui modal tiny']); $modal->add($view); return $modal; }); -\atk4\ui\Header::addTo($tab, ['jsAction can be used too']); +\Atk4\Ui\Header::addTo($tab, ['jsAction can be used too']); $form = Form::addTo($tab); $control = $form->addControl('email5'); $form->buttonSave->set('Save5'); @@ -132,7 +132,7 @@ ///////////////////////////////////////////////////////////////////// $tab = $tabs->addTab('Handler Safety'); -\atk4\ui\Header::addTo($tab, ['Form handles errors (PHP 7.0+)', 'size' => 2]); +\Atk4\Ui\Header::addTo($tab, ['Form handles errors (PHP 7.0+)', 'size' => 2]); $form = Form::addTo($tab); $form->addControl('email'); @@ -142,23 +142,23 @@ return $o['abc']; }); -\atk4\ui\Header::addTo($tab, ['Form shows Agile exceptions', 'size' => 2]); +\Atk4\Ui\Header::addTo($tab, ['Form shows Agile exceptions', 'size' => 2]); $form = Form::addTo($tab); $form->addControl('email'); $form->onSubmit(function (Form $form) { - throw (new \atk4\core\Exception('testing')) + throw (new \Atk4\Core\Exception('testing')) ->addMoreInfo('arg1', 'val1'); return 'somehow it did not crash'; }); -\atk4\ui\Button::addTo($form, ['Modal Test', 'secondary'])->on('click', \atk4\ui\Modal::addTo($form) +\Atk4\Ui\Button::addTo($form, ['Modal Test', 'secondary'])->on('click', \Atk4\Ui\Modal::addTo($form) ->set(function ($p) { $form = Form::addTo($p); $form->addControl('email'); $form->onSubmit(function (Form $form) { - throw (new \atk4\core\Exception('testing')) + throw (new \Atk4\Core\Exception('testing')) ->addMoreInfo('arg1', 'val1'); return 'somehow it did not crash'; @@ -168,9 +168,9 @@ ///////////////////////////////////////////////////////////////////// $tab = $tabs->addTab('Complex Examples'); -\atk4\ui\Header::addTo($tab, ['Conditional response']); +\Atk4\Ui\Header::addTo($tab, ['Conditional response']); -$modelRegister = new \atk4\data\Model(new \atk4\data\Persistence\Array_()); +$modelRegister = new \Atk4\Data\Model(new \Atk4\Data\Persistence\Array_()); $modelRegister->addField('name'); $modelRegister->addField('email'); $modelRegister->addField('is_accept_terms', ['type' => 'boolean', 'mandatory' => true]); @@ -192,10 +192,10 @@ //////////////////////////////////////// $tab = $tabs->addTab('Layout Control'); -\atk4\ui\Header::addTo($tab, ['Shows example of grouping and multiple errors']); +\Atk4\Ui\Header::addTo($tab, ['Shows example of grouping and multiple errors']); $form = Form::addTo($tab, ['segment']); -$form->setModel(new \atk4\data\Model()); +$form->setModel(new \Atk4\Data\Model()); $form->addHeader('Example fields added one-by-one'); $form->addControl('name'); diff --git a/demos/form/form2.php b/demos/form/form2.php index 401960a8bc..1b28f73724 100644 --- a/demos/form/form2.php +++ b/demos/form/form2.php @@ -2,24 +2,24 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; +use Atk4\Ui\Form; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; // Testing form. // create header -\atk4\ui\Header::addTo($app, ['Database-driven form with an enjoyable layout']); +\Atk4\Ui\Header::addTo($app, ['Database-driven form with an enjoyable layout']); // create form $form = Form::addTo($app, ['segment']); //$form = Form::addTo($app, ['segment', 'buttonSave'=>false]); -//$form = Form::addTo($app, ['segment', 'buttonSave'=>new \atk4\ui\Button(['Import', 'secondary', 'iconRight'=>'list'])]); +//$form = Form::addTo($app, ['segment', 'buttonSave'=>new \Atk4\Ui\Button(['Import', 'secondary', 'iconRight'=>'list'])]); //$form = Form::addTo($app, ['segment', 'buttonSave'=>[null, 'Import', 'secondary', 'iconRight'=>'list']]); -\atk4\ui\Label::addTo($form, ['Input new country information here', 'top attached'], ['AboveControls']); +\Atk4\Ui\Label::addTo($form, ['Input new country information here', 'top attached'], ['AboveControls']); $form->setModel(new Country($app->db), false); @@ -74,8 +74,8 @@ // ====== -/** @var \atk4\data\Model $personClass */ -$personClass = get_class(new class() extends \atk4\data\Model { +/** @var \Atk4\Data\Model $personClass */ +$personClass = get_class(new class() extends \Atk4\Data\Model { public $table = 'person'; protected function init(): void diff --git a/demos/form/form3.php b/demos/form/form3.php index ad71677c3f..ec5eb3dc2b 100644 --- a/demos/form/form3.php +++ b/demos/form/form3.php @@ -2,27 +2,27 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; -use atk4\ui\JsReload; +use Atk4\Ui\Form; +use Atk4\Ui\JsReload; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; // Testing form. -\atk4\ui\Header::addTo($app, ['Form automatically decided how many columns to use']); +\Atk4\Ui\Header::addTo($app, ['Form automatically decided how many columns to use']); -$buttons = \atk4\ui\View::addTo($app, ['ui' => 'green basic buttons']); +$buttons = \Atk4\Ui\View::addTo($app, ['ui' => 'green basic buttons']); -$seg = \atk4\ui\View::addTo($app, ['ui' => 'raised segment']); +$seg = \Atk4\Ui\View::addTo($app, ['ui' => 'raised segment']); -\atk4\ui\Button::addTo($buttons, ['Use Country Model', 'icon' => 'arrow down']) +\Atk4\Ui\Button::addTo($buttons, ['Use Country Model', 'icon' => 'arrow down']) ->on('click', new JsReload($seg, ['m' => 'country'])); -\atk4\ui\Button::addTo($buttons, ['Use File Model', 'icon' => 'arrow down']) +\Atk4\Ui\Button::addTo($buttons, ['Use File Model', 'icon' => 'arrow down']) ->on('click', new JsReload($seg, ['m' => 'file'])); -\atk4\ui\Button::addTo($buttons, ['Use Stat Model', 'icon' => 'arrow down']) +\Atk4\Ui\Button::addTo($buttons, ['Use Stat Model', 'icon' => 'arrow down']) ->on('click', new JsReload($seg, ['m' => 'stat'])); $form = Form::addTo($seg, ['layout' => [Form\Layout\Columns::class]]); diff --git a/demos/form/form5.php b/demos/form/form5.php index b4b77cfedd..c00272f2ef 100644 --- a/demos/form/form5.php +++ b/demos/form/form5.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; -use atk4\ui\JsToast; +use Atk4\Ui\Form; +use Atk4\Ui\JsToast; -/** @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, [ 'Forms below focus on Data integration and automated layouts', 'ui' => 'ignored warning message', ]); @@ -19,7 +19,7 @@ return new JsToast($app->encodeJson($f->model->get())); }; -$cc = \atk4\ui\Columns::addTo($app); +$cc = \Atk4\Ui\Columns::addTo($app); $form = Form::addTo($cc->addColumn()); // adding field without model creates a regular line @@ -42,7 +42,7 @@ $form->onSubmit($formSubmit); -$model = new \atk4\data\Model(new \atk4\data\Persistence\Array_()); +$model = new \Atk4\Data\Model(new \Atk4\Data\Persistence\Array_()); // model field uses regular line form control by default $model->addField('one'); diff --git a/demos/form/html-layout.php b/demos/form/html-layout.php index 3d0873da5e..fd79449895 100644 --- a/demos/form/html-layout.php +++ b/demos/form/html-layout.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; -use atk4\ui\GridLayout; -use atk4\ui\Header; -use atk4\ui\Tabs; -use atk4\ui\View; +use Atk4\Ui\Form; +use Atk4\Ui\GridLayout; +use Atk4\Ui\Header; +use Atk4\Ui\Tabs; +use Atk4\Ui\View; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; Header::addTo($app, ['Display form using Html template', 'subHeader' => 'Fully control how to display fields.']); @@ -32,7 +32,7 @@ Header::addTo($right, ['Button on right']); $form = Form::addTo($right, ['layout' => [Form\Layout::class, 'defaultTemplate' => __DIR__ . '/templates/form-button-right.html']]); -$form->setModel(new Flyers(new \atk4\data\Persistence\Array_())); +$form->setModel(new Flyers(new \Atk4\Data\Persistence\Array_())); $form->getControl('last_name')->hint = 'Please enter your last name.'; $left = View::addTo($gridLayout, [], ['r1c2']); @@ -42,19 +42,19 @@ 'layout' => [ Form\Layout::class, ['defaultInputTemplate' => __DIR__ . '/templates/input.html', - 'defaultHint' => [\atk4\ui\Label::class, 'class' => ['pointing', 'below']], + 'defaultHint' => [\Atk4\Ui\Label::class, 'class' => ['pointing', 'below']], ], ], ]); -$form->setModel(new Flyers(new \atk4\data\Persistence\Array_())); +$form->setModel(new Flyers(new \Atk4\Data\Persistence\Array_())); $form->getControl('last_name')->hint = 'Please enter your last name.'; //////////////////////////////////////// $tab = $tabs->addTab('Custom layout class'); $form = Form::addTo($tab, ['layout' => [Form\Layout\Custom::class, 'defaultTemplate' => __DIR__ . '/templates/form-custom-layout.html']]); -$form->setModel(new \atk4\ui\demo\CountryLock($app->db))->loadAny(); +$form->setModel(new \Atk4\Ui\Demos\CountryLock($app->db))->loadAny(); $form->onSubmit(function ($form) { - return new \atk4\ui\JsToast('Saving is disabled'); + return new \Atk4\Ui\JsToast('Saving is disabled'); }); diff --git a/demos/form/jscondform.php b/demos/form/jscondform.php index ecefeff8a8..4cd50011fd 100644 --- a/demos/form/jscondform.php +++ b/demos/form/jscondform.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; +use Atk4\Ui\Form; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; ////////////////////////////////////////////////////////// -\atk4\ui\Header::addTo($app, ['Phone', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Phone', 'size' => 2]); $formPhone = Form::addTo($app, ['segment']); -\atk4\ui\Label::addTo($formPhone, ['Add other phone field input. Note: phone1 required a number of at least 5 char.', 'top attached'], ['AboveControls']); +\Atk4\Ui\Label::addTo($formPhone, ['Add other phone field input. Note: phone1 required a number of at least 5 char.', 'top attached'], ['AboveControls']); $formPhone->addControl('phone1'); $formPhone->addControl('phone2'); @@ -28,10 +28,10 @@ ]); ////////////////////////////////////////////////////////// -\atk4\ui\Header::addTo($app, ['Optional subscription', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Optional subscription', 'size' => 2]); $formSubscribe = Form::addTo($app, ['segment']); -\atk4\ui\Label::addTo($formSubscribe, ['Click on subscribe and add email to receive your gift.', 'top attached'], ['AboveControls']); +\Atk4\Ui\Label::addTo($formSubscribe, ['Click on subscribe and add email to receive your gift.', 'top attached'], ['AboveControls']); $formSubscribe->addControl('name'); $formSubscribe->addControl('subscribe', [Form\Control\Checkbox::class, 'Subscribe to weekly newsletter', 'toggle']); @@ -51,10 +51,10 @@ ]); ////////////////////////////////////////////////////////// -\atk4\ui\Header::addTo($app, ['Dog registration', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Dog registration', 'size' => 2]); $formDog = Form::addTo($app, ['segment']); -\atk4\ui\Label::addTo($formDog, ['You can select type of hair cut only with race that contains "poodle" AND age no more than 5 year OR your dog race equals "bichon".', 'top attached'], ['AboveControls']); +\Atk4\Ui\Label::addTo($formDog, ['You can select type of hair cut only with race that contains "poodle" AND age no more than 5 year OR your dog race equals "bichon".', 'top attached'], ['AboveControls']); $formDog->addControl('race', [Form\Control\Line::class]); $formDog->addControl('age'); $formDog->addControl('hair_cut', [Form\Control\Dropdown::class, 'values' => ['Short', 'Long']]); @@ -67,10 +67,10 @@ ]); ////////////////////////////////////////////////////////// -\atk4\ui\Header::addTo($app, ['Hide or show group', 'size' => 2]); +\Atk4\Ui\Header::addTo($app, ['Hide or show group', 'size' => 2]); $formGroup = Form::addTo($app, ['segment']); -\atk4\ui\Label::addTo($formGroup, ['Work on form group too.', 'top attached'], ['AboveControls']); +\Atk4\Ui\Label::addTo($formGroup, ['Work on form group too.', 'top attached'], ['AboveControls']); $groupBasic = $formGroup->addGroup(['Basic Information']); $groupBasic->addControl('first_name', ['width' => 'eight']); @@ -96,10 +96,10 @@ ////////////////////////////////////////////////////////// /* -\atk4\ui\Header::addTo($app, ['Hide or show accordion section', 'size'=>2]); +\Atk4\Ui\Header::addTo($app, ['Hide or show accordion section', 'size'=>2]); $f_acc = Form::addTo($app, ['segment']); -\atk4\ui\Label::addTo($f_acc, ['Work on section layouts too.', 'top attached'], ['AboveControls']); +\Atk4\Ui\Label::addTo($f_acc, ['Work on section layouts too.', 'top attached'], ['AboveControls']); // Accordion $accordion_layout = $f_acc->layout->addSubLayout([Form\Layout\Section\Accordion::class, 'type' => ['styled', 'fluid'], 'settings' => ['exclusive' => false]]); diff --git a/demos/index.php b/demos/index.php index 8ae1b983b9..77c2f747c4 100644 --- a/demos/index.php +++ b/demos/index.php @@ -2,23 +2,23 @@ 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)->set('Welcome to Agile Toolkit Demo!!'); +\Atk4\Ui\Header::addTo($app)->set('Welcome to Agile Toolkit Demo!!'); -$t = \atk4\ui\Text::addTo(\atk4\ui\View::addTo($app, [false, 'green', 'ui' => 'segment'])); +$t = \Atk4\Ui\Text::addTo(\Atk4\Ui\View::addTo($app, [false, 'green', 'ui' => 'segment'])); $t->addParagraph('Take a quick stroll through some of the amazing features of Agile Toolkit.'); -\atk4\ui\Button::addTo($app, ['Begin the demo..', 'huge primary fluid', 'iconRight' => 'right arrow']) +\Atk4\Ui\Button::addTo($app, ['Begin the demo..', 'huge primary fluid', 'iconRight' => 'right arrow']) ->link('tutorial/intro.php'); -\atk4\ui\Header::addTo($app)->set('What is new in Agile Toolkit 2.0'); +\Atk4\Ui\Header::addTo($app)->set('What is new in Agile Toolkit 2.0'); -$t = \atk4\ui\Text::addTo(\atk4\ui\View::addTo($app, [false, 'green', 'ui' => 'segment'])); +$t = \Atk4\Ui\Text::addTo(\Atk4\Ui\View::addTo($app, [false, 'green', 'ui' => 'segment'])); $t->addParagraph('In this version of Agile Toolkit we introduce "User Actions"!'); -\atk4\ui\Button::addTo($app, ['Learn about User Actions', 'huge basic primary fluid', 'iconRight' => 'right arrow']) +\Atk4\Ui\Button::addTo($app, ['Learn about User Actions', 'huge basic primary fluid', 'iconRight' => 'right arrow']) ->link('tutorial/actions.php'); diff --git a/demos/init-app.php b/demos/init-app.php index 791c2c5dbf..72bb3ea54c 100644 --- a/demos/init-app.php +++ b/demos/init-app.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; date_default_timezone_set('UTC'); @@ -14,7 +14,7 @@ \CoverageUtil::start(); } -$app = new \atk4\ui\App([ +$app = new \Atk4\Ui\App([ 'call_exit' => (bool) ($_GET['APP_CALL_EXIT'] ?? true), 'catch_exceptions' => (bool) ($_GET['APP_CATCH_EXCEPTIONS'] ?? true), 'always_run' => (bool) ($_GET['APP_ALWAYS_RUN'] ?? true), @@ -31,18 +31,18 @@ // collect coverage for HTTP tests 2/2 if (file_exists(__DIR__ . '/coverage.php') && !class_exists(\PHPUnit\Framework\TestCase::class, false)) { - $app->onHook(\atk4\ui\App::HOOK_BEFORE_EXIT, function () { + $app->onHook(\Atk4\Ui\App::HOOK_BEFORE_EXIT, function () { \CoverageUtil::saveData(); }); } try { - /** @var \atk4\data\Persistence\Sql $db */ + /** @var \Atk4\Data\Persistence\Sql $db */ require_once __DIR__ . '/init-db.php'; $app->db = $db; unset($db); } catch (\Throwable $e) { - throw new \atk4\ui\Exception('Database error: ' . $e->getMessage()); + throw new \Atk4\Ui\Exception('Database error: ' . $e->getMessage()); } [$rootUrl, $relUrl] = preg_split('~(?<=/)(?=demos(/|\?|$))|\?~s', $_SERVER['REQUEST_URI'], 3); @@ -53,10 +53,10 @@ } // allow custom layout override -$app->initLayout([$app->stickyGET('layout') ?? \atk4\ui\Layout\Maestro::class]); +$app->initLayout([$app->stickyGET('layout') ?? \Atk4\Ui\Layout\Maestro::class]); $layout = $app->layout; -if ($layout instanceof \atk4\ui\Layout\NavigableInterface) { +if ($layout instanceof \Atk4\Ui\Layout\NavigableInterface) { $layout->addMenuItem(['Welcome to Agile Toolkit', 'icon' => 'gift'], [$demosUrl . 'index']); $path = $demosUrl . 'layout/'; @@ -153,7 +153,7 @@ $layout->addMenuItem('Recursive Views', [$path . 'recursive'], $menu); // view demo source page on Github - \atk4\ui\Button::addTo($layout->menu->addItem()->addClass('aligned right'), ['View Source', 'teal', 'icon' => 'github']) + \Atk4\Ui\Button::addTo($layout->menu->addItem()->addClass('aligned right'), ['View Source', 'teal', 'icon' => 'github']) ->on('click', $app->jsRedirect('https://github.com/atk4/ui/blob/develop/' . $relUrl, true)); } unset($layout, $rootUrl, $relUrl, $demosUrl, $path, $menu); diff --git a/demos/init-autoloader.php b/demos/init-autoloader.php index 711557490e..c547202ae2 100644 --- a/demos/init-autoloader.php +++ b/demos/init-autoloader.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; $isRootProject = file_exists(__DIR__ . '/../vendor/autoload.php'); /** @var \Composer\Autoload\ClassLoader $loader */ $loader = require dirname(__DIR__, $isRootProject ? 1 : 4) . '/vendor/autoload.php'; -if (!$isRootProject && !class_exists(\atk4\ui\tests\ViewTest::class)) { +if (!$isRootProject && !class_exists(\Atk4\Ui\Tests\ViewTest::class)) { throw new \Error('Demos can be run only if atk4/ui is a root composer project or if dev files are autoloaded'); } -$loader->setPsr4('atk4\ui\demo\\', __DIR__ . '/_includes'); +$loader->setPsr4('Atk4\Ui\Demos\\', __DIR__ . '/_includes'); unset($isRootProject, $loader); diff --git a/demos/init-db.php b/demos/init-db.php index 7e2e739dca..d769b718b5 100644 --- a/demos/init-db.php +++ b/demos/init-db.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; +use Atk4\Ui\Form; try { if (file_exists(__DIR__ . '/db.php')) { @@ -14,7 +14,7 @@ } } catch (\PDOException $e) { // do not pass $e unless you can secure DSN! - throw (new \atk4\ui\Exception('This demo requires access to the database. See "demos/init-db.php"')) + throw (new \Atk4\Ui\Exception('This demo requires access to the database. See "demos/init-db.php"')) ->addMoreInfo('PDO error', $e->getMessage()); } @@ -40,7 +40,7 @@ public function lock(): void } } -class Country extends \atk4\data\Model +class Country extends \Atk4\Data\Model { public $table = 'country'; @@ -55,7 +55,7 @@ protected function init(): void $this->addField('numcode', ['caption' => 'ISO Numeric Code', 'type' => 'number', 'required' => true]); $this->addField('phonecode', ['caption' => 'Phone Prefix', 'type' => 'number', 'required' => true]); - $this->onHook(\atk4\data\Model::HOOK_BEFORE_SAVE, function (\atk4\data\Model $model) { + $this->onHook(\Atk4\Data\Model::HOOK_BEFORE_SAVE, function (\Atk4\Data\Model $model) { if (!$model->get('sys_name')) { $model->set('sys_name', mb_strtoupper($model->get('name'))); } @@ -98,7 +98,7 @@ protected function init(): void } } -class Stat extends \atk4\data\Model +class Stat extends \Atk4\Data\Model { public $table = 'stats'; public $title = 'Project Stat'; @@ -125,7 +125,7 @@ protected function init(): void $this->addField('is_commercial', ['type' => 'boolean']); $this->addField('currency', ['values' => ['EUR' => 'Euro', 'USD' => 'US Dollar', 'GBP' => 'Pound Sterling']]); $this->addField('currency_symbol', ['never_persist' => true]); - $this->onHook(\atk4\data\Model::HOOK_AFTER_LOAD, function (\atk4\data\Model $model) { + $this->onHook(\Atk4\Data\Model::HOOK_AFTER_LOAD, function (\Atk4\Data\Model $model) { /* implementation for "intl" $locale='en-UK'; $fmt = new \NumberFormatter( $locale."@currency=".$model->get('currency'), NumberFormatter::CURRENCY ); @@ -151,12 +151,12 @@ protected function init(): void } } -class Percent extends \atk4\data\Field +class Percent extends \Atk4\Data\Field { public $type = 'float'; // will need to be able to affect rendering and storage } -class File extends \atk4\data\Model +class File extends \Atk4\Data\Model { public $table = 'file'; @@ -234,7 +234,7 @@ protected function init(): void } } -class Category extends \atk4\data\Model +class Category extends \Atk4\Data\Model { public $table = 'product_category'; @@ -248,7 +248,7 @@ protected function init(): void } } -class SubCategory extends \atk4\data\Model +class SubCategory extends \Atk4\Data\Model { public $table = 'product_sub_category'; @@ -262,7 +262,7 @@ protected function init(): void } } -class Product extends \atk4\data\Model +class Product extends \Atk4\Data\Model { public $table = 'product'; diff --git a/demos/interactive/accordion-nested.php b/demos/interactive/accordion-nested.php index 958129eb90..a3ede69b74 100644 --- a/demos/interactive/accordion-nested.php +++ b/demos/interactive/accordion-nested.php @@ -2,34 +2,34 @@ 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, ['View Form input split in Accordion section', 'small right floated basic blue', 'iconRight' => 'right arrow']) +\Atk4\Ui\Button::addTo($app, ['View Form input split in Accordion section', 'small right floated basic blue', 'iconRight' => 'right arrow']) ->link(['accordion-in-form']); -\atk4\ui\View::addTo($app, ['ui' => 'clearing divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'clearing divider']); */ -\atk4\ui\Header::addTo($app, ['Nested accordions']); +\Atk4\Ui\Header::addTo($app, ['Nested accordions']); $addAccordionFunc = function ($view, $maxDepth = 2, $level = 0) use (&$addAccordionFunc) { - $accordion = \atk4\ui\Accordion::addTo($view, ['type' => ['styled', 'fluid']]); + $accordion = \Atk4\Ui\Accordion::addTo($view, ['type' => ['styled', 'fluid']]); // static section $i1 = $accordion->addSection('Static Text'); - \atk4\ui\Message::addTo($i1, ['This content is added on page loaded', 'ui' => 'tiny message']); - \atk4\ui\LoremIpsum::addTo($i1, ['size' => 1]); + \Atk4\Ui\Message::addTo($i1, ['This content is added on page loaded', 'ui' => 'tiny message']); + \Atk4\Ui\LoremIpsum::addTo($i1, ['size' => 1]); if ($level < $maxDepth) { $addAccordionFunc($i1, $maxDepth, $level + 1); } // dynamic section - simple view $i2 = $accordion->addSection('Dynamic Text', function ($v) use ($addAccordionFunc, $maxDepth, $level) { - \atk4\ui\Message::addTo($v, ['Every time you open this accordion item, you will see a different text', 'ui' => 'tiny message']); - \atk4\ui\LoremIpsum::addTo($v, ['size' => 2]); + \Atk4\Ui\Message::addTo($v, ['Every time you open this accordion item, you will see a different text', 'ui' => 'tiny message']); + \Atk4\Ui\LoremIpsum::addTo($v, ['size' => 2]); if ($level < $maxDepth) { $addAccordionFunc($v, $maxDepth, $level + 1); } @@ -37,10 +37,10 @@ // dynamic section - form view $i3 = $accordion->addSection('Dynamic Form', function ($v) use ($addAccordionFunc, $maxDepth, $level) { - \atk4\ui\Message::addTo($v, ['Loading a form dynamically.', 'ui' => 'tiny message']); - $form = \atk4\ui\Form::addTo($v); + \Atk4\Ui\Message::addTo($v, ['Loading a form dynamically.', 'ui' => 'tiny message']); + $form = \Atk4\Ui\Form::addTo($v); $form->addControl('Email'); - $form->onSubmit(function (\atk4\ui\Form $form) { + $form->onSubmit(function (\Atk4\Ui\Form $form) { return $form->success('Subscribed ' . $form->model->get('Email') . ' to newsletter.'); }); diff --git a/demos/interactive/accordion.php b/demos/interactive/accordion.php index 5c2739ac8a..d4046b921c 100644 --- a/demos/interactive/accordion.php +++ b/demos/interactive/accordion.php @@ -2,43 +2,43 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; +use Atk4\Ui\Form; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; -\atk4\ui\Button::addTo($app, ['Nested accordions', 'small right floated basic blue', 'iconRight' => 'right arrow']) +\Atk4\Ui\Button::addTo($app, ['Nested accordions', 'small right floated basic blue', 'iconRight' => 'right arrow']) ->link(['accordion-nested']); -\atk4\ui\View::addTo($app, ['ui' => 'clearing divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'clearing divider']); -\atk4\ui\Header::addTo($app, ['Accordion\'s section can be control programmatically.']); +\Atk4\Ui\Header::addTo($app, ['Accordion\'s section can be control programmatically.']); // toggle menu -$bar = \atk4\ui\View::addTo($app, ['ui' => 'buttons']); -$b1 = \atk4\ui\Button::addTo($bar, ['Toggle Section #1']); -$b2 = \atk4\ui\Button::addTo($bar, ['Toggle Section #2']); -$b3 = \atk4\ui\Button::addTo($bar, ['Toggle Section #3']); +$bar = \Atk4\Ui\View::addTo($app, ['ui' => 'buttons']); +$b1 = \Atk4\Ui\Button::addTo($bar, ['Toggle Section #1']); +$b2 = \Atk4\Ui\Button::addTo($bar, ['Toggle Section #2']); +$b3 = \Atk4\Ui\Button::addTo($bar, ['Toggle Section #3']); -\atk4\ui\Header::addTo($app, ['Accordion Sections']); +\Atk4\Ui\Header::addTo($app, ['Accordion Sections']); -$accordion = \atk4\ui\Accordion::addTo($app, ['type' => ['styled', 'fluid']/*, 'settings'=>['exclusive'=>false]*/]); +$accordion = \Atk4\Ui\Accordion::addTo($app, ['type' => ['styled', 'fluid']/*, 'settings'=>['exclusive'=>false]*/]); // static section $i1 = $accordion->addSection('Static Text'); -\atk4\ui\Message::addTo($i1, ['This content is added on page loaded', 'ui' => 'tiny message']); -\atk4\ui\LoremIpsum::addTo($i1, ['size' => 1]); +\Atk4\Ui\Message::addTo($i1, ['This content is added on page loaded', 'ui' => 'tiny message']); +\Atk4\Ui\LoremIpsum::addTo($i1, ['size' => 1]); // dynamic section - simple view $i2 = $accordion->addSection('Dynamic Text', function ($v) { - \atk4\ui\Message::addTo($v, ['Every time you open this accordion item, you will see a different text', 'ui' => 'tiny message']); - \atk4\ui\LoremIpsum::addTo($v, ['size' => 2]); + \Atk4\Ui\Message::addTo($v, ['Every time you open this accordion item, you will see a different text', 'ui' => 'tiny message']); + \Atk4\Ui\LoremIpsum::addTo($v, ['size' => 2]); }); // dynamic section - form view $i3 = $accordion->addSection('Dynamic Form', function ($v) { - \atk4\ui\Message::addTo($v, ['Loading a form dynamically.', 'ui' => 'tiny message']); + \Atk4\Ui\Message::addTo($v, ['Loading a form dynamically.', 'ui' => 'tiny message']); $form = Form::addTo($v); $form->addControl('Email'); $form->onSubmit(function (Form $form) { diff --git a/demos/interactive/card-action.php b/demos/interactive/card-action.php index c89eba826e..08613ab733 100644 --- a/demos/interactive/card-action.php +++ b/demos/interactive/card-action.php @@ -2,25 +2,25 @@ 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\Button::addTo($app, ['Card Deck', 'small right floated basic blue', 'iconRight' => 'right arrow']) +\Atk4\Ui\Button::addTo($app, ['Card Deck', 'small right floated basic blue', 'iconRight' => 'right arrow']) ->link(['card-deck']); -\atk4\ui\Button::addTo($app, ['Card', 'small left floated basic blue', 'icon' => 'left arrow']) +\Atk4\Ui\Button::addTo($app, ['Card', 'small left floated basic blue', 'icon' => 'left arrow']) ->link(['card']); -\atk4\ui\View::addTo($app, ['ui' => 'ui clearing divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'ui clearing divider']); -\atk4\ui\Header::addTo($app, ['Models', 'size' => 1, 'subHeader' => 'Card may display information from many models.']); +\Atk4\Ui\Header::addTo($app, ['Models', 'size' => 1, 'subHeader' => 'Card may display information from many models.']); $stats = new Stat($app->db); $stats->loadAny(); -$c = \atk4\ui\Card::addTo($app); +$c = \Atk4\Ui\Card::addTo($app); $c->setModel($stats, ['client_name', 'description']); $c->addSection('Project: ', $stats, ['start_date', 'finish_date'], true); diff --git a/demos/interactive/card-deck.php b/demos/interactive/card-deck.php index 5687770f10..2931a9ecb3 100644 --- a/demos/interactive/card-deck.php +++ b/demos/interactive/card-deck.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'; -\atk4\ui\Button::addTo($app, ['Card Model', 'small left floated basic blue', 'icon' => 'left arrow']) +\Atk4\Ui\Button::addTo($app, ['Card Model', 'small left floated basic blue', 'icon' => 'left arrow']) ->link(['card-action']); -\atk4\ui\View::addTo($app, ['ui' => 'ui clearing divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'ui clearing divider']); -\atk4\ui\Header::addTo($app, ['Card Deck', 'size' => 1, 'subHeader' => 'Card can be display in a deck, also using model action.']); +\Atk4\Ui\Header::addTo($app, ['Card Deck', 'size' => 1, 'subHeader' => 'Card can be display in a deck, also using model action.']); $countries = new Country($app->db); $countries->addCalculatedField('Cost', function ($model) { @@ -34,15 +34,15 @@ 'callback' => function ($model, $email) { return 'Your request for information was sent to email: ' . $email; }, - 'appliesTo' => \atk4\data\Model\UserAction::APPLIES_TO_NO_RECORDS, - 'ui' => ['button' => ['Request Info', 'ui' => 'button primary', 'icon' => [\atk4\ui\Icon::class, 'mail']]], + 'appliesTo' => \Atk4\Data\Model\UserAction::APPLIES_TO_NO_RECORDS, + 'ui' => ['button' => ['Request Info', 'ui' => 'button primary', 'icon' => [\Atk4\Ui\Icon::class, 'mail']]], ]); $infoAction->args = [ 'email' => ['type' => 'email', 'required' => true, 'caption' => 'Please let us know your email address:'], - 'country' => ['required' => true, 'ui' => ['form' => [\atk4\ui\Form\Control\Lookup::class, 'model' => new Country($app->db), 'placeholder' => 'Please select a country.']]], + 'country' => ['required' => true, 'ui' => ['form' => [\Atk4\Ui\Form\Control\Lookup::class, 'model' => new Country($app->db), 'placeholder' => 'Please select a country.']]], ]; -$deck = \atk4\ui\CardDeck::addTo($app, ['noRecordScopeActions' => ['request_info'], 'singleScopeActions' => ['book']]); +$deck = \Atk4\Ui\CardDeck::addTo($app, ['noRecordScopeActions' => ['request_info'], 'singleScopeActions' => ['book']]); $deck->setModel($countries, ['Cost'], ['iso', 'iso3']); diff --git a/demos/interactive/card.php b/demos/interactive/card.php index 0fef71d125..e1cdd25fe8 100644 --- a/demos/interactive/card.php +++ b/demos/interactive/card.php @@ -2,72 +2,72 @@ 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, ['Card Model', 'small right floated basic blue', 'iconRight' => 'right arrow']) +\Atk4\Ui\Button::addTo($app, ['Card Model', 'small right floated basic blue', 'iconRight' => 'right arrow']) ->link(['card-action']); -\atk4\ui\View::addTo($app, ['ui' => 'ui clearing divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'ui clearing divider']); -\atk4\ui\Header::addTo($app, ['Card.', 'size' => 1, 'subHeader' => 'Component based on Fomantic-Ui Card view.']); +\Atk4\Ui\Header::addTo($app, ['Card.', 'size' => 1, 'subHeader' => 'Component based on Fomantic-Ui Card view.']); // *** Simple Card **/ -\atk4\ui\Header::addTo($app, ['Card can be defined manually.', 'size' => 3]); +\Atk4\Ui\Header::addTo($app, ['Card can be defined manually.', 'size' => 3]); -$card = \atk4\ui\Card::addTo($app); +$card = \Atk4\Ui\Card::addTo($app); -$card->addContent((new \atk4\ui\Header(['Meet Kristy', 'subHeader' => 'Friends']))); +$card->addContent((new \Atk4\Ui\Header(['Meet Kristy', 'subHeader' => 'Friends']))); $card->addDescription('Kristy is a friend of Mully.'); $card->addImage('../images/kristy.png'); -$card->addButton(new \atk4\ui\Button(['Join'])); -$card->addButton(new \atk4\ui\Button(['Email'])); +$card->addButton(new \Atk4\Ui\Button(['Join'])); +$card->addButton(new \Atk4\Ui\Button(['Email'])); -$card->addExtraContent(new \atk4\ui\View(['Copyright notice: Image from Semantic-UI (Fomantic-UI)', 'element' => 'span'])); +$card->addExtraContent(new \Atk4\Ui\View(['Copyright notice: Image from Semantic-UI (Fomantic-UI)', 'element' => 'span'])); // *** Simple Card **/ -$card = \atk4\ui\Card::addTo($app); -$content = new \atk4\ui\View(['class' => ['content']]); -$content->add($img = new \atk4\ui\Image(['../images/kristy.png'])); +$card = \Atk4\Ui\Card::addTo($app); +$content = new \Atk4\Ui\View(['class' => ['content']]); +$content->add($img = new \Atk4\Ui\Image(['../images/kristy.png'])); $img->addClass('right floated mini ui image'); -$content->add($header = new \atk4\ui\Header(['Kristy'])); +$content->add($header = new \Atk4\Ui\Header(['Kristy'])); $card->addContent($content); $card->addDescription('Friend of Bob'); // **** Card with Table and Label***/ -\atk4\ui\Header::addTo($app, ['Card can display model label in a table or in line.', 'size' => 3]); +\Atk4\Ui\Header::addTo($app, ['Card can display model label in a table or in line.', 'size' => 3]); -$deck = \atk4\ui\View::addTo($app, ['ui' => 'cards']); +$deck = \Atk4\Ui\View::addTo($app, ['ui' => 'cards']); -$cardStat = \atk4\ui\Card::addTo($deck, ['useTable' => true]); -$cardStat->addContent(new \atk4\ui\Header(['Project Info'])); +$cardStat = \Atk4\Ui\Card::addTo($deck, ['useTable' => true]); +$cardStat->addContent(new \Atk4\Ui\Header(['Project Info'])); $stats = (new Stat($app->db))->tryLoadAny(); $cardStat->setModel($stats, ['project_name', 'project_code', 'client_name', 'start_date']); -$btn = $cardStat->addButton(new \atk4\ui\Button(['Email Client'])); +$btn = $cardStat->addButton(new \Atk4\Ui\Button(['Email Client'])); -$cardStat = \atk4\ui\Card::addTo($deck, ['useLabel' => true]); -$cardStat->addContent(new \atk4\ui\Header(['Project Info'])); +$cardStat = \Atk4\Ui\Card::addTo($deck, ['useLabel' => true]); +$cardStat->addContent(new \Atk4\Ui\Header(['Project Info'])); $stats = (new Stat($app->db))->tryLoadAny(); $cardStat->setModel($stats, ['project_name', 'project_code', 'client_name', 'start_date']); -$cardStat->addButton(new \atk4\ui\Button(['Email Client'])); +$cardStat->addButton(new \Atk4\Ui\Button(['Email Client'])); // **** Card display horizontally ***/ -\atk4\ui\Header::addTo($app, ['Card can be display horizontally and/or centered.', 'size' => 3]); +\Atk4\Ui\Header::addTo($app, ['Card can be display horizontally and/or centered.', 'size' => 3]); -$card = \atk4\ui\Card::addTo($app)->addClass('horizontal centered'); +$card = \Atk4\Ui\Card::addTo($app)->addClass('horizontal centered'); -$card->addContent((new \atk4\ui\Header(['Meet Kristy', 'subHeader' => 'Friends']))); +$card->addContent((new \Atk4\Ui\Header(['Meet Kristy', 'subHeader' => 'Friends']))); $card->addDescription('Kristy is a friend of Mully.'); $card->addImage('../images/kristy.png'); diff --git a/demos/interactive/cardtable.php b/demos/interactive/cardtable.php index b9c8b6fe1d..1c817ab11a 100644 --- a/demos/interactive/cardtable.php +++ b/demos/interactive/cardtable.php @@ -2,11 +2,11 @@ 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, ['Card displays read-only data of a single record']); +\Atk4\Ui\Header::addTo($app, ['Card displays read-only data of a single record']); -\atk4\ui\CardTable::addTo($app)->setModel((new Stat($app->db))->tryLoadAny()); +\Atk4\Ui\CardTable::addTo($app)->setModel((new Stat($app->db))->tryLoadAny()); diff --git a/demos/interactive/console.php b/demos/interactive/console.php index f273b8c640..c0aa31a671 100644 --- a/demos/interactive/console.php +++ b/demos/interactive/console.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'; -/** @var \atk4\ui\View $testRunClass */ -$testRunClass = get_class(new class() extends \atk4\ui\View { - use \atk4\core\DebugTrait; +/** @var \Atk4\Ui\View $testRunClass */ +$testRunClass = get_class(new class() extends \Atk4\Ui\View { + use \Atk4\Core\DebugTrait; public function generateReport() { @@ -27,53 +27,53 @@ public function generateReport() } }); -$tabs = \atk4\ui\Tabs::addTo($app); +$tabs = \Atk4\Ui\Tabs::addTo($app); $tab = $tabs->addTab('set()'); -\atk4\ui\Header::addTo($tab, [ +\Atk4\Ui\Header::addTo($tab, [ 'icon' => 'terminal', 'Console output streaming', 'subHeader' => 'any output your PHP script produces through console is displayed to user in real-time', ]); -\atk4\ui\Console::addTo($tab)->set(function ($console) { +\Atk4\Ui\Console::addTo($tab)->set(function ($console) { $console->output('Executing test process...'); sleep(1); $console->output('Now trying something dangerous..'); sleep(1); echo 'direct output is captured'; - throw new \atk4\core\Exception('BOOM - exceptions are caught'); + throw new \Atk4\Core\Exception('BOOM - exceptions are caught'); }); $tab = $tabs->addTab('runMethod()', function ($tab) use ($testRunClass) { - \atk4\ui\Header::addTo($tab, [ + \Atk4\Ui\Header::addTo($tab, [ 'icon' => 'terminal', 'Non-interractive method invocation', 'subHeader' => 'console can invoke a method, which normaly would be non-interractive and can still capture debug output', ]); - \atk4\ui\Console::addTo($tab)->runMethod($testRunClass::addTo($tab), 'generateReport'); + \Atk4\Ui\Console::addTo($tab)->runMethod($testRunClass::addTo($tab), 'generateReport'); }); $tab = $tabs->addTab('exec() single', function ($tab) { - \atk4\ui\Header::addTo($tab, [ + \Atk4\Ui\Header::addTo($tab, [ 'icon' => 'terminal', 'Command execution', 'subHeader' => 'it is easy to run server-side commands and stream output through console', ]); - $message = \atk4\ui\Message::addTo($tab, ['This demo may not work', 'warning']); + $message = \Atk4\Ui\Message::addTo($tab, ['This demo may not work', 'warning']); $message->text->addParagraph('This demo requires Linux OS and will display error otherwise.'); - \atk4\ui\Console::addTo($tab)->exec('/bin/pwd'); + \Atk4\Ui\Console::addTo($tab)->exec('/bin/pwd'); }); $tab = $tabs->addTab('exec() chain', function ($tab) { - \atk4\ui\Header::addTo($tab, [ + \Atk4\Ui\Header::addTo($tab, [ 'icon' => 'terminal', 'Command execution', 'subHeader' => 'it is easy to run server-side commands and stream output through console', ]); - $message = \atk4\ui\Message::addTo($tab, ['This demo may not work', 'warning']); + $message = \Atk4\Ui\Message::addTo($tab, ['This demo may not work', 'warning']); $message->text->addParagraph('This demo requires Linux OS and will display error otherwise.'); - \atk4\ui\Console::addTo($tab)->set(function ($console) { + \Atk4\Ui\Console::addTo($tab)->set(function ($console) { $console->exec('/sbin/ping', ['-c', '5', '-i', '1', '192.168.0.1']); $console->exec('/sbin/ping', ['-c', '5', '-i', '2', '8.8.8.8']); $console->exec('/bin/no-such-command'); @@ -81,25 +81,25 @@ public function generateReport() }); $tab = $tabs->addTab('composer update', function ($tab) { - \atk4\ui\Header::addTo($tab, [ + \Atk4\Ui\Header::addTo($tab, [ 'icon' => 'terminal', 'Command execution', 'subHeader' => 'it is easy to run server-side commands and stream output through console', ]); - $message = \atk4\ui\Message::addTo($tab, ['This demo may not work', 'warning']); + $message = \Atk4\Ui\Message::addTo($tab, ['This demo may not work', 'warning']); $message->text->addParagraph('This demo requires you to have "bash" and "composer" installed and may display error if the process running PHP does not have write access to the "vendor" folder and "composer.*".'); - $button = \atk4\ui\Button::addTo($message, ['I understand, proceed anyway', 'primary big']); + $button = \Atk4\Ui\Button::addTo($message, ['I understand, proceed anyway', 'primary big']); - $console = \atk4\ui\Console::addTo($tab, ['event' => false]); + $console = \Atk4\Ui\Console::addTo($tab, ['event' => false]); $console->exec('bash', ['-c', 'cd ../..; echo "Running \'composer update\' in `pwd`"; composer --no-ansi update; echo "Self-updated. OK to refresh now!"']); $button->on('click', $console->jsExecute()); }); $tab = $tabs->addTab('Use after form submit', function ($tab) { - \atk4\ui\Header::addTo($tab, [ + \Atk4\Ui\Header::addTo($tab, [ 'icon' => 'terminal', 'How to log form submit process', 'subHeader' => 'Sometimes you can have long running process after form submit and want to show progress for user...', @@ -107,10 +107,10 @@ public function generateReport() session_start(); - $form = \atk4\ui\Form::addTo($tab); + $form = \Atk4\Ui\Form::addTo($tab); $form->addControls(['foo', 'bar']); - $console = \atk4\ui\Console::addTo($tab, ['event' => false]); + $console = \Atk4\Ui\Console::addTo($tab, ['event' => false]); $console->set(function ($console) { $model = $_SESSION['data']; $console->output('Executing process...'); @@ -122,7 +122,7 @@ public function generateReport() }); $console->js(true)->hide(); - $form->onSubmit(function (\atk4\ui\Form $form) use ($console) { + $form->onSubmit(function (\Atk4\Ui\Form $form) use ($console) { $_SESSION['data'] = $form->model; // only option is to store model in session here in demo return [ diff --git a/demos/interactive/loader.php b/demos/interactive/loader.php index a6473b1e18..e36c1344e7 100644 --- a/demos/interactive/loader.php +++ b/demos/interactive/loader.php @@ -2,39 +2,39 @@ 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, ['Loader Examples - Page 2', 'small right floated basic blue', 'iconRight' => 'right arrow']) +\Atk4\Ui\Button::addTo($app, ['Loader Examples - Page 2', 'small right floated basic blue', 'iconRight' => 'right arrow']) ->link(['loader2']); -\atk4\ui\View::addTo($app, ['ui' => 'clearing divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'clearing divider']); // ViewTester will perform callback to self. ViewTester::addTo($app); // Example 1 - Basic usage of a Loader. -\atk4\ui\Loader::addTo($app)->set(function ($p) { +\Atk4\Ui\Loader::addTo($app)->set(function ($p) { // set your time expensive function here. sleep(1); - \atk4\ui\Header::addTo($p, ['Loader #1']); - \atk4\ui\LoremIpsum::addTo($p, ['size' => 1]); + \Atk4\Ui\Header::addTo($p, ['Loader #1']); + \Atk4\Ui\LoremIpsum::addTo($p, ['size' => 1]); // Any dynamic views can perform call-backs just fine ViewTester::addTo($p); // Loader may be inside another loader, works fine. - $loader = \atk4\ui\Loader::addTo($p); + $loader = \Atk4\Ui\Loader::addTo($p); // use loadEvent to prevent manual loading or even specify custom trigger event $loader->loadEvent = false; $loader->set(function ($p) { // You may pass arguments to the loader, in this case it's "color" sleep(1); - \atk4\ui\Header::addTo($p, ['Loader #1b - ' . $_GET['color']]); - \atk4\ui\LoremIpsum::addTo(\atk4\ui\View::addTo($p, ['ui' => $_GET['color'] . ' segment']), ['size' => 1]); + \Atk4\Ui\Header::addTo($p, ['Loader #1b - ' . $_GET['color']]); + \Atk4\Ui\LoremIpsum::addTo(\Atk4\Ui\View::addTo($p, ['ui' => $_GET['color'] . ' segment']), ['size' => 1]); // don't forget to make your own argument sticky so that Components can communicate with themselves: $p->getApp()->stickyGet('color'); @@ -44,19 +44,19 @@ }); // button may contain load event. - \atk4\ui\Button::addTo($p, ['Load Segment Manually (2s)', 'red'])->js('click', $loader->jsLoad(['color' => 'red'])); - \atk4\ui\Button::addTo($p, ['Load Segment Manually (2s)', 'blue'])->js('click', $loader->jsLoad(['color' => 'blue'])); + \Atk4\Ui\Button::addTo($p, ['Load Segment Manually (2s)', 'red'])->js('click', $loader->jsLoad(['color' => 'red'])); + \Atk4\Ui\Button::addTo($p, ['Load Segment Manually (2s)', 'blue'])->js('click', $loader->jsLoad(['color' => 'blue'])); }); // Example 2 - Loader with custom body. -\atk4\ui\Loader::addTo($app, [ +\Atk4\Ui\Loader::addTo($app, [ 'ui' => '', // this will prevent "loading spinner" from showing 'shim' => [ // shim is displayed while content is leaded - \atk4\ui\Message::class, + \Atk4\Ui\Message::class, 'Generating LoremIpsum, please wait...', 'red', ], ])->set(function ($p) { usleep(500 * 1000); - \atk4\ui\LoremIpsum::addTo($p, ['size' => 2]); + \Atk4\Ui\LoremIpsum::addTo($p, ['size' => 2]); }); diff --git a/demos/interactive/loader2.php b/demos/interactive/loader2.php index f69d0b0f23..a3e96545e0 100644 --- a/demos/interactive/loader2.php +++ b/demos/interactive/loader2.php @@ -2,24 +2,24 @@ 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, ['Loader Example - page 1', 'small left floated basic blue', 'icon' => 'left arrow']) +\Atk4\Ui\Button::addTo($app, ['Loader Example - page 1', 'small left floated basic blue', 'icon' => 'left arrow']) ->link(['loader']); -\atk4\ui\View::addTo($app, ['ui' => 'ui clearing divider']); +\Atk4\Ui\View::addTo($app, ['ui' => 'ui clearing divider']); -$c = \atk4\ui\Columns::addTo($app); +$c = \Atk4\Ui\Columns::addTo($app); -$grid = \atk4\ui\Grid::addTo($c->addColumn(), ['ipp' => 10, 'menu' => false]); +$grid = \Atk4\Ui\Grid::addTo($c->addColumn(), ['ipp' => 10, 'menu' => false]); $grid->setModel(new Country($app->db), ['name']); -$countryLoader = \atk4\ui\Loader::addTo($c->addColumn(), ['loadEvent' => false, 'shim' => [\atk4\ui\Text::class, 'Select country on your left']]); +$countryLoader = \Atk4\Ui\Loader::addTo($c->addColumn(), ['loadEvent' => false, 'shim' => [\Atk4\Ui\Text::class, 'Select country on your left']]); $grid->table->onRowClick($countryLoader->jsLoad(['id' => $grid->table->jsRow()->data('id')])); $countryLoader->set(function ($p) { - \atk4\ui\Form::addTo($p)->setModel(new Country($p->getApp()->db))->load($_GET['id']); + \Atk4\Ui\Form::addTo($p)->setModel(new Country($p->getApp()->db))->load($_GET['id']); }); diff --git a/demos/interactive/modal.php b/demos/interactive/modal.php index 60fb54af17..5acfbaae98 100644 --- a/demos/interactive/modal.php +++ b/demos/interactive/modal.php @@ -2,75 +2,75 @@ 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, ['Modal View']); +\Atk4\Ui\Header::addTo($app, ['Modal View']); $session = new Session(); // Re-usable component implementing counter -\atk4\ui\Header::addTo($app, ['Static Modal Dialog']); +\Atk4\Ui\Header::addTo($app, ['Static Modal Dialog']); -$bar = \atk4\ui\View::addTo($app, ['ui' => 'buttons']); +$bar = \Atk4\Ui\View::addTo($app, ['ui' => 'buttons']); -$modal = \atk4\ui\Modal::addTo($app, ['title' => 'Add a name']); -\atk4\ui\LoremIpsum::addTo($modal); -\atk4\ui\Button::addTo($modal, ['Hide'])->on('click', $modal->hide()); +$modal = \Atk4\Ui\Modal::addTo($app, ['title' => 'Add a name']); +\Atk4\Ui\LoremIpsum::addTo($modal); +\Atk4\Ui\Button::addTo($modal, ['Hide'])->on('click', $modal->hide()); -$noTitle = \atk4\ui\Modal::addTo($app, ['title' => false]); -\atk4\ui\LoremIpsum::addTo($noTitle); -\atk4\ui\Button::addTo($noTitle, ['Hide'])->on('click', $noTitle->hide()); +$noTitle = \Atk4\Ui\Modal::addTo($app, ['title' => false]); +\Atk4\Ui\LoremIpsum::addTo($noTitle); +\Atk4\Ui\Button::addTo($noTitle, ['Hide'])->on('click', $noTitle->hide()); -$scrolling = \atk4\ui\Modal::addTo($app, ['title' => 'Long Content that Scrolls inside Modal']); +$scrolling = \Atk4\Ui\Modal::addTo($app, ['title' => 'Long Content that Scrolls inside Modal']); $scrolling->addScrolling(); -\atk4\ui\LoremIpsum::addTo($scrolling); -\atk4\ui\LoremIpsum::addTo($scrolling); -\atk4\ui\LoremIpsum::addTo($scrolling); -\atk4\ui\Button::addTo($scrolling, ['Hide'])->on('click', $scrolling->hide()); +\Atk4\Ui\LoremIpsum::addTo($scrolling); +\Atk4\Ui\LoremIpsum::addTo($scrolling); +\Atk4\Ui\LoremIpsum::addTo($scrolling); +\Atk4\Ui\Button::addTo($scrolling, ['Hide'])->on('click', $scrolling->hide()); -\atk4\ui\Button::addTo($bar, ['Show'])->on('click', $modal->show()); -\atk4\ui\Button::addTo($bar, ['No Title'])->on('click', $noTitle->show()); -\atk4\ui\Button::addTo($bar, ['Scrolling Content'])->on('click', $scrolling->show()); +\Atk4\Ui\Button::addTo($bar, ['Show'])->on('click', $modal->show()); +\Atk4\Ui\Button::addTo($bar, ['No Title'])->on('click', $noTitle->show()); +\Atk4\Ui\Button::addTo($bar, ['Scrolling Content'])->on('click', $scrolling->show()); // Modal demos. // REGULAR -$simpleModal = \atk4\ui\Modal::addTo($app, ['title' => 'Simple modal']); -\atk4\ui\Message::addTo($simpleModal)->set('Modal message here.'); +$simpleModal = \Atk4\Ui\Modal::addTo($app, ['title' => 'Simple modal']); +\Atk4\Ui\Message::addTo($simpleModal)->set('Modal message here.'); ViewTester::addTo($simpleModal); -$menuBar = \atk4\ui\View::addTo($app, ['ui' => 'buttons']); -$button = \atk4\ui\Button::addTo($menuBar)->set('Show Modal'); +$menuBar = \Atk4\Ui\View::addTo($app, ['ui' => 'buttons']); +$button = \Atk4\Ui\Button::addTo($menuBar)->set('Show Modal'); $button->on('click', $simpleModal->show()); // DYNAMIC -\atk4\ui\Header::addTo($app, ['Three levels of Modal loading dynamic content via callback']); +\Atk4\Ui\Header::addTo($app, ['Three levels of Modal loading dynamic content via callback']); // vp1Modal will be render into page but hide until $vp1Modal->show() is activate. -$vp1Modal = \atk4\ui\Modal::addTo($app, ['title' => 'Lorem Ipsum load dynamically']); +$vp1Modal = \Atk4\Ui\Modal::addTo($app, ['title' => 'Lorem Ipsum load dynamically']); // vp2Modal will be render into page but hide until $vp1Modal->show() is activate. -$vp2Modal = \atk4\ui\Modal::addTo($app, ['title' => 'Text message load dynamically'])->addClass('small'); +$vp2Modal = \Atk4\Ui\Modal::addTo($app, ['title' => 'Text message load dynamically'])->addClass('small'); -$vp3Modal = \atk4\ui\Modal::addTo($app, ['title' => 'Third level modal'])->addClass('small'); +$vp3Modal = \Atk4\Ui\Modal::addTo($app, ['title' => 'Third level modal'])->addClass('small'); $vp3Modal->set(function ($modal) { - \atk4\ui\Text::addTo($modal)->set('This is yet another modal'); - \atk4\ui\LoremIpsum::addTo($modal, ['size' => 2]); + \Atk4\Ui\Text::addTo($modal)->set('This is yet another modal'); + \Atk4\Ui\LoremIpsum::addTo($modal, ['size' => 2]); }); // When $vp1Modal->show() is activate, it will dynamically add this content to it. $vp1Modal->set(function ($modal) use ($vp2Modal) { ViewTester::addTo($modal); - \atk4\ui\View::addTo($modal, ['Showing lorem ipsum']); // need in behat test. - \atk4\ui\LoremIpsum::addTo($modal, ['size' => 2]); - $form = \atk4\ui\Form::addTo($modal); + \Atk4\Ui\View::addTo($modal, ['Showing lorem ipsum']); // need in behat test. + \Atk4\Ui\LoremIpsum::addTo($modal, ['size' => 2]); + $form = \Atk4\Ui\Form::addTo($modal); $form->addControl('color', null, ['enum' => ['red', 'green', 'blue'], 'default' => 'green']); - $form->onSubmit(function (\atk4\ui\Form $form) use ($vp2Modal) { + $form->onSubmit(function (\Atk4\Ui\Form $form) use ($vp2Modal) { return $vp2Modal->show(['color' => $form->model->get('color')]); }); }); @@ -78,12 +78,12 @@ // When $vp2Modal->show() is activate, it will dynamically add this content to it. $vp2Modal->set(function ($modal) use ($vp3Modal) { // ViewTester::addTo($modal); - \atk4\ui\Message::addTo($modal, ['Message', @$_GET['color']])->text->addParagraph('This text is loaded using a second modal.'); - \atk4\ui\Button::addTo($modal)->set('Third modal')->on('click', $vp3Modal->show()); + \Atk4\Ui\Message::addTo($modal, ['Message', @$_GET['color']])->text->addParagraph('This text is loaded using a second modal.'); + \Atk4\Ui\Button::addTo($modal)->set('Third modal')->on('click', $vp3Modal->show()); }); -$bar = \atk4\ui\View::addTo($app, ['ui' => 'buttons']); -$button = \atk4\ui\Button::addTo($bar)->set('Open Lorem Ipsum'); +$bar = \Atk4\Ui\View::addTo($app, ['ui' => 'buttons']); +$button = \Atk4\Ui\Button::addTo($bar)->set('Open Lorem Ipsum'); $button->on('click', $vp1Modal->show()); // ANIMATION @@ -100,14 +100,14 @@ 'static' => ['jiggle', 'flash', 'shake', 'pulse', 'tada', 'bounce'], ]; -\atk4\ui\Header::addTo($app, ['Modal Animation']); +\Atk4\Ui\Header::addTo($app, ['Modal Animation']); -$transitionModal = \atk4\ui\Modal::addTo($app, ['title' => 'Animated modal']); -\atk4\ui\Message::addTo($transitionModal)->set('A lot of animated transition available'); +$transitionModal = \Atk4\Ui\Modal::addTo($app, ['title' => 'Animated modal']); +\Atk4\Ui\Message::addTo($transitionModal)->set('A lot of animated transition available'); $transitionModal->duration(1000); -$menuBar = \atk4\ui\View::addTo($app, ['ui' => 'buttons']); -$main = \atk4\ui\Menu::addTo($menuBar); +$menuBar = \Atk4\Ui\View::addTo($app, ['ui' => 'buttons']); +$main = \Atk4\Ui\Menu::addTo($menuBar); $transitionMenu = $main->addMenu('Select Transition'); foreach ($menuItems as $key => $items) { @@ -125,30 +125,30 @@ // DENY APPROVE -\atk4\ui\Header::addTo($app, ['Modal Options']); +\Atk4\Ui\Header::addTo($app, ['Modal Options']); -$denyApproveModal = \atk4\ui\Modal::addTo($app, ['title' => 'Deny / Approve actions']); -\atk4\ui\Message::addTo($denyApproveModal)->set('This modal is only closable via the green button'); -$denyApproveModal->addDenyAction('No', new \atk4\ui\JsExpression('function(){window.alert("Can\'t do that."); return false;}')); -$denyApproveModal->addApproveAction('Yes', new \atk4\ui\JsExpression('function(){window.alert("You\'re good to go!");}')); +$denyApproveModal = \Atk4\Ui\Modal::addTo($app, ['title' => 'Deny / Approve actions']); +\Atk4\Ui\Message::addTo($denyApproveModal)->set('This modal is only closable via the green button'); +$denyApproveModal->addDenyAction('No', new \Atk4\Ui\JsExpression('function(){window.alert("Can\'t do that."); return false;}')); +$denyApproveModal->addApproveAction('Yes', new \Atk4\Ui\JsExpression('function(){window.alert("You\'re good to go!");}')); $denyApproveModal->notClosable(); -$menuBar = \atk4\ui\View::addTo($app, ['ui' => 'buttons']); -$button = \atk4\ui\Button::addTo($menuBar)->set('Show Deny/Approve'); +$menuBar = \Atk4\Ui\View::addTo($app, ['ui' => 'buttons']); +$button = \Atk4\Ui\Button::addTo($menuBar)->set('Show Deny/Approve'); $button->on('click', $denyApproveModal->show()); // MULTI STEP -\atk4\ui\Header::addTo($app, ['Multiple page modal']); +\Atk4\Ui\Header::addTo($app, ['Multiple page modal']); // Add modal to layout. -$stepModal = \atk4\ui\Modal::addTo($app, ['title' => 'Multi step actions']); +$stepModal = \Atk4\Ui\Modal::addTo($app, ['title' => 'Multi step actions']); $stepModal->setOption('observeChanges', true); // Add buttons to modal for next and previous actions. -$action = new \atk4\ui\View(['ui' => 'buttons']); -$prevAction = new \atk4\ui\Button(['Prev', 'labeled', 'icon' => 'left arrow']); -$nextAction = new \atk4\ui\Button(['Next', 'iconRight' => 'right arrow']); +$action = new \Atk4\Ui\View(['ui' => 'buttons']); +$prevAction = new \Atk4\Ui\Button(['Prev', 'labeled', 'icon' => 'left arrow']); +$nextAction = new \Atk4\Ui\Button(['Next', 'iconRight' => 'right arrow']); $action->add($prevAction); $action->add($nextAction); @@ -173,20 +173,20 @@ } $session->memorize('page', $page); if ($page === 1) { - \atk4\ui\Message::addTo($modal)->set('Thanks for choosing us. We will be asking some questions along the way.'); + \Atk4\Ui\Message::addTo($modal)->set('Thanks for choosing us. We will be asking some questions along the way.'); $session->memorize('success', true); $modal->js(true, $prevAction->js(true)->show()); $modal->js(true, $nextAction->js(true)->show()); $modal->js(true, $prevAction->js()->addClass('disabled')); $modal->js(true, $nextAction->js(true)->removeClass('disabled')); } elseif ($page === 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($modal, ['segment' => true]); + $form = \Atk4\Ui\Form::addTo($modal, ['segment' => true]); $form->setModel($modelRegister); - $form->onSubmit(function (\atk4\ui\Form $form) use ($nextAction, $session) { + $form->onSubmit(function (\Atk4\Ui\Form $form) use ($nextAction, $session) { 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!'); } @@ -202,7 +202,7 @@ $modal->js(true, $nextAction->js(true)->addClass('disabled')); } elseif ($page === 3) { $name = $session->recall('name'); - \atk4\ui\Message::addTo($modal)->set("Thank you {$name} for visiting us! We will be in touch"); + \Atk4\Ui\Message::addTo($modal)->set("Thank you {$name} for visiting us! We will be in touch"); $session->memorize('success', true); $modal->js(true, $prevAction->js(true)->hide()); $modal->js(true, $nextAction->js(true)->hide()); @@ -221,6 +221,6 @@ )); // Bind display modal to page display button. -$menuBar = \atk4\ui\View::addTo($app, ['ui' => 'buttons']); -$button = \atk4\ui\Button::addTo($menuBar)->set('Multi Step Modal'); +$menuBar = \Atk4\Ui\View::addTo($app, ['ui' => 'buttons']); +$button = \Atk4\Ui\Button::addTo($menuBar)->set('Multi Step Modal'); $button->on('click', $stepModal->show()); diff --git a/demos/interactive/paginator.php b/demos/interactive/paginator.php index f845413ad8..c31b16a3f8 100644 --- a/demos/interactive/paginator.php +++ b/demos/interactive/paginator.php @@ -2,36 +2,36 @@ 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'; // Paginator which tracks its own position -\atk4\ui\Header::addTo($app, ['Paginator tracks its own position']); -\atk4\ui\Paginator::addTo($app, ['total' => 40, 'urlTrigger' => 'page']); +\Atk4\Ui\Header::addTo($app, ['Paginator tracks its own position']); +\Atk4\Ui\Paginator::addTo($app, ['total' => 40, 'urlTrigger' => 'page']); // Dynamically reloading paginator -\atk4\ui\Header::addTo($app, ['Dynamic reloading']); -$seg = \atk4\ui\View::addTo($app, ['ui' => 'blue segment']); -$label = \atk4\ui\Label::addTo($seg); -$bb = \atk4\ui\Paginator::addTo($seg, ['total' => 50, 'range' => 2, 'reload' => $seg]); +\Atk4\Ui\Header::addTo($app, ['Dynamic reloading']); +$seg = \Atk4\Ui\View::addTo($app, ['ui' => 'blue segment']); +$label = \Atk4\Ui\Label::addTo($seg); +$bb = \Atk4\Ui\Paginator::addTo($seg, ['total' => 50, 'range' => 2, 'reload' => $seg]); $label->addClass('blue ribbon'); $label->set('Current page: ' . $bb->page); // Multiple dependent Paginators -\atk4\ui\Header::addTo($app, ['Local Sticky Usage']); -$seg = \atk4\ui\View::addTo($app, ['ui' => 'blue segment']); +\Atk4\Ui\Header::addTo($app, ['Local Sticky Usage']); +$seg = \Atk4\Ui\View::addTo($app, ['ui' => 'blue segment']); $month = $seg->stickyGet('month') ?: 1; $day = $seg->stickyGet('day') ?: 1; // we intentionally left 31 days here and do not calculate number of days in particular month to keep example simple -$monthPaginator = \atk4\ui\Paginator::addTo($seg, ['total' => 12, 'range' => 3, 'urlTrigger' => 'month']); -\atk4\ui\View::addTo($seg, ['ui' => 'hidden divider']); -$dayPaginator = \atk4\ui\Paginator::addTo($seg, ['total' => 31, 'range' => 3, 'urlTrigger' => 'day']); -\atk4\ui\View::addTo($seg, ['ui' => 'hidden divider']); +$monthPaginator = \Atk4\Ui\Paginator::addTo($seg, ['total' => 12, 'range' => 3, 'urlTrigger' => 'month']); +\Atk4\Ui\View::addTo($seg, ['ui' => 'hidden divider']); +$dayPaginator = \Atk4\Ui\Paginator::addTo($seg, ['total' => 31, 'range' => 3, 'urlTrigger' => 'day']); +\Atk4\Ui\View::addTo($seg, ['ui' => 'hidden divider']); -$label = \atk4\ui\Label::addTo($seg); +$label = \Atk4\Ui\Label::addTo($seg); $label->addClass('orange'); $label->set('Month: ' . $month . ' and Day: ' . $day); diff --git a/demos/interactive/popup.php b/demos/interactive/popup.php index 051c7df1d0..988680aeda 100644 --- a/demos/interactive/popup.php +++ b/demos/interactive/popup.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace atk4\ui\demo; +namespace Atk4\Ui\Demos; -use atk4\ui\Form; -use atk4\ui\View; +use Atk4\Ui\Form; +use Atk4\Ui\View; -/** @var \atk4\ui\App $app */ +/** @var \Atk4\Ui\App $app */ require_once __DIR__ . '/../init-app.php'; /** @@ -17,9 +17,9 @@ * render the items. */ -/** @var \atk4\ui\Lister $cartClass */ -$cartClass = get_class(new class() extends \atk4\ui\Lister { - use \atk4\core\SessionTrait; +/** @var \Atk4\Ui\Lister $cartClass */ +$cartClass = get_class(new class() extends \Atk4\Ui\Lister { + use \Atk4\Core\SessionTrait; public $items = []; public $defaultTemplate = 'lister.html'; @@ -84,39 +84,39 @@ protected function renderView(): void * item inside a cart reloading it afterwards. */ -/** @var \atk4\ui\View $itemShelfClass */ -$itemShelfClass = get_class(new class() extends \atk4\ui\View { +/** @var \Atk4\Ui\View $itemShelfClass */ +$itemShelfClass = get_class(new class() extends \Atk4\Ui\View { public $ui = 'green segment'; protected function init(): void { parent::init(); - $v = \atk4\ui\View::addTo($this, ['ui' => 'fluid']); - $cols = \atk4\ui\Columns::addTo($v, ['ui' => 'relaxed divided grid']); + $v = \Atk4\Ui\View::addTo($this, ['ui' => 'fluid']); + $cols = \Atk4\Ui\Columns::addTo($v, ['ui' => 'relaxed divided grid']); $c1 = $cols->addColumn(); - \atk4\ui\Header::addTo($c1, ['size' => 'small'])->set('Snacks'); - $l1 = \atk4\ui\View::addTo($c1, ['ui' => 'list']); - \atk4\ui\Item::addTo($l1, ['content' => 'Crisps', 'ui' => 'item'])->setElement('a'); - \atk4\ui\Item::addTo($l1, ['content' => 'Pork Scratchings', 'ui' => 'item'])->setElement('a'); - \atk4\ui\Item::addTo($l1, ['content' => 'Candies', 'ui' => 'item'])->setElement('a'); - \atk4\ui\Item::addTo($l1, ['content' => 'Sweets', 'ui' => 'item'])->setElement('a'); + \Atk4\Ui\Header::addTo($c1, ['size' => 'small'])->set('Snacks'); + $l1 = \Atk4\Ui\View::addTo($c1, ['ui' => 'list']); + \Atk4\Ui\Item::addTo($l1, ['content' => 'Crisps', 'ui' => 'item'])->setElement('a'); + \Atk4\Ui\Item::addTo($l1, ['content' => 'Pork Scratchings', 'ui' => 'item'])->setElement('a'); + \Atk4\Ui\Item::addTo($l1, ['content' => 'Candies', 'ui' => 'item'])->setElement('a'); + \Atk4\Ui\Item::addTo($l1, ['content' => 'Sweets', 'ui' => 'item'])->setElement('a'); $c2 = $cols->addColumn(); - \atk4\ui\Header::addTo($c2, ['size' => 'small'])->set('Drinks'); - $l2 = \atk4\ui\View::addTo($c2, ['ui' => 'list']); - \atk4\ui\Item::addTo($l2, ['content' => 'Fizzy Drink', 'ui' => 'item'])->setElement('a'); - \atk4\ui\Item::addTo($l2, ['content' => 'Hot Latte', 'ui' => 'item'])->setElement('a'); - \atk4\ui\Item::addTo($l2, ['content' => 'Water', 'ui' => 'item'])->setElement('a'); - \atk4\ui\Item::addTo($l2, ['content' => 'Apple Juice', 'ui' => 'item'])->setElement('a'); + \Atk4\Ui\Header::addTo($c2, ['size' => 'small'])->set('Drinks'); + $l2 = \Atk4\Ui\View::addTo($c2, ['ui' => 'list']); + \Atk4\Ui\Item::addTo($l2, ['content' => 'Fizzy Drink', 'ui' => 'item'])->setElement('a'); + \Atk4\Ui\Item::addTo($l2, ['content' => 'Hot Latte', 'ui' => 'item'])->setElement('a'); + \Atk4\Ui\Item::addTo($l2, ['content' => 'Water', 'ui' => 'item'])->setElement('a'); + \Atk4\Ui\Item::addTo($l2, ['content' => 'Apple Juice', 'ui' => 'item'])->setElement('a'); $c3 = $cols->addColumn(); - \atk4\ui\Header::addTo($c3, ['size' => 'small'])->set('Mains'); - $l3 = \atk4\ui\View::addTo($c3, ['ui' => 'list']); - \atk4\ui\Item::addTo($l3, ['content' => 'Chicken Tikka', 'ui' => 'item'])->setElement('a'); - \atk4\ui\Item::addTo($l3, ['content' => 'Green Curry', 'ui' => 'item'])->setElement('a'); - \atk4\ui\Item::addTo($l3, ['content' => 'Pastries', 'ui' => 'item'])->setElement('a'); + \Atk4\Ui\Header::addTo($c3, ['size' => 'small'])->set('Mains'); + $l3 = \Atk4\Ui\View::addTo($c3, ['ui' => 'list']); + \Atk4\Ui\Item::addTo($l3, ['content' => 'Chicken Tikka', 'ui' => 'item'])->setElement('a'); + \Atk4\Ui\Item::addTo($l3, ['content' => 'Green Curry', 'ui' => 'item'])->setElement('a'); + \Atk4\Ui\Item::addTo($l3, ['content' => 'Pastries', 'ui' => 'item'])->setElement('a'); } /** @@ -131,22 +131,22 @@ public function linkCart($cart, $jsAction = null) $cart->addItem($b); return $jsAction; - }, [(new \atk4\ui\Jquery())->text()]); + }, [(new \Atk4\Ui\Jquery())->text()]); } }); -\atk4\ui\Header::addTo($app)->set('Menu popup'); -$menu = \atk4\ui\Menu::addTo($app); +\Atk4\Ui\Header::addTo($app)->set('Menu popup'); +$menu = \Atk4\Ui\Menu::addTo($app); // You may add popup on top of menu items or dropdowns. Dropdowns have a slightly different // look, with that triangle on the right. You don't have to add pop-up right away, it can be // added later. -$browse = \atk4\ui\Dropdown::addTo($menu, ['Browse']); +$browse = \Atk4\Ui\Dropdown::addTo($menu, ['Browse']); // Add cart item into the menu, with a popup inside $cartItem = $menu->addItem([$cartClass, 'icon' => 'cart'])->set('Cart'); -$cartPopup = \atk4\ui\Popup::addTo($app, [$cartItem, 'position' => 'bottom left']); +$cartPopup = \Atk4\Ui\Popup::addTo($app, [$cartItem, 'position' => 'bottom left']); // Popup won't dissapear as you hover over it. $cartPopup->setHoverable(); @@ -179,21 +179,21 @@ public function linkCart($cart, $jsAction = null) // Label now can be added referencing Cart's items. Init() was colled when I added it into app, so the // item property is populated. -$cartOutterLabel = \atk4\ui\Label::addTo($cartItem, [count($cart->items), 'floating red ']); +$cartOutterLabel = \Atk4\Ui\Label::addTo($cartItem, [count($cart->items), 'floating red ']); if (!$cart->items) { $cartOutterLabel->addStyle('display', 'none'); } $cartPopup->set(function ($popup) use ($cart) { - $cartInnerLabel = \atk4\ui\Label::addTo($popup, ['Number of items:']); + $cartInnerLabel = \Atk4\Ui\Label::addTo($popup, ['Number of items:']); // cart is already initialized, so init() is not called again. However, cart will be rendered // as a child of a pop-up now. $cart = $popup->add($cart); $cartInnerLabel->detail = count($cart->items); - \atk4\ui\Item::addTo($popup)->setElement('hr'); - \atk4\ui\Button::addTo($popup, ['Checkout', 'primary small']); + \Atk4\Ui\Item::addTo($popup)->setElement('hr'); + \Atk4\Ui\Button::addTo($popup, ['Checkout', 'primary small']); }); // Add item shelf below menu and link it with the cart @@ -202,12 +202,12 @@ public function linkCart($cart, $jsAction = null) $cartOutterLabel->jsReload(), // also will hide current item from the shelf - (new \atk4\ui\Jquery())->hide(), + (new \Atk4\Ui\Jquery())->hide(), ]); // label placed on top of menu item, not in the popup -$pop = \atk4\ui\Popup::addTo($app, [$browse, 'position' => 'bottom left', 'minWidth' => '500px']) +$pop = \Atk4\Ui\Popup::addTo($app, [$browse, 'position' => 'bottom left', 'minWidth' => '500px']) ->setHoverable() ->setOption('delay', ['show' => 100, 'hide' => 400]); $shelf2 = $itemShelfClass::addTo($pop); @@ -215,21 +215,21 @@ public function linkCart($cart, $jsAction = null) ////////////////////////////////////////////////////////////////////////////// -$userMenu = \atk4\ui\Menu::addTo($menu, ['ui' => false], ['RightMenu']) +$userMenu = \Atk4\Ui\Menu::addTo($menu, ['ui' => false], ['RightMenu']) ->addClass('right menu')->removeClass('item'); $rightMenu = $userMenu->addMenu(['', 'icon' => 'user']); // If you add popup right inside the view, it will link itself with the element. If you are adding it into other container, // you can still manually link it and specify an event. -$signup = \atk4\ui\Popup::addTo($app, [$rightMenu, 'position' => 'bottom right'])->setHoverable(); +$signup = \Atk4\Ui\Popup::addTo($app, [$rightMenu, 'position' => 'bottom right'])->setHoverable(); // This popup will be dynamically loaded. $signup->stickyGet('logged'); $signup->set(function ($pop) { // contetn of the popup will be different depending on this condition. if (isset($_GET['logged'])) { - \atk4\ui\Message::addTo($pop, ['You are already logged in as ' . $_GET['logged']]); - \atk4\ui\Button::addTo($pop, ['Logout', 'primary', 'icon' => 'sign out']) + \Atk4\Ui\Message::addTo($pop, ['You are already logged in as ' . $_GET['logged']]); + \Atk4\Ui\Button::addTo($pop, ['Logout', 'primary', 'icon' => 'sign out']) ->link($pop->getApp()->url()); } else { $form = Form::addTo($pop); @@ -246,28 +246,28 @@ public function linkCart($cart, $jsAction = null) // refreshes entire page return $form->getApp()->jsRedirect(['logged' => $form->model->get('email')]); - //return new \atk4\ui\JsExpression('alert([])', ['Thank you ' . $form->model->get('email')]); + //return new \Atk4\Ui\JsExpression('alert([])', ['Thank you ' . $form->model->get('email')]); }); } }); ////////////////////////////////////////////////////////////////////////////// -\atk4\ui\Header::addTo($app)->set('Specifying trigger'); +\Atk4\Ui\Header::addTo($app)->set('Specifying trigger'); -$button = \atk4\ui\Button::addTo($app, ['Click Me', 'primary']); +$button = \Atk4\Ui\Button::addTo($app, ['Click Me', 'primary']); -$buttonPopup = \atk4\ui\Popup::addTo($app, [$button]); +$buttonPopup = \Atk4\Ui\Popup::addTo($app, [$button]); -\atk4\ui\Header::addTo($buttonPopup)->set('Using click events'); -\atk4\ui\View::addTo($buttonPopup)->set('Adding popup into button activates on click by default. Clicked popups will close if you click away.'); +\Atk4\Ui\Header::addTo($buttonPopup)->set('Using click events'); +\Atk4\Ui\View::addTo($buttonPopup)->set('Adding popup into button activates on click by default. Clicked popups will close if you click away.'); $input = Form\Control\Line::addTo($app, ['placeholder' => 'Search users', 'icon' => 'circular search link']); -$inputPopup = \atk4\ui\Popup::addTo($app, [$input, 'triggerOn' => 'focus']); -\atk4\ui\View::addTo($inputPopup)->set('You can use this field to search data.'); +$inputPopup = \Atk4\Ui\Popup::addTo($app, [$input, 'triggerOn' => 'focus']); +\Atk4\Ui\View::addTo($inputPopup)->set('You can use this field to search data.'); -$button = \atk4\ui\Button::addTo($app, [null, 'icon' => 'volume down']); -$buttonPopup = \atk4\ui\Popup::addTo($app, [$button, 'triggerOn' => 'hover'])->setHoverable(); +$button = \Atk4\Ui\Button::addTo($app, [null, 'icon' => 'volume down']); +$buttonPopup = \Atk4\Ui\Popup::addTo($app, [$button, 'triggerOn' => 'hover'])->setHoverable(); Form\Control\Checkbox::addTo($buttonPopup, ['Just On/Off', 'slider'])->on('change', $button->js()->find('.icon')->toggleClass('up down')); diff --git a/demos/interactive/progress.php b/demos/interactive/progress.php index d47b1cfee7..8d8fbad493 100644 --- a/demos/interactive/progress.php +++ b/demos/interactive/progress.php @@ -2,16 +2,16 @@ 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'; -$p = \atk4\ui\ProgressBar::addTo($app, [20]); +$p = \Atk4\Ui\ProgressBar::addTo($app, [20]); -$p = \atk4\ui\ProgressBar::addTo($app, [60, 'indicating progress', 'indicating']); -\atk4\ui\Button::addTo($app, ['increment'])->on('click', $p->jsIncrement()); -\atk4\ui\Button::addTo($app, ['set'])->on('click', $p->jsValue(20)); +$p = \Atk4\Ui\ProgressBar::addTo($app, [60, 'indicating progress', 'indicating']); +\Atk4\Ui\Button::addTo($app, ['increment'])->on('click', $p->jsIncrement()); +\Atk4\Ui\Button::addTo($app, ['set'])->on('click', $p->jsValue(20)); diff --git a/demos/interactive/scroll-container.php b/demos/interactive/scroll-container.php index 2ed1f50a13..69234af1d2 100644 --- a/demos/interactive/scroll-container.php +++ b/demos/interactive/scroll-container.php @@ -2,31 +2,31 @@ 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\Button::addTo($app, ['Dynamic scroll in Table', 'small left floated basic blue', 'icon' => 'left arrow']) +\Atk4\Ui\Button::addTo($app, ['Dynamic scroll in Table', 'small left floated basic blue', 'icon' => 'left arrow']) ->link(['scroll-table']); -\atk4\ui\Button::addTo($app, ['Dynamic scroll in Grid', 'small right floated basic blue', 'iconRight' => 'right arrow']) +\Atk4\Ui\Button::addTo($app, ['Dynamic scroll in Grid', 'small right floated basic blue', 'iconRight' => 'right arrow']) ->link(['scroll-grid']); -\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 Container']); +\Atk4\Ui\Header::addTo($app, ['Dynamic scroll in Container']); -$view = \atk4\ui\View::addTo($app)->addClass('ui basic segment atk-scroller'); +$view = \Atk4\Ui\View::addTo($app)->addClass('ui basic segment atk-scroller'); -$scrollContainer = \atk4\ui\View::addTo($view)->addClass('ui segment')->addStyle(['max-height' => '400px', 'overflow-y' => 'scroll']); +$scrollContainer = \Atk4\Ui\View::addTo($view)->addClass('ui segment')->addStyle(['max-height' => '400px', 'overflow-y' => 'scroll']); $listerTemplate = '
{List}
{name}andorra{/}
{/}{$Content}
'; -$listerContainer = \atk4\ui\View::addTo($scrollContainer, ['template' => new HtmlTemplate($listerTemplate)]); +$listerContainer = \Atk4\Ui\View::addTo($scrollContainer, ['template' => new HtmlTemplate($listerTemplate)]); -$lister = \atk4\ui\Lister::addTo($listerContainer, [], ['List']); -$lister->onHook(\atk4\ui\Lister::HOOK_BEFORE_ROW, function (\atk4\ui\Lister $lister) { +$lister = \Atk4\Ui\Lister::addTo($listerContainer, [], ['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)); diff --git a/demos/interactive/scroll-grid-container.php b/demos/interactive/scroll-grid-container.php index 2908f5955b..9d9ba9e4b2 100644 --- a/demos/interactive/scroll-grid-container.php +++ b/demos/interactive/scroll-grid-container.php @@ -2,27 +2,27 @@ 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 Crud and Grid', 'small left floated basic blue', 'icon' => 'left arrow']) +\Atk4\Ui\Button::addTo($app, ['Dynamic scroll in Crud and Grid', 'small left floated basic blue', 'icon' => 'left arrow']) ->link(['scroll-grid']); -\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 Grid with fixed column headers']); +\Atk4\Ui\Header::addTo($app, ['Dynamic scroll in Grid with fixed column headers']); -$c = \atk4\ui\Columns::addTo($app); +$c = \Atk4\Ui\Columns::addTo($app); $c1 = $c->addColumn(); -$g1 = \atk4\ui\Crud::addTo($c1); +$g1 = \Atk4\Ui\Crud::addTo($c1); $m1 = $g1->setModel(new CountryLock($app->db)); $g1->addQuickSearch(['name', 'iso']); // demo for additional action buttons in Crud + JsPaginator -$g1->addModalAction(['icon' => [\atk4\ui\Icon::class, 'cogs']], 'Details', function ($p, $id) use ($g1) { - \atk4\ui\Card::addTo($p)->setModel($g1->model->load($id)); +$g1->addModalAction(['icon' => [\Atk4\Ui\Icon::class, 'cogs']], 'Details', function ($p, $id) use ($g1) { + \Atk4\Ui\Card::addTo($p)->setModel($g1->model->load($id)); }); $g1->addActionButton('red', function ($js) { return $js->closest('tr')->css('color', 'red'); @@ -31,10 +31,10 @@ $g1->addJsPaginatorInContainer(30, 350); $c2 = $c->addColumn(); -$g2 = \atk4\ui\Grid::addTo($c2, ['menu' => false]); +$g2 = \Atk4\Ui\Grid::addTo($c2, ['menu' => false]); $m2 = $g2->setModel(new CountryLock($app->db)); $g2->addJsPaginatorInContainer(20, 200); -$g3 = \atk4\ui\Grid::addTo($c2, ['menu' => false]); +$g3 = \Atk4\Ui\Grid::addTo($c2, ['menu' => false]); $m3 = $g3->setModel(new CountryLock($app->db)); $g3->addJsPaginatorInContainer(10, 150); diff --git a/demos/interactive/scroll-grid.php b/demos/interactive/scroll-grid.php index d06c2c6f80..ea8dc5061f 100644 --- a/demos/interactive/scroll-grid.php +++ b/demos/interactive/scroll-grid.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 Container', 'small left floated basic blue', 'icon' => 'left arrow']) +\Atk4\Ui\Button::addTo($app, ['Dynamic scroll in Container', 'small left floated basic blue', 'icon' => 'left arrow']) ->link(['scroll-container']); -\atk4\ui\Button::addTo($app, ['Dynamic scroll in Grid using Container', 'small right floated basic blue', 'iconRight' => 'right arrow']) +\Atk4\Ui\Button::addTo($app, ['Dynamic scroll in Grid using Container', 'small right floated basic blue', 'iconRight' => 'right arrow']) ->link(['scroll-grid-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 Grid']); +\Atk4\Ui\Header::addTo($app, ['Dynamic scroll in Grid']); -$grid = \atk4\ui\Grid::addTo($app, ['menu' => false]); +$grid = \Atk4\Ui\Grid::addTo($app, ['menu' => false]); $model = $grid->setModel(new CountryLock($app->db)); $grid->addJsPaginator(30); diff --git a/demos/interactive/scroll-lister.php b/demos/interactive/scroll-lister.php index 7f1efb6a0a..98b28dbe40 100644 --- a/demos/interactive/scroll-lister.php +++ b/demos/interactive/scroll-lister.php @@ -2,27 +2,27 @@ 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\Button::addTo($app, ['Dynamic scroll in Table', 'small right floated basic blue', 'iconRight' => 'right arrow']) +\Atk4\Ui\Button::addTo($app, ['Dynamic scroll in Table', 'small right floated basic blue', 'iconRight' => 'right arrow']) ->link(['scroll-table']); -\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 Lister']); +\Atk4\Ui\Header::addTo($app, ['Dynamic scroll in Lister']); -$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'))); }); 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 (``) and an appropriate caption. If necessary will include "sorting" icons or any other controls that go in the header of the table. -.. php:method:: getTotalsCellHtml(\atk4\data\Field $field, $value) +.. php:method:: getTotalsCellHtml(\Atk4\Data\Field $field, $value) Provided with the field and the value, format the cell for the footer "totals" row. Table can rely on various strategies for calculating totals. See :php:meth:`Table::addTotals`. -.. php:method:: getDataCellHtml(\atk4\data\Field $field) +.. php:method:: getDataCellHtml(\Atk4\Data\Field $field) Provided with a field, this method will respond with HTML **template**. In order to keep performance of Web Application at the maximum, Table will execute getDataCellHtml for all the @@ -92,7 +92,7 @@ into table column and can be linked with Popup or Menu. Basic Use --------- -The simplest way to use Menus and Popups is through a wrappers: :php:meth:`atk4\\ui\\Grid::addDropdown` and :php:meth:`atk4\\ui\\Grid::addPopup`:: +The simplest way to use Menus and Popups is through a wrappers: :php:meth:`Atk4\\Ui\\Grid::addDropdown` and :php:meth:`Atk4\\Ui\\Grid::addPopup`:: View::addTo($grid->addPopup('iso')) ->set('Grid column popup text'); @@ -112,8 +112,8 @@ Popups .. php:method:: addPopup() To create a popup, you need to get the column decorator object. This must be the first decorator, which -is responsible for rendering of the TH box. If you are adding column manually, :php:meth:`atk4\\ui\\Table::addColumn()` -will return it. When using model, use :php:meth:`atk4\\ui\\Table::getColumnDecorators`:: +is responsible for rendering of the TH box. If you are adding column manually, :php:meth:`Atk4\\Ui\\Table::addColumn()` +will return it. When using model, use :php:meth:`Atk4\\Ui\\Table::getColumnDecorators`:: $table = Table::addTo($app, ['celled' => true]); @@ -124,7 +124,7 @@ will return it. When using model, use :php:meth:`atk4\\ui\\Table::getColumnDecor .. important:: If content of a pop-up is too large, it may not be possible to display it on-screen. Watch for warning. -You may also use :php:meth:`atk4\\ui\\Popup::set` method to dynamically load the content:: +You may also use :php:meth:`Atk4\\Ui\\Popup::set` method to dynamically load the content:: $table = Table::addTo($app, ['celled' => true]); @@ -160,16 +160,16 @@ Link Put `addColumn('name', [\atk4\ui\Table\Column\Link::class, 'https://google.com/?q={$name}']); + $table->addColumn('name', [\Atk4\Ui\Table\Column\Link::class, 'https://google.com/?q={$name}']); The URL may also be specified as an array. It will be passed to App::url() which will encode arguments:: - $table->addColumn('name', [\atk4\ui\Table\Column\Link::class, ['details', 'id'=>123, 'q'=>$anything]]); + $table->addColumn('name', [\Atk4\Ui\Table\Column\Link::class, ['details', 'id'=>123, 'q'=>$anything]]); In this case even if `$anything = '{$name}'` the substitution will not take place for safety reasons. To pass on some values from your model, use second argument to constructor:: - $table->addColumn('name', [\atk4\ui\Table\Column\Link::class, ['details', 'id'=>123], ['q'=>'name']]); + $table->addColumn('name', [\Atk4\Ui\Table\Column\Link::class, ['details', 'id'=>123], ['q'=>'name']]); Money @@ -196,7 +196,7 @@ to use different icons and colors to emphasise status:: $states = [ 'positive'=>['paid', 'archived'], 'negative'=>['declined'] ]; - $table->addColumn('status', new \atk4\ui\Table\Column\Status($states)); + $table->addColumn('status', new \Atk4\Ui\Table\Column\Status($states)); Current list of states supported: @@ -216,7 +216,7 @@ the trouble of setting up your own class. If you wish to display movie rating "4 out of 10" based around the column "rating", you can use:: - $table->addColumn('rating', new \atk4\ui\Table\Column\Template('{$rating} out of 10')); + $table->addColumn('rating', new \Atk4\Ui\Table\Column\Template('{$rating} out of 10')); Template may incorporate values from multiple fields in a data row, but current implementation will only work if you asign it to a primary column (by passing 1st argument to addColumn). @@ -230,7 +230,7 @@ Image This column is suitable if you wish to have image in your table cell:: - $table->addColumn('image_url', new \atk4\ui\Table\Column\Image); + $table->addColumn('image_url', new \Atk4\Ui\Table\Column\Image); Interactive Decorators @@ -252,11 +252,11 @@ If you want to have label above the action column, then:: .. php:method:: addAction($button, $action, $confirm = false) Adds another button into "Actions" column which will perform a certain JavaScript action when clicked. -See also :php:meth:`atk4\\ui\\Grid::addAction()`:: +See also :php:meth:`Atk4\\Ui\\Grid::addAction()`:: $button = $action->addAction('Reload Table', $table->jsReload()); -Normally you would also want to pass the ID of the row which was clicked. You can use :php:meth:`atk4\\ui\\Table:jsRow()` +Normally you would also want to pass the ID of the row which was clicked. You can use :php:meth:`Atk4\\Ui\\Table:jsRow()` and jQuery's data() method to reference it:: $button = $action->addAction('Reload Table', $table->jsReload(['clicked'=>$table->jsRow()->data('id')])); @@ -265,7 +265,7 @@ Moreover you may pass $action argument as a PHP callback. .. php:method:: addModal($button, $title, $callback) -Triggers a modal dialog when you click on the button. See description on :php:meth:`atk4\\ui\\Grid::addModalAction()`:: +Triggers a modal dialog when you click on the button. See description on :php:meth:`Atk4\\Ui\\Grid::addModalAction()`:: $action->addAction(['Say HI'], function ($j, $id) use ($g) { return 'Loaded "'.$g->model->load($id)['name'].'" from ID='.$id; @@ -285,7 +285,7 @@ CheckBox column provides you with a handy jsChecked() method, which you can use current item selection. The next code will allow you to select the checkboxes, and when you click on the button, it will reload $segment component while passing all the id's:: - $box = $table->addColumn(new \atk4\ui\Table\Column\CheckBox()); + $box = $table->addColumn(new \Atk4\Ui\Table\Column\CheckBox()); $button->on('click', new JsReload($segment, ['ids'=>$box->jsChecked()])); @@ -297,17 +297,17 @@ Multiformat ----------- Sometimes your formatting may change depending on value. For example you may want to place link -only on certain rows. For this you can use an `\\atk4\ui\\Table\\Column\\Multiformat` decorator:: +only on certain rows. For this you can use an `\\Atk4\Ui\\Table\\Column\\Multiformat` decorator:: - $table->addColumn('amount', [\atk4\ui\Table\Column\Multiformat::class, function($model) { + $table->addColumn('amount', [\Atk4\Ui\Table\Column\Multiformat::class, function($model) { if ($model->get('is_invoiced') > 0) { - return [\atk4\ui\Table\Column\Money::class, [\atk4\ui\Table\Column\Link::class, 'invoice', ['invoice_id'=>'id']]]; + return [\Atk4\Ui\Table\Column\Money::class, [\Atk4\Ui\Table\Column\Link::class, 'invoice', ['invoice_id'=>'id']]]; } elseif (abs($model->get('is_refunded')) < 50) { - return [[\atk4\ui\Table\Column\Template::class, 'Amount was refunded']]; + return [[\Atk4\Ui\Table\Column\Template::class, 'Amount was refunded']]; } - return \atk4\ui\Table\Column\Money::class; + return \Atk4\Ui\Table\Column\Money::class; }]); You supply a callback to the Multiformat decorator, which will then be used to determine @@ -316,7 +316,7 @@ fields of your models and will conditionally add Link on top of Money formatting Your callback can return things in varous ways: - - return array of seeds: [[\atk4\ui\Table\Column\Link::class], \atk4\ui\Table\Column\Money::class]; + - return array of seeds: [[\Atk4\Ui\Table\Column\Link::class], \Atk4\Ui\Table\Column\Money::class]; - if string or object is returned it is wrapped inside array automatically Multiple decorators will be created and merged. diff --git a/docs/tabs.rst b/docs/tabs.rst index 405e65c217..d8429fbf8b 100644 --- a/docs/tabs.rst +++ b/docs/tabs.rst @@ -1,5 +1,5 @@ -.. php:namespace:: atk4\ui +.. php:namespace:: Atk4\Ui .. php:class:: Tabs @@ -63,7 +63,7 @@ Note that tab contents are refreshed including any values you put on the form:: // dynamic tab $t->addTab('Dynamic Form', function ($tab) { - $m_register = new \atk4\data\Model(new \atk4\data\Persistence_Array($a)); + $m_register = new \Atk4\Data\Model(new \Atk4\Data\Persistence_Array($a)); $m_register->addField('name', ['caption'=>'Please enter your name (John)']); $form = Form::addTo($tab, ['segment'=>true]); diff --git a/docs/template.rst b/docs/template.rst index ed5a5eb7e1..a7fec62168 100644 --- a/docs/template.rst +++ b/docs/template.rst @@ -361,7 +361,7 @@ will return contents of the template without tags:: $result = $template->renderToHtml(); - \atk4\ui\Text::addTo($this)->set($result); + \Atk4\Ui\Text::addTo($this)->set($result); // Will output "Hello, World" @@ -413,10 +413,10 @@ You can use the following code to manipulate the template above:: Same thing using Agile Toolkit Views:: - $envelope = \atk4\ui\View::addTo($this, [], [null], null, ['envelope']); + $envelope = \Atk4\Ui\View::addTo($this, [], [null], null, ['envelope']); - $sender = \atk4\ui\View::addTo($envelope, [], [null], 'Sender', 'Sender'); - $recipient = \atk4\ui\View::addTo($envelope, [], [null], 'Recipient', 'Recipient'); + $sender = \Atk4\Ui\View::addTo($envelope, [], [null], 'Sender', 'Sender'); + $recipient = \Atk4\Ui\View::addTo($envelope, [], [null], 'Recipient', 'Recipient'); $sender ->tempalte->set($sender_data); $recipient ->tempalte->set($recipient_data); @@ -530,7 +530,7 @@ Template is available by the time ``init()`` is called and you can access it from inside the object or from outside through "template" property:: - $grid = \atk4\ui\Grid::addTo($this, [], [null], null, array('grid_with_hint')); + $grid = \Atk4\Ui\Grid::addTo($this, [], [null], null, array('grid_with_hint')); $grid->template->trySet('my_hint', 'Changing value of a grid hint here!'); In this example we have instructed to use a different template for grid, @@ -556,11 +556,11 @@ implemented using generic views. :: - $envelope = \atk4\ui\View::addTo($this, [], [null], null, array('envelope')); + $envelope = \Atk4\Ui\View::addTo($this, [], [null], null, array('envelope')); // 3rd argument is output region, 4th is template location - $sender = \atk4\ui\View::addTo($envelope, [], [null], 'Sender', 'Sender'); - $receiver = \atk4\ui\View::addTo($envelope, [], [null], 'Receiver', 'Receiver'); + $sender = \Atk4\Ui\View::addTo($envelope, [], [null], 'Sender', 'Sender'); + $receiver = \Atk4\Ui\View::addTo($envelope, [], [null], 'Receiver', 'Receiver'); $sender->template->trySet($sender_data); $receiver->template->trySet($receiver_data); diff --git a/docs/text.rst b/docs/text.rst index 700b375937..c2997af54b 100644 --- a/docs/text.rst +++ b/docs/text.rst @@ -4,7 +4,7 @@ Text ==== -.. php:namespace:: atk4\ui +.. php:namespace:: Atk4\Ui .. php:class:: Text diff --git a/docs/tree-item-selector.rst b/docs/tree-item-selector.rst index 566407b375..9224ced85d 100644 --- a/docs/tree-item-selector.rst +++ b/docs/tree-item-selector.rst @@ -1,5 +1,5 @@ -.. php:namespace:: atk4\ui\Form\Control +.. php:namespace:: Atk4\Ui\Form\Control .. php:class:: TreeItemSelector @@ -75,7 +75,7 @@ Adding a TreeItemSelector form control to a Form:: ]; - $form = \atk4\ui\Form::addTo($app); + $form = \Atk4\Ui\Form::addTo($app); $control = $form->addControl('tree', [new TreeItemSelector(['treeItems' => $items]), 'caption' => 'Select items:'], ['type' => 'array', 'serialize' => 'json']); $control->set([201, 301, 503]); @@ -92,7 +92,7 @@ It is possible to run a callback function every time an item is select on the li set by the user.:: $control->onItem(function($value) { - return new \atk4\ui\JsToast($this->getApp()->encodeJson($value)); + return new \Atk4\Ui\JsToast($this->getApp()->encodeJson($value)); }); Note diff --git a/docs/type-presentation.rst b/docs/type-presentation.rst index c121cc95f6..84d1efbee1 100644 --- a/docs/type-presentation.rst +++ b/docs/type-presentation.rst @@ -66,18 +66,18 @@ Manually Specifying Decorators When working with components, they allow to specify decorators manually, even if the type of the field does not seem compatible:: - $table->addColumn('field_name', new \atk4\ui\Table\Column\Password()); + $table->addColumn('field_name', new \Atk4\Ui\Table\Column\Password()); // or - $form->addControl('field_name', new \atk4\ui\Form\Control\Password()); + $form->addControl('field_name', new \Atk4\Ui\Form\Control\Password()); Selecting the decorator is done in the following order: - specified in second argument to UI `addColumn()` or `addControl()` (as shown above) - - specified using `ui` property of :php:class:`\atk4\data\Field`:: + - specified using `ui` property of :php:class:`\Atk4\Data\Field`:: - $field->ui['form'] = new \atk4\ui\Form\Control\Password(); + $field->ui['form'] = new \Atk4\Ui\Form\Control\Password(); - fallback to :php:meth:`Form::controlFactory` @@ -114,7 +114,7 @@ hidden when presented. To hide it from Table:: $model = new User($app->db); $table->setModel($model); - $model->addDecorator('account_number', new \atk4\ui\Table\Column\Password()); + $model->addDecorator('account_number', new \Atk4\Ui\Table\Column\Password()); Create a decorator for hiding credit card number ------------------------------------------------ @@ -122,14 +122,14 @@ Create a decorator for hiding credit card number If you happen to store card numbers and you only want to display the last digits in tables, yet make it available when editing, you could create your own :php:class:`Table\\Column` decorator:: - class Masker extends \atk4\ui\Table\Column + class Masker extends \Atk4\Ui\Table\Column { - public function getDataCellTemplate(\atk4\data\Field $field = null) + public function getDataCellTemplate(\Atk4\Data\Field $field = null) { return '**** **** **** {$mask}'; } - public function getHtmlTags(\atk4\data\Model $row, $field) + public function getHtmlTags(\Atk4\Data\Model $row, $field) { return [ 'mask' => substr($field->get(), -4) @@ -147,10 +147,10 @@ If we always have to display card numbers with spaces, e.g. "1234 1234 1234 1234 the database store them without spaces, then this is a data formatting task best done by extending :php:class:`Persistence\\Ui`:: - class MyPersistence extends \atk4\ui\Persistence\Ui + class MyPersistence extends \Atk4\Ui\Persistence\Ui { - public function _typecastSaveField(\atk4\data\Field $field, $value) + public function _typecastSaveField(\Atk4\Data\Field $field, $value) { switch ($field->type) { case 'card': @@ -160,7 +160,7 @@ extending :php:class:`Persistence\\Ui`:: return parent::_typecastSaveField($field, $value); } - public function _typecastLoadField(\atk4\data\Field $field, $value) + public function _typecastLoadField(\Atk4\Data\Field $field, $value) { switch ($field->type) { case 'card': diff --git a/docs/view.rst b/docs/view.rst index cebb2a8348..122bb68125 100644 --- a/docs/view.rst +++ b/docs/view.rst @@ -9,7 +9,7 @@ Views Agile UI is a component framework, which follows a software patterns known as `Render Tree` and `Two pass HTML rendering`. -.. php:namespace:: atk4\ui +.. php:namespace:: Atk4\Ui .. php:class:: View @@ -19,7 +19,7 @@ Agile UI is a component framework, which follows a software patterns known as View object is recursive. You can take one view and add another View inside of it:: - $v = new \atk4\ui\View(['ui'=>'segment', 'inverted']); + $v = new \Atk4\Ui\View(['ui'=>'segment', 'inverted']); Button::addTo($v, ['Orange', 'inverted orange']); The above code will produce the following HTML block: @@ -72,9 +72,9 @@ in any way you wish, before they will actuallized. In the next example I'll be creating 3 views, but it at the time their __constructor is executed it will be impossible to determine each view's position inside render tree:: - $middle = new \atk4\ui\View(['ui'=>'segment', 'red']); - $top = new \atk4\ui\View(['ui'=>'segments']); - $bottom = new \atk4\ui\Button(['Hello World', 'orange']); + $middle = new \Atk4\Ui\View(['ui'=>'segment', 'red']); + $top = new \Atk4\Ui\View(['ui'=>'segments']); + $bottom = new \Atk4\Ui\Button(['Hello World', 'orange']); // not arranged into render-tree yet @@ -84,7 +84,7 @@ is executed it will be impossible to determine each view's position inside rende // Still not sure if finished adding - $app = new \atk4\ui\App('My App'); + $app = new \Atk4\Ui\App('My App'); $app->initLayout($top); // Calls init() for all elements recursively. @@ -93,8 +93,8 @@ Each View's `init()` method will be executed first before calling the same metho child elements. To make your execution more straightforward we recommend you to create App class first and then continue with Layout initialization:: - $app = new \atk4\ui\App('My App'); - $top = $app->initLayout(new \atk4\ui\View(['ui'=>'segments'])); + $app = new \Atk4\Ui\App('My App'); + $top = $app->initLayout(new \Atk4\Ui\View(['ui'=>'segments'])); $middle = View::addTo($top, ['ui'=>'segment', 'red']); @@ -102,8 +102,8 @@ App class first and then continue with Layout initialization:: Finally, if you prefer a more consise code, you can also use the following format:: - $app = new \atk4\ui\App('My App'); - $top = $app->initLayout([\atk4\ui\View::class, 'ui'=>'segments']); + $app = new \Atk4\Ui\App('My App'); + $top = $app->initLayout([\Atk4\Ui\View::class, 'ui'=>'segments']); $middle = View::addTo($top, ['ui'=>'segment', 'red']); @@ -121,7 +121,7 @@ Use of $app property and Dependency Injeciton .. php:attr:: app - Each View has a property $app that is defined through \atk4\core\AppScopeTrait. + Each View has a property $app that is defined through \Atk4\Core\AppScopeTrait. View elements rely on persistence of the app class in order to perform Dependency Injection. @@ -149,9 +149,9 @@ Integration with Agile Data If you have used Agile Data, you should be familiar with a concept of creating Models:: - $db = new \atk4\data\Persistence_SQL::connect($dsn); + $db = new \Atk4\Data\Persistence_SQL::connect($dsn); - $client = new Client($db); // extends \atk4\data\Model(); + $client = new Client($db); // extends \Atk4\Data\Model(); Once you have a model, you can associate it with a View such as Form or Grid so that those Views would be able to interact with your persistence directly:: @@ -161,7 +161,7 @@ so that those Views would be able to interact with your persistence directly:: In most environments, however, your application will rely on a primary Database, which can be set through your $app class:: - $app->db = new \atk4\data\Persistence_SQL::connect($dsn); + $app->db = new \Atk4\Data\Persistence_SQL::connect($dsn); // next, anywhere in a view $client = new Client($this->getApp()->db); @@ -169,7 +169,7 @@ can be set through your $app class:: Or if you prefer a more consise code:: - $app->db = new \atk4\data\Persistence_SQL::connect($dsn); + $app->db = new \Atk4\Data\Persistence_SQL::connect($dsn); // next, anywhere in a view $form->setModel('Client'); @@ -258,7 +258,7 @@ Special-purpose properties A view may define a special-purpose properties, that may modify how the view is rendered. For example, Button has a property 'icon', that is implemented -by creating instance of \atk4\ui\Icon() inside the button. +by creating instance of \Atk4\Ui\Icon() inside the button. The same pattern can be used for other scenarios:: @@ -337,7 +337,7 @@ to do something before child render, override method :php:meth:`View::recursiveR Template of a current view. This attribute contains an object of a class :php:class:`Template`. You may secify this value explicitly:: - View::addTo($app, ['template'=>new \atk4\ui\Template('hello')]); + View::addTo($app, ['template'=>new \Atk4\Ui\Template('hello')]); .. php:attr:: defaultTemplate @@ -409,7 +409,7 @@ Unique ID tag Agile UI will maintain unique ID for all the elements. The tag is set through 'id' property:: - $b = new \atk4\ui\Button(['id'=>'my-button3']); + $b = new \Atk4\Ui\Button(['id'=>'my-button3']); echo $b->render(); Outputs: @@ -459,7 +459,7 @@ which will respond with JavaScript Action for reloading the view:: $b1->on('click', $b2->jsReload()); // Previously: - // $b1->on('click', new \atk4\ui\JsReload($b2)); + // $b1->on('click', new \Atk4\Ui\JsReload($b2)); diff --git a/docs/virtualpage.rst b/docs/virtualpage.rst index 5f9de6dd07..b7030c5088 100644 --- a/docs/virtualpage.rst +++ b/docs/virtualpage.rst @@ -12,8 +12,8 @@ Unlike any of the Callback classes, VirtualPage is a legitimate :php:class:`View "different". In normal circumstances, rendering VirtualPage will result in empty string. Adding VirtualPage anywhere inside your :ref:`render_tree` simply won't have any visible effect:: - $vp = \atk4\ui\VirtualPage::addTo($layout); - \atk4\ui\LoremIpsum::addTo($vp); + $vp = \Atk4\Ui\VirtualPage::addTo($layout); + \Atk4\Ui\LoremIpsum::addTo($vp); However, VirtualPage has a special trigger argument. If found, then VirtualPage will interrupt normal rendering progress and output HTML of itself and any other Components you added to that page. @@ -29,7 +29,7 @@ This pattern is very easy to implement and is used by many components to transpa Next is an example where :php:class:`Tabs` has support for call-back for generating dynamic content for the tab:: $tabs->addTab('Dynamic Tab Content', function($vp) { - \atk4\ui\LoremIpsum::addTo($vp); + \Atk4\Ui\LoremIpsum::addTo($vp); }); Using VirtualPage inside your component can significantly enhance usability without introducing any complexity @@ -43,10 +43,10 @@ below). VirtuaPage relies on :php:class:`CallbackLater` object, which is stored in a property $cb. If the Callback is triggered through a GET argument, then VirtualPage will change it's rendering technique. Lets examine it in more detail:: - $vp = \atk4\ui\VirtualPage::addTo($layout); - \atk4\ui\LoremIpsum::addTo($vp); + $vp = \Atk4\Ui\VirtualPage::addTo($layout); + \Atk4\Ui\LoremIpsum::addTo($vp); - $label = \atk4\ui\Label::addTo($layout); + $label = \Atk4\Ui\Label::addTo($layout); $label->detail = $vp->cb->getUrl(); $label->link($vp->cb->getUrl()); @@ -82,12 +82,12 @@ Setting Callback Although VirtualPage can work without defining a callback, using one is more reliable and is always recommended:: - $vp = \atk4\ui\VirtualPage::addTo($layout); + $vp = \Atk4\Ui\VirtualPage::addTo($layout); $vp->set(function($vp){ - \atk4\ui\LoremIpsum::addTo($vp); + \Atk4\Ui\LoremIpsum::addTo($vp); }); - $label = \atk4\ui\Label::addTo($layout); + $label = \Atk4\Ui\Label::addTo($layout); $label->detail = $vp->cb->getUrl(); $label->link($vp->cb->getUrl()); @@ -98,10 +98,10 @@ also makes it possible for VirtualPage to be embedded into any :ref:`component` To illustrate, see how :php:class:`Tabs` component rely on VirtualPage, the following code:: - $t = \atk4\ui\Tabs::addTo($layout); + $t = \Atk4\Ui\Tabs::addTo($layout); - \atk4\ui\LoremIpsum::addTo($t->addTab('Tab1')); // regular tab - $t->addTab('Tab2', function($p){ \atk4\ui\LoremIpsum::addTo($p); }); // dynamic tab + \Atk4\Ui\LoremIpsum::addTo($t->addTab('Tab1')); // regular tab + $t->addTab('Tab2', function($p){ \Atk4\Ui\LoremIpsum::addTo($p); }); // dynamic tab .. php:method:: getUrl($html_wrapping) @@ -112,11 +112,11 @@ To illustrate, see how :php:class:`Tabs` component rely on VirtualPage, the foll When using 'popup' mode, the output appears inside a `
`. If you want to change this class, you can set $ui property to something else. Try:: - $vp = \atk4\ui\VirtualPage::addTo($layout); - \atk4\ui\LoremIpsum::addTo($vp); + $vp = \Atk4\Ui\VirtualPage::addTo($layout); + \Atk4\Ui\LoremIpsum::addTo($vp); $vp->ui = 'red inverted segment'; - $label = \atk4\ui\Label::addTo($layout); + $label = \Atk4\Ui\Label::addTo($layout); $label->detail = $vp->cb->getUrl('popup'); $label->link($vp->cb->getUrl('popup')); @@ -141,12 +141,12 @@ Loader extends VirtualPage and is quite similar to it. Like with a VirtualPage - you should use `set()` to define content that will be loaded dynamically, while a spinner is shown to a user:: - $loader = \atk4\ui\Loader::addTo($app); + $loader = \Atk4\Ui\Loader::addTo($app); $loader->set(function($p) { // Simulate slow-loading component sleep(2); - \atk4\ui\LoremIpsum::addTo($p); + \Atk4\Ui\LoremIpsum::addTo($p); }); @@ -159,12 +159,12 @@ Loader needs to occupy some space. By default it will display a white segment with 7em height, but you can specify any other view thorugh $shim property:: - $loader = \atk4\ui\Loader::addTo($app, ['shim'=>['Message', 'Please wait until we load LoremIpsum...', 'red']]); + $loader = \Atk4\Ui\Loader::addTo($app, ['shim'=>['Message', 'Please wait until we load LoremIpsum...', 'red']]); $loader->set(function($p) { // Simulate slow-loading component sleep(2); - \atk4\ui\LoremIpsum::addTo($p); + \Atk4\Ui\LoremIpsum::addTo($p); }); @@ -196,14 +196,14 @@ behaviour does not work, you should set value for $loadEvent: To indicate how custom binding works:: - $loader = \atk4\ui\Loader::addTo($app, ['loadEvent' => 'kaboom']); + $loader = \Atk4\Ui\Loader::addTo($app, ['loadEvent' => 'kaboom']); $loader->set(function($p){ - \atk4\ui\LoremIpsum::addTo($p); + \Atk4\Ui\LoremIpsum::addTo($p); }); - \atk4\ui\Button::addTo($app, ['Load data'])->on('click', $loader->js()->trigger('kaboom')); + \Atk4\Ui\Button::addTo($app, ['Load data'])->on('click', $loader->js()->trigger('kaboom')); This approach allow you to trigger loader from inside JavaScript easily. See also: https://api.jquery.com/trigger/ @@ -219,21 +219,21 @@ Inline Editing Example Next example will display DataTable, but will allow you to replace data with a form temporarily:: - $box = \atk4\ui\View::addTo($app, ['ui'=>'segment']); + $box = \Atk4\Ui\View::addTo($app, ['ui'=>'segment']); - $loader = \atk4\ui\Loader::addTo($box, ['loadEvent'=>'edit']); - \atk4\ui\Table::addTo($loader) + $loader = \Atk4\Ui\Loader::addTo($box, ['loadEvent'=>'edit']); + \Atk4\Ui\Table::addTo($loader) ->setModel($data) ->addCondition('year', $app->stickyGet('year')); - \atk4\ui\Button::addTo($box, ['Edit Data Settings'])->on('click', $loader->js()->trigger('edit')); + \Atk4\Ui\Button::addTo($box, ['Edit Data Settings'])->on('click', $loader->js()->trigger('edit')); $loader->set(function($p) use($loader) { - $form = \atk4\ui\Form::addTo($p); + $form = \Atk4\Ui\Form::addTo($p); $form->addControl('year'); $form->onSubmit(function($form) use ($loader) { - return new \atk4\ui\JsReload($loader, ['year'=>$form->model->get('year')]); + return new \Atk4\Ui\JsReload($loader, ['year'=>$form->model->get('year')]); }); }); @@ -251,7 +251,7 @@ Loader can have a progress bar. Imagine that your Loader has to run slow process You can notify user about this progress through a simple code:: - $loader = \atk4\ui\Loader::addTo($app, ['progressBar'=>true]); + $loader = \Atk4\Ui\Loader::addTo($app, ['progressBar'=>true]); $loader->set(function($p) { // Simulate slow-loading component @@ -263,7 +263,7 @@ You can notify user about this progress through a simple code:: $p->setProgress(0.75); sleep(1); - \atk4\ui\LoremIpsum::addTo($p); + \Atk4\Ui\LoremIpsum::addTo($p); }); diff --git a/docs/wizard.rst b/docs/wizard.rst index 973fff28b0..d101052887 100644 --- a/docs/wizard.rst +++ b/docs/wizard.rst @@ -1,6 +1,6 @@ -.. php:namespace:: atk4\ui +.. php:namespace:: Atk4\Ui .. php:class:: Wizard diff --git a/js/README.md b/js/README.md index 15dd9d9e15..4e22b09454 100644 --- a/js/README.md +++ b/js/README.md @@ -1,7 +1,7 @@ # Agile Toolkit js package The javascript package is necessary to run Agile Toolkit UI. It provide necessary -jQuery plugin needed for atk4\ui and also provide app wide services for semantic-ui module. +jQuery plugin needed for Atk4\Ui and also provide app wide services for semantic-ui module. The package also export some functions via the atk global object. @@ -18,7 +18,7 @@ All services are export via the atk global object. You can access them via atk.s Certain functionalities are offered from these services. For example, if one of your script need to send an ajax request directly, without using semantic-ui api request, you could use the apiService.atkSuccessTest -to run and evaluate the server response from atk4\ui. +to run and evaluate the server response from Atk4\Ui. ``` $.getJSON( "myajax.php", function( resp ) { diff --git a/js/src/plugins/js-sortable.plugin.js b/js/src/plugins/js-sortable.plugin.js index b3d679c757..d1e311b9c8 100644 --- a/js/src/plugins/js-sortable.plugin.js +++ b/js/src/plugins/js-sortable.plugin.js @@ -17,7 +17,7 @@ import 'draggable'; * * Defaut container is set to table boddy (tbody), using table row(tr) as reoderable element. * To use other container, simply set container and draggable accordingly. - * $sortable = \atk4\ui\JsSortable::addTo($lister, ['container' => 'ul', 'draggable' => 'li', 'dataLabel' => 'name']); + * $sortable = \Atk4\Ui\JsSortable::addTo($lister, ['container' => 'ul', 'draggable' => 'li', 'dataLabel' => 'name']); * * Element containing specific css class can be used as the handle for dragging element, if null * is pass, than the entire element is used. diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 100c61ced9..a02303290c 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -16,300 +16,299 @@ parameters: # TODO these rules are generated, this ignores should be fixed in the code # for level = 1 # for tsrc/AbstractView.php - - '~^Access to an undefined property atk4\\ui\\AbstractView\:\:\$skin\.$~' + - '~^Access to an undefined property Atk4\\Ui\\AbstractView\:\:\$skin\.$~' # for tsrc/CardDeck.php - - '~^Access to an undefined property atk4\\ui\\CardDeck\:\:\$editFields\.$~' + - '~^Access to an undefined property Atk4\\Ui\\CardDeck\:\:\$editFields\.$~' # for tsrc/Console.php - '~^Variable \$old_logger might not be defined\.$~' - '~^Variable \$stat might not be defined\.$~' - '~^Variable \$loggerBak might not be defined\.$~' - '~^Variable \$debugBak might not be defined\.$~' # for tsrc/Form/Control/Calendar.php - - '~^Class atk4\\ui\\JsFunction constructor invoked with 3 parameters, 0\-2 required\.$~' + - '~^Class Atk4\\Ui\\JsFunction constructor invoked with 3 parameters, 0\-2 required\.$~' # for tsrc/Form/Control/Lookup.php - - '~^Call to an undefined method atk4\\ui\\Form\\Control\\Lookup\:\:search\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Form\\Control\\Lookup\:\:search\(\)\.$~' # for tsrc/Form/Control/ScopeBuilder.php - '~^Variable \$inputType might not be defined\.$~' # for tsrc/Form/Control/Upload.php - '~^Function array_flip invoked with 2 parameters, 1 required\.$~' # for tsrc/HtmlTemplate.php - - '~^Method atk4\\ui\\HtmlTemplate\:\:del\(\) invoked with 2 parameters, 1 required\.$~' + - '~^Method Atk4\\Ui\\HtmlTemplate\:\:del\(\) invoked with 2 parameters, 1 required\.$~' # for tsrc/Modal.php - - '~^Access to an undefined property atk4\\ui\\Modal\:\:\$options\.$~' + - '~^Access to an undefined property Atk4\\Ui\\Modal\:\:\$options\.$~' # for tsrc/Table.php - - '~^Access to an undefined property atk4\\ui\\Table\:\:\$t_row_master\.$~' - - '~^Access to an undefined property atk4\\ui\\Table\:\:\$model¨\.$~' + - '~^Access to an undefined property Atk4\\Ui\\Table\:\:\$t_row_master\.$~' + - '~^Access to an undefined property Atk4\\Ui\\Table\:\:\$model¨\.$~' # for tsrc/Table/Column/Delete.php - - '~^Access to an undefined property atk4\\ui\\Table\\Column\\Delete\:\:\$vp\.$~' + - '~^Access to an undefined property Atk4\\Ui\\Table\\Column\\Delete\:\:\$vp\.$~' # for tsrc/Table/Column/FilterModel/TypeTime.php - - '~^Call to an undefined method atk4\\ui\\Table\\Column\\FilterModel\\TypeTime\:\:recalData\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Table\\Column\\FilterModel\\TypeTime\:\:recalData\(\)\.$~' # for tsrc/View.php - - '~^Method atk4\\ui\\View\:\:setModel\(\) invoked with 2 parameters, 1 required\.$~' + - '~^Method Atk4\\Ui\\View\:\:setModel\(\) invoked with 2 parameters, 1 required\.$~' # for tsrc/Wizard.php - - '~^Access to an undefined property atk4\\ui\\Wizard\:\:\$stepTemplate\.$~' - - '~^Access to an undefined property atk4\\ui\\Wizard\:\:\$buttonFinish\.$~' + - '~^Access to an undefined property Atk4\\Ui\\Wizard\:\:\$stepTemplate\.$~' + - '~^Access to an undefined property Atk4\\Ui\\Wizard\:\:\$buttonFinish\.$~' # for tests/CallbackTest.php - - '~^Access to an undefined property atk4\\ui\\tests\\AppMock\:\:\$terminate\.$~' + - '~^Access to an undefined property Atk4\\Ui\\Tests\\AppMock\:\:\$terminate\.$~' # TODO these rules are generated, this ignores should be fixed in the code # for level = 2 # for demos/_includes/Counter.php - - '~^Method atk4\\ui\\Jquery\:\:val\(\) invoked with 1 parameter, 0 required\.$~' + - '~^Method Atk4\\Ui\\Jquery\:\:val\(\) invoked with 1 parameter, 0 required\.$~' # for demos/_includes/Demo.php - - '~^Call to an undefined method atk4\\ui\\JsChain\:\:initHighlighting\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsChain\:\:initHighlighting\(\)\.$~' # for demos/_includes/DemoLookup.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:modal\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:dropdown\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:modal\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:dropdown\(\)\.$~' # for demos/_unit-test/callback.php - - '~^Access to an undefined property atk4\\ui\\AbstractView\:\:\$cb\.$~' - - '~^Call to an undefined method atk4\\ui\\AbstractView\:\:setModel\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\AbstractView\:\:jsReload\(\)\.$~' + - '~^Access to an undefined property Atk4\\Ui\\AbstractView\:\:\$cb\.$~' + - '~^Call to an undefined method Atk4\\Ui\\AbstractView\:\:setModel\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\AbstractView\:\:jsReload\(\)\.$~' # for demos/_unit-test/scope-builder-to-query.php - - '~^Method atk4\\ui\\App\:\:decodeJson\(\) invoked with 2 parameters, 1 required\.$~' + - '~^Method Atk4\\Ui\\App\:\:decodeJson\(\) invoked with 2 parameters, 1 required\.$~' # for demos/basic/label.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:fadeOut\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:fadeOut\(\)\.$~' # for demos/basic/message.php - - '~^Method atk4\\ui\\Jquery\:\:attr\(\) invoked with 1 parameter, 0 required\.$~' - - '~^Method atk4\\ui\\Jquery\:\:find\(\) invoked with 1 parameter, 0 required\.$~' + - '~^Method Atk4\\Ui\\Jquery\:\:attr\(\) invoked with 1 parameter, 0 required\.$~' + - '~^Method Atk4\\Ui\\Jquery\:\:find\(\) invoked with 1 parameter, 0 required\.$~' # for demos/basic/view.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:rating\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:transition\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:rating\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:transition\(\)\.$~' # for demos/collection/crud.php - - '~^Method atk4\\ui\\Columns\:\:addColumn\(\) invoked with 2 parameters, 0\-1 required\.$~' + - '~^Method Atk4\\Ui\\Columns\:\:addColumn\(\) invoked with 2 parameters, 0\-1 required\.$~' # for demos/collection/grid.php - - '~^Method atk4\\ui\\Jquery\:\:closest\(\) invoked with 1 parameter, 0 required\.$~' + - '~^Method Atk4\\Ui\\Jquery\:\:closest\(\) invoked with 1 parameter, 0 required\.$~' # for demos/collection/jssortable.php - - '~^Call to method get\(\) on an unknown class atk4\\ui\\Model\.$~' - - '~^Call to method set\(\) on an unknown class atk4\\ui\\Model\.$~' - - '~^Call to an undefined method atk4\\ui\\Table\\Column\:\:onReorder\(\)\.$~' + - '~^Call to method get\(\) on an unknown class Atk4\\Ui\\Model\.$~' + - '~^Call to method set\(\) on an unknown class Atk4\\Ui\\Model\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Table\\Column\:\:onReorder\(\)\.$~' # for demos/collection/lister-ipp.php # for demos/collection/multitable.php - - '~^Method atk4\\ui\\Jquery\:\:addClass\(\) invoked with 1 parameter, 0 required\.$~' + - '~^Method Atk4\\Ui\\Jquery\:\:addClass\(\) invoked with 1 parameter, 0 required\.$~' # for demos/collection/table.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:reload\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:reload\(\)\.$~' # for demos/collection/table2.php - - '~^Call to method getId\(\) on an unknown class atk4\\ui\\Model\.$~' + - '~^Call to method getId\(\) on an unknown class Atk4\\Ui\\Model\.$~' # for demos/collection/tablefilter.php - - '~^Call to an undefined method atk4\\ui\\demo\\CountryLock\:\:expr\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Demos\\CountryLock\:\:expr\(\)\.$~' # for demos/data-action/jsactions.php - - '~^Call to an undefined method atk4\\ui\\View\:\:addFields\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\View\:\:addFields\(\)\.$~' # for demos/form-control/calendar.php - - '~^Call to an undefined method atk4\\ui\\Form\\Control\:\:addAction\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Form\\Control\:\:getJsInstance\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Form\\Control\:\:addAction\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Form\\Control\:\:getJsInstance\(\)\.$~' # for demos/form-control/checkbox.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:checkbox\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:checkbox\(\)\.$~' # for demos/form-control/input2.php - - '~^Call to an undefined method atk4\\ui\\Form\\Control\:\:onDelete\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Form\\Control\:\:onUpload\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Form\\Control\:\:onDelete\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Form\\Control\:\:onUpload\(\)\.$~' # for demos/form-control/multiline.php - - '~^Call to an undefined method atk4\\ui\\Form\\Layout\:\:addColumn\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Form\\Control\:\:onLineChange\(\)\.$~' - - '~^Access to an undefined property atk4\\ui\\Form\\Control\:\:\$jsAfterAdd\.$~' - - '~^Access to an undefined property atk4\\ui\\Form\\Control\:\:\$jsAfterDelete\.$~' - - '~^Call to an undefined method atk4\\ui\\Form\\Control\:\:saveRows\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Form\\Layout\:\:addColumn\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Form\\Control\:\:onLineChange\(\)\.$~' + - '~^Access to an undefined property Atk4\\Ui\\Form\\Control\:\:\$jsAfterAdd\.$~' + - '~^Access to an undefined property Atk4\\Ui\\Form\\Control\:\:\$jsAfterDelete\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Form\\Control\:\:saveRows\(\)\.$~' # for demos/form-control/upload.php - - '~^Access to an undefined property atk4\\ui\\Form\\Control\:\:\$cb\.$~' - - '~^Call to an undefined method atk4\\ui\\Form\\Control\:\:clearThumbnail\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Form\\Control\:\:setThumbnailSrc\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Form\\Control\:\:setFileId\(\)\.$~' + - '~^Access to an undefined property Atk4\\Ui\\Form\\Control\:\:\$cb\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Form\\Control\:\:clearThumbnail\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Form\\Control\:\:setThumbnailSrc\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Form\\Control\:\:setFileId\(\)\.$~' # for demos/form/form-section-accordion.php - - '~^Call to an undefined method atk4\\ui\\Form\\Layout\:\:addSection\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Form\\Layout\:\:activate\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Form\\Layout\:\:addSection\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Form\\Layout\:\:activate\(\)\.$~' # for demos/form/form-section.php - - '~^Call to an undefined method atk4\\ui\\Form\\Layout\:\:addTab\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Form\\Layout\:\:addTab\(\)\.$~' # for demos/form/form.php - - '~^Call to an undefined method atk4\\ui\\JsChain\:\:val\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\JsChain\:\:checkbox\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsChain\:\:val\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsChain\:\:checkbox\(\)\.$~' # for demos/form/form2.php - - '~^Access to an undefined property atk4\\ui\\Form\\Control\:\:\$iconLeft\.$~' + - '~^Access to an undefined property Atk4\\Ui\\Form\\Control\:\:\$iconLeft\.$~' # for demos/init-app.php - - '~^Access to an undefined property atk4\\ui\\Layout&atk4\\ui\\Layout\\NavigableInterface\:\:\$menu\.$~' + - '~^Access to an undefined property Atk4\\Ui\\Layout&Atk4\\Ui\\Layout\\NavigableInterface\:\:\$menu\.$~' # for demos/init-db.php - - '~^Call to an undefined method atk4\\data\\Reference\\HasOne\:\:addField\(\)\.$~' - - '~^Call to an undefined method atk4\\data\\Persistence\:\:expr\(\)\.$~' - - '~^Call to an undefined method atk4\\data\\Reference\\HasOne\:\:addTitle\(\)\.$~' - - '~^Call to an undefined method atk4\\data\\Model\:\:importFromFilesystem\(\)\.$~' + - '~^Call to an undefined method Atk4\\Data\\Reference\\HasOne\:\:addField\(\)\.$~' + - '~^Call to an undefined method Atk4\\Data\\Persistence\:\:expr\(\)\.$~' + - '~^Call to an undefined method Atk4\\Data\\Reference\\HasOne\:\:addTitle\(\)\.$~' + - '~^Call to an undefined method Atk4\\Data\\Model\:\:importFromFilesystem\(\)\.$~' # for demos/interactive/modal.php - - '~^Method atk4\\ui\\Jquery\:\:removeClass\(\) invoked with 1 parameter, 0 required\.$~' - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:atkReloadView\(\)\.$~' + - '~^Method Atk4\\Ui\\Jquery\:\:removeClass\(\) invoked with 1 parameter, 0 required\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:atkReloadView\(\)\.$~' # for demos/interactive/popup.php - - '~^Access to an undefined property atk4\\ui\\Lister\:\:\$items\.$~' - - '~^Call to an undefined method atk4\\ui\\View\:\:linkCart\(\)\.$~' - - '~^Method atk4\\ui\\Jquery\:\:toggleClass\(\) invoked with 1 parameter, 0 required\.$~' + - '~^Access to an undefined property Atk4\\Ui\\Lister\:\:\$items\.$~' + - '~^Call to an undefined method Atk4\\Ui\\View\:\:linkCart\(\)\.$~' + - '~^Method Atk4\\Ui\\Jquery\:\:toggleClass\(\) invoked with 1 parameter, 0 required\.$~' # for demos/interactive/scroll-container.php # for demos/interactive/scroll-lister.php # for demos/interactive/sse.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:atkServerEvent\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:atkServerEvent\(\)\.$~' # for demos/interactive/tabs.php - - '~^Call to an undefined method atk4\\ui\\View\:\:setActive\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\View\:\:setActive\(\)\.$~' # for demos/interactive/wizard.php - - '~^Access to an undefined property atk4\\ui\\Form\\Control\:\:\$placeholder\.$~' + - '~^Access to an undefined property Atk4\\Ui\\Form\\Control\:\:\$placeholder\.$~' # for demos/javascript/js.php - - '~^Method atk4\\ui\\Jquery\:\:hide\(\) invoked with 1 parameter, 0 required\.$~' + - '~^Method Atk4\\Ui\\Jquery\:\:hide\(\) invoked with 1 parameter, 0 required\.$~' # for demos/javascript/vue-component.php # for demos/layout/layout-panel.php - - '~^Call to an undefined method atk4\\ui\\Panel\\Loadable\:\:jsOpen\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Panel\\Loadable\:\:onOpen\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Panel\\Loadable\:\:addConfirmation\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Panel\\Loadable\:\:jsOpen\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Panel\\Loadable\:\:onOpen\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Panel\\Loadable\:\:addConfirmation\(\)\.$~' # for demos/layout/layouts.php - - '~^Method atk4\\ui\\Jquery\:\:attr\(\) invoked with 2 parameters, 0 required\.$~' + - '~^Method Atk4\\Ui\\Jquery\:\:attr\(\) invoked with 2 parameters, 0 required\.$~' # for src/Accordion.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:accordion\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:accordion\(\)\.$~' # for src/Card.php - - '~^Call to an undefined method atk4\\ui\\AbstractView\:\:addFields\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:parents\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\AbstractView\:\:addFields\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:parents\(\)\.$~' - '~^PHPDoc tag @param has invalid value \(\[\] \$args The action argument\)\: Unexpected token "\[", expected type at offset 110$~' - - '~^Call to an undefined method atk4\\ui\\View\:\:addDescription\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\View\:\:addDescription\(\)\.$~' - '~^PHPDoc tag @param references unknown parameter\: \$isFluid$~' # for src/CardDeck.php - - '~^Access to an undefined property atk4\\ui\\AbstractView\:\:\$reload\.$~' - - '~^Access to an undefined property atk4\\ui\\AbstractView\:\:\$queryArg\.$~' - - '~^Call to an undefined method atk4\\ui\\AbstractView\:\:addClass\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\AbstractView\:\:on\(\)\.$~' + - '~^Access to an undefined property Atk4\\Ui\\AbstractView\:\:\$reload\.$~' + - '~^Access to an undefined property Atk4\\Ui\\AbstractView\:\:\$queryArg\.$~' + - '~^Call to an undefined method Atk4\\Ui\\AbstractView\:\:addClass\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\AbstractView\:\:on\(\)\.$~' # for src/CardSection.php # for src/Console.php - - '~^Method atk4\\ui\\Jquery\:\:append\(\) invoked with 1 parameter, 0 required\.$~' + - '~^Method Atk4\\Ui\\Jquery\:\:append\(\) invoked with 1 parameter, 0 required\.$~' - '~^Call to an undefined method object\:\:issetApp\(\)\.$~' - '~^Call to an undefined method object\:\:getApp\(\)\.$~' - '~^Access to an undefined property object\:\:\$debug\.$~' # for src/Crud.php - - '~^Call to an undefined method atk4\\ui\\UserAction\\JsExecutorInterface\:\:stickyGet\(\)\.$~' - - '~^Method atk4\\ui\\UserAction\\JsExecutorInterface\:\:jsExecute\(\) invoked with 0 parameters, 1 required\.$~' + - '~^Call to an undefined method Atk4\\Ui\\UserAction\\JsExecutorInterface\:\:stickyGet\(\)\.$~' + - '~^Method Atk4\\Ui\\UserAction\\JsExecutorInterface\:\:jsExecute\(\) invoked with 0 parameters, 1 required\.$~' # for src/Dropdown.php # for src/Form.php - - '~^Method atk4\\ui\\Jquery\:\:form\(\) invoked with 3 parameters, 0\-1 required\.$~' - - '~^Method atk4\\ui\\Jquery\:\:form\(\) invoked with 2 parameters, 0\-1 required\.$~' - - '~^Call to an undefined method atk4\\ui\\JsChain\:\:preventFormLeave\(\)\.$~' + - '~^Method Atk4\\Ui\\Jquery\:\:form\(\) invoked with 3 parameters, 0\-1 required\.$~' + - '~^Method Atk4\\Ui\\Jquery\:\:form\(\) invoked with 2 parameters, 0\-1 required\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsChain\:\:preventFormLeave\(\)\.$~' # for src/Form/Control/Calendar.php - - '~^Access to an undefined property atk4\\ui\\JsChain\:\:\$l10ns\.$~' - - '~^Call to an undefined method atk4\\ui\\JsChain\:\:localize\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:flatpickr\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:get\(\)\.$~' + - '~^Access to an undefined property Atk4\\Ui\\JsChain\:\:\$l10ns\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsChain\:\:localize\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:flatpickr\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:get\(\)\.$~' # for src/Form/Control/Checkbox.php - - '~^Method atk4\\ui\\Form\\Control\\Checkbox\:\:set\(\) should return \$this\(atk4\\ui\\Form\\Control\\Checkbox\) but return statement is missing\.$~' - - '~^Return typehint of method atk4\\ui\\Form\\Control\\Checkbox\:\:jsChecked\(\) has invalid type atk4\\ui\\Form\\Control\\Jquery\.$~' + - '~^Method Atk4\\Ui\\Form\\Control\\Checkbox\:\:set\(\) should return \$this\(Atk4\\Ui\\Form\\Control\\Checkbox\) but return statement is missing\.$~' + - '~^Return typehint of method Atk4\\Ui\\Form\\Control\\Checkbox\:\:jsChecked\(\) has invalid type Atk4\\Ui\\Form\\Control\\Jquery\.$~' # for src/Form/Control/Dropdown.php # for src/Form/Control/DropdownCascade.php - - '~^Method atk4\\data\\Field\:\:get\(\) invoked with 1 parameter, 0 required\.$~' + - '~^Method Atk4\\Data\\Field\:\:get\(\) invoked with 1 parameter, 0 required\.$~' - '~^PHPDoc tag @param has invalid value \(\$value the current field value\)\: Unexpected token "\$value", expected type at offset 162$~' - '~^PHPDoc tag @param has invalid value \(\$values an array of possible values\)\: Unexpected token "\$values", expected type at offset 109$~' # for src/Form/Control/Lookup.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:serialize\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:serialize\(\)\.$~' # for src/Form/Control/Multiline.php - - '~^Property atk4\\ui\\Form\\Control\\Multiline\:\:\$jsAfterAdd has unknown class atk4\\ui\\Form\\Control\\JsFunction as its type\.$~' - - '~^Property atk4\\ui\\Form\\Control\\Multiline\:\:\$jsAfterDelete has unknown class atk4\\ui\\Form\\Control\\JsFunction as its type\.$~' + - '~^Property Atk4\\Ui\\Form\\Control\\Multiline\:\:\$jsAfterAdd has unknown class Atk4\\Ui\\Form\\Control\\JsFunction as its type\.$~' + - '~^Property Atk4\\Ui\\Form\\Control\\Multiline\:\:\$jsAfterDelete has unknown class Atk4\\Ui\\Form\\Control\\JsFunction as its type\.$~' - '~^PHPDoc tag @return has invalid value \(\|null\)\: Unexpected token "\|", expected type at offset 153$~' - - '~^Class atk4\\core\\Exception referenced with incorrect case\: atk4\\Core\\Exception\.$~' # for src/Form/Control/Radio.php - - '~^Property atk4\\ui\\Form\\Control\\Radio\:\:\$lister has unknown class atk4\\ui\\Form\\Control\\Lister as its type\.$~' - - '~^Call to method setModel\(\) on an unknown class atk4\\ui\\Form\\Control\\Lister\.$~' - - '~^Call to method onHook\(\) on an unknown class atk4\\ui\\Form\\Control\\Lister\.$~' + - '~^Property Atk4\\Ui\\Form\\Control\\Radio\:\:\$lister has unknown class Atk4\\Ui\\Form\\Control\\Lister as its type\.$~' + - '~^Call to method setModel\(\) on an unknown class Atk4\\Ui\\Form\\Control\\Lister\.$~' + - '~^Call to method onHook\(\) on an unknown class Atk4\\Ui\\Form\\Control\\Lister\.$~' # for src/Form/Control/Upload.php - - '~^Property atk4\\ui\\Form\\Control\\Upload\:\:\$action has unknown class atk4\\ui\\Form\\Control\\View as its type\.$~' - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:atkFileUpload\(\)\.$~' - - '~^Access to property \$name on an unknown class atk4\\ui\\Form\\Control\\View\.$~' + - '~^Property Atk4\\Ui\\Form\\Control\\Upload\:\:\$action has unknown class Atk4\\Ui\\Form\\Control\\View as its type\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:atkFileUpload\(\)\.$~' + - '~^Access to property \$name on an unknown class Atk4\\Ui\\Form\\Control\\View\.$~' # for src/Form/Control/UploadImage.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:removeAttr\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:removeAttr\(\)\.$~' # for src/Form/Layout.php # for src/Form/Layout/Custom.php - '~^PHPDoc tag @var has invalid value \(\{@inheritdoc\}\)\: Unexpected token "\{", expected type at offset 9$~' # for src/Grid.php - - '~^Call to an undefined method atk4\\ui\\Table\\Column\:\:addActionMenuItem\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Table\\Column\:\:addActionMenuItem\(\)\.$~' # for src/ItemsPerPageSelector.php # for src/JsCallback.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:atkAjaxec\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:atkAjaxec\(\)\.$~' - '~^Cannot access property \$_chain on string\.$~' # for src/JsConditionalForm.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:atkConditionalForm\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:atkConditionalForm\(\)\.$~' # for src/JsPaginator.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:atkScroll\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:atkScroll\(\)\.$~' # for src/JsReload.php # for src/JsSearch.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:atkJsSearch\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:atkJsSearch\(\)\.$~' # for src/JsSortable.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:atkJsSortable\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:atkJsSortable\(\)\.$~' # for src/JsSse.php # for src/JsToast.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:toast\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:toast\(\)\.$~' # for src/JsVueService.php - - '~^Call to an undefined method atk4\\ui\\JsChain\:\:createAtkVue\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\JsChain\:\:createVue\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\JsChain\:\:useComponent\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsChain\:\:createAtkVue\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsChain\:\:createVue\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsChain\:\:useComponent\(\)\.$~' # for src/Layout/Admin.php - '~^PHPDoc tag @param has invalid value \(\$seed\)\: Unexpected token "\$seed", expected type at offset 58$~' # for src/Layout/Maestro.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:atkSidenav\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:atkSidenav\(\)\.$~' # for src/Layout/NavigableInterface.php # for src/Lister.php - - '~^Property atk4\\ui\\Lister\:\:\$current_row has unknown class atk4\\ui\\Model as its type\.$~' + - '~^Property Atk4\\Ui\\Lister\:\:\$current_row has unknown class Atk4\\Ui\\Model as its type\.$~' # for src/Loader.php - - '~^Default value of the parameter \#1 \$fx \(array\(\)\) of method atk4\\ui\\Loader\:\:set\(\) is incompatible with type Closure\.$~' + - '~^Default value of the parameter \#1 \$fx \(array\(\)\) of method Atk4\\Ui\\Loader\:\:set\(\) is incompatible with type Closure\.$~' # for src/Menu.php - '~^PHPDoc tag @var has invalid value \(\[type\]\)\: Unexpected token "\[", expected type at offset 118$~' - - '~^Call to an undefined method atk4\\ui\\AbstractView\:\:setElement\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\AbstractView\:\:setElement\(\)\.$~' # for src/Modal.php - - '~^Default value of the parameter \#1 \$fx \(array\(\)\) of method atk4\\ui\\Modal\:\:set\(\) is incompatible with type Closure\.$~' + - '~^Default value of the parameter \#1 \$fx \(array\(\)\) of method Atk4\\Ui\\Modal\:\:set\(\) is incompatible with type Closure\.$~' # for src/Panel/Right.php - - '~^PHPDoc tag @return with type mixed is not subtype of native type atk4\\ui\\JsExpression\.$~' - - '~^Call to an undefined method atk4\\ui\\JsExpression\:\:openPanel\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\JsExpression\:\:reloadPanel\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\JsExpression\:\:closePanel\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\AbstractView\:\:addButtonAction\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\AbstractView\:\:notClosable\(\)\.$~' + - '~^PHPDoc tag @return with type mixed is not subtype of native type Atk4\\Ui\\JsExpression\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsExpression\:\:openPanel\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsExpression\:\:reloadPanel\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsExpression\:\:closePanel\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\AbstractView\:\:addButtonAction\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\AbstractView\:\:notClosable\(\)\.$~' - '~^PHPDoc tag @param references unknown parameter\: \$selector$~' - - '~^Call to an undefined method atk4\\ui\\Panel\\LoadableContent\:\:getClearSelector\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\JsExpression\:\:addPanel\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Panel\\LoadableContent\:\:getClearSelector\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsExpression\:\:addPanel\(\)\.$~' # for src/Popup.php - - '~^Method atk4\\ui\\Popup\:\:set\(\) should return \$this\(atk4\\ui\\Popup\) but return statement is missing\.$~' - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:popup\(\)\.$~' + - '~^Method Atk4\\Ui\\Popup\:\:set\(\) should return \$this\(Atk4\\Ui\\Popup\) but return statement is missing\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:popup\(\)\.$~' # for src/ProgressBar.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:progress\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:progress\(\)\.$~' # for src/Tab.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:tab\(\)\.$~' - - '~^Access to an undefined property atk4\\ui\\View\:\:\$activeTabName\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:tab\(\)\.$~' + - '~^Access to an undefined property Atk4\\Ui\\View\:\:\$activeTabName\.$~' # for src/Table.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:atkColumnResizer\(\)\.$~' - - '~^Method atk4\\ui\\Jquery\:\:css\(\) invoked with 2 parameters, 0 required\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:atkColumnResizer\(\)\.$~' + - '~^Method Atk4\\Ui\\Jquery\:\:css\(\) invoked with 2 parameters, 0 required\.$~' # for src/Table/Column.php - - '~^Call to an undefined method atk4\\ui\\AbstractView\:\:setHoverable\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\JsCallback\:\:onSelectItem\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\AbstractView\:\:setHoverable\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsCallback\:\:onSelectItem\(\)\.$~' # for src/Table/Column/ActionMenu.php # for src/Table/Column/Checkbox.php # for src/Table/Column/Delete.php - - '~^Call to an undefined method atk4\\ui\\AbstractView\:\:set\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\AbstractView\:\:set\(\)\.$~' # for src/Table/Column/DragHandler.php - - '~^Call to an undefined method atk4\\ui\\JsCallback\:\:onReorder\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsCallback\:\:onReorder\(\)\.$~' # for src/Table/Column/FilterModel.php - '~^PHPDoc tag @var has invalid value \(\)\: Unexpected token "\\n ", expected type at offset 79$~' - '~^PHPDoc tag @var has invalid value \(\)\: Unexpected token "\\n ", expected type at offset 76$~' - '~^PHPDoc tag @param references unknown parameter\: \$persistence$~' # for src/Table/Column/FilterPopup.php - - '~^Method atk4\\ui\\Jquery\:\:trigger\(\) invoked with 1 parameter, 0 required\.$~' - - '~^Call to an undefined method atk4\\data\\Model\:\:recallData\(\)\.$~' - - '~^Call to an undefined method atk4\\data\\Model\:\:setConditionForModel\(\)\.$~' + - '~^Method Atk4\\Ui\\Jquery\:\:trigger\(\) invoked with 1 parameter, 0 required\.$~' + - '~^Call to an undefined method Atk4\\Data\\Model\:\:recallData\(\)\.$~' + - '~^Call to an undefined method Atk4\\Data\\Model\:\:setConditionForModel\(\)\.$~' # for src/Table/Column/Link.php - - '~^Method atk4\\ui\\Table\\Column\\Link\:\:setDefaults\(\) should return \$this\(atk4\\ui\\Table\\Column\\Link\) but return statement is missing\.$~' + - '~^Method Atk4\\Ui\\Table\\Column\\Link\:\:setDefaults\(\) should return \$this\(Atk4\\Ui\\Table\\Column\\Link\) but return statement is missing\.$~' - '~^Cannot call method set\(\) on array\|string\.$~' # for src/Tabs.php - - '~^Call to an undefined method atk4\\ui\\View\:\:setPath\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\View\:\:setPath\(\)\.$~' # for src/TabsSubview.php # for src/UserAction/ConfirmationExecutor.php - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:off\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:off\(\)\.$~' - '~^PHPDoc tag @param has invalid value \(\$id\)\: Unexpected token "\$id", expected type at offset 99$~' - '~^PHPDoc tag @param has invalid value \(\$obj\)\: Unexpected token "\$obj", expected type at offset 80$~' # for src/UserAction/ModalExecutor.php - - '~^PHPDoc tag @return with type atk4\\ui\\Form\|null is not subtype of native type atk4\\ui\\Form\.$~' - - '~^Access to an undefined property atk4\\ui\\AbstractView\:\:\$buttonSave\.$~' + - '~^PHPDoc tag @return with type Atk4\\Ui\\Form\|null is not subtype of native type Atk4\\Ui\\Form\.$~' + - '~^Access to an undefined property Atk4\\Ui\\AbstractView\:\:\$buttonSave\.$~' # for src/View.php - - '~^Call to an undefined method atk4\\ui\\JsChain\:\:emit\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\JsChain\:\:clearData\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\JsChain\:\:addJsonData\(\)\.$~' - - '~^Access to an undefined property atk4\\ui\\UserAction\\JsExecutorInterface&atk4\\ui\\View\:\:\$viewForUrl\.$~' - - '~^Call to an undefined method atk4\\ui\\AbstractView\:\:setAction\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\App\:\:jsReady\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\App\:\:getViewJS\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsChain\:\:emit\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsChain\:\:clearData\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsChain\:\:addJsonData\(\)\.$~' + - '~^Access to an undefined property Atk4\\Ui\\UserAction\\JsExecutorInterface&Atk4\\Ui\\View\:\:\$viewForUrl\.$~' + - '~^Call to an undefined method Atk4\\Ui\\AbstractView\:\:setAction\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\App\:\:jsReady\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\App\:\:getViewJS\(\)\.$~' # for src/VirtualPage.php - - '~^Method atk4\\ui\\VirtualPage\:\:getHtml\(\) should return string but return statement is missing\.$~' + - '~^Method Atk4\\Ui\\VirtualPage\:\:getHtml\(\) should return string but return statement is missing\.$~' # for tests-behat/bootstrap/Context.php - '~^PHPDoc tag @param has invalid value \(\$arg1\)\: Unexpected token "\$arg1", expected type at offset 100$~' - '~^PHPDoc tag @param has invalid value \(\$arg1\)\: Unexpected token "\$arg1", expected type at offset 68$~' @@ -320,11 +319,11 @@ parameters: # for tests/DemosTest.php - '~^Variable \$app in PHPDoc tag @var does not exist\.$~' # for tests/FormTest.php - - '~^Access to an undefined property atk4\\ui\\App\:\:\$output\.$~' + - '~^Access to an undefined property Atk4\\Ui\\App\:\:\$output\.$~' # for tests/jsTest.php - - '~^Call to an undefined method atk4\\ui\\JsChain\:\:getTextInRange\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:first\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:ready\(\)\.$~' - - '~^Call to an undefined method atk4\\ui\\Jquery\:\:height\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\JsChain\:\:getTextInRange\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:first\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:ready\(\)\.$~' + - '~^Call to an undefined method Atk4\\Ui\\Jquery\:\:height\(\)\.$~' # for tools/get-assets.php - '~^Method GetAssets\:\:requireJs\(\) should return \$this\(GetAssets\) but return statement is missing\.$~' diff --git a/phpunit-mssql.xml.dist b/phpunit-mssql.xml.dist index 4bf1e9a12c..990d84a940 100644 --- a/phpunit-mssql.xml.dist +++ b/phpunit-mssql.xml.dist @@ -1,4 +1,4 @@ - + diff --git a/phpunit-mysql.xml.dist b/phpunit-mysql.xml.dist index 9534933071..117d211b06 100644 --- a/phpunit-mysql.xml.dist +++ b/phpunit-mysql.xml.dist @@ -1,4 +1,4 @@ - + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index daa110a511..4eec5f8383 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,4 +1,4 @@ - + diff --git a/src/AbstractView.php b/src/AbstractView.php index 02bbac7eaf..2e3786cc42 100644 --- a/src/AbstractView.php +++ b/src/AbstractView.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace atk4\ui; - -use atk4\core\AppScopeTrait; -use atk4\core\ContainerTrait; -use atk4\core\DiContainerTrait; -use atk4\core\InitializerTrait; -use atk4\core\StaticAddToTrait; -use atk4\core\TrackableTrait; +namespace Atk4\Ui; + +use Atk4\Core\AppScopeTrait; +use Atk4\Core\ContainerTrait; +use Atk4\Core\DiContainerTrait; +use Atk4\Core\InitializerTrait; +use Atk4\Core\StaticAddToTrait; +use Atk4\Core\TrackableTrait; /** * Abstract view tree item (used only for View and Callback, you want probably to extend one of these). diff --git a/src/Accordion.php b/src/Accordion.php index d7991927fb..a68156bb49 100644 --- a/src/Accordion.php +++ b/src/Accordion.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Accordion is a View holding accordion sections. diff --git a/src/AccordionSection.php b/src/AccordionSection.php index 482d021470..70c2922652 100644 --- a/src/AccordionSection.php +++ b/src/AccordionSection.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * An accordion item in Accordion. diff --git a/src/App.php b/src/App.php index 6a721c001a..438ef3aade 100644 --- a/src/App.php +++ b/src/App.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace atk4\ui; - -use atk4\core\AppScopeTrait; -use atk4\core\DiContainerTrait; -use atk4\core\DynamicMethodTrait; -use atk4\core\HookTrait; -use atk4\core\InitializerTrait; -use atk4\data\Persistence; -use atk4\ui\Exception\ExitApplicationException; -use atk4\ui\Persistence\Ui as UiPersistence; +namespace Atk4\Ui; + +use Atk4\Core\AppScopeTrait; +use Atk4\Core\DiContainerTrait; +use Atk4\Core\DynamicMethodTrait; +use Atk4\Core\HookTrait; +use Atk4\Core\InitializerTrait; +use Atk4\Data\Persistence; +use Atk4\Ui\Exception\ExitApplicationException; +use Atk4\Ui\Persistence\Ui as UiPersistence; use Psr\Log\LoggerInterface; class App @@ -972,15 +972,15 @@ public function encodeJson($data, bool $forceObject = false): string * Return exception message using HTML block and Semantic UI formatting. It's your job * to put it inside boilerplate HTML and output, e.g:. * - * $app = new \atk4\ui\App(); - * $app->initLayout([\atk4\ui\Layout\Centered::class]); + * $app = new \Atk4\Ui\App(); + * $app->initLayout([\Atk4\Ui\Layout\Centered::class]); * $app->layout->template->dangerouslySetHtml('Content', $e->getHtml()); * $app->run(); * $app->callExit(true); */ public function renderExceptionHtml(\Throwable $exception): string { - return (string) new \atk4\core\ExceptionRenderer\Html($exception); + return (string) new \Atk4\Core\ExceptionRenderer\Html($exception); } protected function setupAlwaysRun(): void diff --git a/src/Breadcrumb.php b/src/Breadcrumb.php index 4627120c7a..c280b5da47 100644 --- a/src/Breadcrumb.php +++ b/src/Breadcrumb.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Implements a more sophisticated and interactive Data-Table component. diff --git a/src/Button.php b/src/Button.php index 954c6dd7ac..0e6fec85e4 100644 --- a/src/Button.php +++ b/src/Button.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Component implementing UI Button. diff --git a/src/Callback.php b/src/Callback.php index f78c9e6531..74d3d876f1 100644 --- a/src/Callback.php +++ b/src/Callback.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Add this object to your render tree and it will expose a unique URL which, when diff --git a/src/CallbackLater.php b/src/CallbackLater.php index fb67e8cd75..519749b26a 100644 --- a/src/CallbackLater.php +++ b/src/CallbackLater.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Works same as Callback but will be executed when the current diff --git a/src/Card.php b/src/Card.php index 01d2f41fbd..a3f31cb6a4 100644 --- a/src/Card.php +++ b/src/Card.php @@ -22,10 +22,10 @@ * the id available via javascript (new Jquery())->data('id') */ -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\core\Factory; -use atk4\data\Model; +use Atk4\Core\Factory; +use Atk4\Data\Model; class Card extends View { @@ -178,10 +178,10 @@ public function addContent(View $view) * If Fields are past with $model that field will be add * to the main section of this card. * - * @param \atk4\data\Model $model the model + * @param \Atk4\Data\Model $model the model * @param array|false $fields an array of fields name to display in content * - * @return \atk4\data\Model|void + * @return \Atk4\Data\Model|void */ public function setModel(Model $model, $fields = null) { diff --git a/src/CardDeck.php b/src/CardDeck.php index 6208eb3aab..1b39809b72 100644 --- a/src/CardDeck.php +++ b/src/CardDeck.php @@ -5,11 +5,11 @@ * A collection of Card set from a model. */ -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\core\Factory; -use atk4\data\Model; -use atk4\ui\Component\ItemSearch; +use Atk4\Core\Factory; +use Atk4\Data\Model; +use Atk4\Ui\Component\ItemSearch; class CardDeck extends View { diff --git a/src/CardSection.php b/src/CardSection.php index eb1570d977..8f27c76d09 100644 --- a/src/CardSection.php +++ b/src/CardSection.php @@ -5,9 +5,9 @@ * Display a card section within a Card View. */ -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\data\Model; +use Atk4\Data\Model; class CardSection extends View { diff --git a/src/CardTable.php b/src/CardTable.php index 120ef6d7ee..7ea34bf9d5 100644 --- a/src/CardTable.php +++ b/src/CardTable.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\data\Model; +use Atk4\Data\Model; /** * Card class displays a single record data. diff --git a/src/Columns.php b/src/Columns.php index cc415bd028..a967eda04b 100644 --- a/src/Columns.php +++ b/src/Columns.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\core\Factory; +use Atk4\Core\Factory; /** * Imprements vertically distributed columns based on CSS Grid system. @@ -50,7 +50,7 @@ public function addColumn($defaults = null) $size = $defaults[0]; unset($defaults[0]); - $column = Factory::factory([\atk4\ui\View::class], $defaults); + $column = Factory::factory([\Atk4\Ui\View::class], $defaults); $this->add($column); if ($size && isset($this->sizes[$size])) { diff --git a/src/Component/InlineEdit.php b/src/Component/InlineEdit.php index 660e402d0c..66e25fbe68 100644 --- a/src/Component/InlineEdit.php +++ b/src/Component/InlineEdit.php @@ -5,12 +5,12 @@ * A Simple inline editable text Vue component. */ -namespace atk4\ui\Component; +namespace Atk4\Ui\Component; -use atk4\data\ValidationException; -use atk4\ui\Exception; -use atk4\ui\JsToast; -use atk4\ui\View; +use Atk4\Data\ValidationException; +use Atk4\Ui\Exception; +use Atk4\Ui\JsToast; +use Atk4\Ui\View; class InlineEdit extends View { @@ -19,7 +19,7 @@ class InlineEdit extends View /** * JsCallback for saving data. * - * @var \atk4\ui\JsCallback + * @var \Atk4\Ui\JsCallback */ public $cb; @@ -86,7 +86,7 @@ class InlineEdit extends View protected function init(): void { parent::init(); - $this->cb = \atk4\ui\JsCallback::addTo($this); + $this->cb = \Atk4\Ui\JsCallback::addTo($this); // Set default validation error handler. if (!$this->formatErrorMsg || !($this->formatErrorMsg instanceof \Closure)) { @@ -101,9 +101,9 @@ protected function init(): void /** * Set Model of this View. * - * @return \atk4\data\Model + * @return \Atk4\Data\Model */ - public function setModel(\atk4\data\Model $model) + public function setModel(\Atk4\Data\Model $model) { parent::setModel($model); $this->field = $this->field ? $this->field : $this->model->title_field; @@ -149,7 +149,7 @@ public function onChange(\Closure $fx) * * @param string $message * - * @return \atk4\ui\JsToast + * @return \Atk4\Ui\JsToast */ public function jsSuccess($message) { @@ -165,7 +165,7 @@ public function jsSuccess($message) * * @param string $message * - * @return \atk4\ui\JsToast + * @return \Atk4\Ui\JsToast */ public function jsError($message) { diff --git a/src/Component/ItemSearch.php b/src/Component/ItemSearch.php index ad46605a38..fbec7ccf04 100644 --- a/src/Component/ItemSearch.php +++ b/src/Component/ItemSearch.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\Component; +namespace Atk4\Ui\Component; -use atk4\data\Model; -use atk4\ui\JsVueService; -use atk4\ui\View; +use Atk4\Data\Model; +use Atk4\Ui\JsVueService; +use Atk4\Ui\View; /** * Will send query with define callback and reload a specific view. diff --git a/src/Console.php b/src/Console.php index e5beef60b4..80e2fb3fb9 100644 --- a/src/Console.php +++ b/src/Console.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Console is a black square component resembling terminal window. It can be programmed @@ -57,7 +57,7 @@ class Console extends View implements \Psr\Log\LoggerInterface * $console->output() * $console->outputHtml() * - * If you are using setModel, and if your model implements \atk4\core\DebugTrait, + * If you are using setModel, and if your model implements \Atk4\Core\DebugTrait, * then you you will see debug information generated by $this->debug() or $this->log(). * * This intercepts default application logging for the duration of the process. @@ -299,7 +299,7 @@ protected function execRaw($exec, $args = []) /** * This method is obsolete. Use Console::runMethod() instead. */ - public function setModel(\atk4\data\Model $model, $method = null, $args = []) + public function setModel(\Atk4\Data\Model $model, $method = null, $args = []) { $this->runMethod($model, $method, $args); diff --git a/src/Crud.php b/src/Crud.php index 04b6af73ce..399a0a0018 100644 --- a/src/Crud.php +++ b/src/Crud.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\core\Factory; -use atk4\data\Model; +use Atk4\Core\Factory; +use Atk4\Data\Model; /** * Implements a more sophisticated and interactive Data-Table component. diff --git a/src/Dropdown.php b/src/Dropdown.php index 8bfe9bd6cf..b17a6e00d3 100644 --- a/src/Dropdown.php +++ b/src/Dropdown.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; class Dropdown extends Lister { diff --git a/src/DropdownButton.php b/src/DropdownButton.php index bbf1c300c3..23dc27415f 100644 --- a/src/DropdownButton.php +++ b/src/DropdownButton.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; class DropdownButton extends Dropdown { diff --git a/src/Exception.php b/src/Exception.php index aa3e426c40..d9c73a911e 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -2,8 +2,8 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; -class Exception extends \atk4\core\Exception +class Exception extends \Atk4\Core\Exception { } diff --git a/src/Exception/ExitApplicationException.php b/src/Exception/ExitApplicationException.php index ee363f4556..f86ade3604 100644 --- a/src/Exception/ExitApplicationException.php +++ b/src/Exception/ExitApplicationException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\Exception; +namespace Atk4\Ui\Exception; class ExitApplicationException extends \Exception { diff --git a/src/Exception/NoRenderTree.php b/src/Exception/NoRenderTree.php index 06c6f67dd2..8974c5e43c 100644 --- a/src/Exception/NoRenderTree.php +++ b/src/Exception/NoRenderTree.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Exception; +namespace Atk4\Ui\Exception; -class NoRenderTree extends \atk4\ui\Exception +class NoRenderTree extends \Atk4\Ui\Exception { public function __construct($object, $action = '') { diff --git a/src/Form.php b/src/Form.php index b0c1a04a9c..eb3f97ff44 100644 --- a/src/Form.php +++ b/src/Form.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\core\Factory; -use atk4\data\Model; -use atk4\data\Reference\ContainsMany; +use Atk4\Core\Factory; +use Atk4\Data\Model; +use Atk4\Data\Reference\ContainsMany; /** * Implements a form. */ class Form extends View { - use \atk4\core\HookTrait; + use \Atk4\Core\HookTrait; /** @const string Executed when form is submitted */ public const HOOK_SUBMIT = self::class . '@submit'; @@ -63,7 +63,7 @@ class Form extends View /** * A current layout of a form, needed if you call $form->addControl(). * - * @var \atk4\ui\Form\Layout + * @var \Atk4\Ui\Form\Layout */ public $layout; @@ -263,7 +263,7 @@ public function setGroupDisplayRules($rules = [], $selector = '.atk-form-group') * * @param array $fields * - * @return \atk4\data\Model + * @return \Atk4\Data\Model */ public function setModel(Model $model, $fields = null) { @@ -293,7 +293,7 @@ public function onSubmit(\Closure $callback) $response = $this->hook(self::HOOK_SUBMIT); if (!$response) { - if (!$this->model instanceof \atk4\ui\Misc\ProxyModel) { + if (!$this->model instanceof \Atk4\Ui\Misc\ProxyModel) { $this->model->save(); return $this->success('Form data has been saved'); @@ -303,7 +303,7 @@ public function onSubmit(\Closure $callback) } return $response; - } catch (\atk4\data\ValidationException $val) { + } catch (\Atk4\Data\ValidationException $val) { $response = []; foreach ($val->errors as $field => $error) { $response[] = $this->error($field, $error); @@ -401,7 +401,7 @@ public function success($success = 'Success', $sub_header = null, $useTemplate = public function addControl(?string $name, $control = null, $field = null) { if (!$this->model) { - $this->model = new \atk4\ui\Misc\ProxyModel(); + $this->model = new \Atk4\Ui\Misc\ProxyModel(); } return $this->layout->addControl($name, $control, $field); @@ -487,15 +487,15 @@ public function jsControl($name) * 3. $f->type is converted into seed and evaluated * 4. lastly, falling back to Line, Dropdown (based on $reference and $enum) * - * @param \atk4\data\Field $field Data model field + * @param \Atk4\Data\Field $field Data model field * @param array $seed Defaults to pass to Factory::factory() when control object is initialized * * @return Form\Control */ - public function controlFactory(\atk4\data\Field $field, $seed = []) + public function controlFactory(\Atk4\Data\Field $field, $seed = []) { - if ($field && !$field instanceof \atk4\data\Field) { - throw (new Exception('Argument 1 for controlFactory must be \atk4\data\Field or null')) + if ($field && !$field instanceof \Atk4\Data\Field) { + throw (new Exception('Argument 1 for controlFactory must be \Atk4\Data\Field or null')) ->addMoreInfo('field', $field); } @@ -571,13 +571,13 @@ protected function loadPost() if (!$field->readonly && !$field->disabled) { $field->set($post[$key] ?? null); } - } catch (\atk4\core\Exception $e) { + } catch (\Atk4\Core\Exception $e) { $errors[$key] = $e->getMessage(); } } if ($errors) { - throw new \atk4\data\ValidationException($errors); + throw new \Atk4\Data\ValidationException($errors); } } diff --git a/src/Form/AbstractLayout.php b/src/Form/AbstractLayout.php index df0e043550..263972b77e 100644 --- a/src/Form/AbstractLayout.php +++ b/src/Form/AbstractLayout.php @@ -2,19 +2,19 @@ declare(strict_types=1); -namespace atk4\ui\Form; +namespace Atk4\Ui\Form; -use atk4\ui\Exception; +use Atk4\Ui\Exception; /** * Custom Layout for a form (user-defined HTML). */ -abstract class AbstractLayout extends \atk4\ui\View +abstract class AbstractLayout extends \Atk4\Ui\View { /** * Links layout to the form. * - * @var \atk4\ui\Form + * @var \Atk4\Ui\Form */ public $form; @@ -25,12 +25,12 @@ abstract class AbstractLayout extends \atk4\ui\View * @param array|string|object|null $control * @param array|string|object|null $field * - * @return \atk4\ui\Form\Control + * @return \Atk4\Ui\Form\Control */ public function addControl(string $name, $control = null, $field = null) { if (!$this->form->model) { - $this->form->model = new \atk4\ui\Misc\ProxyModel(); + $this->form->model = new \Atk4\Ui\Misc\ProxyModel(); } if (is_string($field)) { @@ -60,8 +60,8 @@ public function addControl(string $name, $control = null, $field = null) } elseif (!$control) { $control = $this->form->controlFactory($field); } elseif (is_object($control)) { - if (!$control instanceof \atk4\ui\Form\Control) { - throw (new Exception('Form control must descend from ' . \atk4\ui\Form\Control::class)) + if (!$control instanceof \Atk4\Ui\Form\Control) { + throw (new Exception('Form control must descend from ' . \Atk4\Ui\Form\Control::class)) ->addMoreInfo('control', $control); } $control->field = $field; @@ -107,7 +107,7 @@ public function addControls($controls) * * @return array */ - protected function getModelFields(\atk4\data\Model $model) + protected function getModelFields(\Atk4\Data\Model $model) { return array_keys($model->getFields('editable')); } @@ -117,9 +117,9 @@ protected function getModelFields(\atk4\data\Model $model) * * @param array|null $fields * - * @return \atk4\data\Model + * @return \Atk4\Data\Model */ - public function setModel(\atk4\data\Model $model, $fields = null) + public function setModel(\Atk4\Data\Model $model, $fields = null) { parent::setModel($model); @@ -157,7 +157,7 @@ public function setModel(\atk4\data\Model $model, $fields = null) * Return Field decorator associated with * the form's field. * - * @return \atk4\ui\Form\Control + * @return \Atk4\Ui\Form\Control */ public function getControl(string $name): Control { @@ -172,9 +172,9 @@ public function getControl(string $name): Control /** * Adds Button into form layout. * - * @param \atk4\ui\Button|array|string $seed + * @param \Atk4\Ui\Button|array|string $seed * - * @return \atk4\ui\Button + * @return \Atk4\Ui\Button */ abstract public function addButton($seed); } diff --git a/src/Form/Control.php b/src/Form/Control.php index 066bbfcfa6..b715ec78d5 100644 --- a/src/Form/Control.php +++ b/src/Form/Control.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\Form; +namespace Atk4\Ui\Form; -use atk4\ui\Exception; -use atk4\ui\Form; -use atk4\ui\View; +use Atk4\Ui\Exception; +use Atk4\Ui\Form; +use Atk4\Ui\View; /** * Provides generic functionality for a form control. @@ -19,7 +19,7 @@ class Control extends View public $form; /** - * @var \atk4\data\Field - points to model field + * @var \Atk4\Data\Field - points to model field */ public $field; @@ -50,9 +50,9 @@ class Control extends View /** * Placed as a pointing label below the field. This only works when Form\Control appears in a form. You can also - * set this to object, such as \atk4\ui\Text otherwise HTML characters are escaped. + * set this to object, such as \Atk4\Ui\Text otherwise HTML characters are escaped. * - * @var string|\atk4\ui\View|array + * @var string|\Atk4\Ui\View|array */ public $hint; @@ -147,16 +147,16 @@ protected function renderTemplateToHtml(string $region = null): string * * Examples: * $control->onChange('console.log("changed")'); - * $control->onChange(new \atk4\ui\JsExpression('console.log("changed")')); + * $control->onChange(new \Atk4\Ui\JsExpression('console.log("changed")')); * $control->onChange('$(this).parents(".form").form("submit")'); * - * @param string|\atk4\ui\JsExpression|array|\Closure $expr + * @param string|\Atk4\Ui\JsExpression|array|\Closure $expr * @param array|bool $default */ public function onChange($expr, $default = []) { if (is_string($expr)) { - $expr = new \atk4\ui\JsExpression($expr); + $expr = new \Atk4\Ui\JsExpression($expr); } if (is_bool($default)) { @@ -173,7 +173,7 @@ public function onChange($expr, $default = []) * * $field->jsInput(true)->val(123); * - * @return \atk4\ui\Jquery + * @return \Atk4\Ui\Jquery */ public function jsInput($when = null, $action = null) { diff --git a/src/Form/Control/Calendar.php b/src/Form/Control/Calendar.php index 98962b5785..4d1d27ea67 100644 --- a/src/Form/Control/Calendar.php +++ b/src/Form/Control/Calendar.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; -use atk4\ui\App; -use atk4\ui\Jquery; -use atk4\ui\JsChain; -use atk4\ui\JsExpression; +use Atk4\Ui\App; +use Atk4\Ui\Jquery; +use Atk4\Ui\JsChain; +use Atk4\Ui\JsExpression; /** * Date/Time picker attached to a form control. @@ -110,7 +110,7 @@ protected function renderView(): void * * Examples: * $control->onChange('console.log(date, text, mode)'); - * $control->onChange(new \atk4\ui\JsExpression('console.log(date, text, mode)')); + * $control->onChange(new \Atk4\Ui\JsExpression('console.log(date, text, mode)')); * $control->onChange('$(this).parents(".form").form("submit")'); * * @param string|JsExpression|array $expr @@ -119,7 +119,7 @@ protected function renderView(): void public function onChange($expr, $default = []) { if (is_string($expr)) { - $expr = new \atk4\ui\JsExpression($expr); + $expr = new \Atk4\Ui\JsExpression($expr); } if (!is_array($expr)) { $expr = [$expr]; @@ -131,7 +131,7 @@ public function onChange($expr, $default = []) } // flatpickr on change event - $this->options['onChange'] = new \atk4\ui\JsFunction(['date', 'text', 'mode'], $expr, $default); + $this->options['onChange'] = new \Atk4\Ui\JsFunction(['date', 'text', 'mode'], $expr, $default); } /** diff --git a/src/Form/Control/Checkbox.php b/src/Form/Control/Checkbox.php index 78d19d8999..59197b5073 100644 --- a/src/Form/Control/Checkbox.php +++ b/src/Form/Control/Checkbox.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; -use atk4\ui\Exception; -use atk4\ui\Form; +use Atk4\Ui\Exception; +use Atk4\Ui\Form; /** * Input element for a form control. diff --git a/src/Form/Control/Dropdown.php b/src/Form/Control/Dropdown.php index 2f050f7cf4..4c6485894f 100644 --- a/src/Form/Control/Dropdown.php +++ b/src/Form/Control/Dropdown.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; -use atk4\ui\JsExpression; -use atk4\ui\JsExpressionable; -use atk4\ui\JsFunction; +use Atk4\Ui\JsExpression; +use Atk4\Ui\JsExpressionable; +use Atk4\Ui\JsFunction; /** * Input element for a form control. diff --git a/src/Form/Control/DropdownCascade.php b/src/Form/Control/DropdownCascade.php index 4d139304a2..262a257ab5 100644 --- a/src/Form/Control/DropdownCascade.php +++ b/src/Form/Control/DropdownCascade.php @@ -13,11 +13,11 @@ * $form->addControl('product_id', [DropdownCascade::class, 'cascadeFrom' => 'sub_category_id', 'reference' => 'Products']);. */ -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; -use atk4\data\Model; -use atk4\ui\Exception; -use atk4\ui\Form; +use Atk4\Data\Model; +use Atk4\Ui\Exception; +use Atk4\Ui\Form; class DropdownCascade extends Dropdown { diff --git a/src/Form/Control/Hidden.php b/src/Form/Control/Hidden.php index 42fd803455..4e3e06c488 100644 --- a/src/Form/Control/Hidden.php +++ b/src/Form/Control/Hidden.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; /** * Input element for a form control. diff --git a/src/Form/Control/Input.php b/src/Form/Control/Input.php index 332012aa56..1096bc9196 100644 --- a/src/Form/Control/Input.php +++ b/src/Form/Control/Input.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; -use atk4\ui\Button; -use atk4\ui\Form; -use atk4\ui\Icon; -use atk4\ui\Label; +use Atk4\Ui\Button; +use Atk4\Ui\Form; +use Atk4\Ui\Icon; +use Atk4\Ui\Label; /** * Input element for a form control. @@ -155,7 +155,7 @@ protected function prepareRenderButton($button, $spot) if (!is_object($button)) { $button = new Button($button); } - if ($button instanceof \atk4\data\Model\UserAction) { + if ($button instanceof \Atk4\Data\Model\UserAction) { $action = $button; $button = Button::addTo($this, [$action->caption], [$spot]); $this->addClass('action'); diff --git a/src/Form/Control/Line.php b/src/Form/Control/Line.php index 79e2da6728..8eb7ffe7a3 100644 --- a/src/Form/Control/Line.php +++ b/src/Form/Control/Line.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; /** * Input element for a form control. diff --git a/src/Form/Control/Lookup.php b/src/Form/Control/Lookup.php index bd8306a97b..6582927d8a 100644 --- a/src/Form/Control/Lookup.php +++ b/src/Form/Control/Lookup.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; -use atk4\core\Factory; -use atk4\data\Model; -use atk4\ui\Jquery; -use atk4\ui\JsExpression; -use atk4\ui\JsFunction; +use Atk4\Core\Factory; +use Atk4\Data\Model; +use Atk4\Ui\Jquery; +use Atk4\Ui\JsExpression; +use Atk4\Ui\JsFunction; class Lookup extends Input { @@ -25,7 +25,7 @@ class Lookup extends Input /** * Object used to capture requests from the browser. * - * @var \atk4\ui\Callback + * @var \Atk4\Ui\Callback */ public $callback; @@ -106,9 +106,9 @@ class Lookup extends Input * * For example, using this setting will automatically submit * form when field value is changes. - * $form->addControl('field', [\atk4\ui\Form\Control\Lookup::class, 'settings'=>['allowReselection' => true, + * $form->addControl('field', [\Atk4\Ui\Form\Control\Lookup::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); @@ -150,7 +150,7 @@ protected function init(): void $this->settings['forceSelection'] = false; - $this->callback = \atk4\ui\Callback::addTo($this); + $this->callback = \Atk4\Ui\Callback::addTo($this); $this->callback->set([$this, 'outputApiResponse']); } @@ -248,24 +248,24 @@ protected function initQuickNewRecord() $buttonSeed = is_string($buttonSeed) ? ['content' => $buttonSeed] : $buttonSeed; - $defaultSeed = [\atk4\ui\Button::class, 'disabled' => ($this->disabled || $this->readonly)]; + $defaultSeed = [\Atk4\Ui\Button::class, 'disabled' => ($this->disabled || $this->readonly)]; $this->action = Factory::factory(array_merge($defaultSeed, (array) $buttonSeed)); if ($this->form) { - $vp = \atk4\ui\VirtualPage::addTo($this->form); + $vp = \Atk4\Ui\VirtualPage::addTo($this->form); } else { - $vp = \atk4\ui\VirtualPage::addTo($this->getOwner()); + $vp = \Atk4\Ui\VirtualPage::addTo($this->getOwner()); } $vp->set(function ($page) { - $form = \atk4\ui\Form::addTo($page); + $form = \Atk4\Ui\Form::addTo($page); $model = clone $this->model; $form->setModel($model->onlyFields($this->plus['fields'] ?? [])); - $form->onSubmit(function (\atk4\ui\Form $form) { + $form->onSubmit(function (\Atk4\Ui\Form $form) { $form->model->save(); $ret = [ @@ -285,7 +285,7 @@ protected function initQuickNewRecord() $caption = $this->plus['caption'] ?? 'Add New ' . $this->model->getModelCaption(); - $this->action->js('click', new \atk4\ui\JsModal($caption, $vp)); + $this->action->js('click', new \Atk4\Ui\JsModal($caption, $vp)); } /** @@ -444,7 +444,7 @@ protected function renderView(): void * * {@inheritdoc} * - * @see \atk4\ui\Form\Control::set() + * @see \Atk4\Ui\Form\Control::set() */ public function set($value = null, $junk = null) { diff --git a/src/Form/Control/Money.php b/src/Form/Control/Money.php index 768fa25352..3c2dec3a06 100644 --- a/src/Form/Control/Money.php +++ b/src/Form/Control/Money.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; /** * Input element for a form control. diff --git a/src/Form/Control/Multiline.php b/src/Form/Control/Multiline.php index d70e1544b4..5f3c64536e 100644 --- a/src/Form/Control/Multiline.php +++ b/src/Form/Control/Multiline.php @@ -23,7 +23,7 @@ * // Save Form model and then Multiline model * $form->model->save(); * $ml->saveRows(); - * return new \atk4\ui\JsToast('Saved!'); + * return new \Atk4\Ui\JsToast('Saved!'); * }); * * If Multiline's model contains expressions, these will be evaluated on the fly @@ -66,19 +66,19 @@ * }); */ -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; -use atk4\data\Field; -use atk4\data\Field\Callback; -use atk4\data\FieldSqlExpression; -use atk4\data\Model; -use atk4\data\Reference\HasOne; -use atk4\data\ValidationException; -use atk4\ui\Exception; -use atk4\ui\Form; -use atk4\ui\HtmlTemplate; -use atk4\ui\JsCallback; -use atk4\ui\View; +use Atk4\Data\Field; +use Atk4\Data\Field\Callback; +use Atk4\Data\FieldSqlExpression; +use Atk4\Data\Model; +use Atk4\Data\Reference\HasOne; +use Atk4\Data\ValidationException; +use Atk4\Ui\Exception; +use Atk4\Ui\Form; +use Atk4\Ui\HtmlTemplate; +use Atk4\Ui\JsCallback; +use Atk4\Ui\View; class Multiline extends Form\Control { @@ -358,7 +358,7 @@ public function validate(array $rows): array if (!$field->read_only) { $model->set($fieldName, $this->getApp()->ui_persistence->typecastLoadField($field, $value)); } - } catch (\atk4\core\Exception $e) { + } catch (\Atk4\Core\Exception $e) { $rowErrors[$rowId][] = ['field' => $fieldName, 'msg' => $e->getMessage()]; } } @@ -691,7 +691,7 @@ protected function renderView(): void $this->cb->set(function () { try { return $this->renderCallback(); - } catch (\atk4\Core\Exception | \Error $e) { + } catch (\Atk4\Core\Exception | \Error $e) { $this->getApp()->terminateJson(['success' => false, 'error' => $e->getMessage()]); } }); diff --git a/src/Form/Control/Password.php b/src/Form/Control/Password.php index b6ad0fc4f0..6065fa5a56 100644 --- a/src/Form/Control/Password.php +++ b/src/Form/Control/Password.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; /** * Password input element for a form control. diff --git a/src/Form/Control/Radio.php b/src/Form/Control/Radio.php index 2f59bbc7e4..2a948417ef 100644 --- a/src/Form/Control/Radio.php +++ b/src/Form/Control/Radio.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; -use atk4\ui\Form; +use Atk4\Ui\Form; /** * Input element for a form control. @@ -36,7 +36,7 @@ protected function init(): void { parent::init(); - $this->lister = \atk4\ui\Lister::addTo($this, [], ['Radio']); + $this->lister = \Atk4\Ui\Lister::addTo($this, [], ['Radio']); $this->lister->t_row->set('_name', $this->short_name); } @@ -55,7 +55,7 @@ protected function renderView(): void $this->addClass('disabled'); } - $this->lister->onHook(\atk4\ui\Lister::HOOK_BEFORE_ROW, function (\atk4\ui\Lister $lister) use ($value) { + $this->lister->onHook(\Atk4\Ui\Lister::HOOK_BEFORE_ROW, function (\Atk4\Ui\Lister $lister) use ($value) { if ($this->readonly) { $lister->t_row->set('disabled', $value !== (string) $lister->model->getId() ? 'disabled="disabled"' : ''); } elseif ($this->disabled) { @@ -77,16 +77,16 @@ protected function renderView(): void * * Examples: * $control->onChange('console.log("changed")'); - * $control->onChange(new \atk4\ui\JsExpression('console.log("changed")')); + * $control->onChange(new \Atk4\Ui\JsExpression('console.log("changed")')); * $control->onChange('$(this).parents(".form").form("submit")'); * - * @param string|\atk4\ui\JsExpression|array|\Closure $expr + * @param string|\Atk4\Ui\JsExpression|array|\Closure $expr * @param array|bool $default */ public function onChange($expr, $default = []) { if (is_string($expr)) { - $expr = new \atk4\ui\JsExpression($expr); + $expr = new \Atk4\Ui\JsExpression($expr); } if (is_bool($default)) { diff --git a/src/Form/Control/ScopeBuilder.php b/src/Form/Control/ScopeBuilder.php index daa947e132..9ba31cbf12 100644 --- a/src/Form/Control/ScopeBuilder.php +++ b/src/Form/Control/ScopeBuilder.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; -use atk4\data\Field; -use atk4\data\Model; -use atk4\data\Model\Scope; -use atk4\data\Model\Scope\Condition; -use atk4\ui\Callback; -use atk4\ui\Exception; -use atk4\ui\Form\Control; -use atk4\ui\HtmlTemplate; +use Atk4\Data\Field; +use Atk4\Data\Model; +use Atk4\Data\Model\Scope; +use Atk4\Data\Model\Scope\Condition; +use Atk4\Ui\Callback; +use Atk4\Ui\Exception; +use Atk4\Ui\Form\Control; +use Atk4\Ui\HtmlTemplate; class ScopeBuilder extends Control { @@ -84,7 +84,7 @@ class ScopeBuilder extends Control /** * The scopebuilder View. Assigned in init(). * - * @var \atk4\ui\View + * @var \Atk4\Ui\View */ protected $scopeBuilderView; @@ -322,10 +322,10 @@ protected function init(): void $this->scopeBuilderTemplate = new HtmlTemplate('
'); } - $this->scopeBuilderView = \atk4\ui\View::addTo($this, ['template' => $this->scopeBuilderTemplate]); + $this->scopeBuilderView = \Atk4\Ui\View::addTo($this, ['template' => $this->scopeBuilderTemplate]); if ($this->form) { - $this->form->onHook(\atk4\ui\Form::HOOK_LOAD_POST, function ($form, &$post) { + $this->form->onHook(\Atk4\Ui\Form::HOOK_LOAD_POST, function ($form, &$post) { $key = $this->field->short_name; $post[$key] = $this->queryToScope($this->getApp()->decodeJson($post[$key] ?? '{}')); }); diff --git a/src/Form/Control/Textarea.php b/src/Form/Control/Textarea.php index 1be2f359f7..e76eaf2e17 100644 --- a/src/Form/Control/Textarea.php +++ b/src/Form/Control/Textarea.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; /** * Input element for a form control. diff --git a/src/Form/Control/TreeItemSelector.php b/src/Form/Control/TreeItemSelector.php index c77a91f768..aabaafc37a 100644 --- a/src/Form/Control/TreeItemSelector.php +++ b/src/Form/Control/TreeItemSelector.php @@ -14,11 +14,11 @@ * see demos/tree-item-selector.php to see how tree items are build. */ -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; -use atk4\ui\Form; -use atk4\ui\HtmlTemplate; -use atk4\ui\JsCallback; +use Atk4\Ui\Form; +use Atk4\Ui\HtmlTemplate; +use Atk4\Ui\JsCallback; class TreeItemSelector extends Form\Control { @@ -32,7 +32,7 @@ class TreeItemSelector extends Form\Control /** * The tree item selector View. * - * @var \atk4\ui\View|null + * @var \Atk4\Ui\View|null */ public $itemSelector; @@ -86,7 +86,7 @@ protected function init(): void $this->itemSelectorTemplate = new HtmlTemplate('
{$Input}
'); } - $this->itemSelector = \atk4\ui\View::addTo($this, ['template' => $this->itemSelectorTemplate]); + $this->itemSelector = \Atk4\Ui\View::addTo($this, ['template' => $this->itemSelectorTemplate]); } /** diff --git a/src/Form/Control/Upload.php b/src/Form/Control/Upload.php index 1dd683359f..e3b504bd86 100644 --- a/src/Form/Control/Upload.php +++ b/src/Form/Control/Upload.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; -use atk4\ui\Exception; +use Atk4\Ui\Exception; /** * Class Upload. @@ -50,7 +50,7 @@ class Upload extends Input /** * Callback is use for onUpload or onDelete. * - * @var \atk4\ui\JsCallback + * @var \Atk4\Ui\JsCallback */ public $cb; @@ -92,10 +92,10 @@ protected function init(): void //$this->inputType = 'hidden'; - $this->cb = \atk4\ui\JsCallback::addTo($this); + $this->cb = \Atk4\Ui\JsCallback::addTo($this); if (!$this->action) { - $this->action = new \atk4\ui\Button(['icon' => 'upload', 'disabled' => ($this->disabled || $this->readonly)]); + $this->action = new \Atk4\Ui\Button(['icon' => 'upload', 'disabled' => ($this->disabled || $this->readonly)]); } } diff --git a/src/Form/Control/UploadImage.php b/src/Form/Control/UploadImage.php index fb179ab29f..fed12e3876 100644 --- a/src/Form/Control/UploadImage.php +++ b/src/Form/Control/UploadImage.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Form\Control; +namespace Atk4\Ui\Form\Control; -use atk4\ui\View; +use Atk4\Ui\View; class UploadImage extends Upload { diff --git a/src/Form/Layout.php b/src/Form/Layout.php index c4b2ce0018..74debaf29f 100644 --- a/src/Form/Layout.php +++ b/src/Form/Layout.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\Form; +namespace Atk4\Ui\Form; -use atk4\core\Factory; -use atk4\ui\HtmlTemplate; -use atk4\ui\Label; +use Atk4\Core\Factory; +use Atk4\Ui\HtmlTemplate; +use Atk4\Ui\Label; /** * Provides generic layout for a form. @@ -64,13 +64,13 @@ protected function init(): void /** * Adds Button. * - * @param \atk4\ui\Button|array|string $seed + * @param \Atk4\Ui\Button|array|string $seed * - * @return \atk4\ui\Button + * @return \Atk4\Ui\Button */ public function addButton($seed) { - return $this->add(Factory::mergeSeeds([\atk4\ui\Button::class], $seed), 'Buttons'); + return $this->add(Factory::mergeSeeds([\Atk4\Ui\Button::class], $seed), 'Buttons'); } /** @@ -82,7 +82,7 @@ public function addButton($seed) */ public function addHeader($label) { - \atk4\ui\Header::addTo($this, [$label, 'dividing', 'element' => 'h4']); + \Atk4\Ui\Header::addTo($this, [$label, 'dividing', 'element' => 'h4']); return $this; } @@ -121,12 +121,12 @@ public function addGroup($label = null) public function addSubLayout($seed = [self::class], $addDivider = true) { $v = $this->add(Factory::factory($seed, ['form' => $this->form])); - if ($v instanceof \atk4\ui\Form\Layout\Section) { + if ($v instanceof \Atk4\Ui\Form\Layout\Section) { $v = $v->addSection(); } if ($addDivider) { - \atk4\ui\View::addTo($this, ['ui' => 'hidden divider']); + \Atk4\Ui\View::addTo($this, ['ui' => 'hidden divider']); } return $v; @@ -146,7 +146,7 @@ protected function recursiveRender(): void foreach ($this->elements as $element) { // Buttons go under Button section - if ($element instanceof \atk4\ui\Button) { + if ($element instanceof \Atk4\Ui\Button) { $this->template->dangerouslyAppendHtml('Buttons', $element->getHtml()); continue; @@ -185,7 +185,7 @@ protected function recursiveRender(): void $label = $element->caption ?: $element->field->getCaption(); // Anything but form controls gets inserted directly - if ($element instanceof \atk4\ui\Form\Control\Checkbox) { + if ($element instanceof \Atk4\Ui\Form\Control\Checkbox) { $template = $noLabelControl; $element->template->set('Content', $label); } diff --git a/src/Form/Layout/Columns.php b/src/Form/Layout/Columns.php index a72d3a5f16..d562e337e3 100644 --- a/src/Form/Layout/Columns.php +++ b/src/Form/Layout/Columns.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Form\Layout; +namespace Atk4\Ui\Form\Layout; -use atk4\ui\Form; +use Atk4\Ui\Form; /** * Layout that automatically arranges itself into multiple columns. @@ -23,9 +23,9 @@ class Columns extends Form\Layout * * @param array|null $fields * - * @return \atk4\data\Model + * @return \Atk4\Data\Model */ - public function setModel(\atk4\data\Model $model, $fields = null) + public function setModel(\Atk4\Data\Model $model, $fields = null) { // dont add any fields automatically parent::setModel($model, false); @@ -60,7 +60,7 @@ public function setModel(\atk4\data\Model $model, $fields = null) $this->form->addClass($size); } - $c = \atk4\ui\Columns::addTo($this); + $c = \Atk4\Ui\Columns::addTo($this); $chunks = array_chunk($fields, (int) ceil($cnt / $col)); foreach ($chunks as $chunk) { @@ -68,7 +68,7 @@ public function setModel(\atk4\data\Model $model, $fields = null) Form\Layout::addTo($cc, ['form' => $this->form])->setModel($model, $chunk); } - \atk4\ui\View::addTo($this, ['ui' => 'clearing hidden divider']); + \Atk4\Ui\View::addTo($this, ['ui' => 'clearing hidden divider']); return $model; } diff --git a/src/Form/Layout/Custom.php b/src/Form/Layout/Custom.php index d141ef535f..2b7a1ff3b0 100644 --- a/src/Form/Layout/Custom.php +++ b/src/Form/Layout/Custom.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\Form\Layout; +namespace Atk4\Ui\Form\Layout; -use atk4\core\Factory; -use atk4\ui\Exception; -use atk4\ui\Form\AbstractLayout; +use Atk4\Core\Factory; +use Atk4\Ui\Exception; +use Atk4\Ui\Form\AbstractLayout; /** * Custom Layout for a form (user-defined HTML). @@ -28,12 +28,12 @@ protected function init(): void /** * Adds Button into {$Buttons}. * - * @param \atk4\ui\Button|array|string $seed + * @param \Atk4\Ui\Button|array|string $seed * - * @return \atk4\ui\Button + * @return \Atk4\Ui\Button */ public function addButton($seed) { - return $this->add(Factory::mergeSeeds([\atk4\ui\Button::class], $seed), 'Buttons'); + return $this->add(Factory::mergeSeeds([\Atk4\Ui\Button::class], $seed), 'Buttons'); } } diff --git a/src/Form/Layout/Section.php b/src/Form/Layout/Section.php index e6ecddfc71..c834f56cad 100644 --- a/src/Form/Layout/Section.php +++ b/src/Form/Layout/Section.php @@ -2,20 +2,20 @@ declare(strict_types=1); -namespace atk4\ui\Form\Layout; +namespace Atk4\Ui\Form\Layout; /** * Form generic layout section. */ -class Section extends \atk4\ui\View +class Section extends \Atk4\Ui\View { - public $formLayout = \atk4\ui\Form\Layout::class; + public $formLayout = \Atk4\Ui\Form\Layout::class; public $form; /** * Adds sub-layout in existing layout. * - * @return \atk4\ui\Form\Layout + * @return \Atk4\Ui\Form\Layout */ public function addSection() { diff --git a/src/Form/Layout/Section/Accordion.php b/src/Form/Layout/Section/Accordion.php index 29b02ae263..1c0500aa6a 100644 --- a/src/Form/Layout/Section/Accordion.php +++ b/src/Form/Layout/Section/Accordion.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace atk4\ui\Form\Layout\Section; +namespace Atk4\Ui\Form\Layout\Section; -use atk4\ui\AccordionSection; +use Atk4\Ui\AccordionSection; /** * Represents form controls in accordion. */ -class Accordion extends \atk4\ui\Accordion +class Accordion extends \Atk4\Ui\Accordion { - public $formLayout = \atk4\ui\Form\Layout::class; + public $formLayout = \Atk4\Ui\Form\Layout::class; public $form; /** @@ -23,7 +23,7 @@ protected function init(): void { parent::init(); - $this->form->onHook(\atk4\ui\Form::HOOK_DISPLAY_ERROR, function ($form, $fieldName, $str) { + $this->form->onHook(\Atk4\Ui\Form::HOOK_DISPLAY_ERROR, function ($form, $fieldName, $str) { // default behavior $jsError = [$form->js()->form('add prompt', $fieldName, $str)]; @@ -43,7 +43,7 @@ protected function init(): void * @param string $title * @param string $icon * - * @return \atk4\ui\Form\Layout + * @return \Atk4\Ui\Form\Layout */ public function addSection($title, \Closure $callback = null, $icon = 'dropdown') { @@ -61,7 +61,7 @@ public function addSection($title, \Closure $callback = null, $icon = 'dropdown' */ public function getSectionIdx($section) { - if ($section instanceof \atk4\ui\AccordionSection) { + if ($section instanceof \Atk4\Ui\AccordionSection) { return parent::getSectionIdx($section); } diff --git a/src/Form/Layout/Section/Columns.php b/src/Form/Layout/Section/Columns.php index b9d1d3ba5b..afba661526 100644 --- a/src/Form/Layout/Section/Columns.php +++ b/src/Form/Layout/Section/Columns.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace atk4\ui\Form\Layout\Section; +namespace Atk4\Ui\Form\Layout\Section; /** * Represents form controls in columns. */ -class Columns extends \atk4\ui\Columns +class Columns extends \Atk4\Ui\Columns { - public $formLayout = \atk4\ui\Form\Layout::class; + public $formLayout = \Atk4\Ui\Form\Layout::class; public $form; /** @@ -17,7 +17,7 @@ class Columns extends \atk4\ui\Columns * * @param int|array $defaults specify width (1..16) or relative to $width * - * @return \atk4\ui\Form\Layout + * @return \Atk4\Ui\Form\Layout */ public function addColumn($defaults = null) { diff --git a/src/Form/Layout/Section/Tabs.php b/src/Form/Layout/Section/Tabs.php index bad63eb800..e15aedeead 100644 --- a/src/Form/Layout/Section/Tabs.php +++ b/src/Form/Layout/Section/Tabs.php @@ -2,24 +2,24 @@ declare(strict_types=1); -namespace atk4\ui\Form\Layout\Section; +namespace Atk4\Ui\Form\Layout\Section; /** * Represents form controls in tabs. */ -class Tabs extends \atk4\ui\Tabs +class Tabs extends \Atk4\Ui\Tabs { - public $formLayout = \atk4\ui\Form\Layout::class; + public $formLayout = \Atk4\Ui\Form\Layout::class; public $form; /** * Adds tab in tabs widget. * - * @param string|\atk4\ui\Tab $name Name of tab or Tab object + * @param string|\Atk4\Ui\Tab $name Name of tab or Tab object * @param \Closure $callback Callback action or URL (or array with url + parameters) * @param array $settings tab settings * - * @return \atk4\ui\Form\Layout + * @return \Atk4\Ui\Form\Layout */ public function addTab($name, \Closure $callback = null, $settings = []) { diff --git a/src/Grid.php b/src/Grid.php index 2b0631ab62..d6483ee4cc 100644 --- a/src/Grid.php +++ b/src/Grid.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\core\Factory; -use atk4\core\HookTrait; -use atk4\data\Model; +use Atk4\Core\Factory; +use Atk4\Core\HookTrait; +use Atk4\Data\Model; /** * Implements a more sophisticated and interactive Data-Table component. @@ -362,7 +362,7 @@ public function addQuickSearch($fields = [], $hasAutoQuery = false) * @param JsExpression|null $afterSuccess * @param array $apiConfig * - * @return \atk4\ui\JsReload + * @return \Atk4\Ui\JsReload */ public function jsReload($args = [], $afterSuccess = null, $apiConfig = []) { @@ -444,7 +444,7 @@ public function addFilterColumn($names = null) if (!$this->menu) { throw new Exception('Unable to add Filter Column without Menu'); } - $this->menu->addItem(['Clear Filters'], new \atk4\ui\JsReload($this->table->reload, ['atk_clear_filter' => 1])); + $this->menu->addItem(['Clear Filters'], new \Atk4\Ui\JsReload($this->table->reload, ['atk_clear_filter' => 1])); $this->table->setFilterColumn($names); return $this; @@ -606,7 +606,7 @@ public function applySort() * * @param array|bool $columns * - * @return \atk4\data\Model + * @return \Atk4\Data\Model */ public function setModel(Model $model, $columns = null) { diff --git a/src/GridLayout.php b/src/GridLayout.php index 6b8720b8c9..253afa73be 100644 --- a/src/GridLayout.php +++ b/src/GridLayout.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; class GridLayout extends View { diff --git a/src/Header.php b/src/Header.php index b39af64b5f..3c3888b405 100644 --- a/src/Header.php +++ b/src/Header.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Class implements Headers. diff --git a/src/HelloWorld.php b/src/HelloWorld.php index e6df326da5..63f7187e06 100644 --- a/src/HelloWorld.php +++ b/src/HelloWorld.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Implements Hello World. Add this view anywhere! diff --git a/src/HtmlTemplate.php b/src/HtmlTemplate.php index b651180fa6..20f4f171b2 100644 --- a/src/HtmlTemplate.php +++ b/src/HtmlTemplate.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\data\Model; -use atk4\ui\HtmlTemplate\TagTree; -use atk4\ui\HtmlTemplate\Value as HtmlValue; +use Atk4\Data\Model; +use Atk4\Ui\HtmlTemplate\TagTree; +use Atk4\Ui\HtmlTemplate\Value as HtmlValue; class HtmlTemplate implements \ArrayAccess { - use \atk4\core\AppScopeTrait; + use \Atk4\Core\AppScopeTrait; /** @const string */ public const TOP_TAG = '_top'; diff --git a/src/HtmlTemplate/TagTree.php b/src/HtmlTemplate/TagTree.php index d4db76995d..ae8530a247 100644 --- a/src/HtmlTemplate/TagTree.php +++ b/src/HtmlTemplate/TagTree.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\HtmlTemplate; +namespace Atk4\Ui\HtmlTemplate; -use atk4\ui\Exception; -use atk4\ui\HtmlTemplate; +use Atk4\Ui\Exception; +use Atk4\Ui\HtmlTemplate; class TagTree { diff --git a/src/HtmlTemplate/Value.php b/src/HtmlTemplate/Value.php index 40cd859c55..38ed654327 100644 --- a/src/HtmlTemplate/Value.php +++ b/src/HtmlTemplate/Value.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\HtmlTemplate; +namespace Atk4\Ui\HtmlTemplate; -use atk4\ui\Exception; +use Atk4\Ui\Exception; class Value { diff --git a/src/Icon.php b/src/Icon.php index 15d4967cc3..ee5debf3f5 100644 --- a/src/Icon.php +++ b/src/Icon.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; class Icon extends View { diff --git a/src/Image.php b/src/Image.php index 32a1e33456..8893b4b51e 100644 --- a/src/Image.php +++ b/src/Image.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; class Image extends View { diff --git a/src/Item.php b/src/Item.php index e6898fb10c..1b5340fee5 100644 --- a/src/Item.php +++ b/src/Item.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Place menu. diff --git a/src/ItemsPerPageSelector.php b/src/ItemsPerPageSelector.php index cd252284e2..1417d8a381 100644 --- a/src/ItemsPerPageSelector.php +++ b/src/ItemsPerPageSelector.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Implement an item per page length selector. diff --git a/src/Jquery.php b/src/Jquery.php index e32d145376..e8b65a6963 100644 --- a/src/Jquery.php +++ b/src/Jquery.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Implements mapper for jQuery library. Following mappings are just to keep PhpStorm happy. diff --git a/src/JsCallback.php b/src/JsCallback.php index ec6a78d900..bfbe1f21e5 100644 --- a/src/JsCallback.php +++ b/src/JsCallback.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; class JsCallback extends Callback implements JsExpressionable { @@ -115,7 +115,7 @@ public function set($fx = null, $args = null) $ajaxec = $response ? $this->getAjaxec($response, $chain) : null; $this->terminateAjax($ajaxec); - } catch (\atk4\data\ValidationException $e) { + } catch (\Atk4\Data\ValidationException $e) { // Validation exceptions will be presented to user in a friendly way $msg = new Message($e->getMessage()); $msg->addClass('error'); diff --git a/src/JsChain.php b/src/JsChain.php index 16d769bdf0..d319fbd302 100644 --- a/src/JsChain.php +++ b/src/JsChain.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Implements a transparent mapper that will actually translate into JavaScript code. Used diff --git a/src/JsConditionalForm.php b/src/JsConditionalForm.php index 5bbd2f7ed4..1f5a6e3244 100644 --- a/src/JsConditionalForm.php +++ b/src/JsConditionalForm.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Implements conditions for displaying fields on form. */ class JsConditionalForm implements JsExpressionable { - use \atk4\core\DiContainerTrait; + use \Atk4\Core\DiContainerTrait; // {{{ Properties diff --git a/src/JsExpression.php b/src/JsExpression.php index 3f18be9a87..3497a40787 100644 --- a/src/JsExpression.php +++ b/src/JsExpression.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Implements a class that can be mapped into arbitrary JavaScript expression. */ class JsExpression implements JsExpressionable { - use \atk4\core\DiContainerTrait; + use \Atk4\Core\DiContainerTrait; /** * @var string diff --git a/src/JsExpressionable.php b/src/JsExpressionable.php index b5be540b6c..3528262f07 100644 --- a/src/JsExpressionable.php +++ b/src/JsExpressionable.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Implements a class that can be mapped into arbitrary JavaScript expression. diff --git a/src/JsFunction.php b/src/JsFunction.php index a641370c05..1d7a24dc22 100644 --- a/src/JsFunction.php +++ b/src/JsFunction.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Implements structure for js closure. diff --git a/src/JsModal.php b/src/JsModal.php index 2c33d25485..9eb3ad2104 100644 --- a/src/JsModal.php +++ b/src/JsModal.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * This class generates action, that will be able to loop-back to the callback method. diff --git a/src/JsNotify.php b/src/JsNotify.php index 8080cca563..16f8e9b843 100644 --- a/src/JsNotify.php +++ b/src/JsNotify.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Class JsNotify. */ class JsNotify implements JsExpressionable { - use \atk4\core\DiContainerTrait; + use \Atk4\Core\DiContainerTrait; public $options = []; public $attachTo; diff --git a/src/JsPaginator.php b/src/JsPaginator.php index 6ed7e4a0f6..1ae3d14c96 100644 --- a/src/JsPaginator.php +++ b/src/JsPaginator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Paginate content using scroll event in JS. diff --git a/src/JsReload.php b/src/JsReload.php index 99526e2eb6..0b82b969e9 100644 --- a/src/JsReload.php +++ b/src/JsReload.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * This class generates action, that will be able to loop-back to the callback method. diff --git a/src/JsSearch.php b/src/JsSearch.php index 95e8c74a1b..ab057d8f7e 100644 --- a/src/JsSearch.php +++ b/src/JsSearch.php @@ -6,7 +6,7 @@ * using the view->url with a _q arguments attach to url. */ -namespace atk4\ui; +namespace Atk4\Ui; class JsSearch extends View { diff --git a/src/JsSortable.php b/src/JsSortable.php index 0abf4fc8c0..6c839b457a 100644 --- a/src/JsSortable.php +++ b/src/JsSortable.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; class JsSortable extends JsCallback { diff --git a/src/JsSse.php b/src/JsSse.php index ff81b5c685..8b9f80d77f 100644 --- a/src/JsSse.php +++ b/src/JsSse.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\core\HookTrait; +use Atk4\Core\HookTrait; /** * Implements a class that can be mapped into arbitrary JavaScript expression. diff --git a/src/JsToast.php b/src/JsToast.php index 24aaa86bde..9666a810f4 100644 --- a/src/JsToast.php +++ b/src/JsToast.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\core\DiContainerTrait; +use Atk4\Core\DiContainerTrait; /** * Class JsToast diff --git a/src/JsVueService.php b/src/JsVueService.php index 5dfe4f9213..4acb63248c 100644 --- a/src/JsVueService.php +++ b/src/JsVueService.php @@ -6,7 +6,7 @@ * the atk javascript vue service. */ -namespace atk4\ui; +namespace Atk4\Ui; class JsVueService { diff --git a/src/Label.php b/src/Label.php index d3a0961d4c..a41a6092bf 100644 --- a/src/Label.php +++ b/src/Label.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; class Label extends View { diff --git a/src/Layout.php b/src/Layout.php index 4e2aea72c8..7e2856b30d 100644 --- a/src/Layout.php +++ b/src/Layout.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; class Layout extends View { diff --git a/src/Layout/Admin.php b/src/Layout/Admin.php index 529125ca5a..c05280e286 100644 --- a/src/Layout/Admin.php +++ b/src/Layout/Admin.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace atk4\ui\Layout; +namespace Atk4\Ui\Layout; -use atk4\ui\Header; -use atk4\ui\Icon; -use atk4\ui\Item; -use atk4\ui\Jquery; -use atk4\ui\Menu; +use Atk4\Ui\Header; +use Atk4\Ui\Icon; +use Atk4\Ui\Item; +use Atk4\Ui\Jquery; +use Atk4\Ui\Menu; /** * Implements a classic 100% width admin layout. @@ -32,7 +32,7 @@ * * - Content */ -class Admin extends \atk4\ui\Layout implements NavigableInterface +class Admin extends \Atk4\Ui\Layout implements NavigableInterface { public $menuLeft; // vertical menu public $menu; // horizontal menu diff --git a/src/Layout/Centered.php b/src/Layout/Centered.php index 4a9056c440..4883250d4a 100644 --- a/src/Layout/Centered.php +++ b/src/Layout/Centered.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\Layout; +namespace Atk4\Ui\Layout; /** * Implements a fixed-width single-column bevel in the middle of the page, centered @@ -11,14 +11,14 @@ * Bevel will use some padding and will contain your Content. * This layout is handy for a simple and single-purpose applications. */ -class Centered extends \atk4\ui\Layout +class Centered extends \Atk4\Ui\Layout { - use \atk4\core\DebugTrait; + use \Atk4\Core\DebugTrait; public $defaultTemplate = 'layout/centered.html'; /** - * @see \atk4\ui\App::$cdn + * @see \Atk4\Ui\App::$cdn * * @var string|null */ diff --git a/src/Layout/Column.php b/src/Layout/Column.php index bfbeb63cb7..7cff745c6c 100644 --- a/src/Layout/Column.php +++ b/src/Layout/Column.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\Layout; +namespace Atk4\Ui\Layout; /** * Implements a single content column application, typically used in your favourite @@ -13,7 +13,7 @@ * * Sticky top-bar for simple navigation and three flexible areas for flexible use. */ -class Column extends \atk4\ui\Layout +class Column extends \Atk4\Ui\Layout { public $defaultTemplate = 'layout/column.html'; diff --git a/src/Layout/Maestro.php b/src/Layout/Maestro.php index 04418afb13..2d734a48ca 100644 --- a/src/Layout/Maestro.php +++ b/src/Layout/Maestro.php @@ -8,11 +8,11 @@ * Note that it is possible to change these default value if another template is use. */ -namespace atk4\ui\Layout; +namespace Atk4\Ui\Layout; -use atk4\ui\Item; -use atk4\ui\Jquery; -use atk4\ui\Menu; +use Atk4\Ui\Item; +use Atk4\Ui\Jquery; +use Atk4\Ui\Menu; class Maestro extends Admin { diff --git a/src/Layout/NavigableInterface.php b/src/Layout/NavigableInterface.php index ea29cf3c3f..3d29e2151b 100644 --- a/src/Layout/NavigableInterface.php +++ b/src/Layout/NavigableInterface.php @@ -5,10 +5,10 @@ * Interface for a Layout using a navigable side menu. */ -namespace atk4\ui\Layout; +namespace Atk4\Ui\Layout; -use atk4\ui\Item; -use atk4\ui\Menu; +use Atk4\Ui\Item; +use Atk4\Ui\Menu; interface NavigableInterface { diff --git a/src/Layout/Product.php b/src/Layout/Product.php index 8626a0d3cd..9fe1a08224 100644 --- a/src/Layout/Product.php +++ b/src/Layout/Product.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace atk4\ui\Layout; +namespace Atk4\Ui\Layout; /** * Ideally suited for your product page, this layout is a single-column * layout designed specifically product description. */ -class Product extends \atk4\ui\Layout +class Product extends \Atk4\Ui\Layout { public $defaultTemplate = 'layout/product.html'; } diff --git a/src/Lister.php b/src/Lister.php index 2d0aa6010c..2fe50cceca 100644 --- a/src/Lister.php +++ b/src/Lister.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; class Lister extends View { - use \atk4\core\HookTrait; + use \Atk4\Core\HookTrait; /** @const string */ public const HOOK_BEFORE_ROW = self::class . '@beforeRow'; diff --git a/src/Loader.php b/src/Loader.php index 5992312ab5..96d995ac2b 100644 --- a/src/Loader.php +++ b/src/Loader.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Class implements Loader, which is a View that will dynamically render it's content. @@ -65,7 +65,7 @@ protected function init(): void * $l1->set([$my_object, 'run_long_process']); * * NOTE: default values are like that due ot PHP 7.0 warning: - * Declaration of \atk4\ui\Loader::set($fx, $args = Array) should be compatible with \atk4\ui\View::set($arg1 = Array, $arg2 = NULL) + * Declaration of \Atk4\Ui\Loader::set($fx, $args = Array) should be compatible with \Atk4\Ui\View::set($arg1 = Array, $arg2 = NULL) * * @param \Closure $fx * diff --git a/src/Locale.php b/src/Locale.php index 6e3a482b47..4360765d01 100644 --- a/src/Locale.php +++ b/src/Locale.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; class Locale { diff --git a/src/LoremIpsum.php b/src/LoremIpsum.php index f01e16b1fb..1eba25932a 100644 --- a/src/LoremIpsum.php +++ b/src/LoremIpsum.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Provides a handy object that generates some amount of random text-filler. diff --git a/src/Menu.php b/src/Menu.php index 09b7c85bb8..c21b7f2da6 100644 --- a/src/Menu.php +++ b/src/Menu.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\data\Model; +use Atk4\Data\Model; /** * Place menu. diff --git a/src/Message.php b/src/Message.php index 74f05a9b02..5138295b30 100644 --- a/src/Message.php +++ b/src/Message.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Class implements Messages (a visual box). diff --git a/src/Misc/ProxyModel.php b/src/Misc/ProxyModel.php index 7e335f4f99..711a02e429 100644 --- a/src/Misc/ProxyModel.php +++ b/src/Misc/ProxyModel.php @@ -2,8 +2,8 @@ declare(strict_types=1); -namespace atk4\ui\Misc; +namespace Atk4\Ui\Misc; -class ProxyModel extends \atk4\data\Model +class ProxyModel extends \Atk4\Data\Model { } diff --git a/src/Modal.php b/src/Modal.php index 50c8447b7b..db5e09a33b 100644 --- a/src/Modal.php +++ b/src/Modal.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * This class add modal dialog to a page. @@ -20,8 +20,8 @@ * * Modal can use semantic-ui predefine method onApprove or onDeny by passing * a jsAction to Modal::addDenyAction or Modal::addApproveAction method. It will not close until the jsAction return true. - * $modal->addDenyAction('No', new \atk4\ui\JsExpression('function(){window.alert("Can\'t do that."); return false;}')); - * $modal->addApproveAction('Yes', new \atk4\ui\JsExpression('function(){window.alert("You\'re good to go!");}')); + * $modal->addDenyAction('No', new \Atk4\Ui\JsExpression('function(){window.alert("Can\'t do that."); return false;}')); + * $modal->addApproveAction('Yes', new \Atk4\Ui\JsExpression('function(){window.alert("You\'re good to go!");}')); * * You may also prevent modal from closing via the esc or dimmed area click using $modal->notClosable(). * diff --git a/src/Paginator.php b/src/Paginator.php index ab722ae65e..9e1565fe5a 100644 --- a/src/Paginator.php +++ b/src/Paginator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; class Paginator extends View { diff --git a/src/Panel/Content.php b/src/Panel/Content.php index 382c6cc7ef..2717f7e7d1 100644 --- a/src/Panel/Content.php +++ b/src/Panel/Content.php @@ -5,10 +5,10 @@ * Slide Panel Content. */ -namespace atk4\ui\Panel; +namespace Atk4\Ui\Panel; -use atk4\ui\Callback; -use atk4\ui\View; +use Atk4\Ui\Callback; +use Atk4\Ui\View; class Content extends View implements LoadableContent { @@ -60,7 +60,7 @@ public function getClearSelector(): array return ['.atk-panel-content']; } - protected function mergeStickyArgsFromChildView(): ?\atk4\ui\AbstractView + protected function mergeStickyArgsFromChildView(): ?\Atk4\Ui\AbstractView { return $this->cb; } diff --git a/src/Panel/Loadable.php b/src/Panel/Loadable.php index 55be3a5b94..bd6a2ff8be 100644 --- a/src/Panel/Loadable.php +++ b/src/Panel/Loadable.php @@ -5,7 +5,7 @@ * Loadable Interface. */ -namespace atk4\ui\Panel; +namespace Atk4\Ui\Panel; interface Loadable { diff --git a/src/Panel/LoadableContent.php b/src/Panel/LoadableContent.php index 38e672640e..43f70be343 100644 --- a/src/Panel/LoadableContent.php +++ b/src/Panel/LoadableContent.php @@ -5,9 +5,9 @@ * LoadableContent interface. */ -namespace atk4\ui\Panel; +namespace Atk4\Ui\Panel; -use atk4\ui\Callback; +use Atk4\Ui\Callback; interface LoadableContent { diff --git a/src/Panel/Right.php b/src/Panel/Right.php index 886e8c8414..53f395822b 100644 --- a/src/Panel/Right.php +++ b/src/Panel/Right.php @@ -10,14 +10,14 @@ * This view must implement a callback for content to be add via the callback function. */ -namespace atk4\ui\Panel; +namespace Atk4\Ui\Panel; -use atk4\core\Factory; -use atk4\ui\Button; -use atk4\ui\Jquery; -use atk4\ui\JsExpression; -use atk4\ui\Modal; -use atk4\ui\View; +use Atk4\Core\Factory; +use Atk4\Ui\Button; +use Atk4\Ui\Jquery; +use Atk4\Ui\JsExpression; +use Atk4\Ui\Modal; +use Atk4\Ui\View; class Right extends View implements Loadable { @@ -83,7 +83,7 @@ public function getDynamicContent(): LoadableContent */ public function service(): JsExpression { - return new \atk4\ui\JsChain('atk.panelService'); + return new \Atk4\Ui\JsChain('atk.panelService'); } /** @@ -213,7 +213,7 @@ protected function renderView(): void $this->js(true, $this->service()->addPanel($this->getPanelOptions())); } - protected function mergeStickyArgsFromChildView(): ?\atk4\ui\AbstractView + protected function mergeStickyArgsFromChildView(): ?\Atk4\Ui\AbstractView { return $this->dynamicContent; } diff --git a/src/Persistence/Post.php b/src/Persistence/Post.php index 2cf3a4931c..d50646d152 100644 --- a/src/Persistence/Post.php +++ b/src/Persistence/Post.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\Persistence; +namespace Atk4\Ui\Persistence; -use atk4\data\Model; +use Atk4\Data\Model; -class Post extends \atk4\data\Persistence +class Post extends \Atk4\Data\Persistence { public function load(Model $model, $id = 0): array { diff --git a/src/Persistence/Ui.php b/src/Persistence/Ui.php index a640f1943b..1bbd6ec583 100644 --- a/src/Persistence/Ui.php +++ b/src/Persistence/Ui.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\Persistence; +namespace Atk4\Ui\Persistence; -use atk4\data\Model; -use atk4\ui\Exception; +use Atk4\Data\Model; +use Atk4\Ui\Exception; /** * This class is used for typecasting model types to the values that will be presented to the user. App will @@ -17,7 +17,7 @@ * * You may want to localize some of the output. */ -class Ui extends \atk4\data\Persistence +class Ui extends \Atk4\Data\Persistence { public $date_format = 'M d, Y'; @@ -52,7 +52,7 @@ class Ui extends \atk4\data\Persistence /** * This method contains the logic of casting generic values into user-friendly format. */ - public function _typecastSaveField(\atk4\data\Field $f, $value) + public function _typecastSaveField(\Atk4\Data\Field $f, $value) { // serialize if we explicitly want that if ($f->serialize) { @@ -109,7 +109,7 @@ public function _typecastSaveField(\atk4\data\Field $f, $value) /** * Interpret user-defined input for various types. */ - public function _typecastLoadField(\atk4\data\Field $f, $value) + public function _typecastLoadField(\Atk4\Data\Field $f, $value) { // serialize if we explicitly want that if ($f->serialize && $value) { diff --git a/src/Popup.php b/src/Popup.php index ee0f2d0112..d6cf4c0637 100644 --- a/src/Popup.php +++ b/src/Popup.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Implement popup view. diff --git a/src/ProgressBar.php b/src/ProgressBar.php index 067a11ab03..14a0bd208c 100644 --- a/src/ProgressBar.php +++ b/src/ProgressBar.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Class implements ProgressBar. diff --git a/src/Step.php b/src/Step.php index b1578f8280..9c780e8ec2 100644 --- a/src/Step.php +++ b/src/Step.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * One step of the wizard. diff --git a/src/Tab.php b/src/Tab.php index 610aac9b83..39ea6b2b40 100644 --- a/src/Tab.php +++ b/src/Tab.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * One Tab of Tabs widget. diff --git a/src/Table.php b/src/Table.php index 625bc58fe2..10b710e38d 100644 --- a/src/Table.php +++ b/src/Table.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\core\Factory; +use Atk4\Core\Factory; class Table extends Lister { @@ -187,7 +187,7 @@ public function addColumn(?string $name, $columnDecorator = null, $field = null) } if (!$this->model) { - $this->model = new \atk4\ui\Misc\ProxyModel(); + $this->model = new \Atk4\Ui\Misc\ProxyModel(); } // This code should be vaugely consistent with Form\Layout::addControl() @@ -346,12 +346,12 @@ protected function getColumn(string $name) * Will come up with a column object based on the field object supplied. * By default will use default column. * - * @param \atk4\data\Field $field Data model field + * @param \Atk4\Data\Field $field Data model field * @param mixed $seed Defaults to pass to Factory::factory() when decorator is initialized * * @return Table\Column */ - public function decoratorFactory(\atk4\data\Field $field, $seed = []) + public function decoratorFactory(\Atk4\Data\Field $field, $seed = []) { $seed = Factory::mergeSeeds( $seed, @@ -452,9 +452,9 @@ public function addTotals($plan = []) * * @param array|bool $columns * - * @return \atk4\data\Model + * @return \Atk4\Data\Model */ - public function setModel(\atk4\data\Model $model, $columns = null) + public function setModel(\Atk4\Data\Model $model, $columns = null) { parent::setModel($model); @@ -641,7 +641,7 @@ public function updateTotals() } // closure support - // arguments - current value, key, \atk4\ui\Table object + // arguments - current value, key, \Atk4\Ui\Table object if ($f instanceof \Closure) { $this->totals[$key] += ($f($this->model->get($key), $key, $this) ?: 0); } elseif (is_string($f)) { // built-in methods diff --git a/src/Table/Column.php b/src/Table/Column.php index f5a1fc85b7..211d173312 100644 --- a/src/Table/Column.php +++ b/src/Table/Column.php @@ -2,26 +2,26 @@ declare(strict_types=1); -namespace atk4\ui\Table; +namespace Atk4\Ui\Table; -use atk4\data\Field; -use atk4\data\Model; -use atk4\ui\Exception; -use atk4\ui\Jquery; -use atk4\ui\JsExpression; -use atk4\ui\Popup; +use Atk4\Data\Field; +use Atk4\Data\Model; +use Atk4\Ui\Exception; +use Atk4\Ui\Jquery; +use Atk4\Ui\JsExpression; +use Atk4\Ui\Popup; /** * Implements Column helper for table. * - * @method \atk4\ui\Table getOwner() + * @method \Atk4\Ui\Table getOwner() */ class Column { - use \atk4\core\AppScopeTrait; - use \atk4\core\InitializerTrait; - use \atk4\core\TrackableTrait; - use \atk4\core\DiContainerTrait; + use \Atk4\Core\AppScopeTrait; + use \Atk4\Core\InitializerTrait; + use \Atk4\Core\TrackableTrait; + use \Atk4\Core\DiContainerTrait; /** @const string */ public const HOOK_GET_HTML_TAGS = self::class . '@getHtmlTags'; @@ -31,7 +31,7 @@ class Column /** * Link back to the table, where column is used. * - * @var \atk4\ui\Table + * @var \Atk4\Ui\Table */ public $table; @@ -173,7 +173,7 @@ public function addDropdown(array $items, \Closure $fx, $icon = 'caret square do * This method return a callback where you can detect * menu item change via $cb->onMenuItem($item) function. * - * @return \atk4\ui\JsCallback + * @return \Atk4\Ui\JsCallback */ public function setHeaderDropdown($items, string $icon = 'caret square down', string $menuId = null) { diff --git a/src/Table/Column/ActionButtons.php b/src/Table/Column/ActionButtons.php index a80e3c5209..c4918f8ccb 100644 --- a/src/Table/Column/ActionButtons.php +++ b/src/Table/Column/ActionButtons.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\core\Factory; -use atk4\data\Model; -use atk4\ui\Table; +use Atk4\Core\Factory; +use Atk4\Data\Model; +use Atk4\Ui\Table; /** * Formatting action buttons column. @@ -38,10 +38,10 @@ protected function init(): void * * Returns button object * - * @param \atk4\ui\View|string $button + * @param \Atk4\Ui\View|string $button * @param \Closure|Model\UserAction|null $action * - * @return \atk4\ui\View + * @return \Atk4\Ui\View */ public function addButton($button, $action = null, string $confirmMsg = '', bool $isDisabled = false) { @@ -77,7 +77,7 @@ public function addButton($button, $action = null, string $confirmMsg = '', bool $button = [1 => $button]; } - $button = Factory::factory([\atk4\ui\Button::class], Factory::mergeSeeds($button, ['id' => false])); + $button = Factory::factory([\Atk4\Ui\Button::class], Factory::mergeSeeds($button, ['id' => false])); } $button->setApp($this->table->getApp()); @@ -96,12 +96,12 @@ public function addButton($button, $action = null, string $confirmMsg = '', bool * Adds a new button which will open a modal dialog and dynamically * load contents through $callback. Will pass a virtual page. * - * @param \atk4\ui\View|string $button + * @param \Atk4\Ui\View|string $button * @param string|array $defaults modal title or modal defaults array - * @param \atk4\ui\View $owner + * @param \Atk4\Ui\View $owner * @param array $args * - * @return \atk4\ui\View + * @return \Atk4\Ui\View */ public function addModal($button, $defaults, \Closure $callback, $owner = null, $args = []) { @@ -113,7 +113,7 @@ public function addModal($button, $defaults, \Closure $callback, $owner = null, $defaults['appStickyCb'] = true; - $modal = \atk4\ui\Modal::addTo($owner, $defaults); + $modal = \Atk4\Ui\Modal::addTo($owner, $defaults); $modal->observeChanges(); // adds scrollbar if needed @@ -136,7 +136,7 @@ public function getTag($position, $value, $attr = []) return parent::getTag($position, $value, $attr); } - public function getDataCellTemplate(\atk4\data\Field $field = null) + public function getDataCellTemplate(\Atk4\Data\Field $field = null) { if (!$this->buttons) { return ''; diff --git a/src/Table/Column/ActionMenu.php b/src/Table/Column/ActionMenu.php index 5ce1f910ca..6337229b37 100644 --- a/src/Table/Column/ActionMenu.php +++ b/src/Table/Column/ActionMenu.php @@ -6,14 +6,14 @@ * Will create a dropdown menu within table column. */ -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\core\Factory; -use atk4\data\Model; -use atk4\ui\Jquery; -use atk4\ui\JsChain; -use atk4\ui\Table; -use atk4\ui\View; +use Atk4\Core\Factory; +use Atk4\Data\Model; +use Atk4\Ui\Jquery; +use Atk4\Ui\JsChain; +use Atk4\Ui\Table; +use Atk4\Ui\View; class ActionMenu extends Table\Column { @@ -110,7 +110,7 @@ public function addActionMenuItem($item, $action = null, string $confirmMsg = '' } if (!is_object($item)) { - $item = Factory::factory([\atk4\ui\View::class], ['id' => false, 'ui' => 'item', 'content' => $item]); + $item = Factory::factory([\Atk4\Ui\View::class], ['id' => false, 'ui' => 'item', 'content' => $item]); } $this->items[] = $item; @@ -132,7 +132,7 @@ public function addActionMenuItem($item, $action = null, string $confirmMsg = '' /** * {@inheritdoc} */ - public function getHeaderCellHtml(\atk4\data\Field $field = null, $value = null) + public function getHeaderCellHtml(\Atk4\Data\Field $field = null, $value = null) { $this->table->js(true)->find('.atk-action-menu')->dropdown( array_merge( @@ -152,7 +152,7 @@ public function getHeaderCellHtml(\atk4\data\Field $field = null, $value = null) /** * {@inheritdoc} */ - public function getDataCellTemplate(\atk4\data\Field $field = null) + public function getDataCellTemplate(\Atk4\Data\Field $field = null) { if (!$this->items) { return ''; diff --git a/src/Table/Column/Checkbox.php b/src/Table/Column/Checkbox.php index 5a7eb17c47..3dadfabe59 100644 --- a/src/Table/Column/Checkbox.php +++ b/src/Table/Column/Checkbox.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\data\Field; -use atk4\ui\Exception; -use atk4\ui\JsExpression; -use atk4\ui\Table; +use Atk4\Data\Field; +use Atk4\Ui\Exception; +use Atk4\Ui\JsExpression; +use Atk4\Ui\Table; /** * Implements Checkbox column for selecting rows. diff --git a/src/Table/Column/ColorRating.php b/src/Table/Column/ColorRating.php index a1f628bdf8..7e4fad6daa 100644 --- a/src/Table/Column/ColorRating.php +++ b/src/Table/Column/ColorRating.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\data\Field; -use atk4\data\Model; -use atk4\ui\Exception; -use atk4\ui\Table; +use Atk4\Data\Field; +use Atk4\Data\Model; +use Atk4\Ui\Exception; +use Atk4\Ui\Table; /** * Class ColorRating diff --git a/src/Table/Column/Delete.php b/src/Table/Column/Delete.php index 757661f8fe..ff872f2899 100644 --- a/src/Table/Column/Delete.php +++ b/src/Table/Column/Delete.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\ui\Table; +use Atk4\Ui\Table; /** * Formatting action buttons column. @@ -15,7 +15,7 @@ protected function init(): void { parent::init(); - $this->vp = $this->table->add(new \atk4\ui\CallbackLater()); + $this->vp = $this->table->add(new \Atk4\Ui\CallbackLater()); $this->vp->set(function () { $this->table->model->load($_POST[$this->name])->delete(); @@ -25,9 +25,9 @@ protected function init(): void }); } - public function getDataCellTemplate(\atk4\data\Field $field = null) + public function getDataCellTemplate(\Atk4\Data\Field $field = null) { - $this->table->on('click', 'a.' . $this->short_name, null, ['confirm' => (new \atk4\ui\Jquery())->attr('title')])->atkAjaxec([ + $this->table->on('click', 'a.' . $this->short_name, null, ['confirm' => (new \Atk4\Ui\Jquery())->attr('title')])->atkAjaxec([ 'uri' => $this->vp->getJsUrl(), 'uri_options' => [$this->name => $this->table->jsRow()->data('id')], ]); diff --git a/src/Table/Column/DragHandler.php b/src/Table/Column/DragHandler.php index 96916c2a43..8eb41f4c56 100644 --- a/src/Table/Column/DragHandler.php +++ b/src/Table/Column/DragHandler.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\ui\Table; +use Atk4\Ui\Table; /** * Implement drag handler column for sorting table. @@ -13,7 +13,7 @@ class DragHandler extends Table\Column { public $class; public $tag = 'i'; - /** @var \atk4\ui\JsCallback */ + /** @var \Atk4\Ui\JsCallback */ public $cb; protected function init(): void @@ -23,7 +23,7 @@ protected function init(): void if (!$this->class) { $this->class = 'content icon'; } - $this->cb = \atk4\ui\JsSortable::addTo($this->table, ['handleClass' => 'atk-handle']); + $this->cb = \Atk4\Ui\JsSortable::addTo($this->table, ['handleClass' => 'atk-handle']); } /** @@ -34,7 +34,7 @@ public function onReorder(\Closure $fx) $this->cb->onReorder($fx); } - public function getDataCellTemplate(\atk4\data\Field $field = null) + public function getDataCellTemplate(\Atk4\Data\Field $field = null) { return $this->getApp()->getTag($this->tag, ['class' => $this->class . ' atk-handle', 'style' => 'cursor:pointer; color: #bcbdbd']); } diff --git a/src/Table/Column/FilterModel.php b/src/Table/Column/FilterModel.php index da4587a707..059eef59fb 100644 --- a/src/Table/Column/FilterModel.php +++ b/src/Table/Column/FilterModel.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\core\NameTrait; -use atk4\core\SessionTrait; -use atk4\data\Field; -use atk4\data\Persistence; +use Atk4\Core\NameTrait; +use Atk4\Core\SessionTrait; +use Atk4\Data\Field; +use Atk4\Data\Persistence; /** * Implement a generic filter model for filtering column data. */ -class FilterModel extends \atk4\data\Model +class FilterModel extends \Atk4\Data\Model { use SessionTrait; use NameTrait; // needed for SessionTrait @@ -69,7 +69,7 @@ public static function factoryType($field) * Field class and setting your filter model class. */ if (!empty($field->filterModel) && isset($field->filterModel)) { - if ($field->filterModel instanceof \atk4\data\Model) { + if ($field->filterModel instanceof \Atk4\Data\Model) { return $field->filterModel; } $class = $field->filterModel; diff --git a/src/Table/Column/FilterModel/TypeBoolean.php b/src/Table/Column/FilterModel/TypeBoolean.php index ae68654979..5ca9d62bc1 100644 --- a/src/Table/Column/FilterModel/TypeBoolean.php +++ b/src/Table/Column/FilterModel/TypeBoolean.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column\FilterModel; +namespace Atk4\Ui\Table\Column\FilterModel; -use atk4\ui\Table\Column; +use Atk4\Ui\Table\Column; class TypeBoolean extends Column\FilterModel { diff --git a/src/Table/Column/FilterModel/TypeDate.php b/src/Table/Column/FilterModel/TypeDate.php index aec740fe13..53d2d2c3f5 100644 --- a/src/Table/Column/FilterModel/TypeDate.php +++ b/src/Table/Column/FilterModel/TypeDate.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column\FilterModel; +namespace Atk4\Ui\Table\Column\FilterModel; -use atk4\data\Model; -use atk4\ui\Table\Column; +use Atk4\Data\Model; +use Atk4\Ui\Table\Column; use DateTime; class TypeDate extends Column\FilterModel @@ -60,7 +60,7 @@ protected function init(): void $this->addField('exact_date', ['type' => 'date', 'ui' => ['caption' => '']]); // The integer field to generate a date when x day selector is used. - $this->addField('number_days', ['ui' => ['caption' => '', 'form' => [\atk4\ui\Form\Control\Line::class, 'inputType' => 'number']]]); + $this->addField('number_days', ['ui' => ['caption' => '', 'form' => [\Atk4\Ui\Form\Control\Line::class, 'inputType' => 'number']]]); } /** diff --git a/src/Table/Column/FilterModel/TypeDatetime.php b/src/Table/Column/FilterModel/TypeDatetime.php index 54679272e4..4e5d447e2b 100644 --- a/src/Table/Column/FilterModel/TypeDatetime.php +++ b/src/Table/Column/FilterModel/TypeDatetime.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column\FilterModel; +namespace Atk4\Ui\Table\Column\FilterModel; -use atk4\ui\Table\Column; +use Atk4\Ui\Table\Column; use DateTime; class TypeDatetime extends Column\FilterModel @@ -59,7 +59,7 @@ protected function init(): void $this->addField('exact_date', ['type' => 'date', 'ui' => ['caption' => '']]); // The integer field to generate a date when x day selector is used. - $this->addField('number_days', ['ui' => ['caption' => '', 'form' => [\atk4\ui\Form\Control\Line::class, 'inputType' => 'number']]]); + $this->addField('number_days', ['ui' => ['caption' => '', 'form' => [\Atk4\Ui\Form\Control\Line::class, 'inputType' => 'number']]]); } /** diff --git a/src/Table/Column/FilterModel/TypeEnum.php b/src/Table/Column/FilterModel/TypeEnum.php index 753655141b..46016b0739 100644 --- a/src/Table/Column/FilterModel/TypeEnum.php +++ b/src/Table/Column/FilterModel/TypeEnum.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column\FilterModel; +namespace Atk4\Ui\Table\Column\FilterModel; -use atk4\data\Model; -use atk4\ui\Table\Column; +use Atk4\Data\Model; +use Atk4\Ui\Table\Column; class TypeEnum extends Column\FilterModel { diff --git a/src/Table/Column/FilterModel/TypeInteger.php b/src/Table/Column/FilterModel/TypeInteger.php index aa9375f047..f2a66ebfd2 100644 --- a/src/Table/Column/FilterModel/TypeInteger.php +++ b/src/Table/Column/FilterModel/TypeInteger.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column\FilterModel; +namespace Atk4\Ui\Table\Column\FilterModel; class TypeInteger extends TypeNumber { diff --git a/src/Table/Column/FilterModel/TypeMoney.php b/src/Table/Column/FilterModel/TypeMoney.php index c854a5886f..02245efc95 100644 --- a/src/Table/Column/FilterModel/TypeMoney.php +++ b/src/Table/Column/FilterModel/TypeMoney.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column\FilterModel; +namespace Atk4\Ui\Table\Column\FilterModel; class TypeMoney extends TypeNumber { diff --git a/src/Table/Column/FilterModel/TypeNumber.php b/src/Table/Column/FilterModel/TypeNumber.php index f7ae41605f..72a7c042cd 100644 --- a/src/Table/Column/FilterModel/TypeNumber.php +++ b/src/Table/Column/FilterModel/TypeNumber.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column\FilterModel; +namespace Atk4\Ui\Table\Column\FilterModel; -use atk4\ui\Table\Column; +use Atk4\Ui\Table\Column; class TypeNumber extends Column\FilterModel { @@ -23,8 +23,8 @@ protected function init(): void ]; $this->op->default = '='; - $this->value->ui['form'] = [\atk4\ui\Form\Control\Line::class, 'inputType' => 'number']; - $this->addField('range', ['ui' => ['caption' => '', 'form' => [\atk4\ui\Form\Control\Line::class, 'inputType' => 'number']]]); + $this->value->ui['form'] = [\Atk4\Ui\Form\Control\Line::class, 'inputType' => 'number']; + $this->addField('range', ['ui' => ['caption' => '', 'form' => [\Atk4\Ui\Form\Control\Line::class, 'inputType' => 'number']]]); } public function setConditionForModel($model) diff --git a/src/Table/Column/FilterModel/TypeString.php b/src/Table/Column/FilterModel/TypeString.php index 54278d78a9..73cf814345 100644 --- a/src/Table/Column/FilterModel/TypeString.php +++ b/src/Table/Column/FilterModel/TypeString.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column\FilterModel; +namespace Atk4\Ui\Table\Column\FilterModel; -use atk4\ui\Table\Column; +use Atk4\Ui\Table\Column; class TypeString extends Column\FilterModel { diff --git a/src/Table/Column/FilterModel/TypeText.php b/src/Table/Column/FilterModel/TypeText.php index bc0591077a..58fdeaef8f 100644 --- a/src/Table/Column/FilterModel/TypeText.php +++ b/src/Table/Column/FilterModel/TypeText.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column\FilterModel; +namespace Atk4\Ui\Table\Column\FilterModel; class TypeText extends TypeString { diff --git a/src/Table/Column/FilterModel/TypeTime.php b/src/Table/Column/FilterModel/TypeTime.php index f2bc2391de..b5b0660465 100644 --- a/src/Table/Column/FilterModel/TypeTime.php +++ b/src/Table/Column/FilterModel/TypeTime.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column\FilterModel; +namespace Atk4\Ui\Table\Column\FilterModel; -use atk4\ui\Table\Column; +use Atk4\Ui\Table\Column; class TypeTime extends Column\FilterModel { diff --git a/src/Table/Column/FilterPopup.php b/src/Table/Column/FilterPopup.php index 875ebae73a..5c6b4da76b 100644 --- a/src/Table/Column/FilterPopup.php +++ b/src/Table/Column/FilterPopup.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\data\Field; -use atk4\ui\Form; -use atk4\ui\Jquery; -use atk4\ui\JsReload; -use atk4\ui\Popup; +use Atk4\Data\Field; +use Atk4\Ui\Form; +use Atk4\Ui\Jquery; +use Atk4\Ui\JsReload; +use Atk4\Ui\Popup; /** * Implement a filterPopup in a table column. @@ -34,7 +34,7 @@ class FilterPopup extends Popup /** * The view associate with this filter popup that need to be reload. * - * @var \atk4\ui\View|null + * @var \Atk4\Ui\View|null */ public $reload; @@ -75,7 +75,7 @@ protected function init(): void return new jsReload($this->reload); }); - \atk4\ui\Button::addTo($this->form, ['Clear', 'clear '])->on('click', function ($f) use ($model) { + \Atk4\Ui\Button::addTo($this->form, ['Clear', 'clear '])->on('click', function ($f) use ($model) { $model->clearData(); return [ diff --git a/src/Table/Column/Html.php b/src/Table/Column/Html.php index a9ce1fb7bf..4a314cdcf8 100644 --- a/src/Table/Column/Html.php +++ b/src/Table/Column/Html.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\data\Field; -use atk4\data\Model; -use atk4\ui\Table; +use Atk4\Data\Field; +use Atk4\Data\Model; +use Atk4\Ui\Table; /** * Class HTML. diff --git a/src/Table/Column/Image.php b/src/Table/Column/Image.php index 540bcbe97b..c4e0591b18 100644 --- a/src/Table/Column/Image.php +++ b/src/Table/Column/Image.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\ui\Table; +use Atk4\Ui\Table; /** * Column for formatting image. @@ -23,7 +23,7 @@ class Image extends Table\Column * * @return string */ - public function getDataCellTemplate(\atk4\data\Field $field = null) + public function getDataCellTemplate(\Atk4\Data\Field $field = null) { $caption = $field ? $field->getCaption() : $this->short_name; diff --git a/src/Table/Column/JsHeader.php b/src/Table/Column/JsHeader.php index 5ec7625e2e..e7bf0d1532 100644 --- a/src/Table/Column/JsHeader.php +++ b/src/Table/Column/JsHeader.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\ui\JsCallback; +use Atk4\Ui\JsCallback; /** * Implement a callback for a column header dropdown menu. diff --git a/src/Table/Column/KeyValue.php b/src/Table/Column/KeyValue.php index 8261853335..dbf42f4b58 100644 --- a/src/Table/Column/KeyValue.php +++ b/src/Table/Column/KeyValue.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\data\Field; -use atk4\data\Model; -use atk4\ui\Exception; -use atk4\ui\Table; +use Atk4\Data\Field; +use Atk4\Data\Model; +use Atk4\Ui\Exception; +use Atk4\Ui\Table; /** * Class KeyValue. @@ -37,7 +37,7 @@ * 3 => __('paid'), * ], * 'ui' => [ - * 'form' => [\atk4\ui\Form\Control\Dropdown::class], + * 'form' => [\Atk4\Ui\Form\Control\Dropdown::class], * 'table' => ['KeyValue'], * ], * ]); diff --git a/src/Table/Column/Labels.php b/src/Table/Column/Labels.php index 4268aa1db0..09282e75b5 100644 --- a/src/Table/Column/Labels.php +++ b/src/Table/Column/Labels.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\data\Field; -use atk4\data\Model; -use atk4\ui\Table; +use Atk4\Data\Field; +use Atk4\Data\Model; +use Atk4\Ui\Table; /** * Class Labels. diff --git a/src/Table/Column/Link.php b/src/Table/Column/Link.php index 70b4311b36..76bc2cc573 100644 --- a/src/Table/Column/Link.php +++ b/src/Table/Column/Link.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\data\Model; -use atk4\ui\HtmlTemplate; -use atk4\ui\Table; +use Atk4\Data\Model; +use Atk4\Ui\HtmlTemplate; +use Atk4\Ui\Table; /** * Implements Column helper for grid. @@ -124,7 +124,7 @@ protected function init(): void } } - public function getDataCellTemplate(\atk4\data\Field $field = null) + public function getDataCellTemplate(\Atk4\Data\Field $field = null) { $download = $this->force_download ? ' download="true" ' : ''; $external = $this->target ? ' target="' . $this->target . '" ' : ''; diff --git a/src/Table/Column/Money.php b/src/Table/Column/Money.php index c2d0387c6c..6f8241c237 100644 --- a/src/Table/Column/Money.php +++ b/src/Table/Column/Money.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\data\Model; -use atk4\ui\Table; +use Atk4\Data\Model; +use Atk4\Ui\Table; /** * Column for formatting money. @@ -25,10 +25,10 @@ public function getTagAttributes($position, $attr = []) return parent::getTagAttributes($position, $attr); } - public function getDataCellHtml(\atk4\data\Field $field = null, $extra_tags = []) + public function getDataCellHtml(\Atk4\Data\Field $field = null, $extra_tags = []) { if (!isset($field)) { - throw new \atk4\ui\Exception('Money column requires a field'); + throw new \Atk4\Ui\Exception('Money column requires a field'); } return $this->getTag( diff --git a/src/Table/Column/Multiformat.php b/src/Table/Column/Multiformat.php index c6e5fcdd48..4d985acdfb 100644 --- a/src/Table/Column/Multiformat.php +++ b/src/Table/Column/Multiformat.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\data\Field; -use atk4\data\Model; -use atk4\ui\Exception; -use atk4\ui\HtmlTemplate; -use atk4\ui\Table; +use Atk4\Data\Field; +use Atk4\Data\Model; +use Atk4\Ui\Exception; +use Atk4\Ui\HtmlTemplate; +use Atk4\Ui\Table; /** * Swaps out column decorators based on logic. diff --git a/src/Table/Column/NoValue.php b/src/Table/Column/NoValue.php index fd1f9a4d9e..cccf8ff327 100644 --- a/src/Table/Column/NoValue.php +++ b/src/Table/Column/NoValue.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\data\Model; -use atk4\ui\Table; +use Atk4\Data\Model; +use Atk4\Ui\Table; /** * Class NoValue. diff --git a/src/Table/Column/Password.php b/src/Table/Column/Password.php index 0776efb359..32ef4bd6c9 100644 --- a/src/Table/Column/Password.php +++ b/src/Table/Column/Password.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\ui\Table; +use Atk4\Ui\Table; /** * Implements Column helper for grid. @@ -13,7 +13,7 @@ class Password extends Table\Column { public $sortable = false; - public function getDataCellTemplate(\atk4\data\Field $field = null) + public function getDataCellTemplate(\Atk4\Data\Field $field = null) { return '***'; } diff --git a/src/Table/Column/Status.php b/src/Table/Column/Status.php index a32c103810..41c3531d0a 100644 --- a/src/Table/Column/Status.php +++ b/src/Table/Column/Status.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\data\Model; -use atk4\ui\Table; +use Atk4\Data\Model; +use Atk4\Ui\Table; /** * Implements Column helper for grid. @@ -31,10 +31,10 @@ public function __construct($states) $this->states = $states; } - public function getDataCellHtml(\atk4\data\Field $field = null, $extra_tags = []) + public function getDataCellHtml(\Atk4\Data\Field $field = null, $extra_tags = []) { if ($field === null) { - throw new \atk4\ui\Exception('Status can be used only with model field'); + throw new \Atk4\Ui\Exception('Status can be used only with model field'); } $attr = $this->getTagAttributes('body'); diff --git a/src/Table/Column/Template.php b/src/Table/Column/Template.php index 1675190f28..8949ae3d1c 100644 --- a/src/Table/Column/Template.php +++ b/src/Table/Column/Template.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\ui\Table; +use Atk4\Ui\Table; /** * Implements Column helper for grid. @@ -35,7 +35,7 @@ public function __construct($template) */ } - public function getDataCellTemplate(\atk4\data\Field $field = null) + public function getDataCellTemplate(\Atk4\Data\Field $field = null) { return $this->template; } diff --git a/src/Table/Column/Text.php b/src/Table/Column/Text.php index 6d2b8716bb..e957a6265f 100644 --- a/src/Table/Column/Text.php +++ b/src/Table/Column/Text.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\ui\Table; +use Atk4\Ui\Table; /** * Implements Column helper for grid. diff --git a/src/Table/Column/Tooltip.php b/src/Table/Column/Tooltip.php index 2e75bbaa2f..db64c08eb4 100644 --- a/src/Table/Column/Tooltip.php +++ b/src/Table/Column/Tooltip.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace atk4\ui\Table\Column; +namespace Atk4\Ui\Table\Column; -use atk4\data\Field; -use atk4\data\Model; -use atk4\ui\Exception; -use atk4\ui\Table; +use Atk4\Data\Field; +use Atk4\Data\Model; +use Atk4\Ui\Exception; +use Atk4\Ui\Table; /** * Class Tooltip. @@ -15,9 +15,9 @@ * column to add a little icon to show on hover a text * text is taken by the Row Model in $tooltip_field * - * @usage : $crud->addDecorator('paid_date', new \atk4\ui\Table\Column\Tooltip('note')); + * @usage : $crud->addDecorator('paid_date', new \Atk4\Ui\Table\Column\Tooltip('note')); * - * @usage : $crud->addDecorator('paid_date', new \atk4\ui\Table\Column\Tooltip('note','error red')); + * @usage : $crud->addDecorator('paid_date', new \Atk4\Ui\Table\Column\Tooltip('note','error red')); */ class Tooltip extends Table\Column { diff --git a/src/Tabs.php b/src/Tabs.php index 6fef47c186..adcd4bb7a4 100644 --- a/src/Tabs.php +++ b/src/Tabs.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\core\Factory; +use Atk4\Core\Factory; /** * Tabs widget. diff --git a/src/TabsSubview.php b/src/TabsSubview.php index eb4a689819..538dcec467 100644 --- a/src/TabsSubview.php +++ b/src/TabsSubview.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * One Sub view of Tabs widget. diff --git a/src/Template.php b/src/Template.php index 373bfed0e9..df16855ec5 100644 --- a/src/Template.php +++ b/src/Template.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; if (!class_exists(\SebastianBergmann\CodeCoverage\CodeCoverage::class, false)) { - 'trigger_error'('Class atk4\ui\Template is deprecated. Use atk4\ui\HtmlTemplate instead', E_USER_DEPRECATED); + 'trigger_error'('Class Atk4\Ui\Template is deprecated. Use Atk4\Ui\HtmlTemplate instead', E_USER_DEPRECATED); } /** * @deprecated will be removed in 2.5 version */ -class Template extends \atk4\ui\HtmlTemplate +class Template extends \Atk4\Ui\HtmlTemplate { } diff --git a/src/Text.php b/src/Text.php index 6e8bbc729f..8b7f45a290 100644 --- a/src/Text.php +++ b/src/Text.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Simple text block view. diff --git a/src/UserAction/ArgumentFormExecutor.php b/src/UserAction/ArgumentFormExecutor.php index 56f333e798..de531426ff 100644 --- a/src/UserAction/ArgumentFormExecutor.php +++ b/src/UserAction/ArgumentFormExecutor.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace atk4\ui\UserAction; +namespace Atk4\Ui\UserAction; -use atk4\core\Factory; -use atk4\data\Model; -use atk4\ui\Exception; -use atk4\ui\Form; -use atk4\ui\Header; +use Atk4\Core\Factory; +use Atk4\Data\Model; +use Atk4\Ui\Exception; +use Atk4\Ui\Form; +use Atk4\Ui\Header; /** * BasicExecutor executor will typically fail if supplied arguments are not sufficient. diff --git a/src/UserAction/BasicExecutor.php b/src/UserAction/BasicExecutor.php index 73ad855cf9..d907ec3974 100644 --- a/src/UserAction/BasicExecutor.php +++ b/src/UserAction/BasicExecutor.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace atk4\ui\UserAction; +namespace Atk4\Ui\UserAction; -use atk4\core\HookTrait; -use atk4\data\Model; -use atk4\ui\Button; -use atk4\ui\Exception; -use atk4\ui\JsExpressionable; -use atk4\ui\JsToast; -use atk4\ui\Message; +use Atk4\Core\HookTrait; +use Atk4\Data\Model; +use Atk4\Ui\Button; +use Atk4\Ui\Exception; +use Atk4\Ui\JsExpressionable; +use Atk4\Ui\JsToast; +use Atk4\Ui\Message; -class BasicExecutor extends \atk4\ui\View implements ExecutorInterface +class BasicExecutor extends \Atk4\Ui\View implements ExecutorInterface { use HookTrait; @@ -125,7 +125,7 @@ protected function initPreview() $this->addHeader(); - \atk4\ui\Button::addToWithCl($this, $this->executorButton)->on('click', function () { + \Atk4\Ui\Button::addToWithCl($this, $this->executorButton)->on('click', function () { return $this->jsExecute(); }); } @@ -158,7 +158,7 @@ public function jsExecute() public function addHeader() { if ($this->hasHeader) { - \atk4\ui\Header::addTo($this, [$this->action->getCaption(), 'subHeader' => $this->description ?: $this->action->getDescription()]); + \Atk4\Ui\Header::addTo($this, [$this->action->getCaption(), 'subHeader' => $this->description ?: $this->action->getDescription()]); } } } diff --git a/src/UserAction/ConfirmationExecutor.php b/src/UserAction/ConfirmationExecutor.php index 222f529e44..664d149828 100644 --- a/src/UserAction/ConfirmationExecutor.php +++ b/src/UserAction/ConfirmationExecutor.php @@ -2,19 +2,19 @@ declare(strict_types=1); -namespace atk4\ui\UserAction; - -use atk4\core\HookTrait; -use atk4\data\Model; -use atk4\ui\Button; -use atk4\ui\Exception; -use atk4\ui\JsExpressionable; -use atk4\ui\JsFunction; -use atk4\ui\JsToast; -use atk4\ui\Loader; -use atk4\ui\Modal; -use atk4\ui\Text; -use atk4\ui\View; +namespace Atk4\Ui\UserAction; + +use Atk4\Core\HookTrait; +use Atk4\Data\Model; +use Atk4\Ui\Button; +use Atk4\Ui\Exception; +use Atk4\Ui\JsExpressionable; +use Atk4\Ui\JsFunction; +use Atk4\Ui\JsToast; +use Atk4\Ui\Loader; +use Atk4\Ui\Modal; +use Atk4\Ui\Text; +use Atk4\Ui\View; /** * Modal executor for action that required a confirmation. diff --git a/src/UserAction/ExecutorInterface.php b/src/UserAction/ExecutorInterface.php index fc129acc11..7889cb2410 100644 --- a/src/UserAction/ExecutorInterface.php +++ b/src/UserAction/ExecutorInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\UserAction; +namespace Atk4\Ui\UserAction; /** * ExecutorInterface can be implemented by a View that can be displayed on a page or in a modal window @@ -31,5 +31,5 @@ interface ExecutorInterface /** * Will associate executor with the action. */ - public function setAction(\atk4\data\Model\UserAction $action); + public function setAction(\Atk4\Data\Model\UserAction $action); } diff --git a/src/UserAction/FormExecutor.php b/src/UserAction/FormExecutor.php index ff3617df89..dbea3b8bb7 100644 --- a/src/UserAction/FormExecutor.php +++ b/src/UserAction/FormExecutor.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\UserAction; +namespace Atk4\Ui\UserAction; -use atk4\data\Model; -use atk4\ui\Form; +use Atk4\Data\Model; +use Atk4\Ui\Form; class FormExecutor extends BasicExecutor { diff --git a/src/UserAction/JsCallbackExecutor.php b/src/UserAction/JsCallbackExecutor.php index 965ebee57e..ca783b0730 100644 --- a/src/UserAction/JsCallbackExecutor.php +++ b/src/UserAction/JsCallbackExecutor.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace atk4\ui\UserAction; +namespace Atk4\Ui\UserAction; -use atk4\core\HookTrait; -use atk4\data\Model; -use atk4\ui\Exception; -use atk4\ui\JsCallback; -use atk4\ui\JsExpressionable; -use atk4\ui\JsToast; -use atk4\ui\View; +use Atk4\Core\HookTrait; +use Atk4\Data\Model; +use Atk4\Ui\Exception; +use Atk4\Ui\JsCallback; +use Atk4\Ui\JsExpressionable; +use Atk4\Ui\JsToast; +use Atk4\Ui\View; /** * Javascript Action executor. @@ -45,7 +45,7 @@ class JsCallbackExecutor extends JsCallback implements ExecutorInterface * consider as the model Id to be loaded with the action owner model. * * Ex. - * $btn = \atk4\ui\Button::addTo($app, ['Import File']); + * $btn = \Atk4\Ui\Button::addTo($app, ['Import File']); * $ex = JsCallbackExecutor::addTo($app); * $ex->setAction($f_action, [8, 'path' => '.']); * diff --git a/src/UserAction/JsExecutorInterface.php b/src/UserAction/JsExecutorInterface.php index 758464dc10..29334ae3d0 100644 --- a/src/UserAction/JsExecutorInterface.php +++ b/src/UserAction/JsExecutorInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\UserAction; +namespace Atk4\Ui\UserAction; /** * Add js trigger for executing an action. diff --git a/src/UserAction/ModalExecutor.php b/src/UserAction/ModalExecutor.php index 4c51a92133..be68c715c5 100644 --- a/src/UserAction/ModalExecutor.php +++ b/src/UserAction/ModalExecutor.php @@ -2,21 +2,21 @@ declare(strict_types=1); -namespace atk4\ui\UserAction; - -use atk4\core\Factory; -use atk4\core\HookTrait; -use atk4\data\Model; -use atk4\data\ValidationException; -use atk4\ui\Button; -use atk4\ui\Exception; -use atk4\ui\Form; -use atk4\ui\JsExpressionable; -use atk4\ui\JsFunction; -use atk4\ui\JsToast; -use atk4\ui\Message; -use atk4\ui\Modal; -use atk4\ui\View; +namespace Atk4\Ui\UserAction; + +use Atk4\Core\Factory; +use Atk4\Core\HookTrait; +use Atk4\Data\Model; +use Atk4\Data\ValidationException; +use Atk4\Ui\Button; +use Atk4\Ui\Exception; +use Atk4\Ui\Form; +use Atk4\Ui\JsExpressionable; +use Atk4\Ui\JsFunction; +use Atk4\Ui\JsToast; +use Atk4\Ui\Message; +use Atk4\Ui\Modal; +use Atk4\Ui\View; /** * Modal executor for action. @@ -100,7 +100,7 @@ class ModalExecutor extends Modal implements JsExecutorInterface /** * The Loader that will execute all action step. * - * @var \atk4\ui\Loader + * @var \Atk4\Ui\Loader */ public $loader; public $loaderUi = 'ui basic segment'; @@ -137,7 +137,7 @@ public function afterActionInit(Model\UserAction $action) $this->nextStepBtn = Button::addTo($this->btns, ['Next', 'blue']); $this->addButtonAction($this->btns); - $this->loader = \atk4\ui\Loader::addTo($this, ['ui' => $this->loaderUi, 'shim' => $this->loaderShim]); + $this->loader = \Atk4\Ui\Loader::addTo($this, ['ui' => $this->loaderUi, 'shim' => $this->loaderShim]); $this->loader->loadEvent = false; $this->loader->addClass('atk-hide-loading-content'); $this->actionData = $this->loader->jsGetStoreData()['session']; diff --git a/src/UserAction/PreviewExecutor.php b/src/UserAction/PreviewExecutor.php index a3bb4ff770..70d645bc7e 100644 --- a/src/UserAction/PreviewExecutor.php +++ b/src/UserAction/PreviewExecutor.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\UserAction; +namespace Atk4\Ui\UserAction; -use atk4\ui\View; +use Atk4\Ui\View; class PreviewExecutor extends BasicExecutor { @@ -19,7 +19,7 @@ class PreviewExecutor extends BasicExecutor public function initPreview() { if (!$this->hasAllArguments()) { - \atk4\ui\Message::addTo($this, ['type' => 'error', $this->missingArgsMsg]); + \Atk4\Ui\Message::addTo($this, ['type' => 'error', $this->missingArgsMsg]); return; } @@ -44,7 +44,7 @@ public function initPreview() break; } - \atk4\ui\Button::addToWithCl($this, $this->executorButton)->on('click', function () { + \Atk4\Ui\Button::addToWithCl($this, $this->executorButton)->on('click', function () { return $this->jsExecute(); }); } diff --git a/src/View.php b/src/View.php index 6a524b7d93..5a18cd91a2 100644 --- a/src/View.php +++ b/src/View.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\core\Factory; -use atk4\data\Model; -use atk4\data\Persistence\Static_; +use Atk4\Core\Factory; +use Atk4\Data\Model; +use Atk4\Data\Persistence\Static_; /** * Implements a most core view, which all of the other components descend @@ -807,7 +807,7 @@ public function js($when = null, $action = null, $selector = null) /** * Create Vue.js instance. - * Vue.js instance can be create from atk4\ui\View. + * Vue.js instance can be create from Atk4\Ui\View. * * Component managed and defined by atk does not need componentDefinition variable name * because these are already loaded within the atk js namespace. @@ -968,7 +968,7 @@ public function jsReload($args = [], $afterSuccess = null, $apiConfig = []) * * @param string $event JavaScript event * @param string $selector Optional jQuery-style selector - * @param JsChain|\Closure|Model\UserAction $action code to execute or \atk4\Data\UserAction + * @param JsChain|\Closure|Model\UserAction $action code to execute or \Atk4\Data\UserAction * @param array $defaults Options * * @return Jquery diff --git a/src/VirtualPage.php b/src/VirtualPage.php index b4cded5521..da7249767a 100644 --- a/src/VirtualPage.php +++ b/src/VirtualPage.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; /** * Virtual page normally does not render, yet it has it's own trigger and will respond diff --git a/src/Wizard.php b/src/Wizard.php index 48119d25da..a437b6717d 100644 --- a/src/Wizard.php +++ b/src/Wizard.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace atk4\ui; +namespace Atk4\Ui; -use atk4\core\Factory; +use Atk4\Core\Factory; /** * Wizard widget. */ class Wizard extends View { - use \atk4\core\SessionTrait; + use \Atk4\Core\SessionTrait; public $defaultTemplate = 'wizard.html'; public $ui = 'steps'; diff --git a/tests-behat/bootstrap/Context.php b/tests-behat/bootstrap/Context.php index d079756804..88257ef08f 100644 --- a/tests-behat/bootstrap/Context.php +++ b/tests-behat/bootstrap/Context.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\behat; +namespace Atk4\Ui\Behat; use Behat\Behat\Context\Context as BehatContext; use Behat\Behat\Hook\Scope\AfterStepScope; diff --git a/tests-behat/bootstrap/ContextDump.php b/tests-behat/bootstrap/ContextDump.php index 1b3866e465..79c09fa45e 100644 --- a/tests-behat/bootstrap/ContextDump.php +++ b/tests-behat/bootstrap/ContextDump.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\behat; +namespace Atk4\Ui\Behat; use Behat\Behat\Hook\Scope\AfterStepScope; use Behat\Testwork\Tester\Result\TestResult; diff --git a/tests/AppTest.php b/tests/AppTest.php index d84d01e90c..877eded4c9 100644 --- a/tests/AppTest.php +++ b/tests/AppTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; -use atk4\ui\App; -use atk4\ui\HtmlTemplate; +use Atk4\Core\AtkPhpunit; +use Atk4\Ui\App; +use Atk4\Ui\HtmlTemplate; class AppTest extends AtkPhpunit\TestCase { diff --git a/tests/ButtonTest.php b/tests/ButtonTest.php index 4e63cec17c..6768341c8c 100644 --- a/tests/ButtonTest.php +++ b/tests/ButtonTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; -use atk4\ui\Button; +use Atk4\Core\AtkPhpunit; +use Atk4\Ui\Button; class ButtonTest extends AtkPhpunit\TestCase { diff --git a/tests/CallbackTest.php b/tests/CallbackTest.php index e8b686063a..0721b50347 100644 --- a/tests/CallbackTest.php +++ b/tests/CallbackTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; +use Atk4\Core\AtkPhpunit; -class AppMock extends \atk4\ui\App +class AppMock extends \Atk4\Ui\App { public $terminated = false; @@ -29,13 +29,13 @@ class CallbackTest extends AtkPhpunit\TestCase /** @var string */ private $htmlDoctypeRegex = '~^app = new AppMock(['always_run' => false, 'catch_exceptions' => false]); - $this->app->initLayout([\atk4\ui\Layout\Centered::class]); + $this->app->initLayout([\Atk4\Ui\Layout\Centered::class]); // reset var, between tests $_GET = []; @@ -46,7 +46,7 @@ public function testCallback() { $var = null; - $cb = \atk4\ui\Callback::addTo($this->app); + $cb = \Atk4\Ui\Callback::addTo($this->app); // simulate triggering $_GET[$cb->name] = '1'; @@ -62,7 +62,7 @@ public function testCallbackNotFiring() { $var = null; - $cb = \atk4\ui\Callback::addTo($this->app); + $cb = \Atk4\Ui\Callback::addTo($this->app); // don't simulate triggering $cb->set(function ($x) use (&$var) { @@ -76,7 +76,7 @@ public function testCallbackLater() { $var = null; - $cb = \atk4\ui\CallbackLater::addTo($this->app); + $cb = \Atk4\Ui\CallbackLater::addTo($this->app); // simulate triggering $_GET[$cb->name] = '1'; @@ -97,7 +97,7 @@ public function testCallbackLaterNested() { $var = null; - $cb = \atk4\ui\CallbackLater::addTo($this->app); + $cb = \Atk4\Ui\CallbackLater::addTo($this->app); // simulate triggering $_GET[$cb->name] = '1'; @@ -105,7 +105,7 @@ public function testCallbackLaterNested() $app = $this->app; $cb->set(function ($x) use (&$var, $app, &$cbname) { - $cb2 = \atk4\ui\CallbackLater::addTo($app); + $cb2 = \Atk4\Ui\CallbackLater::addTo($app); $cbname = $cb2->name; $cb2->set(function ($y) use (&$var) { $var = $y; @@ -124,7 +124,7 @@ public function testCallbackLaterNotFiring() { $var = null; - $cb = \atk4\ui\CallbackLater::addTo($this->app); + $cb = \Atk4\Ui\CallbackLater::addTo($this->app); // don't simulate triggering $cb->set(function ($x) use (&$var) { @@ -143,7 +143,7 @@ public function testVirtualPage() { $var = null; - $vp = \atk4\ui\VirtualPage::addTo($this->app); + $vp = \Atk4\Ui\VirtualPage::addTo($this->app); // simulate triggering $vp->set(function ($p) use (&$var) { @@ -161,7 +161,7 @@ public function testVirtualPageCustomTrigger() { $var = null; - $vp = \atk4\ui\VirtualPage::addTo($this->app, ['urlTrigger' => 'bah']); + $vp = \Atk4\Ui\VirtualPage::addTo($this->app, ['urlTrigger' => 'bah']); $vp->set(function ($p) use (&$var) { $var = 25; }); @@ -185,7 +185,7 @@ public function testPull230() { $var = null; - $vp = \atk4\ui\VirtualPage::addTo($this->app); + $vp = \Atk4\Ui\VirtualPage::addTo($this->app); $vp->set([$this, 'callPull230']); // simulate triggering diff --git a/tests/Concerns/HandlesTable.php b/tests/Concerns/HandlesTable.php index 3afe17c4e5..92fcd15e82 100644 --- a/tests/Concerns/HandlesTable.php +++ b/tests/Concerns/HandlesTable.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace atk4\ui\tests\Concerns; +namespace Atk4\Ui\Tests\Concerns; -use atk4\ui\Table; +use Atk4\Ui\Table; trait HandlesTable { /** - * Extract only out from an \atk4\ui\Table given the data-id attribute value. + * Extract only out from an \Atk4\Ui\Table given the data-id attribute value. * * @param string $rowDataId * diff --git a/tests/DemosHttpNoExitTest.php b/tests/DemosHttpNoExitTest.php index 72fa60dec9..5346c849fb 100644 --- a/tests/DemosHttpNoExitTest.php +++ b/tests/DemosHttpNoExitTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; /** * Same as DemosHttpTest, only App::call_exit is set to false. diff --git a/tests/DemosHttpTest.php b/tests/DemosHttpTest.php index 3f30e130a6..bf090c17a3 100644 --- a/tests/DemosHttpTest.php +++ b/tests/DemosHttpTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; use GuzzleHttp\Client; use Symfony\Component\Process\Process; diff --git a/tests/DemosTest.php b/tests/DemosTest.php index f9300f189f..120a7f38b4 100644 --- a/tests/DemosTest.php +++ b/tests/DemosTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; -use atk4\data\Persistence; -use atk4\ui\App; +use Atk4\Core\AtkPhpunit; +use Atk4\Data\Persistence; +use Atk4\Ui\App; use GuzzleHttp\Client; use GuzzleHttp\Psr7\Request; use Psr\Http\Message\RequestInterface; @@ -55,7 +55,7 @@ protected function setUp(): void $initVars = array_diff_key(get_defined_vars(), $initVars + ['initVars' => true]); if (array_keys($initVars) !== ['app']) { - throw new \atk4\ui\Exception('Demos init must setup only $app variable'); + throw new \Atk4\Ui\Exception('Demos init must setup only $app variable'); } // @phpstan-ignore-next-line remove once https://github.com/phpstan/phpstan/issues/4155 is resolved @@ -125,7 +125,7 @@ public function callExit($for_shutdown = false): void throw new DemosTestExitException(); } }; - $app->initLayout([\atk4\ui\Layout\Maestro::class]); + $app->initLayout([\Atk4\Ui\Layout\Maestro::class]); // clone DB (mainly because all Models remains attached now, TODO can be removed once they are GCed) $app->db = clone self::$_db; @@ -455,6 +455,6 @@ public function testDemoAssertJsonResponsePost(string $uri, array $postData) } } -class DemosTestExitException extends \atk4\ui\Exception +class DemosTestExitException extends \Atk4\Ui\Exception { } diff --git a/tests/ForFieldUiTest.php b/tests/ForFieldUiTest.php index 4ed5f4a48f..8f548bc867 100644 --- a/tests/ForFieldUiTest.php +++ b/tests/ForFieldUiTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; -use atk4\data\Model; -use atk4\data\Persistence; +use Atk4\Core\AtkPhpunit; +use Atk4\Data\Model; +use Atk4\Data\Persistence; class MyTestModel extends Model { @@ -42,7 +42,7 @@ public function testModelLevel() public function testRegularField() { - $f = new \atk4\ui\Form(); + $f = new \Atk4\Ui\Form(); $f->invokeInit(); $f->setModel($this->m); $this->assertFalse($f->getControl('regular_field')->readonly); @@ -50,7 +50,7 @@ public function testRegularField() public function testJustDataField() { - $f = new \atk4\ui\Form(); + $f = new \Atk4\Ui\Form(); $f->invokeInit(); $f->setModel($this->m, ['just_for_data']); $this->assertTrue($f->getControl('just_for_data')->readonly); @@ -58,7 +58,7 @@ public function testJustDataField() public function testShowInUi() { - $f = new \atk4\ui\Form(); + $f = new \Atk4\Ui\Form(); $f->invokeInit(); $f->setModel($this->m); $this->assertFalse($f->getControl('no_persist_but_show_in_ui')->readonly); diff --git a/tests/FormTest.php b/tests/FormTest.php index 8a69855b74..0165f9be48 100644 --- a/tests/FormTest.php +++ b/tests/FormTest.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; -use atk4\data\Model; -use atk4\ui\App; -use atk4\ui\Form; +use Atk4\Core\AtkPhpunit; +use Atk4\Data\Model; +use Atk4\Ui\App; +use Atk4\Ui\Form; class FormTest extends AtkPhpunit\TestCase { @@ -21,7 +21,7 @@ protected function setUp(): void { parent::setUp(); // TODO: Change the autogenerated stub - $this->f = new \atk4\ui\Form(); + $this->f = new \Atk4\Ui\Form(); $this->f->setApp(new AppFormTestMock([ 'catch_exceptions' => false, 'always_run' => false, diff --git a/tests/GridTest.php b/tests/GridTest.php index 40032b354a..a31a8d3076 100644 --- a/tests/GridTest.php +++ b/tests/GridTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\ui\Table; +use Atk4\Ui\Table; -class GridTest extends \atk4\core\AtkPhpunit\TestCase +class GridTest extends \Atk4\Core\AtkPhpunit\TestCase { use Concerns\HandlesTable; @@ -18,7 +18,7 @@ protected function setUp(): void 1 => ['id' => 1, 'email' => 'test@test.com', 'password' => 'abc123', 'xtra' => 'xtra'], 2 => ['id' => 2, 'email' => 'test@yahoo.com', 'password' => 'secret'], ]; - $this->m = new MyModel(new \atk4\data\Persistence\Array_($a)); + $this->m = new MyModel(new \Atk4\Data\Persistence\Array_($a)); } public function test1() @@ -82,7 +82,7 @@ public function test3() } } -class MyModel extends \atk4\data\Model +class MyModel extends \Atk4\Data\Model { public $title_field = 'email'; diff --git a/tests/HtmlTemplateTest.php b/tests/HtmlTemplateTest.php index 0b00ce0ef9..759f914f25 100644 --- a/tests/HtmlTemplateTest.php +++ b/tests/HtmlTemplateTest.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; -use atk4\ui\Exception; -use atk4\ui\HtmlTemplate; -use atk4\ui\HtmlTemplate\TagTree; +use Atk4\Core\AtkPhpunit; +use Atk4\Ui\Exception; +use Atk4\Ui\HtmlTemplate; +use Atk4\Ui\HtmlTemplate\TagTree; class HtmlTemplateTest extends AtkPhpunit\TestCase { diff --git a/tests/ListerTest.php b/tests/ListerTest.php index ca2f8b68b5..58707d2092 100644 --- a/tests/ListerTest.php +++ b/tests/ListerTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; -use atk4\ui\Exception; -use atk4\ui\HtmlTemplate; +use Atk4\Core\AtkPhpunit; +use Atk4\Ui\Exception; +use Atk4\Ui\HtmlTemplate; class ListerTest extends AtkPhpunit\TestCase { @@ -15,9 +15,9 @@ class ListerTest extends AtkPhpunit\TestCase */ public function testListerRender() { - $v = new \atk4\ui\View(); + $v = new \Atk4\Ui\View(); $v->invokeInit(); - $l = \atk4\ui\Lister::addTo($v, ['defaultTemplate' => 'lister.html']); + $l = \Atk4\Ui\Lister::addTo($v, ['defaultTemplate' => 'lister.html']); $l->setSource(['foo', 'bar']); } @@ -26,9 +26,9 @@ public function testListerRender() */ public function testListerRender2() { - $v = new \atk4\ui\View(['template' => new HtmlTemplate('hello{list}, world{/list}')]); + $v = new \Atk4\Ui\View(['template' => new HtmlTemplate('hello{list}, world{/list}')]); $v->invokeInit(); - $l = \atk4\ui\Lister::addTo($v, [], ['list']); + $l = \Atk4\Ui\Lister::addTo($v, [], ['list']); $l->setSource(['foo', 'bar']); $this->assertSame('hello, world, world', $v->render()); } @@ -36,9 +36,9 @@ public function testListerRender2() public function testAddAfterRender() { $this->expectException(Exception::class); - $v = new \atk4\ui\View(); + $v = new \Atk4\Ui\View(); $v->invokeInit(); - $l = \atk4\ui\Lister::addTo($v); + $l = \Atk4\Ui\Lister::addTo($v); $l->setSource(['foo', 'bar']); } } diff --git a/tests/LocaleTest.php b/tests/LocaleTest.php index 23669892e4..d7018852b7 100644 --- a/tests/LocaleTest.php +++ b/tests/LocaleTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; -use atk4\ui\Exception; -use atk4\ui\Locale; +use Atk4\Core\AtkPhpunit; +use Atk4\Ui\Exception; +use Atk4\Ui\Locale; class LocaleTest extends AtkPhpunit\TestCase { diff --git a/tests/PaginatorTest.php b/tests/PaginatorTest.php index 317e44fffe..6974564242 100644 --- a/tests/PaginatorTest.php +++ b/tests/PaginatorTest.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; +use Atk4\Core\AtkPhpunit; class PaginatorTest extends AtkPhpunit\TestCase { @@ -43,7 +43,7 @@ public function addDataProvider() */ public function testPaginator($page, $range, $total, $expected) { - $p = new \atk4\ui\Paginator(['page' => $page, 'range' => $range, 'total' => $total]); + $p = new \Atk4\Ui\Paginator(['page' => $page, 'range' => $range, 'total' => $total]); $this->assertSame($expected, $p->getPaginatorItems()); } } diff --git a/tests/PostTest.php b/tests/PostTest.php index 7e4e991164..cdde17e19d 100644 --- a/tests/PostTest.php +++ b/tests/PostTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; -use atk4\data\Model; +use Atk4\Core\AtkPhpunit; +use Atk4\Data\Model; class PostTest extends AtkPhpunit\TestCase { @@ -26,7 +26,7 @@ protected function setUp(): void */ public function testPost() { - $p = new \atk4\ui\Persistence\Post(); + $p = new \Atk4\Ui\Persistence\Post(); $this->model->set('surname', 'DefSurname'); diff --git a/tests/RenderTreeTest.php b/tests/RenderTreeTest.php index bdb32a5ff1..514f9bd91d 100644 --- a/tests/RenderTreeTest.php +++ b/tests/RenderTreeTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; -use atk4\ui\View; +use Atk4\Core\AtkPhpunit; +use Atk4\Ui\View; /** * Multiple tests to ensure that adding views through various patterns initializes them diff --git a/tests/TableColumnColorRatingTest.php b/tests/TableColumnColorRatingTest.php index 7a9ac14fe1..d65f9d5a55 100644 --- a/tests/TableColumnColorRatingTest.php +++ b/tests/TableColumnColorRatingTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; -use atk4\ui\Table; +use Atk4\Core\AtkPhpunit; +use Atk4\Ui\Table; class TableColumnColorRatingTest extends AtkPhpunit\TestCase { @@ -28,12 +28,12 @@ protected function setUp(): void ], ], ]; - $db = new \atk4\data\Persistence\Array_($arr); - $m = new \atk4\data\Model($db, 'table'); + $db = new \Atk4\Data\Persistence\Array_($arr); + $m = new \Atk4\Data\Model($db, 'table'); $m->addField('name'); $m->addField('ref'); $m->addField('rating'); - $this->table = new \atk4\ui\Table(); + $this->table = new \Atk4\Ui\Table(); $this->table->invokeInit(); $this->table->setModel($m, ['name', 'ref', 'rating']); } @@ -140,7 +140,7 @@ public function testValueLowerThanMinNoColor() public function testExceptionMinGreaterThanMax() { - $this->expectException(\atk4\ui\Exception::class); + $this->expectException(\Atk4\Ui\Exception::class); $this->table->addDecorator('rating', [ Table\Column\ColorRating::class, @@ -159,7 +159,7 @@ public function testExceptionMinGreaterThanMax() public function testExceptionMinEqualsMax() { - $this->expectException(\atk4\ui\Exception::class); + $this->expectException(\Atk4\Ui\Exception::class); $this->table->addDecorator('rating', [ Table\Column\ColorRating::class, @@ -178,7 +178,7 @@ public function testExceptionMinEqualsMax() public function testExceptionZeroSteps() { - $this->expectException(\atk4\ui\Exception::class); + $this->expectException(\Atk4\Ui\Exception::class); $this->table->addDecorator('rating', [ Table\Column\ColorRating::class, @@ -197,7 +197,7 @@ public function testExceptionZeroSteps() public function testExceptionLessThan2ColorsDefined() { - $this->expectException(\atk4\ui\Exception::class); + $this->expectException(\Atk4\Ui\Exception::class); $this->table->addDecorator('rating', [ Table\Column\ColorRating::class, diff --git a/tests/TableColumnLinkTest.php b/tests/TableColumnLinkTest.php index 55dd562e5c..9ee845ee28 100644 --- a/tests/TableColumnLinkTest.php +++ b/tests/TableColumnLinkTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; -use atk4\ui\Table; +use Atk4\Core\AtkPhpunit; +use Atk4\Ui\Table; class TableColumnLinkTest extends AtkPhpunit\TestCase { @@ -18,12 +18,12 @@ class TableColumnLinkTest extends AtkPhpunit\TestCase protected function setUp(): void { $arr = ['table' => [1 => ['id' => 1, 'name' => 'bar', 'ref' => 'ref123', 'salary' => -123]]]; - $db = new \atk4\data\Persistence\Array_($arr); - $m = new \atk4\data\Model($db, 'table'); + $db = new \Atk4\Data\Persistence\Array_($arr); + $m = new \Atk4\Data\Model($db, 'table'); $m->addField('name'); $m->addField('ref'); $m->addField('salary'); - $this->table = new \atk4\ui\Table(); + $this->table = new \Atk4\Ui\Table(); $this->table->invokeInit(); $this->table->setModel($m, ['name', 'ref']); } @@ -259,12 +259,12 @@ public function testLink10() { // need to reset all to set a nulled value in field name model $arr = ['table' => [1 => ['id' => 1, 'name' => '', 'ref' => 'ref123', 'salary' => -123]]]; - $db = new \atk4\data\Persistence\Array_($arr); - $m = new \atk4\data\Model($db, 'table'); + $db = new \Atk4\Data\Persistence\Array_($arr); + $m = new \Atk4\Data\Model($db, 'table'); $m->addField('name'); $m->addField('ref'); $m->addField('salary'); - $this->table = new \atk4\ui\Table(); + $this->table = new \Atk4\Ui\Table(); $this->table->invokeInit(); $this->table->setModel($m, ['name', 'ref']); diff --git a/tests/TableTest.php b/tests/TableTest.php index cae43016f6..00a212a813 100644 --- a/tests/TableTest.php +++ b/tests/TableTest.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; +use Atk4\Core\AtkPhpunit; class TableTest extends AtkPhpunit\TestCase { @@ -13,7 +13,7 @@ class TableTest extends AtkPhpunit\TestCase */ public function testAddColumnWithoutModel() { - $t = new \atk4\ui\Table(); + $t = new \Atk4\Ui\Table(); $t->invokeInit(); $t->setSource([ ['one' => 1, 'two' => 2, 'three' => 3, 'four' => 4], @@ -21,12 +21,12 @@ public function testAddColumnWithoutModel() ]); // 4 ways to add column - $t->addColumn(null, new \atk4\ui\Table\Column\Link('test.php?id=1')); + $t->addColumn(null, new \Atk4\Ui\Table\Column\Link('test.php?id=1')); // multiple ways to add column which doesn't exist in model - $t->addColumn('five', new \atk4\ui\Table\Column\Link('test.php?id=1')); - $t->addColumn('seven', [\atk4\ui\Table\Column\Link::class, ['id' => 3]]); - $t->addColumn('eight', \atk4\ui\Table\Column\Link::class); + $t->addColumn('five', new \Atk4\Ui\Table\Column\Link('test.php?id=1')); + $t->addColumn('seven', [\Atk4\Ui\Table\Column\Link::class, ['id' => 3]]); + $t->addColumn('eight', \Atk4\Ui\Table\Column\Link::class); $t->addColumn('nine'); $t->render(); diff --git a/tests/TagTest.php b/tests/TagTest.php index a9871a17e3..9e1565910e 100644 --- a/tests/TagTest.php +++ b/tests/TagTest.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; +use Atk4\Core\AtkPhpunit; class TagTest extends AtkPhpunit\TestCase { public function getApp() { - return new \atk4\ui\App(['catch_exceptions' => false, 'always_run' => false]); + return new \Atk4\Ui\App(['catch_exceptions' => false, 'always_run' => false]); } public function assertTagRender($html, $args) diff --git a/tests/ViewTest.php b/tests/ViewTest.php index b7aef1ee1b..fcb61cbbd9 100644 --- a/tests/ViewTest.php +++ b/tests/ViewTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; -use atk4\core\Exception; +use Atk4\Core\AtkPhpunit; +use Atk4\Core\Exception; class ViewTest extends AtkPhpunit\TestCase { @@ -14,7 +14,7 @@ class ViewTest extends AtkPhpunit\TestCase */ public function testMultipleRender() { - $v = new \atk4\ui\View(); + $v = new \Atk4\Ui\View(); $v->set('foo'); $a = $v->render(); @@ -26,11 +26,11 @@ public function testAddAfterRender() { $this->expectException(Exception::class); - $v = new \atk4\ui\View(); + $v = new \Atk4\Ui\View(); $v->set('foo'); $a = $v->render(); - \atk4\ui\View::addTo($v); // this should fail. No adding after rendering. + \Atk4\Ui\View::addTo($v); // this should fail. No adding after rendering. $b = $v->render(); $this->assertSame($a, $b); } diff --git a/tests/jsIntegrationTest.php b/tests/jsIntegrationTest.php index 4a60ed59de..31b9b9ae2f 100644 --- a/tests/jsIntegrationTest.php +++ b/tests/jsIntegrationTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; -use atk4\ui\Button; -use atk4\ui\View; +use Atk4\Core\AtkPhpunit; +use Atk4\Ui\Button; +use Atk4\Ui\View; class jsIntegrationTest extends AtkPhpunit\TestCase { diff --git a/tests/jsTest.php b/tests/jsTest.php index 740c37a180..e9fa0909d2 100644 --- a/tests/jsTest.php +++ b/tests/jsTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Ui\Tests; -use atk4\core\AtkPhpunit; -use atk4\ui\Jquery; -use atk4\ui\JsChain; -use atk4\ui\JsExpression; -use atk4\ui\JsFunction; +use Atk4\Core\AtkPhpunit; +use Atk4\Ui\Jquery; +use Atk4\Ui\JsChain; +use Atk4\Ui\JsExpression; +use Atk4\Ui\JsFunction; class jsTest extends AtkPhpunit\TestCase { @@ -41,7 +41,7 @@ public function testNumbers() // test JSON renderer in App too // test extensively because of (possibly fragile) custom regex impl - $app = (new \ReflectionClass(\atk4\ui\App::class))->newInstanceWithoutConstructor(); + $app = (new \ReflectionClass(\Atk4\Ui\App::class))->newInstanceWithoutConstructor(); $expectedRaw = json_decode($expected); foreach ([ [$expectedRaw, $in], // direct value diff --git a/tools/get-assets.php b/tools/get-assets.php index a574a6f9ad..3c0d31a65b 100644 --- a/tools/get-assets.php +++ b/tools/get-assets.php @@ -4,7 +4,7 @@ require_once __DIR__ . '/../vendor/autoload.php'; -class GetAssets extends \atk4\ui\App +class GetAssets extends \Atk4\Ui\App { public $always_run = false; public $catch_exceptions = false;