Replace "index.php" files with a controller.

This commit is contained in:
Dmitriy Simushev 2014-06-03 14:39:47 +00:00
parent 66a68d0f23
commit 1a628d39f7
7 changed files with 92 additions and 70 deletions

View File

@ -24,13 +24,18 @@ Options +FollowSymLinks
php_flag session.auto_start off php_flag session.auto_start off
</IfModule> </IfModule>
# Do not allow apache to automatically add trailing slashes for existing
# directories. They should be processed by the application.
<IfModule mod_dir.c>
DirectorySlash Off
</IfModule>
# Redirect requests to the front controller # Redirect requests to the front controller
<IfModule mod_rewrite.c> <IfModule mod_rewrite.c>
RewriteEngine On RewriteEngine On
# Alter only requests for files and directories that do not exist # Alter only requests for files that do not exist
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all requests to front controller # Rewrite all requests to front controller
RewriteRule ^(.*)$ app.php [QSA,L] RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule> </IfModule>

View File

@ -1,18 +0,0 @@
<?php
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
header("Location: operator/index.php");

View File

@ -0,0 +1,71 @@
<?php
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Mibew\Controller;
use Mibew\Settings;
use Symfony\Component\HttpFoundation\Request;
/**
* Generates content for home pages.
*/
class HomeController extends AbstractController
{
/**
* Redirects client's browser to operator's home page.
*
* @param Request $request Incoming request.
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function redirectAction(Request $request)
{
return $this->redirect($this->generateUrl('home_operator'));
}
/**
* Renders operator's home page.
*
* @param Request $request Incoming request
* @return string Rendered page content.
*/
public function dashboardAction(Request $request)
{
$operator = $this->getOperator();
$base_url = $request->getBaseUrl();
$is_online = is_operator_online($operator['operatorid']);
$page = array(
'version' => MIBEW_VERSION,
'localeLinks' => get_locale_links(),
'needUpdate' => Settings::get('dbversion') != DB_VERSION,
'needChangePassword' => check_password_hash($operator['vclogin'], '', $operator['vcpassword']),
'profilePage' => $base_url . '/operator/operator/' . $operator['operatorid'] . '/edit',
'updateWizard' => $base_url . '/install/',
'newFeatures' => Settings::get('featuresversion') != FEATURES_VERSION,
'featuresPage' => $base_url . '/operator/settings/features',
'isOnline' => $is_online,
'warnOffline' => true,
'title' => getlocal('topMenu.admin'),
'menuid' => 'main',
);
$page = array_merge($page, prepare_menu($operator));
return $this->render('index', $page);
}
}

View File

@ -218,7 +218,7 @@ class ProfileController extends AbstractController
// Redirect the admin to the home page if needed. // Redirect the admin to the home page if needed.
if ($to_dashboard) { if ($to_dashboard) {
return $this->redirect($request->getBasePath() . '/operator/index.php'); return $this->redirect($this->generateUrl('home_operator'));
} }
} }

View File

@ -304,6 +304,18 @@ history_user_track:
_controller: Mibew\Controller\HistoryController::userTrackAction _controller: Mibew\Controller\HistoryController::userTrackAction
_access_check: Mibew\AccessControl\Check\LoggedInCheck _access_check: Mibew\AccessControl\Check\LoggedInCheck
## Home
home:
path: /
defaults:
_controller: Mibew\Controller\HomeController::redirectAction
home_operator:
path: /operator
defaults:
_controller: Mibew\Controller\HomeController::dashboardAction
_access_check: Mibew\AccessControl\Check\LoggedInCheck
## Invitations ## Invitations
invite: invite:
path: /operator/invite path: /operator/invite

View File

@ -1,48 +0,0 @@
<?php
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Import namespaces and classes of the core
use Mibew\Settings;
use Mibew\Style\PageStyle;
// Initialize libraries
require_once(dirname(dirname(__FILE__)) . '/libs/init.php');
$operator = check_login();
force_password($operator);
$is_online = is_operator_online($operator['operatorid']);
$page = array(
'version' => MIBEW_VERSION,
'localeLinks' => get_locale_links(),
'needUpdate' => Settings::get('dbversion') != DB_VERSION,
'needChangePassword' => check_password_hash($operator['vclogin'], '', $operator['vcpassword']),
'profilePage' => MIBEW_WEB_ROOT . "/operator/operator/" . $operator['operatorid'] . '/edit',
'updateWizard' => MIBEW_WEB_ROOT . "/install/",
'newFeatures' => Settings::get('featuresversion') != FEATURES_VERSION,
'featuresPage' => MIBEW_WEB_ROOT . "/operator/settings/features",
'isOnline' => $is_online,
'warnOffline' => true,
'title' => getlocal("topMenu.admin"),
'menuid' => "main",
);
$page = array_merge($page, prepare_menu($operator));
$page_style = new PageStyle(PageStyle::getCurrentStyle());
$page_style->render('index', $page);

View File

@ -12,7 +12,7 @@
<li> <li>
<h2>{{l10n "right.main"}}</h2> <h2>{{l10n "right.main"}}</h2>
<ul class="submenu"> <ul class="submenu">
<li{{#ifEqual menuid "main"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/index.php">{{l10n "topMenu.main"}}</a></li> <li{{#ifEqual menuid "main"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator">{{l10n "topMenu.main"}}</a></li>
<li{{#ifEqual menuid "users"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/users">{{l10n "topMenu.users"}}</a> <span class="small">(<a class="inner" href="{{mibewRoot}}/operator/users?nomenu">{{l10n "topMenu.users.nomenu"}}</a>)</span></li> <li{{#ifEqual menuid "users"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/users">{{l10n "topMenu.users"}}</a> <span class="small">(<a class="inner" href="{{mibewRoot}}/operator/users?nomenu">{{l10n "topMenu.users.nomenu"}}</a>)</span></li>
<li{{#ifEqual menuid "history"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/history">{{l10n "page_analysis.search.title"}}</a></li> <li{{#ifEqual menuid "history"}} class="active"{{/ifEqual}}><a href="{{mibewRoot}}/operator/history">{{l10n "page_analysis.search.title"}}</a></li>
{{#if showstat}} {{#if showstat}}