From f256db237bfe3bb645fca5d2672c05effdd787e4 Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Fri, 17 May 2013 17:34:31 +0100 Subject: [PATCH] Fixing PHPCI so that it'll work in a subdirectory. --- PHPCI/Application.php | 9 +++++++++ PHPCI/Controller/BuildController.php | 4 ++-- PHPCI/Controller/ProjectController.php | 12 ++++++------ PHPCI/Controller/SessionController.php | 4 ++-- PHPCI/Controller/UserController.php | 6 +++--- PHPCI/View/Build.phtml | 10 +++++----- PHPCI/View/BuildsTable.phtml | 8 ++++---- PHPCI/View/Index.phtml | 8 ++++---- PHPCI/View/Layout.phtml | 14 +++++++------- PHPCI/View/Login.phtml | 6 ++---- PHPCI/View/Project.phtml | 18 +++++++++--------- PHPCI/View/User.phtml | 12 ++++++------ README.md | 3 ++- bootstrap.php | 5 +++++ 14 files changed, 66 insertions(+), 53 deletions(-) diff --git a/PHPCI/Application.php b/PHPCI/Application.php index fe3bcca4..a2d2f940 100644 --- a/PHPCI/Application.php +++ b/PHPCI/Application.php @@ -18,6 +18,15 @@ use b8\Registry; */ class Application extends b8\Application { + public function __construct() + { + if (isset($_SERVER['REDIRECT_PATH_INFO'])) { + $_SERVER['REQUEST_URI'] = $_SERVER['REDIRECT_PATH_INFO']; + } + + return parent::__construct(); + } + /** * Handle an incoming web request. */ diff --git a/PHPCI/Controller/BuildController.php b/PHPCI/Controller/BuildController.php index 3bcfbcd7..77c4762a 100644 --- a/PHPCI/Controller/BuildController.php +++ b/PHPCI/Controller/BuildController.php @@ -81,7 +81,7 @@ class BuildController extends b8\Controller $build = $this->_buildStore->save($build); - header('Location: /build/view/' . $build->getId()); + header('Location: '.PHPCI_URL.'build/view/' . $build->getId()); } /** @@ -96,7 +96,7 @@ class BuildController extends b8\Controller $build = $this->_buildStore->getById($buildId); $this->_buildStore->delete($build); - header('Location: /project/view/' . $build->getProjectId()); + header('Location: '.PHPCI_URL.'project/view/' . $build->getProjectId()); } /** diff --git a/PHPCI/Controller/ProjectController.php b/PHPCI/Controller/ProjectController.php index 03f4f7fa..7448f352 100644 --- a/PHPCI/Controller/ProjectController.php +++ b/PHPCI/Controller/ProjectController.php @@ -61,7 +61,7 @@ class ProjectController extends b8\Controller $build = $this->_buildStore->save($build); - header('Location: /build/view/' . $build->getId()); + header('Location: '.PHPCI_URL.'build/view/' . $build->getId()); } /** @@ -76,7 +76,7 @@ class ProjectController extends b8\Controller $project = $this->_projectStore->getById($projectId); $this->_projectStore->delete($project); - header('Location: /'); + header('Location: '.PHPCI_URL); } /** @@ -164,7 +164,7 @@ class ProjectController extends b8\Controller $project = $this->_projectStore->save($project); - header('Location: /project/view/' . $project->getId()); + header('Location: '.PHPCI_URL.'project/view/' . $project->getId()); die; } @@ -187,7 +187,7 @@ class ProjectController extends b8\Controller if ($resp['success']) { parse_str($resp['body'], $resp); $_SESSION['github_token'] = $resp['access_token']; - header('Location: /project/add'); + header('Location: '.PHPCI_URL.'project/add'); die; } } @@ -230,7 +230,7 @@ class ProjectController extends b8\Controller $project->setValues($values); $project = $this->_projectStore->save($project); - header('Location: /project/view/' . $project->getId()); + header('Location: '.PHPCI_URL.'project/view/' . $project->getId()); die; } @@ -241,7 +241,7 @@ class ProjectController extends b8\Controller { $form = new Form(); $form->setMethod('POST'); - $form->setAction('/project/' . $type); + $form->setAction(PHPCI_URL.'project/' . $type); $form->addField(new Form\Element\Csrf('csrf')); $form->addField(new Form\Element\Hidden('token')); $form->addField(new Form\Element\Hidden('pubkey')); diff --git a/PHPCI/Controller/SessionController.php b/PHPCI/Controller/SessionController.php index de877e49..a05c708d 100644 --- a/PHPCI/Controller/SessionController.php +++ b/PHPCI/Controller/SessionController.php @@ -34,7 +34,7 @@ class SessionController extends b8\Controller if ($user && password_verify($this->getParam('password', ''), $user->getHash())) { $_SESSION['user_id'] = $user->getId(); - header('Location: /'); + header('Location: ' . PHPCI_URL); die; } } @@ -72,7 +72,7 @@ class SessionController extends b8\Controller { $_SESSION = array(); session_destroy(); - header('Location: /'); + header('Location: ' . PHPCI_URL); die; } } diff --git a/PHPCI/Controller/UserController.php b/PHPCI/Controller/UserController.php index dc77ff0a..2160bd9b 100644 --- a/PHPCI/Controller/UserController.php +++ b/PHPCI/Controller/UserController.php @@ -76,7 +76,7 @@ class UserController extends b8\Controller $user = $this->_userStore->save($user); - header('Location: /user'); + header('Location: '.PHPCI_URL.'user'); die; } @@ -120,7 +120,7 @@ class UserController extends b8\Controller $user->setValues($values); $user = $this->_userStore->save($user); - header('Location: /user'); + header('Location: '.PHPCI_URL.'user'); die; } @@ -179,7 +179,7 @@ class UserController extends b8\Controller $user = $this->_userStore->getById($userId); $this->_userStore->delete($user); - header('Location: /user'); + header('Location: '.PHPCI_URL.'user'); die; } } diff --git a/PHPCI/View/Build.phtml b/PHPCI/View/Build.phtml index 9f4effad..b5aa7324 100644 --- a/PHPCI/View/Build.phtml +++ b/PHPCI/View/Build.phtml @@ -7,13 +7,13 @@
@@ -69,7 +69,7 @@ getStatus() == 0 || $build->getStatus() == 1 || true): ?> setInterval(function() { - $.getJSON('/build/data/getId(); ?>', updateBuildView); + $.getJSON('build/data/getId(); ?>', updateBuildView); }, 10000); diff --git a/PHPCI/View/BuildsTable.phtml b/PHPCI/View/BuildsTable.phtml index 1508b95f..8ced123f 100644 --- a/PHPCI/View/BuildsTable.phtml +++ b/PHPCI/View/BuildsTable.phtml @@ -31,20 +31,20 @@ switch($build->getStatus()) } ?> - #getId(), 6, '0', STR_PAD_LEFT); ?> - getProject()->getTitle(); ?> + #getId(), 6, '0', STR_PAD_LEFT); ?> + getProject()->getTitle(); ?> getCommitId(); ?> getBranch(); ?>
- View + View User()->getIsAdmin()): ?>
diff --git a/PHPCI/View/Index.phtml b/PHPCI/View/Index.phtml index 2dcea736..4a53ec33 100644 --- a/PHPCI/View/Index.phtml +++ b/PHPCI/View/Index.phtml @@ -5,8 +5,8 @@
@@ -61,6 +61,6 @@ \ No newline at end of file diff --git a/PHPCI/View/Layout.phtml b/PHPCI/View/Layout.phtml index 1aab6115..f5b95baf 100644 --- a/PHPCI/View/Layout.phtml +++ b/PHPCI/View/Layout.phtml @@ -7,24 +7,24 @@ - - + + - - + +