Adding per-page titles throughout PHPCI, fixes #371
This commit is contained in:
parent
4ab390d950
commit
8685f2ac36
|
@ -73,6 +73,12 @@ class Application extends b8\Application
|
|||
|
||||
if (View::exists('layout') && $this->response->hasLayout()) {
|
||||
$view = new View('layout');
|
||||
$pageTitle = $this->config->get('page_title', null);
|
||||
|
||||
if (!is_null($pageTitle)) {
|
||||
$view->title = $pageTitle;
|
||||
}
|
||||
|
||||
$view->content = $this->response->getContent();
|
||||
$this->response->setContent($view->render());
|
||||
}
|
||||
|
|
|
@ -40,6 +40,9 @@ class BuildController extends \PHPCI\Controller
|
|||
$this->view->plugins = $this->getUiPlugins();
|
||||
$this->view->build = $build;
|
||||
$this->view->data = $this->getBuildData($build);
|
||||
|
||||
$title = 'Build #' . $build->getId() . ' - ' . $build->getProjectTitle();
|
||||
$this->config->set('page_title', $title);
|
||||
}
|
||||
|
||||
protected function getUiPlugins()
|
||||
|
|
|
@ -56,6 +56,8 @@ class HomeController extends \PHPCI\Controller
|
|||
$this->view->projects = $projects['items'];
|
||||
$this->view->summary = $summaryView->render();
|
||||
|
||||
$this->config->set('page_title', 'Dashboard');
|
||||
|
||||
return $this->view->render();
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,8 @@ class PluginController extends \PHPCI\Controller
|
|||
|
||||
$this->view->plugins = $pluginInfo->getInstalledPlugins();
|
||||
|
||||
$this->config->set('page_title', 'Plugins');
|
||||
|
||||
return $this->view->render();
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,8 @@ class ProjectController extends \PHPCI\Controller
|
|||
$this->view->project = $project;
|
||||
$this->view->page = $page;
|
||||
|
||||
$this->config->set('page_title', $project->getTitle());
|
||||
|
||||
return $this->view->render();
|
||||
}
|
||||
|
||||
|
@ -134,6 +136,8 @@ class ProjectController extends \PHPCI\Controller
|
|||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->config->set('page_title', 'Add Project');
|
||||
|
||||
if (!$_SESSION['user']->getIsAdmin()) {
|
||||
throw new \Exception('You do not have permission to do that.');
|
||||
}
|
||||
|
@ -229,6 +233,9 @@ class ProjectController extends \PHPCI\Controller
|
|||
$method = $this->request->getMethod();
|
||||
$project = $this->projectStore->getById($projectId);
|
||||
|
||||
$this->config->set('page_title', 'Edit: ' . $project->getTitle());
|
||||
|
||||
|
||||
if ($method == 'POST') {
|
||||
$values = $this->getParams();
|
||||
} else {
|
||||
|
|
|
@ -40,6 +40,8 @@ class UserController extends Controller
|
|||
$users = $this->userStore->getWhere(array(), 1000, 0, array(), array('email' => 'ASC'));
|
||||
$this->view->users = $users;
|
||||
|
||||
$this->config->set('page_title', 'Users');
|
||||
|
||||
return $this->view->render();
|
||||
}
|
||||
|
||||
|
@ -52,6 +54,9 @@ class UserController extends Controller
|
|||
throw new \Exception('You do not have permission to do that.');
|
||||
}
|
||||
|
||||
$this->config->set('page_title', 'Add User');
|
||||
|
||||
|
||||
$method = $this->request->getMethod();
|
||||
|
||||
if ($method == 'POST') {
|
||||
|
@ -96,6 +101,9 @@ class UserController extends Controller
|
|||
$method = $this->request->getMethod();
|
||||
$user = $this->userStore->getById($userId);
|
||||
|
||||
$this->config->set('page_title', 'Edit: ' . $user->getName());
|
||||
|
||||
|
||||
if ($method == 'POST') {
|
||||
$values = $this->getParams();
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>PHPCI</title>
|
||||
<title><?php if (!empty($title)) { print $title . ' - '; } ?>PHPCI</title>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
Loading…
Reference in a new issue