From 97d16bd71249391559d3eeb0cc1eec6c853986dc Mon Sep 17 00:00:00 2001 From: abijah Date: Thu, 13 Aug 2009 20:07:49 +0000 Subject: [PATCH] Changed the default of the debug flag when generating grid data. The original intention was to have it debug by default, so that debugging would be on if the url were manually typed in. That has never been needed though, and this change not only results in cleaner logic, it makes sure we have no issues with routing. git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@546 97e9348a-65ac-dc4b-aefc-98561f571b83 --- app_controller.php | 29 +++++++++++++++++++---------- views/elements/jqGrid.ctp | 5 ++--- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app_controller.php b/app_controller.php index cb92e3b..b414f4f 100644 --- a/app_controller.php +++ b/app_controller.php @@ -38,7 +38,21 @@ class AppController extends Controller { var $helpers = array('Html', 'Form', 'Javascript', 'Format', 'Time', 'Grid'); var $components = array('DebugKit.Toolbar'); + function __construct() { + $this->params['dev'] = false; + $this->params['admin'] = false; + parent::__construct(); + } + function sideMenuLinks() { + // Stupid Cake... our constructor sets admin/dev, + // but cake stomps it somewhere along the way + // after constructing the CakeError controller. + if ($this->name === 'CakeError') { + $this->params['dev'] = false; + $this->params['admin'] = false; + } + $menu = array(); $menu[] = array('name' => 'Common', 'header' => true); $menu[] = array('name' => 'Site Map', 'url' => array('controller' => 'maps', 'action' => 'view', 1)); @@ -52,7 +66,8 @@ class AppController extends Controller { $menu[] = array('name' => 'Accounts', 'url' => array('controller' => 'accounts', 'action' => 'index')); $menu[] = array('name' => 'Contacts', 'url' => array('controller' => 'contacts', 'action' => 'index')); $menu[] = array('name' => 'Ledgers', 'url' => array('controller' => 'ledgers', 'action' => 'index')); - $menu[] = array('name' => 'New Ledgers', 'url' => array('controller' => 'accounts', 'action' => 'newledger')); + $menu[] = array('name' => 'New Ledgers', 'url' => array('controller' => 'accounts', 'action' => 'newledger')); + $menu[] = array('name' => 'Assess Charges', 'url' => array('controller' => 'leases', 'action' => 'assess_all')); } if ($this->params['dev']) { @@ -178,16 +193,10 @@ class AppController extends Controller { } function gridDataSetup(&$params) { - // Assume we're debugging. - // The actual grid request will set this to false - $debug = true; + // Debug only if requested + $params['debug'] = !empty($this->passedArgs['debug']); - if (isset($this->passedArgs['debug'])) - $debug = $this->passedArgs['debug']; - - $params['debug'] = $debug; - - if ($debug) { + if ($params['debug']) { ob_start(); } else { diff --git a/views/elements/jqGrid.ctp b/views/elements/jqGrid.ctp index ba86642..9bdddd4 100644 --- a/views/elements/jqGrid.ctp +++ b/views/elements/jqGrid.ctp @@ -63,7 +63,6 @@ $javascript->link('pmgr_jqGrid', false); // as part of the data fetch. $url = $html->url(array('controller' => $controller, 'action' => 'gridData', - 'debug' => 0, )); // Create extra parameters that jqGrid will pass to our @@ -202,11 +201,11 @@ foreach (array_merge(array('loadComplete' => '', 'loadError' => ''), if ($event == 'loadComplete') { $grid_events[$event] = - array('--special' => "function($params) {url=jQuery('#{$grid_id}').getGridParam('url');url=url.replace(/\/debug.*$/,'?'); pd=jQuery('#{$grid_id}').getPostData();$.each(pd,function(i){ url+=i+'='+escape(pd[i])+'&'; }); jQuery('#{$grid_id}-query').html('Grid Query
'); $statement;}"); + array('--special' => "function($params) {url=jQuery('#{$grid_id}').getGridParam('url');url=url+'/debug:1?'; pd=jQuery('#{$grid_id}').getPostData();$.each(pd,function(i){ url+=i+'='+escape(pd[i])+'&'; }); jQuery('#{$grid_id}-query').html('Grid Query
'); $statement;}"); } elseif ($event == 'loadError') { $grid_events[$event] = - array('--special' => "function($params) {url=jQuery('#{$grid_id}').getGridParam('url');url=url.replace(/\/debug.*$/,'?'); pd=jQuery('#{$grid_id}').getPostData();$.each(pd,function(i){ url+=i+'='+escape(pd[i])+'&'; }); jQuery('#{$grid_id}-query').html('Grid Error Query
'); $statement;}"); + array('--special' => "function($params) {url=jQuery('#{$grid_id}').getGridParam('url');url=url+'/debug:1?'; pd=jQuery('#{$grid_id}').getPostData();$.each(pd,function(i){ url+=i+'='+escape(pd[i])+'&'; }); jQuery('#{$grid_id}-query').html('Grid Error Query
'); $statement;}"); } else { $grid_events[$event] =