Just looking at the index.php file, the following comments (in PHPDoc-style "/**" format) may give you some ideas.
While writing your own MVC framework can certainly be educational, there's a lot to be said, too, for learning by using an existing framework. The objective should be a structure similar to what you can see in the CodeIgniter video tutorials for separating responsibilities among the M, V, and C classes/objects as shown there. (Which is why I use CI when I want to use a MVC approach instead of reinventing the wheel, regardless of how interesting it might be to do so -- I have other things to do with my time. 🙂 )
<?php
/**
* These things might better be handled in the controller >>>//
*/
session_start(); //we must always start the session first
include("./includes/db.php"); // Connect to database, set up table name variables
/**
* E.g.: what if a given page does not require database access?
*/
/**
* Again, some of this might belong in the controller. You *will* need some
* code to decide *which* controller class/object to call, but then let that
* controller figure everything else out (making use of class inheritence
* for mutliple controllers)
*
* You might want to look into using $_SERVER['PATH_INFO'] so that you can have
* URLs in the form: http://site.com/index.php/controller/method/arg1/arg2
*/
// Get Common variables
$action = isset($_GET['action']) ? $_GET['action'] : "";
$curpage = isset($_GET['curpage']) ? $_GET['curpage'] : "1";
/**
* This stuff probably belongs in a view, which would then be called by the
* controller
*/
// Set-up default page settings
include("./classes/page.php");
$page = new page("Home Page");
$page->addKeywords(array("my","home","page"));
$page->addStylesheets("default");
$page->setNav(array("Home" => "index.php",
"Gallery" => "index.php?action=gallery",
)
);
$page->setTemplatePath("./templates/default/");
$page->setCopyright(date("Y",time())." me and all my glory.");
/**
* This sounds like it's probably model stuff, which would then be called from
* within a controller, not something to be here
*/
// set-up user
include("classes/user.php");
$user = new user;
/**
* Again, this is some combination of view material plus logic that should be
* in a controller class. Each case would instead be a controller method
*/
// Determine content view
switch ($action)
{
case "gallery";
include("./classes/gallery.php");
$gid = ISSET($_GET['gid']) ? $_GET['gid'] : 0;
$aid = ISSET($_GET['aid']) ? $_GET['aid'] : 0;
$view = new gallery;
$view->pickGallery($gid);
$view->pickAlbum($aid);
$view->setPage($curpage);
break;
case "logout";
unset($_SESSION['user']);
session_destroy();
default:
include("./classes/blog.php");
$view = new blog;
}
// Print the page
$page->Display($view);