Merge branch 'master' into fixes-for-windows
This commit is contained in:
commit
37bdffbbdd
|
@ -10,6 +10,7 @@
|
||||||
namespace PHPCI;
|
namespace PHPCI;
|
||||||
|
|
||||||
use b8;
|
use b8;
|
||||||
|
use b8\Exception\HttpException;
|
||||||
use b8\Http\Response;
|
use b8\Http\Response;
|
||||||
use b8\Http\Response\RedirectResponse;
|
use b8\Http\Response\RedirectResponse;
|
||||||
use b8\View;
|
use b8\View;
|
||||||
|
@ -51,6 +52,7 @@ class Application extends b8\Application
|
||||||
$response->setResponseCode(401);
|
$response->setResponseCode(401);
|
||||||
$response->setContent('');
|
$response->setContent('');
|
||||||
} else {
|
} else {
|
||||||
|
$_SESSION['login_redirect'] = substr($request->getPath(), 1);
|
||||||
$response = new RedirectResponse($response);
|
$response = new RedirectResponse($response);
|
||||||
$response->setHeader('Location', PHPCI_URL.'session/login');
|
$response->setHeader('Location', PHPCI_URL.'session/login');
|
||||||
}
|
}
|
||||||
|
@ -69,7 +71,25 @@ class Application extends b8\Application
|
||||||
*/
|
*/
|
||||||
public function handleRequest()
|
public function handleRequest()
|
||||||
{
|
{
|
||||||
$this->response = parent::handleRequest();
|
try {
|
||||||
|
$this->response = parent::handleRequest();
|
||||||
|
} catch (HttpException $ex) {
|
||||||
|
$this->config->set('page_title', 'Error');
|
||||||
|
|
||||||
|
$view = new View('exception');
|
||||||
|
$view->exception = $ex;
|
||||||
|
|
||||||
|
$this->response->setResponseCode($ex->getErrorCode());
|
||||||
|
$this->response->setContent($view->render());
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
$this->config->set('page_title', 'Error');
|
||||||
|
|
||||||
|
$view = new View('exception');
|
||||||
|
$view->exception = $ex;
|
||||||
|
|
||||||
|
$this->response->setResponseCode(500);
|
||||||
|
$this->response->setContent($view->render());
|
||||||
|
}
|
||||||
|
|
||||||
if (View::exists('layout') && $this->response->hasLayout()) {
|
if (View::exists('layout') && $this->response->hasLayout()) {
|
||||||
$view = new View('layout');
|
$view = new View('layout');
|
||||||
|
|
|
@ -21,11 +21,16 @@ class BuildFactory
|
||||||
/**
|
/**
|
||||||
* @param $buildId
|
* @param $buildId
|
||||||
* @return Build
|
* @return Build
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function getBuildById($buildId)
|
public static function getBuildById($buildId)
|
||||||
{
|
{
|
||||||
$build = Factory::getStore('Build')->getById($buildId);
|
$build = Factory::getStore('Build')->getById($buildId);
|
||||||
|
|
||||||
|
if (empty($build)) {
|
||||||
|
throw new \Exception('Build ID ' . $buildId . ' does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
return self::getBuild($build);
|
return self::getBuild($build);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
namespace PHPCI\Controller;
|
namespace PHPCI\Controller;
|
||||||
|
|
||||||
use b8;
|
use b8;
|
||||||
|
use b8\Exception\HttpException\NotFoundException;
|
||||||
use PHPCI\BuildFactory;
|
use PHPCI\BuildFactory;
|
||||||
use PHPCI\Model\Build;
|
use PHPCI\Model\Build;
|
||||||
|
|
||||||
|
@ -36,7 +37,16 @@ class BuildController extends \PHPCI\Controller
|
||||||
*/
|
*/
|
||||||
public function view($buildId)
|
public function view($buildId)
|
||||||
{
|
{
|
||||||
$build = BuildFactory::getBuildById($buildId);
|
try {
|
||||||
|
$build = BuildFactory::getBuildById($buildId);
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
$build = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($build)) {
|
||||||
|
throw new NotFoundException('Build with ID: ' . $buildId . ' does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->view->plugins = $this->getUiPlugins();
|
$this->view->plugins = $this->getUiPlugins();
|
||||||
$this->view->build = $build;
|
$this->view->build = $build;
|
||||||
$this->view->data = $this->getBuildData($build);
|
$this->view->data = $this->getBuildData($build);
|
||||||
|
@ -110,6 +120,10 @@ class BuildController extends \PHPCI\Controller
|
||||||
{
|
{
|
||||||
$copy = BuildFactory::getBuildById($buildId);
|
$copy = BuildFactory::getBuildById($buildId);
|
||||||
|
|
||||||
|
if (empty($copy)) {
|
||||||
|
throw new NotFoundException('Build with ID: ' . $buildId . ' does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
$build = new Build();
|
$build = new Build();
|
||||||
$build->setProjectId($copy->getProjectId());
|
$build->setProjectId($copy->getProjectId());
|
||||||
$build->setCommitId($copy->getCommitId());
|
$build->setCommitId($copy->getCommitId());
|
||||||
|
@ -134,11 +148,10 @@ class BuildController extends \PHPCI\Controller
|
||||||
throw new \Exception('You do not have permission to do that.');
|
throw new \Exception('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$build = BuildFactory::getBuildById($buildId);
|
$build = BuildFactory::getBuildById($buildId);
|
||||||
|
|
||||||
if (!$build) {
|
if (empty($build)) {
|
||||||
$this->response->setResponseCode(404);
|
throw new NotFoundException('Build with ID: ' . $buildId . ' does not exist.');
|
||||||
return '404 - Not Found';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->buildStore->delete($build);
|
$this->buildStore->delete($build);
|
||||||
|
|
|
@ -65,7 +65,8 @@ class BuildStatusController extends \PHPCI\Controller
|
||||||
public function view($projectId)
|
public function view($projectId)
|
||||||
{
|
{
|
||||||
$project = $this->projectStore->getById($projectId);
|
$project = $this->projectStore->getById($projectId);
|
||||||
if (!$project) {
|
|
||||||
|
if (empty($project)) {
|
||||||
throw new NotFoundException('Project with id: ' . $projectId . ' not found');
|
throw new NotFoundException('Project with id: ' . $projectId . ' not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,17 +9,17 @@
|
||||||
|
|
||||||
namespace PHPCI\Controller;
|
namespace PHPCI\Controller;
|
||||||
|
|
||||||
|
use b8;
|
||||||
|
use b8\Controller;
|
||||||
|
use b8\Form;
|
||||||
|
use b8\Exception\HttpException\ForbiddenException;
|
||||||
|
use b8\Exception\HttpException\NotFoundException;
|
||||||
|
use b8\Store;
|
||||||
use PHPCI\BuildFactory;
|
use PHPCI\BuildFactory;
|
||||||
use PHPCI\Helper\Github;
|
use PHPCI\Helper\Github;
|
||||||
use PHPCI\Helper\SshKey;
|
use PHPCI\Helper\SshKey;
|
||||||
use PHPCI\Model\Build;
|
use PHPCI\Model\Build;
|
||||||
use PHPCI\Model\Project;
|
use PHPCI\Model\Project;
|
||||||
use b8;
|
|
||||||
use b8\Config;
|
|
||||||
use b8\Controller;
|
|
||||||
use b8\Store;
|
|
||||||
use b8\Form;
|
|
||||||
use b8\Exception\HttpException\NotFoundException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project Controller - Allows users to create, edit and view projects.
|
* Project Controller - Allows users to create, edit and view projects.
|
||||||
|
@ -41,8 +41,8 @@ class ProjectController extends \PHPCI\Controller
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->buildStore = Store\Factory::getStore('Build');
|
$this->buildStore = Store\Factory::getStore('Build');
|
||||||
$this->projectStore = Store\Factory::getStore('Project');
|
$this->projectStore = Store\Factory::getStore('Project');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,17 +51,18 @@ class ProjectController extends \PHPCI\Controller
|
||||||
public function view($projectId)
|
public function view($projectId)
|
||||||
{
|
{
|
||||||
$project = $this->projectStore->getById($projectId);
|
$project = $this->projectStore->getById($projectId);
|
||||||
if (!$project) {
|
|
||||||
|
if (empty($project)) {
|
||||||
throw new NotFoundException('Project with id: ' . $projectId . ' not found');
|
throw new NotFoundException('Project with id: ' . $projectId . ' not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = $this->getParam('p', 1);
|
$page = $this->getParam('p', 1);
|
||||||
$builds = $this->getLatestBuildsHtml($projectId, (($page - 1) * 10));
|
$builds = $this->getLatestBuildsHtml($projectId, (($page - 1) * 10));
|
||||||
|
|
||||||
$this->view->builds = $builds[0];
|
$this->view->builds = $builds[0];
|
||||||
$this->view->total = $builds[1];
|
$this->view->total = $builds[1];
|
||||||
$this->view->project = $project;
|
$this->view->project = $project;
|
||||||
$this->view->page = $page;
|
$this->view->page = $page;
|
||||||
|
|
||||||
$this->config->set('page_title', $project->getTitle());
|
$this->config->set('page_title', $project->getTitle());
|
||||||
|
|
||||||
|
@ -76,6 +77,10 @@ class ProjectController extends \PHPCI\Controller
|
||||||
/* @var \PHPCI\Model\Project $project */
|
/* @var \PHPCI\Model\Project $project */
|
||||||
$project = $this->projectStore->getById($projectId);
|
$project = $this->projectStore->getById($projectId);
|
||||||
|
|
||||||
|
if (empty($project)) {
|
||||||
|
throw new NotFoundException('Project with id: ' . $projectId . ' not found');
|
||||||
|
}
|
||||||
|
|
||||||
$build = new Build();
|
$build = new Build();
|
||||||
$build->setProjectId($projectId);
|
$build->setProjectId($projectId);
|
||||||
$build->setCommitId('Manual');
|
$build->setCommitId('Manual');
|
||||||
|
@ -96,7 +101,7 @@ class ProjectController extends \PHPCI\Controller
|
||||||
public function delete($projectId)
|
public function delete($projectId)
|
||||||
{
|
{
|
||||||
if (!$_SESSION['user']->getIsAdmin()) {
|
if (!$_SESSION['user']->getIsAdmin()) {
|
||||||
throw new \Exception('You do not have permission to do that.');
|
throw new ForbiddenException('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$project = $this->projectStore->getById($projectId);
|
$project = $this->projectStore->getById($projectId);
|
||||||
|
@ -120,10 +125,10 @@ class ProjectController extends \PHPCI\Controller
|
||||||
*/
|
*/
|
||||||
protected function getLatestBuildsHtml($projectId, $start = 0)
|
protected function getLatestBuildsHtml($projectId, $start = 0)
|
||||||
{
|
{
|
||||||
$criteria = array('project_id' => $projectId);
|
$criteria = array('project_id' => $projectId);
|
||||||
$order = array('id' => 'DESC');
|
$order = array('id' => 'DESC');
|
||||||
$builds = $this->buildStore->getWhere($criteria, 10, $start, array(), $order);
|
$builds = $this->buildStore->getWhere($criteria, 10, $start, array(), $order);
|
||||||
$view = new b8\View('BuildsTable');
|
$view = new b8\View('BuildsTable');
|
||||||
|
|
||||||
foreach ($builds['items'] as &$build) {
|
foreach ($builds['items'] as &$build) {
|
||||||
$build = BuildFactory::getBuild($build);
|
$build = BuildFactory::getBuild($build);
|
||||||
|
@ -142,7 +147,7 @@ class ProjectController extends \PHPCI\Controller
|
||||||
$this->config->set('page_title', 'Add Project');
|
$this->config->set('page_title', 'Add Project');
|
||||||
|
|
||||||
if (!$_SESSION['user']->getIsAdmin()) {
|
if (!$_SESSION['user']->getIsAdmin()) {
|
||||||
throw new \Exception('You do not have permission to do that.');
|
throw new ForbiddenException('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$method = $this->request->getMethod();
|
$method = $this->request->getMethod();
|
||||||
|
@ -210,31 +215,33 @@ class ProjectController extends \PHPCI\Controller
|
||||||
public function edit($projectId)
|
public function edit($projectId)
|
||||||
{
|
{
|
||||||
if (!$_SESSION['user']->getIsAdmin()) {
|
if (!$_SESSION['user']->getIsAdmin()) {
|
||||||
throw new \Exception('You do not have permission to do that.');
|
throw new ForbiddenException('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$method = $this->request->getMethod();
|
$method = $this->request->getMethod();
|
||||||
$project = $this->projectStore->getById($projectId);
|
$project = $this->projectStore->getById($projectId);
|
||||||
|
|
||||||
|
if (empty($project)) {
|
||||||
|
throw new NotFoundException('Project with id: ' . $projectId . ' not found');
|
||||||
|
}
|
||||||
|
|
||||||
$this->config->set('page_title', 'Edit: ' . $project->getTitle());
|
$this->config->set('page_title', 'Edit: ' . $project->getTitle());
|
||||||
|
|
||||||
|
$values = $project->getDataArray();
|
||||||
|
$values['key'] = $values['git_key'];
|
||||||
|
$values['pubkey'] = $values['public_key'];
|
||||||
|
|
||||||
|
if ($values['type'] == "gitlab") {
|
||||||
|
$accessInfo = $project->getAccessInformation();
|
||||||
|
$reference = $accessInfo["user"].'@'.$accessInfo["domain"].':' . $project->getReference().".git";
|
||||||
|
$values['reference'] = $reference;
|
||||||
|
}
|
||||||
|
|
||||||
if ($method == 'POST') {
|
if ($method == 'POST') {
|
||||||
$values = $this->getParams();
|
$values = $this->getParams();
|
||||||
} else {
|
|
||||||
$values = $project->getDataArray();
|
|
||||||
$values['key'] = $values['git_key'];
|
|
||||||
$values['pubkey'] = $values['public_key'];
|
|
||||||
|
|
||||||
if ($values['type'] == "gitlab") {
|
|
||||||
$accessInfo = $project->getAccessInformation();
|
|
||||||
$reference = $accessInfo["user"].'@'.$accessInfo["domain"].':' . $project->getReference().".git";
|
|
||||||
$values['reference'] = $reference;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$form = $this->projectForm($values, 'edit/' . $projectId);
|
||||||
$form = $this->projectForm($values, 'edit/' . $projectId);
|
|
||||||
|
|
||||||
if ($method != 'POST' || ($method == 'POST' && !$form->validate())) {
|
if ($method != 'POST' || ($method == 'POST' && !$form->validate())) {
|
||||||
$view = new b8\View('ProjectForm');
|
$view = new b8\View('ProjectForm');
|
||||||
|
|
|
@ -43,7 +43,7 @@ class SessionController extends \PHPCI\Controller
|
||||||
|
|
||||||
if ($user && password_verify($this->getParam('password', ''), $user->getHash())) {
|
if ($user && password_verify($this->getParam('password', ''), $user->getHash())) {
|
||||||
$_SESSION['user_id'] = $user->getId();
|
$_SESSION['user_id'] = $user->getId();
|
||||||
header('Location: ' . PHPCI_URL);
|
header('Location: ' . $this->getLoginRedirect());
|
||||||
die;
|
die;
|
||||||
} else {
|
} else {
|
||||||
$isLoginFailure = true;
|
$isLoginFailure = true;
|
||||||
|
@ -159,4 +159,16 @@ MSG;
|
||||||
|
|
||||||
return $this->view->render();
|
return $this->view->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getLoginRedirect()
|
||||||
|
{
|
||||||
|
$rtn = PHPCI_URL;
|
||||||
|
|
||||||
|
if (!empty($_SESSION['login_redirect'])) {
|
||||||
|
$rtn .= $_SESSION['login_redirect'];
|
||||||
|
$_SESSION['login_redirect'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rtn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
namespace PHPCI\Controller;
|
namespace PHPCI\Controller;
|
||||||
|
|
||||||
use b8;
|
use b8;
|
||||||
|
use b8\Exception\HttpException\ForbiddenException;
|
||||||
|
use b8\Exception\HttpException\NotFoundException;
|
||||||
use b8\Form;
|
use b8\Form;
|
||||||
use PHPCI\Controller;
|
use PHPCI\Controller;
|
||||||
use PHPCI\Model\User;
|
use PHPCI\Model\User;
|
||||||
|
@ -106,12 +108,11 @@ class UserController extends Controller
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
if (!$_SESSION['user']->getIsAdmin()) {
|
if (!$_SESSION['user']->getIsAdmin()) {
|
||||||
throw new \Exception('You do not have permission to do that.');
|
throw new ForbiddenException('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->config->set('page_title', 'Add User');
|
$this->config->set('page_title', 'Add User');
|
||||||
|
|
||||||
|
|
||||||
$method = $this->request->getMethod();
|
$method = $this->request->getMethod();
|
||||||
|
|
||||||
if ($method == 'POST') {
|
if ($method == 'POST') {
|
||||||
|
@ -132,7 +133,6 @@ class UserController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$values = $form->getValues();
|
$values = $form->getValues();
|
||||||
$values['is_admin'] = $values['admin'] ? 1 : 0;
|
|
||||||
$values['hash'] = password_hash($values['password'], PASSWORD_DEFAULT);
|
$values['hash'] = password_hash($values['password'], PASSWORD_DEFAULT);
|
||||||
|
|
||||||
$user = new User();
|
$user = new User();
|
||||||
|
@ -150,42 +150,40 @@ class UserController extends Controller
|
||||||
public function edit($userId)
|
public function edit($userId)
|
||||||
{
|
{
|
||||||
if (!$_SESSION['user']->getIsAdmin()) {
|
if (!$_SESSION['user']->getIsAdmin()) {
|
||||||
throw new \Exception('You do not have permission to do that.');
|
throw new ForbiddenException('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$method = $this->request->getMethod();
|
$method = $this->request->getMethod();
|
||||||
$user = $this->userStore->getById($userId);
|
$user = $this->userStore->getById($userId);
|
||||||
|
|
||||||
$this->config->set('page_title', 'Edit: ' . $user->getName());
|
if (empty($user)) {
|
||||||
|
throw new NotFoundException('User with ID: ' . $userId . ' does not exist.');
|
||||||
|
|
||||||
if ($method == 'POST') {
|
|
||||||
$values = $this->getParams();
|
|
||||||
} else {
|
|
||||||
$values = $user->getDataArray();
|
|
||||||
$values['admin'] = $values['is_admin'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = $this->userForm($values, 'edit/' . $userId);
|
$values = array_merge($user->getDataArray(), $this->getParams());
|
||||||
|
$form = $this->userForm($values, 'edit/' . $userId);
|
||||||
|
|
||||||
if ($method != 'POST' || ($method == 'POST' && !$form->validate())) {
|
if ($method != 'POST' || ($method == 'POST' && !$form->validate())) {
|
||||||
$view = new b8\View('UserForm');
|
$view = new b8\View('UserForm');
|
||||||
$view->type = 'edit';
|
$view->type = 'edit';
|
||||||
$view->user = $user;
|
$view->user = $user;
|
||||||
$view->form = $form;
|
$view->form = $form;
|
||||||
|
|
||||||
return $view->render();
|
return $view->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
$values = $form->getValues();
|
|
||||||
$values['is_admin'] = $values['admin'] ? 1 : 0;
|
|
||||||
|
|
||||||
if (!empty($values['password'])) {
|
if (!empty($values['password'])) {
|
||||||
$values['hash'] = password_hash($values['password'], PASSWORD_DEFAULT);
|
$values['hash'] = password_hash($values['password'], PASSWORD_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->setValues($values);
|
$user->setValues($values);
|
||||||
$user = $this->userStore->save($user);
|
|
||||||
|
$isAdmin = $this->getParam('is_admin');
|
||||||
|
if (empty($isAdmin)) {
|
||||||
|
$user->setIsAdmin(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->userStore->save($user);
|
||||||
|
|
||||||
header('Location: '.PHPCI_URL.'user');
|
header('Location: '.PHPCI_URL.'user');
|
||||||
die;
|
die;
|
||||||
|
@ -216,13 +214,20 @@ class UserController extends Controller
|
||||||
$form->addField($field);
|
$form->addField($field);
|
||||||
|
|
||||||
$field = new Form\Element\Password('password');
|
$field = new Form\Element\Password('password');
|
||||||
$field->setRequired(true);
|
|
||||||
$field->setLabel('Password' . ($type == 'edit' ? ' (leave blank to keep current password)' : ''));
|
if ($type == 'add') {
|
||||||
|
$field->setRequired(true);
|
||||||
|
$field->setLabel('Password');
|
||||||
|
} else {
|
||||||
|
$field->setRequired(false);
|
||||||
|
$field->setLabel('Password (leave blank to keep current password)');
|
||||||
|
}
|
||||||
|
|
||||||
$field->setClass('form-control');
|
$field->setClass('form-control');
|
||||||
$field->setContainerClass('form-group');
|
$field->setContainerClass('form-group');
|
||||||
$form->addField($field);
|
$form->addField($field);
|
||||||
|
|
||||||
$field = new Form\Element\Checkbox('admin');
|
$field = new Form\Element\Checkbox('is_admin');
|
||||||
$field->setRequired(false);
|
$field->setRequired(false);
|
||||||
$field->setCheckedValue(1);
|
$field->setCheckedValue(1);
|
||||||
$field->setLabel('Is this user an administrator?');
|
$field->setLabel('Is this user an administrator?');
|
||||||
|
@ -244,10 +249,15 @@ class UserController extends Controller
|
||||||
public function delete($userId)
|
public function delete($userId)
|
||||||
{
|
{
|
||||||
if (!$_SESSION['user']->getIsAdmin()) {
|
if (!$_SESSION['user']->getIsAdmin()) {
|
||||||
throw new \Exception('You do not have permission to do that.');
|
throw new ForbiddenException('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->userStore->getById($userId);
|
$user = $this->userStore->getById($userId);
|
||||||
|
|
||||||
|
if (empty($user)) {
|
||||||
|
throw new NotFoundException('User with ID: ' . $userId . ' does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->userStore->delete($user);
|
$this->userStore->delete($user);
|
||||||
|
|
||||||
header('Location: '.PHPCI_URL.'user');
|
header('Location: '.PHPCI_URL.'user');
|
||||||
|
|
|
@ -89,13 +89,7 @@ class PhpDocblockChecker implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
||||||
*/
|
*/
|
||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
$ignore = '';
|
// Check that the binary exists:
|
||||||
if (count($this->ignore)) {
|
|
||||||
$ignore = ' --exclude="' . implode(',', $this->ignore) . '"';
|
|
||||||
}
|
|
||||||
|
|
||||||
var_dump($ignore);
|
|
||||||
|
|
||||||
$checker = $this->phpci->findBinary('phpdoccheck');
|
$checker = $this->phpci->findBinary('phpdoccheck');
|
||||||
|
|
||||||
if (!$checker) {
|
if (!$checker) {
|
||||||
|
@ -103,9 +97,25 @@ class PhpDocblockChecker implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = $this->phpci->buildPath . $this->path;
|
// Build ignore string:
|
||||||
|
$ignore = '';
|
||||||
|
if (count($this->ignore)) {
|
||||||
|
$ignore = ' --exclude="' . implode(',', $this->ignore) . '"';
|
||||||
|
}
|
||||||
|
|
||||||
$cmd = $checker . ' --json --directory="%s"%s%s%s';
|
// Are we skipping any checks?
|
||||||
|
$add = '';
|
||||||
|
if ($this->skipClasses) {
|
||||||
|
$add .= ' --skip-classes';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->skipMethods) {
|
||||||
|
$add .= ' --skip-methods';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build command string:
|
||||||
|
$path = $this->phpci->buildPath . $this->path;
|
||||||
|
$cmd = $checker . ' --json --directory="%s"%s%s';
|
||||||
|
|
||||||
// Disable exec output logging, as we don't want the XML report in the log:
|
// Disable exec output logging, as we don't want the XML report in the log:
|
||||||
$this->phpci->logExecOutput(false);
|
$this->phpci->logExecOutput(false);
|
||||||
|
@ -115,8 +125,7 @@ class PhpDocblockChecker implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
||||||
$cmd,
|
$cmd,
|
||||||
$path,
|
$path,
|
||||||
$ignore,
|
$ignore,
|
||||||
($this->skipClasses ? ' --skip-classes' : ''),
|
$add
|
||||||
($this->skipMethods ? ' --skip-methods' : '')
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Re-enable exec output logging:
|
// Re-enable exec output logging:
|
||||||
|
|
|
@ -58,7 +58,7 @@ class PhpSpec implements PHPCI\Plugin
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$success = $this->phpci->executeCommand($phpspec . ' --format=pretty --no-code-generation');
|
$success = $this->phpci->executeCommand($phpspec . ' --format=pretty --no-code-generation run');
|
||||||
|
|
||||||
chdir($curdir);
|
chdir($curdir);
|
||||||
|
|
||||||
|
|
9
PHPCI/View/exception.phtml
Normal file
9
PHPCI/View/exception.phtml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<div class="panel panel-danger">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h2 class="panel-title">Sorry, there was a problem</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="panel-body">
|
||||||
|
<?php print $exception->getMessage(); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -59,8 +59,10 @@ if (!file_exists(dirname(__FILE__) . '/vendor/autoload.php') && defined('PHPCI_I
|
||||||
// Load Composer autoloader:
|
// Load Composer autoloader:
|
||||||
require_once(dirname(__FILE__) . '/vendor/autoload.php');
|
require_once(dirname(__FILE__) . '/vendor/autoload.php');
|
||||||
|
|
||||||
$loggerConfig = LoggerConfig::newFromFile(__DIR__ . "/loggerconfig.php");
|
if (defined('PHPCI_IS_CONSOLE') && PHPCI_IS_CONSOLE) {
|
||||||
Handler::register($loggerConfig->getFor('_'));
|
$loggerConfig = LoggerConfig::newFromFile(__DIR__ . "/loggerconfig.php");
|
||||||
|
Handler::register($loggerConfig->getFor('_'));
|
||||||
|
}
|
||||||
|
|
||||||
// Load configuration if present:
|
// Load configuration if present:
|
||||||
$conf = array();
|
$conf = array();
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.3",
|
"php": ">=5.3.8",
|
||||||
"ext-mcrypt": "*",
|
"ext-mcrypt": "*",
|
||||||
"ext-pdo": "*",
|
"ext-pdo": "*",
|
||||||
"ext-pdo_mysql": "*",
|
"ext-pdo_mysql": "*",
|
||||||
|
|
4
composer.lock
generated
4
composer.lock
generated
|
@ -3,7 +3,7 @@
|
||||||
"This file locks the dependencies of your project to a known state",
|
"This file locks the dependencies of your project to a known state",
|
||||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||||
],
|
],
|
||||||
"hash": "0692857385ac27090b3000cbc680ced8",
|
"hash": "07244b4e81274ba07fdb9f0166c73678",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "block8/b8framework",
|
"name": "block8/b8framework",
|
||||||
|
@ -885,7 +885,7 @@
|
||||||
|
|
||||||
],
|
],
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": ">=5.3.3",
|
"php": ">=5.3.8",
|
||||||
"ext-mcrypt": "*",
|
"ext-mcrypt": "*",
|
||||||
"ext-pdo": "*",
|
"ext-pdo": "*",
|
||||||
"ext-pdo_mysql": "*"
|
"ext-pdo_mysql": "*"
|
||||||
|
|
|
@ -4,6 +4,7 @@ var locPlugin = PHPCI.UiPlugin.extend({
|
||||||
title: 'Lines of Code',
|
title: 'Lines of Code',
|
||||||
lastData: null,
|
lastData: null,
|
||||||
displayOnUpdate: false,
|
displayOnUpdate: false,
|
||||||
|
rendered: false,
|
||||||
|
|
||||||
register: function() {
|
register: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -14,8 +15,7 @@ var locPlugin = PHPCI.UiPlugin.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('build-updated', function(data) {
|
$(window).on('build-updated', function(data) {
|
||||||
if (data.queryData.status > 1) {
|
if (data.queryData.status > 1 && !self.rendered) {
|
||||||
self.displayOnUpdate = true;
|
|
||||||
query();
|
query();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -29,10 +29,7 @@ var locPlugin = PHPCI.UiPlugin.extend({
|
||||||
|
|
||||||
onUpdate: function(e) {
|
onUpdate: function(e) {
|
||||||
this.lastData = e.queryData;
|
this.lastData = e.queryData;
|
||||||
|
this.displayChart();
|
||||||
if (this.displayOnUpdate) {
|
|
||||||
this.displayChart();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
displayChart: function() {
|
displayChart: function() {
|
||||||
|
@ -42,6 +39,8 @@ var locPlugin = PHPCI.UiPlugin.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.rendered = true;
|
||||||
|
|
||||||
$('#phploc-lines').empty().animate({height: '275px'});
|
$('#phploc-lines').empty().animate({height: '275px'});
|
||||||
|
|
||||||
var titles = ['Build', 'Lines', 'Comment Lines', 'Non-Comment Lines', 'Logical Lines'];
|
var titles = ['Build', 'Lines', 'Comment Lines', 'Non-Comment Lines', 'Logical Lines'];
|
||||||
|
|
|
@ -3,8 +3,8 @@ var phpcsPlugin = PHPCI.UiPlugin.extend({
|
||||||
css: 'col-lg-12 col-md-12 col-sm-12 col-xs-12',
|
css: 'col-lg-12 col-md-12 col-sm-12 col-xs-12',
|
||||||
title: 'PHP Code Sniffer',
|
title: 'PHP Code Sniffer',
|
||||||
lastData: null,
|
lastData: null,
|
||||||
displayOnUpdate: false,
|
|
||||||
box: true,
|
box: true,
|
||||||
|
rendered: false,
|
||||||
|
|
||||||
register: function() {
|
register: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -14,16 +14,14 @@ var phpcsPlugin = PHPCI.UiPlugin.extend({
|
||||||
self.onUpdate(data);
|
self.onUpdate(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('build-updated', function(data) {
|
$(window).on('build-updated', function() {
|
||||||
if (data.queryData.status > 1) {
|
if (!self.rendered) {
|
||||||
self.displayOnUpdate = true;
|
|
||||||
query();
|
query();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
||||||
return $('<table class="table table-striped" id="phpcs-data">' +
|
return $('<table class="table table-striped" id="phpcs-data">' +
|
||||||
'<thead>' +
|
'<thead>' +
|
||||||
'<tr>' +
|
'<tr>' +
|
||||||
|
@ -35,10 +33,11 @@ var phpcsPlugin = PHPCI.UiPlugin.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
onUpdate: function(e) {
|
onUpdate: function(e) {
|
||||||
if (this.lastData && this.lastData[0]) {
|
if (!e.queryData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.rendered = true;
|
||||||
this.lastData = e.queryData;
|
this.lastData = e.queryData;
|
||||||
|
|
||||||
var errors = this.lastData[0].meta_value;
|
var errors = this.lastData[0].meta_value;
|
||||||
|
|
|
@ -5,6 +5,7 @@ var phpdoccheckPlugin = PHPCI.UiPlugin.extend({
|
||||||
lastData: null,
|
lastData: null,
|
||||||
displayOnUpdate: false,
|
displayOnUpdate: false,
|
||||||
box: true,
|
box: true,
|
||||||
|
rendered: false,
|
||||||
|
|
||||||
register: function() {
|
register: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -14,8 +15,8 @@ var phpdoccheckPlugin = PHPCI.UiPlugin.extend({
|
||||||
self.onUpdate(data);
|
self.onUpdate(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('build-updated', function(data) {
|
$(window).on('build-updated', function() {
|
||||||
if (data.queryData.status > 1) {
|
if (!self.rendered) {
|
||||||
self.displayOnUpdate = true;
|
self.displayOnUpdate = true;
|
||||||
query();
|
query();
|
||||||
}
|
}
|
||||||
|
@ -23,7 +24,6 @@ var phpdoccheckPlugin = PHPCI.UiPlugin.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
||||||
return $('<table class="table table-striped" id="phpdoccheck-data">' +
|
return $('<table class="table table-striped" id="phpdoccheck-data">' +
|
||||||
'<thead>' +
|
'<thead>' +
|
||||||
'<tr>' +
|
'<tr>' +
|
||||||
|
@ -37,10 +37,11 @@ var phpdoccheckPlugin = PHPCI.UiPlugin.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
onUpdate: function(e) {
|
onUpdate: function(e) {
|
||||||
if (this.lastData && this.lastData[0]) {
|
if (!e.queryData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.rendered = true;
|
||||||
this.lastData = e.queryData;
|
this.lastData = e.queryData;
|
||||||
|
|
||||||
var errors = this.lastData[0].meta_value;
|
var errors = this.lastData[0].meta_value;
|
||||||
|
|
|
@ -5,6 +5,7 @@ var phpmdPlugin = PHPCI.UiPlugin.extend({
|
||||||
lastData: null,
|
lastData: null,
|
||||||
displayOnUpdate: false,
|
displayOnUpdate: false,
|
||||||
box: true,
|
box: true,
|
||||||
|
rendered: false,
|
||||||
|
|
||||||
register: function() {
|
register: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -14,8 +15,8 @@ var phpmdPlugin = PHPCI.UiPlugin.extend({
|
||||||
self.onUpdate(data);
|
self.onUpdate(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('build-updated', function(data) {
|
$(window).on('build-updated', function() {
|
||||||
if (data.queryData.status > 1) {
|
if (!self.rendered) {
|
||||||
self.displayOnUpdate = true;
|
self.displayOnUpdate = true;
|
||||||
query();
|
query();
|
||||||
}
|
}
|
||||||
|
@ -36,10 +37,11 @@ var phpmdPlugin = PHPCI.UiPlugin.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
onUpdate: function(e) {
|
onUpdate: function(e) {
|
||||||
if (this.lastData && this.lastData[0]) {
|
if (!e.queryData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.rendered = true;
|
||||||
this.lastData = e.queryData;
|
this.lastData = e.queryData;
|
||||||
|
|
||||||
var errors = this.lastData[0].meta_value;
|
var errors = this.lastData[0].meta_value;
|
||||||
|
|
|
@ -5,6 +5,7 @@ var phpunitPlugin = PHPCI.UiPlugin.extend({
|
||||||
lastData: null,
|
lastData: null,
|
||||||
displayOnUpdate: false,
|
displayOnUpdate: false,
|
||||||
box: true,
|
box: true,
|
||||||
|
rendered: false,
|
||||||
|
|
||||||
register: function() {
|
register: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -14,8 +15,8 @@ var phpunitPlugin = PHPCI.UiPlugin.extend({
|
||||||
self.onUpdate(data);
|
self.onUpdate(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('build-updated', function(data) {
|
$(window).on('build-updated', function() {
|
||||||
if (data.queryData.status > 1) {
|
if (!self.rendered) {
|
||||||
self.displayOnUpdate = true;
|
self.displayOnUpdate = true;
|
||||||
query();
|
query();
|
||||||
}
|
}
|
||||||
|
@ -33,10 +34,11 @@ var phpunitPlugin = PHPCI.UiPlugin.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
onUpdate: function(e) {
|
onUpdate: function(e) {
|
||||||
if (this.lastData && this.lastData[0]) {
|
if (!e.queryData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.rendered = true;
|
||||||
this.lastData = e.queryData;
|
this.lastData = e.queryData;
|
||||||
|
|
||||||
var tests = this.lastData[0].meta_value;
|
var tests = this.lastData[0].meta_value;
|
||||||
|
|
|
@ -12,6 +12,7 @@ var warningsPlugin = PHPCI.UiPlugin.extend({
|
||||||
},
|
},
|
||||||
data: {},
|
data: {},
|
||||||
displayOnUpdate: false,
|
displayOnUpdate: false,
|
||||||
|
rendered: false,
|
||||||
|
|
||||||
register: function() {
|
register: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -26,7 +27,7 @@ var warningsPlugin = PHPCI.UiPlugin.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('build-updated', function(data) {
|
$(window).on('build-updated', function(data) {
|
||||||
if (data.queryData.status > 1) {
|
if (!self.rendered && data.queryData.status > 1) {
|
||||||
self.displayOnUpdate = true;
|
self.displayOnUpdate = true;
|
||||||
for (var query in queries) {
|
for (var query in queries) {
|
||||||
queries[query]();
|
queries[query]();
|
||||||
|
@ -68,6 +69,7 @@ var warningsPlugin = PHPCI.UiPlugin.extend({
|
||||||
|
|
||||||
displayChart: function() {
|
displayChart: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
self.rendered = true;
|
||||||
|
|
||||||
$('#build-warnings').empty().animate({height: '275px'});
|
$('#build-warnings').empty().animate({height: '275px'});
|
||||||
|
|
||||||
|
|
|
@ -317,8 +317,19 @@ var PHPCIObject = Class.extend({
|
||||||
updateInterval: null,
|
updateInterval: null,
|
||||||
|
|
||||||
init: function(build) {
|
init: function(build) {
|
||||||
|
var self = this;
|
||||||
this.buildId = build;
|
this.buildId = build;
|
||||||
this.registerQuery('build-updated', 10);
|
this.registerQuery('build-updated', 10);
|
||||||
|
|
||||||
|
$(window).on('build-updated', function(data) {
|
||||||
|
|
||||||
|
// If the build has finished, stop updating every 10 seconds:
|
||||||
|
if (data.queryData.status > 1) {
|
||||||
|
self.cancelQuery('build-updated');
|
||||||
|
$(window).trigger({type: 'build-complete'});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
registerQuery: function(name, seconds, query) {
|
registerQuery: function(name, seconds, query) {
|
||||||
|
@ -337,12 +348,16 @@ var PHPCIObject = Class.extend({
|
||||||
};
|
};
|
||||||
|
|
||||||
if (seconds != -1) {
|
if (seconds != -1) {
|
||||||
setInterval(cb, seconds * 1000);
|
self.queries[name] = setInterval(cb, seconds * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cb;
|
return cb;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cancelQuery: function (name) {
|
||||||
|
clearInterval(this.queries[name]);
|
||||||
|
},
|
||||||
|
|
||||||
registerPlugin: function(plugin) {
|
registerPlugin: function(plugin) {
|
||||||
this.plugins[plugin.id] = plugin;
|
this.plugins[plugin.id] = plugin;
|
||||||
plugin.register();
|
plugin.register();
|
||||||
|
|
Loading…
Reference in a new issue