From 4ee14ec5ea96d57de472daf9db77eaadcc34ad99 Mon Sep 17 00:00:00 2001 From: Awilum Date: Mon, 2 Apr 2018 23:58:51 +0300 Subject: [PATCH] Admin plugin #3 General Updates --- site/plugins/admin/CHANGELOG.md | 2 + site/plugins/admin/LICENSE.txt | 21 +++++++ site/plugins/admin/README.md | 1 + site/plugins/admin/admin.php | 88 +++++++++++++++++++++++++++++ site/plugins/admin/admin.yml | 13 +++++ site/plugins/admin/languages/en.yml | 2 + site/plugins/admin/languages/ru.yml | 2 + 7 files changed, 129 insertions(+) create mode 100755 site/plugins/admin/CHANGELOG.md create mode 100755 site/plugins/admin/LICENSE.txt create mode 100755 site/plugins/admin/README.md create mode 100755 site/plugins/admin/admin.php create mode 100755 site/plugins/admin/admin.yml create mode 100755 site/plugins/admin/languages/en.yml create mode 100755 site/plugins/admin/languages/ru.yml diff --git a/site/plugins/admin/CHANGELOG.md b/site/plugins/admin/CHANGELOG.md new file mode 100755 index 00000000..40510895 --- /dev/null +++ b/site/plugins/admin/CHANGELOG.md @@ -0,0 +1,2 @@ +# v0.0.0, 2018-XX-XX +* Initial release diff --git a/site/plugins/admin/LICENSE.txt b/site/plugins/admin/LICENSE.txt new file mode 100755 index 00000000..3f865be1 --- /dev/null +++ b/site/plugins/admin/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2018 Flextype + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/site/plugins/admin/README.md b/site/plugins/admin/README.md new file mode 100755 index 00000000..a3b085bf --- /dev/null +++ b/site/plugins/admin/README.md @@ -0,0 +1 @@ +# Admin Plugin for [Flextype](http://flextype.org/) diff --git a/site/plugins/admin/admin.php b/site/plugins/admin/admin.php new file mode 100755 index 00000000..d4d0457a --- /dev/null +++ b/site/plugins/admin/admin.php @@ -0,0 +1,88 @@ + + * @link http://flextype.org + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flextype; + +use Url; +use Arr; +use Response; +use Request; + +// +// Add listner for onPageBeforeRender event +// +if (Url::getUriSegment(0) == 'admin') { + Events::addListener('onPageBeforeRender', function () { + Admin::instance(); + }); +} + + +class Admin { + + /** + * An instance of the Admin class + * + * @var object + * @access protected + */ + protected static $instance = null; + + /** + * Protected clone method to enforce singleton behavior. + * + * @access protected + */ + protected function __clone() + { + // Nothing here. + } + + /** + * Protected constructor since this is a static class. + * + * @access protected + */ + protected function __construct() + { + static::init(); + } + + protected static function init() + { + if (static::isLoggedIn()) { + echo 'ADMIN AREA'; + } else { + echo 'LOGIN AREA'; + } + + Request::shutdown(); + } + + protected static function isLoggedIn() : bool + { + return false; + } + + /** + * Return the Admin instance. + * Create it if it's not already created. + * + * @access public + * @return object + */ + public static function instance() + { + return !isset(self::$instance) and self::$instance = new Admin(); + } +} diff --git a/site/plugins/admin/admin.yml b/site/plugins/admin/admin.yml new file mode 100755 index 00000000..31f462ab --- /dev/null +++ b/site/plugins/admin/admin.yml @@ -0,0 +1,13 @@ +name: Admin +version: 0.0.0 +description: "Admin plugin for Flextype" +author: + name: Sergey Romanenko + email: awilum@yandex.ru + url: http://flextype.org +homepage: https://github.com/flextype/flextype +bugs: https://github.com/flextype/flextype/issues +license: MIT + +# Plugin settings +enabled: true diff --git a/site/plugins/admin/languages/en.yml b/site/plugins/admin/languages/en.yml new file mode 100755 index 00000000..7af0d0dc --- /dev/null +++ b/site/plugins/admin/languages/en.yml @@ -0,0 +1,2 @@ +sitemap: "Sitemap" +sitemap_description: "Sitemap plugin provide automatically generated XML sitemap for Flextype." diff --git a/site/plugins/admin/languages/ru.yml b/site/plugins/admin/languages/ru.yml new file mode 100755 index 00000000..7af0d0dc --- /dev/null +++ b/site/plugins/admin/languages/ru.yml @@ -0,0 +1,2 @@ +sitemap: "Sitemap" +sitemap_description: "Sitemap plugin provide automatically generated XML sitemap for Flextype."