Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //----------------------------------------------
- // BootStrap
- //----------------------------------------------
- define ('DS',DIRECTORY_SEPARATOR);
- define ('ROOT', dirname(__FILE__));
- define ('DEBUG_MODE', true);
- session_start();
- Debugger::prepare();
- $controller = isset($_GET['controller']) ? $_GET['controller'] : 'questions';
- $action = isset($_GET['action']) ? $_GET['action'] : 'view_page';
- init();
- $output4 = dispatch($controller, $action);
- //----------------------------------------------
- // autoload
- //----------------------------------------------
- function __autoload($className) {
- $controller_f = ROOT. DS. 'app'.DS.'controllers'.DS. strtolower($className).'.inc.php';
- $model_f = ROOT. DS. 'app'.DS.'models'.DS. strtolower($className).'.inc.php';
- $view_f = ROOT. DS. 'app'.DS.'views'.DS. strtolower($className).'.inc.php';
- $base_f = ROOT. DS. 'library'.DS. 'base.inc.php';
- if (file_exists($controller_f)) {
- require_once($controller_f);
- }
- else if (file_exists($model_f)) {
- require_once($model_f);
- }
- else if (file_exists($view_f)) {
- require_once($view_f);
- }
- else
- require_once($base_f);
- }
- //----------------------------------------------
- // initialization
- //----------------------------------------------
- function init() {
- define('DB_HOST','localhost');
- define('DB_NAME','');
- define('DB_USER','');
- define('DB_PASSWORD','');
- DBConn::set(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
- }
- //----------------------------------------------
- // dispatch
- //----------------------------------------------
- function dispatch($controller, $action) {
- $controllerName = $controller;
- $controller = ucwords($controller);
- $model = rtrim($controller,'s');
- $view = $controller.'View';
- $controller .= 'Controller';
- $dispatch = new $controller($model, $view, $controllerName, $action);
- $dispatch->dispatch();
- $output = $dispatch->render(false);
- $related = $dispatch->related();
- //----------------------------
- foreach ($related as $controller_related) {
- $output .= dispatch($controller_related, $action);
- }
- return $output;
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>mvc - example</title>
- <style type="text/css">
- * {
- margin: 0;
- padding: 0;
- border: none;
- outline: none;
- }
- body {
- font-family: verdana, sans-serif;
- font-size:100%;
- }
- #container {
- width:1000px;
- margin:0 auto;
- }
- #questions {
- margin-bottom: 10px;
- }
- .header {
- height:100px;
- color:#333;
- font-size:1.5em;
- line-height:1.5em;
- text-align:center;
- letter-spacing:3px;
- background: #eee;
- border-radius: 100px 60px 50px 10px;
- -moz-border-radius: 100px 60px 50px 10px;
- -webkit-border-radius: 100px 60px 50px 10px;
- }
- .content {
- float:left;
- width:800px;
- margin-bottom: 20px;
- }
- .page {
- }
- .entrytitle {
- margin-top: 10px;
- font-size:1.2em;
- font-weight:bold;
- height:30px;
- line-height:30px;
- text-align:center;
- background: #aaa;
- border-radius:10px;
- -moz-border-radius:10px;
- -webkit-border-radius:10px;
- }
- .entrytitle a {
- color:white;
- text-decoration: none;
- }
- .entrytitle a:hover {
- color:#3f3;
- }
- .entrycontent {
- padding: 4px 20px 5px 10px;
- border-bottom: solid 1px #999;
- }
- .entrycategory {
- height:30px;
- background: #eee;
- }
- .entryuser {
- font-family:georgia, serif;
- font-size:0.75em;
- }
- .entrydate {
- font-size:0.75em;
- font-style: italic;
- }
- .entryeditpanel {
- margin-top:10px;
- overflow:hidden;
- }
- .editpanel {
- overflow:hidden;
- }
- .editbutton, .deletebutton, .addbutton, .backtolistbutton {
- background:#ff9;
- font-weight:bold;
- font-size: 0.75em;
- text-align:center;
- padding:4px 10px;
- margin-right:5px;
- border: solid 2px #800;
- -moz-border-radius: 8px;
- -webkit-border-radius: 8px;
- border-radius: 8px;
- float:left;
- }
- .editbutton a, .deletebutton a, .addbutton a, .backtolistbutton a{
- color:#c00;
- text-decoration: none;
- }
- .editbutton {
- }
- .deletebutton {
- }
- .addbutton {
- }
- .backtolistbutton {
- }
- .sidebar {
- float:right;
- width:190px;
- min-height: 200px;
- margin-top:10px;
- background: #f5f5f5;
- }
- .footer {
- clear:both;
- background: #f0f0f0;
- padding: 10px 20px;
- }
- .navigation {
- margin-top:4px;
- overflow: hidden;
- }
- .navigation ul {
- list-style-type:none;
- }
- .navigation li {
- float:left;
- margin-right: 5px;
- text-align:center;
- height:40px;
- line-height:40px;
- background: white;
- font-weight: bold;
- width: 40px;
- border: solid 1px #555;
- -moz-border-radius:4px;
- -webkit-border-radius:4px;
- }
- .navigation li a, .navigation li a:visited {
- text-decoration:none;
- color: #800;
- }
- .navigation li a:hover {
- text-decoration: underline;
- }
- form {
- padding:20px 40px 10px 20px;
- }
- fieldset {
- padding-top:10px;
- }
- legend {
- border:solid 1px #aaa;
- border-radius:4px;
- -moz-border-radius:4px;
- -webkit-border-radius:4px;
- padding:4px 20px;
- }
- label {
- display:block;
- float:left;
- clear:left;
- width:200px;
- margin-right:10px;
- margin-top: 5px;
- }
- input {
- display: block;
- border: solid 1px #aaa;
- border-radius: 4px;
- -moz-border-radius: 4px;
- -webkit-border-radius: 4px;
- padding:2px 5px;
- margin-top:5px;
- }
- input[type=text] {
- width:400px;
- }
- input[type=submit], input[type=button] {
- background:#ffa;
- float:left;
- border:solid 2px #a00;
- border-radius 8px;
- -moz-border-radius 8px;
- -webkit-border-radius 8px;
- color:#b00;
- cursor:pointer;
- padding:4px 20px;
- font-size:1em;
- margin-right:10px;
- margin-top:10px;
- }
- </style>
- </head>
- <body>
- <div id="container">
- <?php echo $output4; ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement