diff --git a/.htaccess b/.htaccess index 188ac6bb..e85ab7b5 100644 --- a/.htaccess +++ b/.htaccess @@ -2,6 +2,9 @@ AddDefaultCharset UTF-8 RewriteEngine on +DirectorySlash Off + RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^(.*) index.php [L] + +RewriteRule ^(.*) index.php [L] \ No newline at end of file diff --git a/admin/controllers/add-user.php b/admin/controllers/add-user.php new file mode 100644 index 00000000..8988d60b --- /dev/null +++ b/admin/controllers/add-user.php @@ -0,0 +1,47 @@ +userExists($args['username']) || helperText::isEmpty($args['username']) ) + { + Alert::set('Username already exists or is empty'); + return false; + } + + // Validate password. + if( ($args['password'] != $args['confirm-password'] ) || helperText::isEmpty($args['password']) ) + { + Alert::set('The password and confirmation password do not match'); + return false; + } + + // Add the user. + if( $dbUsers->add($args) ) + { + Alert::set('User has been added successfull'); + return true; + } + else + { + Alert::set('Error occurred when trying to add a new user'); + return false; + } +} + +// ============================================================================ +// POST Method +// ============================================================================ + +if( $_SERVER['REQUEST_METHOD'] == 'POST' ) +{ + if( addUser($_POST) ) { + Redirect::page('admin', 'users'); + } +} diff --git a/admin/controllers/edit-page.php b/admin/controllers/edit-page.php new file mode 100644 index 00000000..9711c638 --- /dev/null +++ b/admin/controllers/edit-page.php @@ -0,0 +1,74 @@ +edit($args) ) + { + $dbPages->regenerate(); + + Alert::set('The page has been saved successfully'); + Redirect::page('admin', 'manage-pages'); + } + else + { + Alert::set('Error occurred when trying to edit the page'); + } +} + +function deletePage($key) +{ + global $dbPages; + + if( $dbPages->delete($key) ) + { + Alert::set('The page has been deleted successfully'); + Redirect::page('admin', 'manage-pages'); + } + else + { + Alert::set('Error occurred when trying to delete the page'); + } +} + +// ============================================================================ +// POST Method +// ============================================================================ + +if( $_SERVER['REQUEST_METHOD'] == 'POST' ) +{ + if( isset($_POST['delete']) ) { + deletePage($_POST['key']); + } + else { + editPage($_POST); + } +} + +// ============================================================================ +// Main +// ============================================================================ + +if(!$dbPages->pageExists($layout['parameters'])) { + Redirect::page('admin', 'manage-pages'); +} + +$_Page = $pages[$layout['parameters']]; diff --git a/admin/controllers/edit-post.php b/admin/controllers/edit-post.php new file mode 100644 index 00000000..3c9b453b --- /dev/null +++ b/admin/controllers/edit-post.php @@ -0,0 +1,68 @@ +edit($args) ) + { + Alert::set('The post has been saved successfull'); + Redirect::page('admin', 'manage-posts'); + } + else + { + Alert::set('Error occurred when trying to edit the post'); + } +} + +function deletePost($key) +{ + global $dbPosts; + + if( $dbPosts->delete($key) ) + { + Alert::set('The post has been deleted successfull'); + Redirect::page('admin', 'manage-posts'); + } + else + { + Alert::set('Error occurred when trying to delete the post'); + } +} + +// ============================================================================ +// POST Method +// ============================================================================ + +if( $_SERVER['REQUEST_METHOD'] == 'POST' ) +{ + if( isset($_POST['delete']) ) { + deletePost($_POST['key']); + } + else { + editPost($_POST); + } +} + +// ============================================================================ +// Main +// ============================================================================ + +if(!$dbPosts->postExists($layout['parameters'])) { + Redirect::page('admin', 'manage-posts'); +} + +$_Post = buildPost($layout['parameters']); diff --git a/admin/controllers/edit-user.php b/admin/controllers/edit-user.php new file mode 100644 index 00000000..7fdd0da5 --- /dev/null +++ b/admin/controllers/edit-user.php @@ -0,0 +1,35 @@ +set($args); + } + else { + Alert::set('Passwords are differents.'); + return false; + } + } + else + { + return $dbUsers->set($args); + } + +} + +if( $_SERVER['REQUEST_METHOD'] == 'POST' ) +{ + if( editUser($_POST) ) { + Alert::set('User saved successfuly.'); + } +} + +$_user = $dbUsers->get($layout['parameters']); + +// If the user doesn't exist, redirect to the users list. +if($_user===false) + Redirect::page('admin', 'users'); \ No newline at end of file diff --git a/admin/controllers/new-page.php b/admin/controllers/new-page.php new file mode 100644 index 00000000..dbe3b4f1 --- /dev/null +++ b/admin/controllers/new-page.php @@ -0,0 +1,30 @@ +add($args) ) + { + Alert::set('Page added successfuly.'); + Redirect::page('admin', 'manage-pages'); + } + else + { + Alert::set('Error occurred when trying to create the page.'); + } +} + +if( $_SERVER['REQUEST_METHOD'] == 'POST' ) +{ + addPage($_POST); +} \ No newline at end of file diff --git a/admin/controllers/new-post.php b/admin/controllers/new-post.php new file mode 100644 index 00000000..26024b9a --- /dev/null +++ b/admin/controllers/new-post.php @@ -0,0 +1,30 @@ +add($args) ) + { + Alert::set('Post added successfuly.'); + Redirect::page('admin', 'manage-posts'); + } + else + { + Alert::set('Error occurred when trying to create the post.'); + } +} + +if( $_SERVER['REQUEST_METHOD'] == 'POST' ) +{ + addPost($_POST); +} \ No newline at end of file diff --git a/admin/controllers/settings.php b/admin/controllers/settings.php new file mode 100644 index 00000000..90a926dc --- /dev/null +++ b/admin/controllers/settings.php @@ -0,0 +1,30 @@ +set($args) ) { + Alert::set('Settings has been saved successfully'); + } + else { + Alert::set('Error occurred when trying to saved the settings'); + } +} + +// ============================================================================ +// POST Method +// ============================================================================ + +if( $_SERVER['REQUEST_METHOD'] == 'POST' ) +{ + setSettings($_POST); +} diff --git a/admin/controllers/users.php b/admin/controllers/users.php new file mode 100644 index 00000000..7e550c48 --- /dev/null +++ b/admin/controllers/users.php @@ -0,0 +1,6 @@ +set($_POST); +} diff --git a/admin/themes/default/css/default.css b/admin/themes/default/css/default.css index e4dd0eed..7a55db08 100644 --- a/admin/themes/default/css/default.css +++ b/admin/themes/default/css/default.css @@ -58,6 +58,17 @@ a:hover { border-bottom: 1px solid #eee; } +/* ----------- ALERT ----------- */ +#alert { + top: 0 !important; + right: 0 !important; + left: 0 !important; + width: 100% !important; + padding: 20px 0px !important; + max-width: 100% !important; + text-align: center; +} + /* ----------- CONTENT ----------- */ #content { overflow: auto; @@ -68,3 +79,34 @@ h2.title { font-weight: normal; } +/* ----------- FORMS ----------- */ + +form h4 { + border-bottom: 1px solid #e2e2e2; + font-weight: 300; + margin: 33px 0 20px; + padding-bottom: 10px; + width: 60%; +} + +#advancedOptions { + +} + +p.advOptions { + color: #777; + font-size: 0.8em; +} + +/* ----------- SUB-NAVBAR ----------- */ +.sublinks a { + color: #2672ec; +} + +.sublinks a:hover { + color: #333 !important; +} + +li.active { + border-bottom: 2px solid #ccc; +} diff --git a/admin/themes/default/index.php b/admin/themes/default/index.php index 7f8a9dff..9b9dc3fb 100644 --- a/admin/themes/default/index.php +++ b/admin/themes/default/index.php @@ -11,39 +11,63 @@ + + +
+ + + + + +