diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b2871d --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# this is the '.gitignore' file and helps you to do not publish +# stupid stuff inside your amazing git project + +# my database configuration file and other stuff +/load.php diff --git a/include/class-Page.php b/include/class-Page.php new file mode 100644 index 0000000..de5f0b2 --- /dev/null +++ b/include/class-Page.php @@ -0,0 +1,71 @@ +args = $args; + + $this->prepare(); + } + + /** + * Set a page argument + * + * @param $name string + * @param $value mixed + * @return self + */ + protected function setArg( $name, $value ) { + $this->args[ $name ] = $value; + return $this; + } + + /** + * Set the page title + * + * @param $title string + * @return self + */ + protected function setTitle( $title ) { + return $this->setArg( 'title', $title ); + } + + /** + * Do something at startup + */ + protected function prepare() { + // actually nothing. You can override this! + } + + /** + * Print the site header + */ + public function printHeader() { + template( 'header', $this->args ); + } + + /** + * Print the site footer + */ + public function printFooter() { + template( 'footer', $this->args ); + } + +} diff --git a/include/class-PageHome.php b/include/class-PageHome.php new file mode 100644 index 0000000..642ce12 --- /dev/null +++ b/include/class-PageHome.php @@ -0,0 +1,45 @@ +requestedUser = + ( new QueryUser() ) + ->whereUserID( $id ) + ->queryRow(); + } + } + + /** + * Get the requested User (if any!) + * + * @return User|null + */ + public function getRequestedUser() { + return $this->requestedUser; + } + +} diff --git a/include/class-PageLogin.php b/include/class-PageLogin.php new file mode 100644 index 0000000..7aa1fee --- /dev/null +++ b/include/class-PageLogin.php @@ -0,0 +1,31 @@ +setTitle( __( "Login" ) ); + + // check if we should do the login + if( is_action( 'do-login' ) ) { + + // process the login form + login(); + } + + } + +} diff --git a/include/class-QueryUser.php b/include/class-QueryUser.php new file mode 100644 index 0000000..c07de69 --- /dev/null +++ b/include/class-QueryUser.php @@ -0,0 +1,32 @@ +from( 'user' ); + + // set default class name for the results + $this->defaultClass( 'User' ); + } + + /** + * Where the User ID is... + * + * @param int User ID + * @return self + */ + public function whereUserID( $id ) { + return $this->whereInt( 'user_ID', $id ); + } + +} diff --git a/include/class-User.php b/include/class-User.php new file mode 100644 index 0000000..5f821e4 --- /dev/null +++ b/include/class-User.php @@ -0,0 +1,48 @@ +get( 'user_name' ); + } + + /** + * Get the User ID + * + * @return int + */ + public function getUserID() { + return $this->getSessionuserID(); + } + + /** + * Check if the user is me + * + * @return boolean + */ + public function isUserMe() { + + // if I'm logged, compare the IDs + if( is_logged() ) { + return $this->getUserID() === get_user()->getUserID(); + } + + return false; + } + +} diff --git a/include/functions.php b/include/functions.php new file mode 100644 index 0000000..78d225e --- /dev/null +++ b/include/functions.php @@ -0,0 +1,16 @@ + + Copyleft + + diff --git a/template/header.php b/template/header.php new file mode 100644 index 0000000..8233485 --- /dev/null +++ b/template/header.php @@ -0,0 +1,23 @@ + title + +if( empty( $title ) ) { + throw new Exception( 'the template header need the title parameter' ); +} + +?> + + + +<?= esc_html( $title ) ?> + + + + + + +

diff --git a/www/index.php b/www/index.php new file mode 100644 index 0000000..78a6485 --- /dev/null +++ b/www/index.php @@ -0,0 +1,19 @@ + __( "Welcome!" ), +] ); + +// I want this stylesheet +enqueue_js( 'my-style'); + +// print site header +$page->printHeader(); +?> + + +printFooter(); diff --git a/www/login.php b/www/login.php new file mode 100644 index 0000000..bafab2d --- /dev/null +++ b/www/login.php @@ -0,0 +1,36 @@ +printHeader(); +?> + +
+ + + + +

+ +
+ +

+ + +

+ +
+ +

+ + +

+ +
+ +printFooter(); diff --git a/www/static/my-script.js b/www/static/my-script.js new file mode 100644 index 0000000..e69de29 diff --git a/www/static/my-style.css b/www/static/my-style.css new file mode 100644 index 0000000..42ad49d --- /dev/null +++ b/www/static/my-style.css @@ -0,0 +1,4 @@ +body { + max-width: 900px; + margin:0 auto; +}