From 49b19e95939cd38ffc9b2601a2c97ea1ee4d8eb3 Mon Sep 17 00:00:00 2001 From: M Date: Sat, 21 Nov 2015 19:59:25 -0500 Subject: + Added app root controller * Finished implementing app main function to instanciate root and delegate to it --- app/controller/root.control.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 app/controller/root.control.php (limited to 'app/controller/root.control.php') diff --git a/app/controller/root.control.php b/app/controller/root.control.php new file mode 100644 index 0000000..2d12eb6 --- /dev/null +++ b/app/controller/root.control.php @@ -0,0 +1,20 @@ + -- cgit v1.2.3 From edb25b777896910705df7b6ce991ef1e4870400c Mon Sep 17 00:00:00 2001 From: M Date: Sun, 22 Nov 2015 01:13:30 -0500 Subject: + Added function to root controller for normalizing the $argv array --- app/controller/root.control.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'app/controller/root.control.php') diff --git a/app/controller/root.control.php b/app/controller/root.control.php index 2d12eb6..fffb2fc 100644 --- a/app/controller/root.control.php +++ b/app/controller/root.control.php @@ -15,6 +15,38 @@ class Root extends Controller { /* TODO */ } + + /* + * Get a useful path string by normalizeing the $argv array received from the main function. + * This will remove directory names that appear in the $this->ar() string and the initial + * and trailing (if present) empty strings + */ + function normalizeArgv($argv) + { + $argv = array_filter($argv); + $ar = array_filter(explode("/", $this->ar())); + $i = 0; + $trunc = true; + + if (count($ar) == 0) + return $argv; + + foreach ($ar as $elem) + { + if ($elem != $argv[$i]) + { + $trunc = false; + break; + } + + $i++; + } + + if (!$trunc) + return $argv; + + return array_slice($argv, count($ar)); + } } ?> -- cgit v1.2.3 From 5c43e0f85077e758a9a260fde198e38ff42a28ab Mon Sep 17 00:00:00 2001 From: M Date: Sun, 22 Nov 2015 01:34:10 -0500 Subject: * Bug fix in normalizeArgv function --- app/controller/root.control.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'app/controller/root.control.php') diff --git a/app/controller/root.control.php b/app/controller/root.control.php index fffb2fc..bb7bb4e 100644 --- a/app/controller/root.control.php +++ b/app/controller/root.control.php @@ -14,6 +14,8 @@ class Root extends Controller function handle($argv) { /* TODO */ + $argv = $this->normalizeArgv($argv); + echo implode("/", $argv); } /* @@ -23,8 +25,8 @@ class Root extends Controller */ function normalizeArgv($argv) { - $argv = array_filter($argv); - $ar = array_filter(explode("/", $this->ar())); + $argv = array_values(array_filter($argv)); + $ar = array_values(array_filter(explode("/", $this->ar()))); $i = 0; $trunc = true; @@ -45,7 +47,7 @@ class Root extends Controller if (!$trunc) return $argv; - return array_slice($argv, count($ar)); + return array_values(array_slice($argv, count($ar))); } } -- cgit v1.2.3 From 9250262017b605495c879a12ed38c693b1e024cc Mon Sep 17 00:00:00 2001 From: M Date: Sun, 22 Nov 2015 02:25:58 -0500 Subject: * Root controller is now asserting the existence of scrott.conf.php and delegating to the correct mvc if it is missing --- app/controller/root.control.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'app/controller/root.control.php') diff --git a/app/controller/root.control.php b/app/controller/root.control.php index bb7bb4e..6263862 100644 --- a/app/controller/root.control.php +++ b/app/controller/root.control.php @@ -1,6 +1,7 @@ scrottConfExists()) + { + $ctrl = new Sysconf(); + $ctrl->handle($argv); + } + /* TODO */ - $argv = $this->normalizeArgv($argv); - echo implode("/", $argv); } /* -- cgit v1.2.3 From 0eb4a38716f48dfa5f40601cdafef16f38282765 Mon Sep 17 00:00:00 2001 From: M Date: Sun, 22 Nov 2015 17:01:22 -0500 Subject: * Placeholder message for site content --- app/controller/root.control.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/controller/root.control.php') diff --git a/app/controller/root.control.php b/app/controller/root.control.php index 6263862..d77b0e6 100644 --- a/app/controller/root.control.php +++ b/app/controller/root.control.php @@ -22,6 +22,8 @@ class Root extends Controller } /* TODO */ + else + echo "Configuration is present!"; } /* -- cgit v1.2.3 From 182ec782d61749ca67bf0cd9e67821849fc29584 Mon Sep 17 00:00:00 2001 From: M Date: Sat, 5 Dec 2015 22:56:39 -0500 Subject: * Now normalizing the $argv array in the root app controller --- app/controller/root.control.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/controller/root.control.php') diff --git a/app/controller/root.control.php b/app/controller/root.control.php index d77b0e6..7ccf35e 100644 --- a/app/controller/root.control.php +++ b/app/controller/root.control.php @@ -14,6 +14,8 @@ class Root extends Controller */ function handle($argv) { + $argv = $this->normalizeArgv($argv); + /* First, make sure the system configuration file has been included */ if (!$this->scrottConfExists()) { -- cgit v1.2.3 From b21251ef971d262dc414869fed83f52d0098bfe6 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Fri, 18 Dec 2015 22:44:08 -0500 Subject: ! Review of app/ directory for merging upstream to dev has been completed..... whew + Added some TODO comments for later development --- app/controller/root.control.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app/controller/root.control.php') diff --git a/app/controller/root.control.php b/app/controller/root.control.php index 7ccf35e..437cae1 100644 --- a/app/controller/root.control.php +++ b/app/controller/root.control.php @@ -14,6 +14,9 @@ class Root extends Controller */ function handle($argv) { + /* TODO -- Catch app exceptions here and display a special view to communicate them to user */ + /* TODO -- Authentication (login / logout / register) MVC */ + $argv = $this->normalizeArgv($argv); /* First, make sure the system configuration file has been included */ -- cgit v1.2.3