diff --git a/modules/base/dashboardTrendWidget.php b/modules/base/dashboardTrendWidget.php
index 9f024e4fb..03f66ec87 100644
--- a/modules/base/dashboardTrendWidget.php
+++ b/modules/base/dashboardTrendWidget.php
@@ -41,7 +41,7 @@ function action() {
$m->setConstraint('is_browser', 1);
$m->setPeriod($this->params['period']);
$m->setOrder(OWA_SQL_ASCENDING);
- $results = $m->generate();
+
if (array_key_exists('format', $this->params)):
$format = $this->params['format'];
@@ -50,16 +50,24 @@ function action() {
endif;
$data['title'] = 'Dashboard Trend';
- $data['view'] = 'base.widget';
- $data['y']['label'] = 'Page Views';
- $data['y2']['label'] = 'Visits';
- $data['x']['label'] = 'Day';
+ $data['params'] = $this->params;
+ $data['widget'] = 'base.dashboardTrendWidget';
switch ($format) {
case 'graph':
+ $data['view'] = 'base.openFlashChart';
+ $data['height'] = $this->params['height'];
+ $data['width'] = $this->params['width'];
+ break;
+
+ case 'graph-data':
+ $results = $m->generate();
$series = owa_lib::deconstruct_assoc($results);
+ $data['y']['label'] = 'Page Views';
+ $data['y2']['label'] = 'Visits';
+ $data['x']['label'] = 'Day';
$data['y']['series'] = $series['page_views'];
$data['y2']['series'] = $series['sessions'];
$data['x']['series'] = owa_lib::makeDateArray($results, "n/j");
@@ -67,14 +75,22 @@ function action() {
break;
case 'table':
- $data['column_labels'] = array();
- $data['data'] = '';
+ $m->setLimit(5);
+ $results = $m->generate();
+ $data['labels'] = $m->getLabels();
+ $data['rows'] = $results;
$data['view'] = 'base.genericTable';
break;
}
+ if ($this->params['initial-view'] == true):
+ $data['subview'] = $data['view'];
+ $data['view'] = 'base.widget';
+ endif;
+
+
return $data;
}
diff --git a/modules/base/metrics/dashCoreByDay.php b/modules/base/metrics/dashCoreByDay.php
index 2cf5a2efe..f873e821e 100644
--- a/modules/base/metrics/dashCoreByDay.php
+++ b/modules/base/metrics/dashCoreByDay.php
@@ -32,9 +32,15 @@ class owa_dashCoreByDay extends owa_metric {
function owa_dashCoreByDay($params = null) {
- $this->params = $params;
+ return owa_dashCoreByDay::__construct($params);
+
+ }
+
+ function __construct($params = null) {
+
+ parent::__construct($params);
- $this->owa_metric();
+ $this->setLabels(array('Month', 'Day', 'Year', 'Unique Visitors', 'Sessions', 'Page Views'));
return;
@@ -61,32 +67,14 @@ function calculate() {
$db->orderBy('month');
$db->orderBy('day');
+ if (array_key_exists('limit', $this->params)):
+ $db->limit($this->params['limit']);
+ endif;
+
$ret = $db->getAllRows();
return $ret;
-
-
-/*
-
- $this->params['select'] = "session.month,
- session.day,
- session.year,
- count(distinct session.visitor_id) as unique_visitors,
- count(session.id) as sessions,
- sum(session.num_pageviews) as page_views ";
-
-
- $this->params['groupby'] = array('day', 'month');
-
- $this->params['orderby'] = array('year', 'month', 'day');
-
- $this->setTimePeriod($this->params['period']);
-
- $s = owa_coreAPI::entityFactory('base.session');
-
- return $s->query($this->params);
-
-*/
+
}
diff --git a/modules/base/metrics/dashCoreByMonth.php b/modules/base/metrics/dashCoreByMonth.php
index 8fcd10e55..cd1f7cfb5 100644
--- a/modules/base/metrics/dashCoreByMonth.php
+++ b/modules/base/metrics/dashCoreByMonth.php
@@ -32,10 +32,16 @@ class owa_dashCoreByMonth extends owa_metric {
function owa_dashCoreByMonth($params = null) {
- $this->params = $params;
+ return owa_dashCoreByMonth::__construct($params);
- $this->owa_metric();
+ }
+
+ function __construct($params = null) {
+
+ parent::__construct($params);
+ $this->setLabels(array('Month', 'Day', 'Year', 'Unique Visitors', 'Sessions', 'Page Views'));
+
return;
}
@@ -60,28 +66,6 @@ function calculate() {
return $db->getAllRows();
- /*
-
- $this->params['select'] = "session.month,
- session.day,
- session.year,
- count(distinct session.visitor_id) as unique_visitors,
- count(session.id) as sessions,
- sum(session.num_pageviews) as page_views ";
-
- $this->params['use_summary'] = true;
-
- $this->params['groupby'] = array('month', 'year');
-
- $this->params['orderby'] = array('year', 'month');
-
- $this->setTimePeriod($this->params['period']);
-
- $s = owa_coreAPI::entityFactory('base.session');
-
- return $s->query($this->params);
-
-*/
}
diff --git a/modules/base/templates/generic_table.tpl b/modules/base/templates/generic_table.tpl
new file mode 100644
index 000000000..5f95d336f
--- /dev/null
+++ b/modules/base/templates/generic_table.tpl
@@ -0,0 +1,14 @@
+
+
+
+ =$label;?> |
+
+
+
+
+
+ =$item;?> |
+
+
+
+
\ No newline at end of file
diff --git a/modules/base/templates/ofc.tpl b/modules/base/templates/ofc.tpl
new file mode 100644
index 000000000..047fb6e58
--- /dev/null
+++ b/modules/base/templates/ofc.tpl
@@ -0,0 +1 @@
+=$this->ofc($width, $height, $this->makeAbsoluteLink(array('do' => $widget, 'period' => 'last_thirty_days', 'site_id' => $params['site_id'], 'format' => 'graph-data'), false , $this->config['action_url'])); ?>
diff --git a/modules/base/templates/report_dashboard.tpl b/modules/base/templates/report_dashboard.tpl
index 4a0bec64f..87a46ff55 100644
--- a/modules/base/templates/report_dashboard.tpl
+++ b/modules/base/templates/report_dashboard.tpl
@@ -12,15 +12,18 @@
#recent_visitors{width:; margin-left: px}
+
+
include('report_header.tpl');?>
-
+
=$this->getWidget('base.dashboardTrendWidget', 'graph', array('height' => 300, 'width' => 900));?>
+ //$this->getWidget('base.dashboardTrendWidget', 'table', array('height' => 300, 'width' => 900));?>
|
diff --git a/modules/base/templates/widget.tpl b/modules/base/templates/widget.tpl
index 8887c59a4..b3f51f339 100644
--- a/modules/base/templates/widget.tpl
+++ b/modules/base/templates/widget.tpl
@@ -1,16 +1,73 @@
-
+
-
-
-
+
-
+
+
+
diff --git a/modules/base/widget.php b/modules/base/widget.php
index e896b683d..d94a137c0 100644
--- a/modules/base/widget.php
+++ b/modules/base/widget.php
@@ -82,24 +82,25 @@ function construct($data) {
// load template
- if ($data['is_external'] == true):
+ if ($data['params']['is_external'] == true):
$this->t->set_template('wrapper_widget.tpl');
else:
$this->t->set_template('wrapper_blank.tpl');
endif;
if (!array_key_exists('width', $data)):
- $data['width'] = 300;
+ $data['params']['width'] = 300;
endif;
if (!array_key_exists('width', $data)):
- $data['height'] = 250;
+ $data['params']['height'] = 250;
endif;
$this->body->set_template('widget.tpl');
- $this->body->set('format', $data['format']);
- $this->body->set('widget', $data['widget']);
- $this->body->set('params', $data['params']);
+ $this->body->set('format', $data['params']['format']);
+ $this->body->set('widget', str_replace('.', '-', $data['widget']));
+ $this->body->set('params', $data['params']['params']);
+ $this->body->set('title', $data['title']);
return;
}
diff --git a/owa_base.php b/owa_base.php
index 3a7cbe655..5b0709472 100644
--- a/owa_base.php
+++ b/owa_base.php
@@ -74,12 +74,18 @@ class owa_base {
*/
function owa_base() {
+ return owa_base::__construct();
+
+ }
+
+ function __construct() {
+
$this->e = &owa_coreAPI::errorSingleton();
$this->c = &owa_coreAPI::configSingleton();
$this->config = &$this->c->fetch('base');
return;
-
+
}
/**
diff --git a/owa_coreAPI.php b/owa_coreAPI.php
index e61a6affa..efff61960 100644
--- a/owa_coreAPI.php
+++ b/owa_coreAPI.php
@@ -299,7 +299,7 @@ function moduleFactory($modulefile, $class_suffix = null, $params = '', $class_n
list($module, $file) = split("\.", $modulefile);
$class = $class_ns.$file.$class_suffix;
-
+ //print $class;
// Require class file if class does not already exist
if(!class_exists($class)):
owa_coreAPI::moduleRequireOnce($module, '', $file);
@@ -368,7 +368,7 @@ function subViewFactory($subview, $params = array()) {
list($module, $class) = split("\.", $subview);
- owa_lib::moduleRequireOnce($module, $class);
+ //owa_lib::moduleRequireOnce($module, $class);
$subview = owa_lib::moduleFactory($module, $class.'View', $params);
$subview->is_subview = true;
diff --git a/owa_metric.php b/owa_metric.php
index 4c936b0c0..534539ab4 100644
--- a/owa_metric.php
+++ b/owa_metric.php
@@ -51,8 +51,13 @@ class owa_metric extends owa_base {
* @var array
*/
var $params = array();
-
- var $db;
+
+ /**
+ * The lables for calculated measures
+ *
+ * @var array
+ */
+ var $labels = array();
/**
* Constructor
@@ -62,7 +67,7 @@ class owa_metric extends owa_base {
*/
function owa_metric($params = '') {
- return $this->__construct($params);
+ return owa_metric::__construct($params);
}
function __construct($params = '') {
@@ -411,6 +416,29 @@ function generate() {
return $this->calculate();
}
+
+
+ /**
+ * Set the labels of the measures
+ *
+ */
+ function setLabels($array) {
+
+ $this->labels = $array;
+ return;
+ }
+
+ /**
+ * Retrieve the labels of the measures
+ *
+ */
+ function getLabels() {
+
+ return $this->labels;
+
+ }
+
+
}
?>
\ No newline at end of file
diff --git a/owa_template.php b/owa_template.php
index 078aed00f..ea7454ca3 100644
--- a/owa_template.php
+++ b/owa_template.php
@@ -578,7 +578,7 @@ function performAction($action, $params) {
}
- function getWidget($widget, $format, $params = '') {
+ function getWidget($widget, $format, $params = array()) {
if (empty($params)):
$params = array();
@@ -586,10 +586,9 @@ function getWidget($widget, $format, $params = '') {
$params['widget'] = $widget;
$params['format'] = $format;
+ $params['initial-view'] = true;
- $api = owa_coreAPI::singleton();
-
- return $api->performAction('base.widget', $params);
+ return owa_coreAPI::performAction($widget, $params);
}
}
diff --git a/owa_view.php b/owa_view.php
index 4dfee4309..96b75288b 100644
--- a/owa_view.php
+++ b/owa_view.php
@@ -16,10 +16,10 @@
// $Id$
//
-require_once('owa_template.php');
-require_once('owa_base.php');
-require_once('owa_requestContainer.php');
-require_once(OWA_BASE_CLASSES_DIR.'owa_coreAPI.php');
+require_once(OWA_BASE_CLASSES_DIR.'owa_template.php');
+//require_once(OWA_BASE_CLASSES_DIR.'owa_base.php');
+require_once(OWA_BASE_CLASSES_DIR.'owa_requestContainer.php'); // ??
+//require_once(OWA_BASE_CLASSES_DIR.'owa_coreAPI.php');
/**
* Abstract View Class
@@ -300,9 +300,9 @@ function assembleSubView($data) {
else:
//$this->e->debug('RenderView: '.print_r($data, true));
- $api = &owa_coreAPI::singleton();
+ //$api = &owa_coreAPI::singleton();
- $subview = $api->displaySubView($auth_data);
+ $subview = owa_coreAPI::displaySubView($auth_data);
return $subview;
endif;
@@ -411,7 +411,7 @@ function assembleView($data) {
}
-class owa_pieFlashChartView extends owa_base {
+class owa_pieFlashChartView extends owa_view {
function owa_pieFlashChartView() {
@@ -420,7 +420,7 @@ function owa_pieFlashChartView() {
function __construct() {
- return $this->owa_base();
+ return parent::__construct();
}
@@ -457,8 +457,71 @@ function assembleView($data) {
}
+class owa_genericTableView extends owa_view {
+ function __construct() {
+
+ return parent::__construct();
+
+ }
+
+ function owa_genericTableView() {
+
+ return owa_genericTableView::__construct();
+ }
+
+ function construct($data) {
+
+ $this->t->set_template('wrapper_blank.tpl');
+ $this->body->set_template('generic_table.tpl');
+
+ if (!empty($data['labels'])):
+ $this->body->set('labels', $data['labels']);
+ else:
+ $this->body->set('labels', '');
+ endif;
+
+ if (!empty($data['rows'])):
+ $this->body->set('rows', $data['rows']);
+ $this->body->set('row_count', count($data['rows']));
+ else:
+ $this->body->set('rows', '');
+ $this->body->set('row_count', 0);
+ endif;
+
+ }
+
+}
+class owa_openFlashChartView extends owa_view {
+ function owa_openFlashChartView() {
+
+ owa_openFlashChartView::__construct();
+
+ return;
+ }
+
+ function __construct() {
+
+ return parent::__construct();
+
+ }
+
+ function construct($data) {
+
+ // load template
+ $this->t->set_template('wrapper_blank.tpl');
+ $this->body->set_template('ofc.tpl');
+ // set
+ $this->body->set('widget', $data['widget']);
+ $this->body->set('height', $data['height']);
+ $this->body->set('width', $data['width']);
+
+ return;
+
+ }
+
+}
?>
\ No newline at end of file
diff --git a/public/js/jQuery.owa.js b/public/js/jQuery.owa.js
new file mode 100644
index 000000000..4082da556
--- /dev/null
+++ b/public/js/jQuery.owa.js
@@ -0,0 +1,6 @@
+// OWA JQuery plugin
+
+$.fn.owa = function() {
+
+
+};
\ No newline at end of file