Skip to content

Commit

Permalink
Merge branch 'feature-issue79' into develop
Browse files Browse the repository at this point in the history
Conflicts:
	application/libs/application.php
	application/views/_templates/header.php
  • Loading branch information
panique committed Oct 14, 2014
2 parents 40d6076 + 6759019 commit 6514d4d
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 42 deletions.
22 changes: 2 additions & 20 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -1,20 +1,2 @@
# Necessary to prevent problems when using a controller named "index" and having a root index.php
# more here: http://httpd.apache.org/docs/2.2/content-negotiation.html
Options -MultiViews

# Activates URL rewriting (like myproject.com/controller/action/1/2/3)
RewriteEngine On

# Disallows others to look directly into /public/ folder
Options -Indexes

# When using the script within a sub-folder, put this path here, like /mysubfolder/
# If your app is in the root of your web folder, then leave it commented out
RewriteBase /php-mvc/

# General rewrite rules
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
RewriteEngine on
RewriteRule ^(.*) public/$1 [L]
4 changes: 0 additions & 4 deletions application/.htaccess

This file was deleted.

18 changes: 9 additions & 9 deletions application/controller/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public function index()
// debug message to show where you are, just for the demo
echo 'Message from Controller: You are in the controller home, using the method index()';
// load views. within the views we can echo out $songs and $amount_of_songs easily
require 'application/views/_templates/header.php';
require 'application/views/home/index.php';
require 'application/views/_templates/footer.php';
require APP . 'views/_templates/header.php';
require APP . 'views/home/index.php';
require APP . 'views/_templates/footer.php';
}

/**
Expand All @@ -34,9 +34,9 @@ public function exampleOne()
// debug message to show where you are, just for the demo
echo 'Message from Controller: You are in the controller home, using the method exampleOne()';
// load views. within the views we can echo out $songs and $amount_of_songs easily
require 'application/views/_templates/header.php';
require 'application/views/home/example_one.php';
require 'application/views/_templates/footer.php';
require APP . 'views/_templates/header.php';
require APP . 'views/home/example_one.php';
require APP . 'views/_templates/footer.php';
}

/**
Expand All @@ -49,8 +49,8 @@ public function exampleTwo()
// debug message to show where you are, just for the demo
echo 'Message from Controller: You are in the controller home, using the method exampleTwo()';
// load views. within the views we can echo out $songs and $amount_of_songs easily
require 'application/views/_templates/header.php';
require 'application/views/home/example_two.php';
require 'application/views/_templates/footer.php';
require APP . 'views/_templates/header.php';
require APP . 'views/home/example_two.php';
require APP . 'views/_templates/footer.php';
}
}
6 changes: 3 additions & 3 deletions application/controller/songs.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public function index()
$amount_of_songs = $stats_model->getAmountOfSongs();

// load views. within the views we can echo out $songs and $amount_of_songs easily
require 'application/views/_templates/header.php';
require 'application/views/songs/index.php';
require 'application/views/_templates/footer.php';
require APP . 'views/_templates/header.php';
require APP . 'views/songs/index.php';
require APP . 'views/_templates/footer.php';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion application/libs/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private function openDatabaseConnection()
*/
public function loadModel($model_name)
{
require 'application/models/' . strtolower($model_name) . '.php';
require APP . '/models/' . strtolower($model_name) . '.php';
// return new model (and pass the database connection to the model)
return new $model_name($this->db);
}
Expand Down
16 changes: 16 additions & 0 deletions public/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Necessary to prevent problems when using a controller named "index" and having a root index.php
# more here: http://httpd.apache.org/docs/2.2/content-negotiation.html
Options -MultiViews

# Activates URL rewriting (like myproject.com/controller/action/1/2/3)
RewriteEngine On

# Disallows others to look directly into /public/ folder
Options -Indexes

# General rewrite rules
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
12 changes: 7 additions & 5 deletions index.php → public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@
* @license http://opensource.org/licenses/MIT MIT License
*/

define('ROOT', dirname(__DIR__) . DIRECTORY_SEPARATOR);
define('APP', ROOT . 'application' . DIRECTORY_SEPARATOR);
// load the (optional) Composer auto-loader
if (file_exists('vendor/autoload.php')) {
require 'vendor/autoload.php';
if (file_exists(ROOT . 'vendor/autoload.php')) {
require ROOT . 'vendor/autoload.php';
}

// load application config (error reporting etc.)
require 'application/config/config.php';
require APP . '/config/config.php';

// load application class
require 'application/libs/application.php';
require 'application/libs/controller.php';
require APP . '/libs/application.php';
require APP . '/libs/controller.php';

// start the application
$app = new Application();

0 comments on commit 6514d4d

Please sign in to comment.