Merge in single site support for both the sandbox and a development box as well.
git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@839 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -251,24 +251,32 @@ class AppController extends Controller {
|
|||||||
array('controller' => 'tenders', 'action' => 'deposit'), null,
|
array('controller' => 'tenders', 'action' => 'deposit'), null,
|
||||||
'SITE', $this->op_area);
|
'SITE', $this->op_area);
|
||||||
|
|
||||||
if (sandbox()) {
|
$url_components = array('plugin', 'controller', 'action', 'named');
|
||||||
|
if (devbox()) {
|
||||||
|
/* $sources = ConnectionManager::sourceList(); */
|
||||||
|
/* $db = ConnectionManager::getDataSource($sources[0])->config['database']; */
|
||||||
|
/* $this->sideMenuAreaName($db, 'SANDBOX', $this->std_area); */
|
||||||
|
$this->sideMenuAreaName('DevBox', 'SANDBOX', $this->std_area);
|
||||||
|
$this->addSideMenuLink('Rebuild DevBox',
|
||||||
|
array('controller' => 'util', 'action' => 'rebuild_devbox'), null,
|
||||||
|
'SANDBOX');
|
||||||
|
}
|
||||||
|
elseif (sandbox()) {
|
||||||
$this->addSideMenuLink('Rebuild Sandbox',
|
$this->addSideMenuLink('Rebuild Sandbox',
|
||||||
array('controller' => 'util', 'action' => 'rebuild_sandbox'), null,
|
array('controller' => 'util', 'action' => 'rebuild_sandbox'), null,
|
||||||
'SANDBOX');
|
'SANDBOX');
|
||||||
$this->addSideMenuLink('Leave Sandbox',
|
$this->addSideMenuLink('Leave Sandbox',
|
||||||
((empty($_SERVER['HTTPS']) ? 'http://' : 'https://') .
|
array('sand_route' => false)
|
||||||
$_SERVER['SERVER_NAME'] .
|
+ array_intersect_key($this->params, array_flip($url_components))
|
||||||
preg_replace("%^/([^/]+)\.sand%", "/$1", $_SERVER['REQUEST_URI'])),
|
+ $this->params['pass'],
|
||||||
null,
|
null, 'SANDBOX');
|
||||||
'SANDBOX');
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->addSideMenuLink('Enter Sandbox',
|
$this->addSideMenuLink('Enter Sandbox',
|
||||||
((empty($_SERVER['HTTPS']) ? 'http://' : 'https://') .
|
array('sand_route' => true)
|
||||||
$_SERVER['SERVER_NAME'] .
|
+ array_intersect_key($this->params, array_flip($url_components))
|
||||||
preg_replace("%^/([^/]+)%", "/$1.sand", $_SERVER['REQUEST_URI'])),
|
+ $this->params['pass'],
|
||||||
null,
|
null, 'SANDBOX');
|
||||||
'SANDBOX');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// REVISIT <AP>: 20090824
|
// REVISIT <AP>: 20090824
|
||||||
@@ -297,8 +305,11 @@ class AppController extends Controller {
|
|||||||
|
|
||||||
function beforeFilter() {
|
function beforeFilter() {
|
||||||
$this->params['user'] = $this->Permission->User->currentUser();
|
$this->params['user'] = $this->Permission->User->currentUser();
|
||||||
$this->params['dev'] = $this->Option->enabled('dev');
|
|
||||||
$this->params['admin'] = $this->Option->enabled('admin');
|
$this->params['admin'] = $this->Option->enabled('admin');
|
||||||
|
$this->params['dev'] = devbox();
|
||||||
|
|
||||||
|
if ($this->params['dev'] && !$this->Option->enabled('dev'))
|
||||||
|
$this->redirect("/");
|
||||||
|
|
||||||
if (!$this->params['dev'])
|
if (!$this->params['dev'])
|
||||||
Configure::write('debug', '0');
|
Configure::write('debug', '0');
|
||||||
|
|||||||
@@ -38,5 +38,13 @@ App::import('Core', 'Helper');
|
|||||||
*/
|
*/
|
||||||
class AppHelper extends Helper {
|
class AppHelper extends Helper {
|
||||||
|
|
||||||
|
function url($url = null, $full = false) {
|
||||||
|
foreach(array('sand_route', 'dev_route') AS $mod) {
|
||||||
|
if (isset($this->params[$mod]) && is_array($url) && !isset($url[$mod]))
|
||||||
|
$url[$mod] = $this->params[$mod];
|
||||||
|
}
|
||||||
|
return parent::url($url, $full);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
5
site/build_devbox.cmd
Normal file
5
site/build_devbox.cmd
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
@echo off
|
||||||
|
mysqldump --user=pmgr --password=pmgruser --opt property_manager > H:\pmgr_dev.sql
|
||||||
|
mysql --user=pmgr --password=pmgruser --database=pmgr_dev < H:\pmgr_dev.sql
|
||||||
|
del H:\pmgr_dev.sql
|
||||||
|
echo Build Complete!
|
||||||
@@ -33,7 +33,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function sandbox() {
|
function sandbox() {
|
||||||
return preg_match("%^/[^/]*sand/%", $_SERVER['REQUEST_URI']);
|
$r = Router::requestRoute();
|
||||||
|
return !empty($r[3]['sand_route']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function devbox() {
|
||||||
|
$r = Router::requestRoute();
|
||||||
|
return !empty($r[3]['dev_route']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function server_request_var($var) {
|
function server_request_var($var) {
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ class DATABASE_CONFIG {
|
|||||||
);
|
);
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
|
if (devbox())
|
||||||
|
$this->default['database'] = 'pmgr_dev';
|
||||||
if (sandbox())
|
if (sandbox())
|
||||||
$this->default['database'] = 'pmgr_sand';
|
$this->default['database'] = 'pmgr_sand';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,4 +36,20 @@ $default_path = array('controller' => 'maps', 'action' => 'view', '1');
|
|||||||
*/
|
*/
|
||||||
Router::connect('/', $default_path);
|
Router::connect('/', $default_path);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Route for sandbox functionality
|
||||||
|
*/
|
||||||
|
Router::connect('/sand',
|
||||||
|
array('sand_route' => true) + $default_path);
|
||||||
|
Router::connect('/sand/:controller/:action/*',
|
||||||
|
array('sand_route' => true, 'action' => null));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Route for developement functionality
|
||||||
|
*/
|
||||||
|
Router::connect('/dev',
|
||||||
|
array('dev_route' => true) + $default_path);
|
||||||
|
Router::connect('/dev/:controller/:action/*',
|
||||||
|
array('dev_route' => true, 'action' => null));
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -32,16 +32,16 @@ class UtilController extends AppController {
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* function: rebuild_sandbox
|
* function: rebuild_box
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function rebuild_sandbox() {
|
function rebuild_box($type) {
|
||||||
$this->layout = null;
|
$this->layout = null;
|
||||||
$this->autoLayout = false;
|
$this->autoLayout = false;
|
||||||
$this->autoRender = false;
|
$this->autoRender = false;
|
||||||
Configure::write('debug', '0');
|
Configure::write('debug', '0');
|
||||||
$script = preg_replace('%/webroot/index.php$%',
|
$script = preg_replace('%/webroot/index.php$%',
|
||||||
'/build_sandbox.cmd',
|
'/build_'.$type.'box.cmd',
|
||||||
$_SERVER['SCRIPT_FILENAME']);
|
$_SERVER['SCRIPT_FILENAME']);
|
||||||
|
|
||||||
// REVISIT <AP>: 20090828
|
// REVISIT <AP>: 20090828
|
||||||
@@ -59,4 +59,7 @@ class UtilController extends AppController {
|
|||||||
$this->redirect($url);
|
$this->redirect($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function rebuild_sandbox() { $this->rebuild_box('sand'); }
|
||||||
|
function rebuild_devbox() { $this->rebuild_box('dev'); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,9 +34,11 @@
|
|||||||
<head>
|
<head>
|
||||||
<?php echo $html->charset(); ?>
|
<?php echo $html->charset(); ?>
|
||||||
<title>
|
<title>
|
||||||
|
<?php if (devbox()) echo "*DEVBOX* "; ?>
|
||||||
<?php if (sandbox()) echo "*SANDBOX* "; ?>
|
<?php if (sandbox()) echo "*SANDBOX* "; ?>
|
||||||
Property Manager: <?php echo $title_for_layout; ?>
|
Property Manager: <?php echo $title_for_layout; ?>
|
||||||
<?php if (sandbox()) echo " *SANDBOX*"; ?>
|
<?php if (sandbox()) echo " *SANDBOX*"; ?>
|
||||||
|
<?php if (devbox()) echo " *DEVBOX*"; ?>
|
||||||
</title>
|
</title>
|
||||||
<?php
|
<?php
|
||||||
// Reset the __scripts variable, which has already been dumped to
|
// Reset the __scripts variable, which has already been dumped to
|
||||||
@@ -66,6 +68,8 @@
|
|||||||
$theme = 'dotluv';
|
$theme = 'dotluv';
|
||||||
$theme = 'dark-hive';
|
$theme = 'dark-hive';
|
||||||
$theme = 'start';
|
$theme = 'start';
|
||||||
|
if (devbox())
|
||||||
|
$theme = 'dotluv';
|
||||||
if (sandbox())
|
if (sandbox())
|
||||||
$theme = 'darkness';
|
$theme = 'darkness';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user