Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add concat spaces #1019

Merged
merged 2 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"behat/mink-extension": "^2.2",
"fzaninotto/faker": "*",
"guzzlehttp/guzzle": "^6.3",
"symfony/process": "^4.3"
"symfony/process": "^4.3",
"friendsofphp/php-cs-fixer": "^2.16"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion demos/accordion-nested.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function addAccordion($view, $max_depth = 2, $level = 0)
$f = \atk4\ui\Form::addTo($v);
$f->addField('Email');
$f->onSubmit(function ($form) {
return $form->success('Subscribed '.$form->model['Email'].' to newsletter.');
return $form->success('Subscribed ' . $form->model['Email'] . ' to newsletter.');
});

if ($level < $max_depth) {
Expand Down
2 changes: 1 addition & 1 deletion demos/accordion.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
$f = \atk4\ui\Form::addTo($v);
$f->addField('Email');
$f->onSubmit(function ($form) {
return $form->success('Subscribed '.$form->model['Email'].' to newsletter.');
return $form->success('Subscribed ' . $form->model['Email'] . ' to newsletter.');
});
});

Expand Down
8 changes: 4 additions & 4 deletions demos/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
[
'callback'=> 'importFromFilesystem',
'preview' => function ($model, $path) {
return 'Considering path: '.$path;
return 'Considering path: ' . $path;
},
'args' => [
'path'=> ['type'=>'string', 'required'=>true],
Expand All @@ -44,15 +44,15 @@
$executor->description = 'Execute action using "Basic" executor and path="." argument';
$executor->setArguments(['path'=>'.']);
$executor->onHook('afterExecute', function ($x, $ret) {
return new \atk4\ui\jsToast('Files imported: '.$ret);
return new \atk4\ui\jsToast('Files imported: ' . $ret);
});

$grid->add($executor = new \atk4\ui\ActionExecutor\ArgumentForm(), 'r1c2');
$executor->setAction($action);
$executor->description = 'ArgumentForm executor will ask user about arguments';
$executor->ui = 'segment';
$executor->onHook('afterExecute', function ($x, $ret) {
return new \atk4\ui\jsToast('Files imported: '.$ret);
return new \atk4\ui\jsToast('Files imported: ' . $ret);
});

$grid->add($executor = new \atk4\ui\ActionExecutor\Preview(), 'r1c3');
Expand All @@ -62,7 +62,7 @@
$executor->description = 'Displays preview in console prior to executing';
$executor->setArguments(['path'=>'.']);
$executor->onHook('afterExecute', function ($x, $ret) {
return new \atk4\ui\jsToast('Files imported: '.$ret);
return new \atk4\ui\jsToast('Files imported: ' . $ret);
});

\atk4\ui\CRUD::addTo($app, ['ipp'=>5])->setModel($files);
12 changes: 6 additions & 6 deletions demos/autocomplete.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
]);

$form->onSubmit(function ($f) use ($db) {
$str = $f->model->ref('country1')['name'].' '.$f->model->ref('country2')['name'].' '.(new Country($db))->tryLoad($f->model['country3'])->get('name');
$str = $f->model->ref('country1')['name'] . ' ' . $f->model->ref('country2')['name'] . ' ' . (new Country($db))->tryLoad($f->model['country3'])->get('name');
$view = new \atk4\ui\Message('Select:'); // need in behat test.
$view->init();
$view->text->addParagraph($str);
Expand Down Expand Up @@ -128,21 +128,21 @@
'dependency' => function ($model, $data) {
$conditions = [];
foreach (explode(',', $data['starts_with'] ?? '') as $letter) {
$conditions[] = ['name', 'like', $letter.'%'];
$conditions[] = ['name', 'like', $letter . '%'];
}

if ($conditions) {
$model->addCondition($conditions);
}

isset($data['contains']) ? $model->addCondition('name', 'like', '%'.$data['contains'].'%') : null;
isset($data['contains']) ? $model->addCondition('name', 'like', '%' . $data['contains'] . '%') : null;
},
'placeholder' => 'Selection depends on DropDown above',
'search' => ['name', 'iso', 'iso3'],
]);

$form->onSubmit(function ($form) {
return 'Submitted: '.print_r($form->model->get(), true);
return 'Submitted: ' . print_r($form->model->get(), true);
});

\atk4\ui\Header::addTo($app, ['Auto-complete multiple values']);
Expand All @@ -165,12 +165,12 @@
'AutoComplete',
'model' => new Country($db),
'dependency' => function ($model, $data) {
isset($data['ends_with']) ? $model->addCondition('name', 'like', '%'.$data['ends_with']) : null;
isset($data['ends_with']) ? $model->addCondition('name', 'like', '%' . $data['ends_with']) : null;
},
'multiple' => true,
'search' => ['name', 'iso', 'iso3'],
]);

$form->onSubmit(function ($form) {
return 'Submitted: '.print_r($form->model->get(), true);
return 'Submitted: ' . print_r($form->model->get(), true);
});
6 changes: 3 additions & 3 deletions demos/card-deck.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

$countries = new Country($db);
$countries->addCalculatedField('Cost', function ($m) {
return '$ '.number_format(rand(500, 1500));
return '$ ' . number_format(rand(500, 1500));
});

$action = $countries->addAction('book', [
'callback' => function ($m, $email, $city) {
return 'Your request to visit '.ucwords($city).' in '.$m->get('name').' was sent to: '.$email;
return 'Your request to visit ' . ucwords($city) . ' in ' . $m->get('name') . ' was sent to: ' . $email;
},
'ui' => ['button'=>[null, 'icon'=>'plane']],
]);
Expand All @@ -29,7 +29,7 @@
$info_action = $countries->addAction('request_info', [

'callback' => function ($m, $email) {
return 'Your request for information was sent to email: '.$email;
return 'Your request for information was sent to email: ' . $email;
},
'scope' => 'none',
'ui' => ['button' => ['Request Info', 'ui' => 'button primary', 'icon' => 'mail']],
Expand Down
2 changes: 1 addition & 1 deletion demos/crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

// Because CRUD inherits Grid, you can also define custom actions
$crud->addModalAction(['icon'=>'cogs'], 'Details', function ($p, $id) use ($crud) {
\atk4\ui\Message::addTo($p, ['Details for: '.$crud->model->load($id)['name'].' (id: '.$id.')']);
\atk4\ui\Message::addTo($p, ['Details for: ' . $crud->model->load($id)['name'] . ' (id: ' . $id . ')']);
});

$cc = $c->addColumn();
Expand Down
8 changes: 4 additions & 4 deletions demos/dropdown-plus.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
'renderRowFunction' => function ($row) {
return [
'value' => $row->id,
'title' => $row->getTitle().' ('.$row->get('iso3').')',
'title' => $row->getTitle() . ' (' . $row->get('iso3') . ')',
];
},
]);
Expand Down Expand Up @@ -68,9 +68,9 @@
]);

$form->onSubmit(function ($form) {
$echo = print_r($form->model['enum'], true).' / ';
$echo .= print_r($form->model['values'], true).' / ';
$echo .= print_r($form->model['icon'], true).' / ';
$echo = print_r($form->model['enum'], true) . ' / ';
$echo .= print_r($form->model['values'], true) . ' / ';
$echo .= print_r($form->model['icon'], true) . ' / ';
$echo .= print_r($form->model['multi'], true);

echo $echo;
Expand Down
2 changes: 1 addition & 1 deletion demos/field2.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
$form_page->addField('age', new \atk4\ui\FormField\Line());

$form->onSubmit(function ($f) {
return $f->model['name'].' has age '.$f->model['age'];
return $f->model['name'] . ' has age ' . $f->model['age'];
});

\atk4\ui\Header::addTo($app, ['onChange event', 'subHeader'=>'see in browser console']);
Expand Down
2 changes: 1 addition & 1 deletion demos/form-custom-layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

\atk4\ui\Header::addTo($app, ['Custom Form Layout']);

$form = \atk4\ui\Form::addTo($app, ['layout'=>['Custom', 'defaultTemplate'=>__DIR__.'/form-custom-layout.html']]);
$form = \atk4\ui\Form::addTo($app, ['layout'=>['Custom', 'defaultTemplate'=>__DIR__ . '/form-custom-layout.html']]);
$form->setModel(new Stat($app->db));
2 changes: 1 addition & 1 deletion demos/form-section.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$noSave = function ($f) {
return new \atk4\ui\jsToast([
'title' => 'POSTed field values',
'message' => '<pre>'.json_encode($f->model->get(), JSON_PRETTY_PRINT).'</pre>',
'message' => '<pre>' . json_encode($f->model->get(), JSON_PRETTY_PRINT) . '</pre>',
'class' => 'success',
'displayTime' => 5000,
]);
Expand Down
14 changes: 7 additions & 7 deletions demos/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
$form->onSubmit(function ($form) {
// implement subscribe here

return $form->success('Subscribed '.$form->model['email'].' to newsletter.');
return $form->success('Subscribed ' . $form->model['email'] . ' to newsletter.');
});

$form->buttonSave->set('Subscribe');
Expand Down Expand Up @@ -59,7 +59,7 @@
$form->buttonSave->set('Compare Date');

$form->onSubmit(function ($form) {
echo 'date1 = '.print_r($form->model['date1'], true).' and date2 = '.print_r($form->model['date2'], true);
echo 'date1 = ' . print_r($form->model['date1'], true) . ' and date2 = ' . print_r($form->model['date2'], true);
});

////////////////////////////////////////////////////////////
Expand All @@ -70,7 +70,7 @@
$form->addField('email1');
$form->buttonSave->set('Save1');
$form->onSubmit(function ($form) {
return $form->error('email1', 'some error action '.rand(1, 100));
return $form->error('email1', 'some error action ' . rand(1, 100));
});

\atk4\ui\Header::addTo($tab, ['..or success message']);
Expand All @@ -88,7 +88,7 @@
$form->onSubmit(function ($form) {
$view = new \atk4\ui\Message('some header');
$view->init();
$view->text->addParagraph('some text '.rand(1, 100));
$view->text->addParagraph('some text ' . rand(1, 100));

return $view;
});
Expand All @@ -98,7 +98,7 @@
$field = $form->addField('email4');
$form->buttonSave->set('Save4');
$form->onSubmit(function ($form) use ($field) {
return $field->jsInput()->val('random is '.rand(1, 100));
return $field->jsInput()->val('random is ' . rand(1, 100));
});

/////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -159,7 +159,7 @@

$f->onSubmit(function ($f) {
if ($f->model['name'] != 'John') {
return $f->error('name', 'Your name is not John! It is "'.$f->model['name'].'". It should be John. Pleeease!');
return $f->error('name', 'Your name is not John! It is "' . $f->model['name'] . '". It should be John. Pleeease!');
} else {
return [
$f->jsInput('email')->val('[email protected]'),
Expand Down Expand Up @@ -203,7 +203,7 @@
}

if ($f->model[$name] != 'a') {
$errors[] = $f->error($name, 'Field '.$name.' should contain exactly "a", but contains '.$f->model[$name]);
$errors[] = $f->error($name, 'Field ' . $name . ' should contain exactly "a", but contains ' . $f->model[$name]);
}
}

Expand Down
4 changes: 2 additions & 2 deletions demos/form2.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
// In-form validation
$errors = [];
if (strlen($f->model['first_name']) < 3) {
$errors[] = $f->error('first_name', 'too short, '.$f->model['first_name']);
$errors[] = $f->error('first_name', 'too short, ' . $f->model['first_name']);
}
if (strlen($f->model['last_name']) < 5) {
$errors[] = $f->error('last_name', 'too short');
Expand All @@ -63,7 +63,7 @@

return $f->success(
'Record Added',
'there are now '.$f->model->action('count')->getOne().' records in DB'
'there are now ' . $f->model->action('count')->getOne() . ' records in DB'
);
});

Expand Down
2 changes: 1 addition & 1 deletion demos/form3.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
foreach ($form->model->dirty as $field => $value) {
// we should care only about editable fields
if ($form->model->getField($field)->isEditable()) {
$errors[] = $form->error($field, 'Value was changed, '.json_encode($value).' to '.json_encode($form->model[$field]));
$errors[] = $form->error($field, 'Value was changed, ' . json_encode($value) . ' to ' . json_encode($form->model[$field]));
}
}

Expand Down
6 changes: 3 additions & 3 deletions demos/grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$g = \atk4\ui\Grid::addTo($app);
$m = new Country($db);
$m->addAction('test', function ($m) {
return 'test from '.$m->getTitle().' was successful!';
return 'test from ' . $m->getTitle() . ' was successful!';
});
$g->setModel($m);

Expand All @@ -24,11 +24,11 @@
$g->addActionButton('test');

$g->addActionButton('Say HI', function ($j, $id) use ($g) {
return 'Loaded "'.$g->model->load($id)['name'].'" from ID='.$id;
return 'Loaded "' . $g->model->load($id)['name'] . '" from ID=' . $id;
});

$g->addModalAction(['icon'=>'external'], 'Modal Test', function ($p, $id) {
\atk4\ui\Message::addTo($p, ['Clicked on ID='.$id]);
\atk4\ui\Message::addTo($p, ['Clicked on ID=' . $id]);
});

$sel = $g->addSelection();
Expand Down
4 changes: 2 additions & 2 deletions demos/grid_action.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'jsSuccess' => [
new atk4\ui\jsExpression('$(".atk-dialog-content").parent().modal("hide")'),
new atk4\ui\jsToast('Action Complete with success!'),
$g->container->jsReload([$g->getName().'_sort' => $g->getSortBy()]),
$g->container->jsReload([$g->getName() . '_sort' => $g->getSortBy()]),
],
]);

Expand Down Expand Up @@ -40,7 +40,7 @@
//$m->delete();
},
'preview' => function ($m) {
return 'Will delete record: '.$m->getTitle();
return 'Will delete record: ' . $m->getTitle();
},
'ui' => ['Grid' => ['Executor' => $del_executor, 'Button' => ['icon' => 'delete']]],
]);
Expand Down
6 changes: 3 additions & 3 deletions demos/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function setCode($code, $lang = 'php')
public function highLightCode()
{
if (!self::$isInitialized) {
$this->app->requireCSS('//cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/'.$this->highlightDefaultStyle.'.min.css');
$this->app->requireCSS('//cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/' . $this->highlightDefaultStyle . '.min.css');
$this->app->requireJS('//cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js');
$this->js(true, (new \atk4\ui\jsChain('hljs'))->initHighlighting());
self::$isInitialized = true;
Expand Down Expand Up @@ -65,7 +65,7 @@ public function highLightCode()
}
/* END - PHPUNIT & COVERAGE SETUP */

$app->title = 'Agile UI Demo v'.$app->version;
$app->title = 'Agile UI Demo v' . $app->version;

if (file_exists('../public/atkjs-ui.min.js')) {
$app->cdn['atk'] = '../public';
Expand Down Expand Up @@ -146,7 +146,7 @@ public function highLightCode()

// Would be nice if this would be a link.
\atk4\ui\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]));

$img = 'https://raw.githubusercontent.com/atk4/ui/07208a0af84109f0d6e3553e242720d8aeedb784/public/logo.png';
}
Expand Down
4 changes: 2 additions & 2 deletions demos/jsactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
$country = new Country($db);

$c_action = $country->addAction('Email', function ($m) {
return 'Email to Kristy in '.$m->get('name').' has been sent!';
return 'Email to Kristy in ' . $m->get('name') . ' has been sent!';
});

$country->tryLoadAny();
Expand Down Expand Up @@ -75,7 +75,7 @@
],
'ui' => ['executor' => \atk4\ui\ActionExecutor\jsUserAction::class],
'callback'=> function ($m, $age) {
return 'Age is '.$age;
return 'Age is ' . $age;
},
]);

Expand Down
Loading