Fixes to google chart and other minor items
This commit is contained in:
parent
dce2daddc4
commit
f2fed0c54f
@ -25,7 +25,7 @@ class Controller_Admin_Account extends Controller_TemplateDefault_Admin {
|
|||||||
ORM::factory('account_log')->order_by('id','DESC')->find_all(),
|
ORM::factory('account_log')->order_by('id','DESC')->find_all(),
|
||||||
25,
|
25,
|
||||||
array(
|
array(
|
||||||
'id'=>array('label'=>'ID','url'=>'admin/account/view/'),
|
'id'=>array('label'=>'ID'),
|
||||||
'date_orig'=>array('label'=>'Date'),
|
'date_orig'=>array('label'=>'Date'),
|
||||||
'account->name()'=>array('label'=>'Account'),
|
'account->name()'=>array('label'=>'Account'),
|
||||||
'ip'=>array('label'=>'IP Address'),
|
'ip'=>array('label'=>'IP Address'),
|
||||||
|
@ -18,7 +18,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
|||||||
// If user already signed-in
|
// If user already signed-in
|
||||||
if (Auth::instance()->logged_in()!= 0) {
|
if (Auth::instance()->logged_in()!= 0) {
|
||||||
// Redirect to the user account
|
// Redirect to the user account
|
||||||
Request::current()->redirect('user/welcome');
|
Request::current()->redirect('user/welcome/index');
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a post and $_POST is not empty
|
// If there is a post and $_POST is not empty
|
||||||
@ -35,7 +35,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
|||||||
Request::current()->redirect($redir);
|
Request::current()->redirect($redir);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
Request::current()->redirect('user/welcome');
|
Request::current()->redirect('user/welcome/index');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OSB User Main home page controller
|
* lnApp User Main home page controller
|
||||||
*
|
*
|
||||||
* @package OSB
|
* @package lnApp
|
||||||
* @subpackage Page/Admin
|
* @subpackage Page/Admin
|
||||||
* @category Controllers
|
* @category Controllers
|
||||||
* @author Deon George
|
* @author Deon George
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OSB User Main home page controller
|
* lnApp User Main home page controller
|
||||||
*
|
*
|
||||||
* @package OSB
|
* @package lnApp
|
||||||
* @subpackage Page/User
|
* @subpackage Page/User
|
||||||
* @category Controllers
|
* @category Controllers
|
||||||
* @author Deon George
|
* @author Deon George
|
||||||
|
@ -14,6 +14,12 @@ class Controller_Welcome extends Controller_TemplateDefault {
|
|||||||
protected $auth_required = FALSE;
|
protected $auth_required = FALSE;
|
||||||
|
|
||||||
public function action_index() {
|
public function action_index() {
|
||||||
|
if (! Kohana::config('config.appname'))
|
||||||
|
Request::current()->redirect('guide/app');
|
||||||
|
|
||||||
|
if (! Auth::instance()->logged_in())
|
||||||
|
Request::current()->redirect('login');
|
||||||
|
|
||||||
Block::add(array(
|
Block::add(array(
|
||||||
'title'=>'Welcome to lnApp (public)!',
|
'title'=>'Welcome to lnApp (public)!',
|
||||||
'subtitle'=>'Using lnApp',
|
'subtitle'=>'Using lnApp',
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This class provides Country routines
|
* This class provides Country routines
|
||||||
*
|
*
|
||||||
* @package OSB
|
* @package OSB
|
||||||
* @subpackage Cart
|
* @subpackage Country
|
||||||
* @category Helpers
|
* @category Helpers
|
||||||
* @author Deon George
|
* @author Deon George
|
||||||
* @copyright (c) 2010 Deon George
|
* @copyright (c) 2010 Deon George
|
||||||
|
@ -115,7 +115,7 @@ class GoogleChart implements Iterator,Countable {
|
|||||||
return $this->render();
|
return $this->render();
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
echo Kohana::debug($e);
|
echo Debug::vars($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,13 +138,10 @@ class GoogleChart implements Iterator,Countable {
|
|||||||
if (! in_array($data['axis'],array('x','r')))
|
if (! in_array($data['axis'],array('x','r')))
|
||||||
throw new Kohana_Exception('Unknown data type :type',array(':type'=>$data['axis']));
|
throw new Kohana_Exception('Unknown data type :type',array(':type'=>$data['axis']));
|
||||||
|
|
||||||
$m = 0;
|
|
||||||
if (is_array($data['data'])) {
|
if (is_array($data['data'])) {
|
||||||
foreach ($data['data'] as $title => $values) {
|
foreach ($data['data'] as $title => $values) {
|
||||||
$this->numseries++;
|
$this->numseries++;
|
||||||
|
|
||||||
$m += max($values);
|
|
||||||
|
|
||||||
$this->chartdata['legend'][$this->numseries] = $title;
|
$this->chartdata['legend'][$this->numseries] = $title;
|
||||||
$this->chartdata['axis'][$data['axis']][] = $this->numseries;
|
$this->chartdata['axis'][$data['axis']][] = $this->numseries;
|
||||||
|
|
||||||
@ -155,9 +152,6 @@ class GoogleChart implements Iterator,Countable {
|
|||||||
throw new Kohana_Exception('Series data needs to be an array');
|
throw new Kohana_Exception('Series data needs to be an array');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($this->chartdata['max'][$data['axis']]) OR ($m > $this->chartdata['max'][$data['axis']]))
|
|
||||||
$this->chartdata['max'][$data['axis']] = $m*1.1; // @todo This inflation should be configurable.
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Kohana_Exception('Series data needs to be an array');
|
throw new Kohana_Exception('Series data needs to be an array');
|
||||||
}
|
}
|
||||||
@ -228,12 +222,13 @@ class GoogleChart implements Iterator,Countable {
|
|||||||
|
|
||||||
$sd = $max = array();
|
$sd = $max = array();
|
||||||
foreach ($this->plotdata as $label => $seriesdata)
|
foreach ($this->plotdata as $label => $seriesdata)
|
||||||
foreach ($seriesdata as $type => $data)
|
foreach ($seriesdata as $type => $data) {
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
$sd[$key][$label] = $value;
|
$sd[$key][$label] = $value;
|
||||||
$max[$key] = $this->chartdata['max'][$type];
|
$max[$key] = $this->chartdata['max'][$type];
|
||||||
$invs[$type][$key] = TRUE;
|
$invs[$type][$key] = TRUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($sd as $k => $v)
|
foreach ($sd as $k => $v)
|
||||||
array_push($sreturn,$this->encode($v,$max[$k]));
|
array_push($sreturn,$this->encode($v,$max[$k]));
|
||||||
@ -262,9 +257,9 @@ class GoogleChart implements Iterator,Countable {
|
|||||||
|
|
||||||
// Render
|
// Render
|
||||||
$output .= sprintf('<img src="%s?%s" alt="%s">',$this->url,http_build_query($this->build()),_('Traffic Summary'));
|
$output .= sprintf('<img src="%s?%s" alt="%s">',$this->url,http_build_query($this->build()),_('Traffic Summary'));
|
||||||
// $output .= Kohana::debug($this->build());
|
// $output .= Debug::vars($this->build());
|
||||||
// $output .= Kohana::debug($this->chartdata);
|
// $output .= Debug::vars($this->chartdata);
|
||||||
// $output .= Kohana::debug($this->plotdata);
|
// $output .= Debug::vars($this->plotdata);
|
||||||
|
|
||||||
// Toggle the display of the chart.
|
// Toggle the display of the chart.
|
||||||
// @todo This JS should be placed elsewhere for HTML validation
|
// @todo This JS should be placed elsewhere for HTML validation
|
||||||
@ -326,11 +321,39 @@ class GoogleChart implements Iterator,Countable {
|
|||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some pre-render processing
|
||||||
|
*/
|
||||||
|
private function process() {
|
||||||
|
$max = array();
|
||||||
|
|
||||||
|
// Work out our maximum number for each series.
|
||||||
|
foreach ($this->plotdata as $label => $seriesdata) {
|
||||||
|
|
||||||
|
foreach ($seriesdata as $type => $data) {
|
||||||
|
$c = 0;
|
||||||
|
foreach ($data as $value)
|
||||||
|
$c += $value;
|
||||||
|
|
||||||
|
// Scale up our max, so we get some extra space at the top of our chart.
|
||||||
|
// @todo This should be configurable.
|
||||||
|
$c *= 1.1;
|
||||||
|
|
||||||
|
if (! isset($this->chartdata['max'][$type]))
|
||||||
|
$this->chartdata['max'][$type] = $c;
|
||||||
|
else
|
||||||
|
$this->chartdata['max'][$type] = ($c > $this->chartdata['max'][$type]) ? $c : $this->chartdata['max'][$type];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the chart
|
* Build the chart
|
||||||
*/
|
*/
|
||||||
private function build() {
|
private function build() {
|
||||||
if ($this->plotdata)
|
if ($this->plotdata) {
|
||||||
|
$this->process();
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'chf'=>'bg,s,FFFFFF00',
|
'chf'=>'bg,s,FFFFFF00',
|
||||||
'cht'=>$this->chart_type,
|
'cht'=>$this->chart_type,
|
||||||
@ -347,7 +370,8 @@ class GoogleChart implements Iterator,Countable {
|
|||||||
'chxl'=>$this->series_x_labels(),
|
'chxl'=>$this->series_x_labels(),
|
||||||
'chxr'=>$this->series_scale(),
|
'chxr'=>$this->series_scale(),
|
||||||
);
|
);
|
||||||
else
|
|
||||||
|
} else
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user