diff --git a/include/class-PageHome.php b/include/class-PageHome.php index 2735209..46e47db 100644 --- a/include/class-PageHome.php +++ b/include/class-PageHome.php @@ -1,68 +1,74 @@ . /** * Homepage of my website */ class PageHome extends Page { + /** + * Generator of my App(s) + * + * @generator + */ + private $apps; + /** * Do something at startup * * @override */ protected function prepare() { // must be logged-in require_permission( 'backend' ); - // read the ID from the query string or zero - $id = $_GET['id'] ?? 0; + // set page title + $this->setTitle( __( "Panel" ) ); - // make sure that it's an integer - $id = (int) $id; + // query my App(s) + $this->apps = + ( new QueryAppUser() ) + ->select( [ + 'app.app_ID', + 'app_name', + ] ) + ->whereUserIsMe() + ->joinApp() + ->queryGenerator(); - // if it's non-zero - if( $id ) { + } - // query the User with that ID (or get NULL) - $this->requestedUser = - ( new QueryUser() ) - ->whereUserID( $id ) - ->queryRow(); - } + /** + * Check if I have apps + * + * @return boolean + */ + public function areThereMyApps() { + return $this->apps->valid(); } /** * Get a generator of my apps * * @generator */ - public function myAppsGenerator() { - - return ( new QueryAppUser() ) - ->select( [ - 'app.app_ID', - 'app_name', - ] ) - ->whereUserIsMe() - ->joinApp() - ->queryGenerator(); - + public function getMyApps() { + return $this->apps; } } diff --git a/load-post.php b/load-post.php index 1f11cdf..9c5e53d 100644 --- a/load-post.php +++ b/load-post.php @@ -1,72 +1,73 @@ . /* * This file describes the website core. * This file is automagically called after the 'load.php' file. */ // name of the website define( 'SITE_NAME', 'WikiCAPTCHA' ); // set the default class for the User retrieved from database define( 'SESSIONUSER_CLASS', 'User' ); // register a custom CSS stylesheet register_css( 'my-style', 'static/my-style.css' ); // register a custom JavaScript register_js( 'my-script', 'static/my-script.js' ); // register an 'user' role with some permissions register_permissions('user', [ 'backend', + 'add-app', ] ); // register an 'analist' role that it's somehow more than an 'user' inherit_permissions( 'analist', 'user', [ 'view-dashboard', 'create-monsters', ] ); /** * register an 'admin' role that can edit everything */ inherit_permissions( 'admin', 'analist', [ 'edit-all-app', ] ); // autoload classes and traits from the 'include' directory spl_autoload_register( function( $missing_class_name ) { // if the class name ends with 'Trait' just autoload it's class $suffix = substr( $missing_class_name, -5 ); if( $suffix === 'Trait' ) { $missing_class_name = substr( $missing_class_name, 0, -5 ); } // the class should be there $path = ABSPATH . "/include/class-{$missing_class_name}.php"; // eventually load if valid if( file_exists( $path ) ) { require $path; } } ); // load some additional functions require ABSPATH . '/include/functions.php'; diff --git a/www/index.php b/template/form-add-app.php similarity index 67% copy from www/index.php copy to template/form-add-app.php index 8ee06be..4e27e43 100644 --- a/www/index.php +++ b/template/form-add-app.php @@ -1,33 +1,34 @@ . -// load everything -require '../load.php'; - -// this is the homepage (the business logic of this page it's in this class) -$page = new PageHome(); +?> -// I want this stylesheet -enqueue_css( 'my-style' ); + +
-// print site header -$page->printHeader(); -?> + +

+
+ +

-printFooter(); +

+ +

+
+ diff --git a/www/index.php b/www/index.php index 8ee06be..d14a50d 100644 --- a/www/index.php +++ b/www/index.php @@ -1,33 +1,44 @@ . // load everything require '../load.php'; // this is the homepage (the business logic of this page it's in this class) $page = new PageHome(); // I want this stylesheet enqueue_css( 'my-style' ); // print site header $page->printHeader(); ?> +

+ areThereMyApps() ): ?> + getMyApps() as $app ): ?> + getAppName() ) ?> + + +

+ + +

+ printFooter();