diff --git a/app/bootstrap.php b/app/bootstrap.php index 096c35e5..9e8aa662 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -69,6 +69,11 @@ return function(array $config_array = []) { $container->set('url-generator', new UrlGenerator($container)); $container->set('auth', new HummingbirdAuth($container)); + + // Miscellaneous helper methods + $anime_client = new AnimeClient(); + $anime_client->setContainer($container); + $container->set('anime_client', $anime_client); // ------------------------------------------------------------------------- // Dispatcher diff --git a/app/views/header.php b/app/views/header.php index 0bd39668..51e5c85d 100644 --- a/app/views/header.php +++ b/app/views/header.php @@ -1,3 +1,4 @@ + @@ -26,11 +27,11 @@ diff --git a/index.php b/index.php index cfaf8035..ae78c827 100644 --- a/index.php +++ b/index.php @@ -56,7 +56,6 @@ spl_autoload_register(function($class) { }); require _dir(ROOT_DIR, '/vendor/autoload.php'); -require _dir(SRC_DIR, '/functions.php'); // ------------------------------------------------------------------------- // Setup error handling diff --git a/src/Aviat/AnimeClient/AnimeClient.php b/src/Aviat/AnimeClient/AnimeClient.php new file mode 100644 index 00000000..501f0a3b --- /dev/null +++ b/src/Aviat/AnimeClient/AnimeClient.php @@ -0,0 +1,61 @@ +container->get('request') + ->server->get('REQUEST_URI'); + $blacklist = ['edit', 'add', 'update', 'login', 'logout']; + $page_segments = explode("/", $url); + + $intersect = array_intersect($page_segments, $blacklist); + + return empty($intersect); + } + +} +// End of anime_client.php \ No newline at end of file diff --git a/src/Aviat/Ion/View/HtmlView.php b/src/Aviat/Ion/View/HtmlView.php index a655c049..8c7f81bd 100644 --- a/src/Aviat/Ion/View/HtmlView.php +++ b/src/Aviat/Ion/View/HtmlView.php @@ -56,6 +56,7 @@ class HtmlView extends HttpView { { $data['helper'] = $this->helper; $data['escape'] = $this->helper->escape(); + $data['container'] = $this->container; ob_start(); extract($data); diff --git a/src/functions.php b/src/functions.php deleted file mode 100644 index 8f06cb92..00000000 --- a/src/functions.php +++ /dev/null @@ -1,57 +0,0 @@ -assertEquals('foo' . DIRECTORY_SEPARATOR . 'bar', \_dir('foo', 'bar')); + } + + public function testIsSelected() + { + // Failure to match + $this->assertEquals('', AnimeClient::is_selected('foo', 'bar')); + + // Matches + $this->assertEquals('selected', AnimeClient::is_selected('foo', 'foo')); + } + + public function testIsNotSelected() + { + // Failure to match + $this->assertEquals('selected', AnimeClient::is_not_selected('foo', 'bar')); + + // Matches + $this->assertEquals('', AnimeClient::is_not_selected('foo', 'foo')); + } +} diff --git a/tests/AnimeClient/FunctionsTest.php b/tests/AnimeClient/FunctionsTest.php deleted file mode 100644 index 342a7e7f..00000000 --- a/tests/AnimeClient/FunctionsTest.php +++ /dev/null @@ -1,32 +0,0 @@ -assertEquals('foo' . DIRECTORY_SEPARATOR . 'bar', _dir('foo', 'bar')); - } - - public function testIsSelected() - { - // Failure to match - $this->assertEquals('', is_selected('foo', 'bar')); - - // Matches - $this->assertEquals('selected', is_selected('foo', 'foo')); - } - - public function testIsNotSelected() - { - // Failure to match - $this->assertEquals('selected', is_not_selected('foo', 'bar')); - - // Matches - $this->assertEquals('', is_not_selected('foo', 'foo')); - } -} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index e5018489..d1090108 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -27,7 +27,6 @@ define('BASE_DIR', _dir(SRC_DIR, 'Base')); define('TEST_DATA_DIR', _dir(__DIR__, 'test_data')); define('TEST_VIEW_DIR', _dir(__DIR__, 'test_views')); require _dir(ROOT_DIR, '/vendor/autoload.php'); -require _dir(SRC_DIR, '/functions.php'); /** * Set up autoloaders