@@ -33,7 +33,9 @@ discard block |
||
| 33 | 33 | function mergesort(&$array, $cmp_function) |
| 34 | 34 | { |
| 35 | 35 | // Arrays of size < 2 require no action. |
| 36 | - if (count($array) < 2) return; |
|
| 36 | + if (count($array) < 2) { |
|
| 37 | + return; |
|
| 38 | + } |
|
| 37 | 39 | // Split the array in half |
| 38 | 40 | $halfway = count($array) / 2; |
| 39 | 41 | $array1 = array_slice($array, 0, $halfway); |
@@ -57,7 +59,11 @@ discard block |
||
| 57 | 59 | } |
| 58 | 60 | } |
| 59 | 61 | // Merge the remainder |
| 60 | - while ($ptr1 < count($array1)) $array[] = $array1[$ptr1++]; |
|
| 61 | - while ($ptr2 < count($array2)) $array[] = $array2[$ptr2++]; |
|
| 62 | + while ($ptr1 < count($array1)) { |
|
| 63 | + $array[] = $array1[$ptr1++]; |
|
| 64 | + } |
|
| 65 | + while ($ptr2 < count($array2)) { |
|
| 66 | + $array[] = $array2[$ptr2++]; |
|
| 67 | + } |
|
| 62 | 68 | return; |
| 63 | 69 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | * Properties |
| 14 | 14 | * |
| 15 | 15 | */ |
| 16 | - const URL_CLEAN = 'clean'; // controller/action/param1/param2 |
|
| 16 | + const URL_CLEAN = 'clean'; // controller/action/param1/param2 |
|
| 17 | 17 | const URL_APPEND = 'append'; // index.php/controller/action/param1/param2 |
| 18 | 18 | |
| 19 | 19 | private $urlType = self::URL_APPEND; // What type of urls to generate |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | // Get environment & autoloader. |
| 8 | -require __DIR__.'/config.php'; |
|
| 8 | +require __DIR__ . '/config.php'; |
|
| 9 | 9 | |
| 10 | 10 | |
| 11 | 11 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | // Create a default route to catch all |
| 34 | -$app->router->add('*', function () use ($app, $pages) { |
|
| 34 | +$app->router->add('*', function() use ($app, $pages) { |
|
| 35 | 35 | |
| 36 | 36 | // Get current route |
| 37 | 37 | $route = $app->request->getRoute(); |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | // Get environment & autoloader. |
| 8 | -require __DIR__.'/config.php'; |
|
| 8 | +require __DIR__ . '/config.php'; |
|
| 9 | 9 | |
| 10 | 10 | // Create services and inject into the app. |
| 11 | 11 | $di = new \Anax\DI\CDIFactoryDefault(); |
@@ -5,20 +5,20 @@ discard block |
||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | // Get environment & autoloader. |
| 8 | -require __DIR__.'/config.php'; |
|
| 8 | +require __DIR__ . '/config.php'; |
|
| 9 | 9 | |
| 10 | 10 | // Create services and inject into the app. |
| 11 | -$di = new \Anax\DI\CDIFactoryDefault(); |
|
| 11 | +$di = new \Anax\DI\CDIFactoryDefault(); |
|
| 12 | 12 | |
| 13 | 13 | $di->set('form', '\Mos\HTMLForm\CForm'); |
| 14 | 14 | |
| 15 | -$di->set('FormController', function () use ($di) { |
|
| 15 | +$di->set('FormController', function() use ($di) { |
|
| 16 | 16 | $controller = new \Anax\HTMLForm\FormController(); |
| 17 | 17 | $controller->setDI($di); |
| 18 | 18 | return $controller; |
| 19 | 19 | }); |
| 20 | 20 | |
| 21 | -$di->set('FormSmallController', function () use ($di) { |
|
| 21 | +$di->set('FormSmallController', function() use ($di) { |
|
| 22 | 22 | $controller = new \Anax\HTMLForm\FormSmallController(); |
| 23 | 23 | $controller->setDI($di); |
| 24 | 24 | return $controller; |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | $app = new \Anax\MVC\CApplicationBasic($di); |
| 28 | 28 | |
| 29 | 29 | // Home route |
| 30 | -$app->router->add('', function () use ($app) { |
|
| 30 | +$app->router->add('', function() use ($app) { |
|
| 31 | 31 | |
| 32 | 32 | $app->theme->setTitle("Testing CForm with Anax"); |
| 33 | 33 | $app->views->add('default/page', [ |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | // Test form route |
| 57 | -$app->router->add('test1', function () use ($app) { |
|
| 57 | +$app->router->add('test1', function() use ($app) { |
|
| 58 | 58 | |
| 59 | 59 | $app->session(); // Will load the session service which also starts the session |
| 60 | 60 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | ], |
| 78 | 78 | 'submit' => [ |
| 79 | 79 | 'type' => 'submit', |
| 80 | - 'callback' => function ($form) { |
|
| 80 | + 'callback' => function($form) { |
|
| 81 | 81 | $form->AddOutput("<p><i>DoSubmit(): Form was submitted. Do stuff (save to database) and return true (success) or false (failed processing form)</i></p>"); |
| 82 | 82 | $form->AddOutput("<p><b>Name: " . $form->Value('name') . "</b></p>"); |
| 83 | 83 | $form->AddOutput("<p><b>Email: " . $form->Value('email') . "</b></p>"); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | ], |
| 89 | 89 | 'submit-fail' => [ |
| 90 | 90 | 'type' => 'submit', |
| 91 | - 'callback' => function ($form) { |
|
| 91 | + 'callback' => function($form) { |
|
| 92 | 92 | $form->AddOutput("<p><i>DoSubmitFail(): Form was submitted but I failed to process/save/validate it</i></p>"); |
| 93 | 93 | return false; |
| 94 | 94 | } |
@@ -137,13 +137,13 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | |
| 139 | 139 | |
| 140 | - $callbackSuccess = function ($form) use ($app) { |
|
| 140 | + $callbackSuccess = function($form) use ($app) { |
|
| 141 | 141 | // What to do if the form was submitted? |
| 142 | 142 | $form->AddOUtput("<p><i>Form was submitted and the callback method returned true.</i></p>"); |
| 143 | 143 | $app->redirectTo(); |
| 144 | 144 | }; |
| 145 | 145 | |
| 146 | - $callbackFail = function ($form) use ($app) { |
|
| 146 | + $callbackFail = function($form) use ($app) { |
|
| 147 | 147 | // What to do when form could not be processed? |
| 148 | 148 | $form->AddOutput("<p><i>Form was submitted and the Check() method returned false.</i></p>"); |
| 149 | 149 | $app->redirectTo(); |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | |
| 12 | 12 | // Prepare the page content |
| 13 | 13 | $app->theme->setVariable('title', "Hello World Pagecontroller") |
| 14 | - ->setVariable('main', " |
|
| 14 | + ->setVariable('main', " |
|
| 15 | 15 | <h1>Hello World Pagecontroller</h1> |
| 16 | 16 | <p>This is a sample pagecontroller that shows how to use Anax.</p> |
| 17 | 17 | "); |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | // Get environment & autoloader and the $app-object. |
| 8 | -require __DIR__.'/config_with_app.php'; |
|
| 8 | +require __DIR__ . '/config_with_app.php'; |
|
| 9 | 9 | |
| 10 | 10 | |
| 11 | 11 | |
@@ -42,8 +42,8 @@ |
||
| 42 | 42 | // Prepare the page content |
| 43 | 43 | |
| 44 | 44 | $app->theme->addStylesheet("css/dice.css") |
| 45 | - ->setVariable('title', "Throw a dice") |
|
| 46 | - ->setVariable('main', " |
|
| 45 | + ->setVariable('title', "Throw a dice") |
|
| 46 | + ->setVariable('main', " |
|
| 47 | 47 | <h1>Throw a dice</h1> |
| 48 | 48 | <p>This is a sample pagecontroller showing how to use <i>application specific modules</i> in a pagecontroller.</p> |
| 49 | 49 | <p>How many rolls do you want to do, <a href='?roll=1'>1 roll</a>, <a href='?roll=3'>3 rolls</a> or <a href='?roll=6'>6 rolls</a>? </p> |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | // Get environment & autoloader. |
| 8 | -require __DIR__.'/config_with_app.php'; |
|
| 8 | +require __DIR__ . '/config_with_app.php'; |
|
| 9 | 9 | |
| 10 | 10 | |
| 11 | 11 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | ? $_GET['roll'] |
| 18 | 18 | : 0; |
| 19 | 19 | |
| 20 | -if($roll > 100) { |
|
| 20 | +if ($roll > 100) { |
|
| 21 | 21 | throw new Exception("To many rolls on the dice. Not allowed."); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | // Make roll and prepare reply |
| 27 | 27 | $html = null; |
| 28 | -if($roll) { |
|
| 28 | +if ($roll) { |
|
| 29 | 29 | $dice->roll($roll); |
| 30 | 30 | |
| 31 | 31 | $html = "<p>You made {$roll} roll(s) and you got this serie.</p>\n<ul class='dice'>"; |
| 32 | - foreach($dice->getResults() as $val) { |
|
| 32 | + foreach ($dice->getResults() as $val) { |
|
| 33 | 33 | $html .= "\n<li class='dice-{$val}'></li>"; |
| 34 | 34 | } |
| 35 | 35 | $html .= "\n</ul>\n"; |
@@ -5,14 +5,14 @@ discard block |
||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | // Get environment & autoloader. |
| 8 | -require __DIR__.'/../config.php'; |
|
| 8 | +require __DIR__ . '/../config.php'; |
|
| 9 | 9 | |
| 10 | 10 | // Create services and inject into the app. |
| 11 | 11 | $di = new \Anax\DI\CDIFactoryTest(); |
| 12 | 12 | $app = new \Anax\Kernel\CAnax($di); |
| 13 | 13 | |
| 14 | 14 | |
| 15 | -$di->set('TestController', function () use ($di) { |
|
| 15 | +$di->set('TestController', function() use ($di) { |
|
| 16 | 16 | $controller = new TestController(); |
| 17 | 17 | $controller->setDI($di); |
| 18 | 18 | return $controller; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | |
| 75 | -$app->router->add('', function () use ($app) { |
|
| 75 | +$app->router->add('', function() use ($app) { |
|
| 76 | 76 | |
| 77 | 77 | $app->dispatcher->forward(['controller' => 'test']); |
| 78 | 78 | }); |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | // Get environment & autoloader. |
| 8 | -require __DIR__.'/../config.php'; |
|
| 8 | +require __DIR__ . '/../config.php'; |
|
| 9 | 9 | |
| 10 | 10 | |
| 11 | 11 | // Create services and inject into the app. |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | // Create the home route |
| 18 | -$app->router->add('*', function () use ($app) { |
|
| 18 | +$app->router->add('*', function() use ($app) { |
|
| 19 | 19 | |
| 20 | 20 | $app->theme->setTitle("Creating urls"); |
| 21 | 21 | $app->views->add('default/page', [ |