Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2009-04-27 08:18:16 +0400
committermatt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2009-04-27 08:18:16 +0400
commitbfba0e7e3e0ad6814598d25852289024e8083c9d (patch)
tree6379b457ce107dc84454e26c2ce5938ff3befab2
parent343f365af322f68d6ea86ea929041ce34e8957d6 (diff)
- API CHANGE: the API for the function Piwik_AddWidget has changed. The new API is Piwik_AddWidget( $widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array()). See examples of calls in all the core Piwik plugins. This change was necessary to make widgets more modular (they now accept custom parameters).
- API CHANGE: a small number of CSV outputs for some API calls would change following the simplification of DataTable_Simple implementation. Affected calls are VisitsSummary.get, Goals.get, VisitFrequency.get. This is due to a change in the implementation of DataTable_Simple (we simplified implementation). - FIXED #84 Added proper translations for all columns, in tables, and graphs. - FIXED #322 piwik is now using open flash chart 2 - FIXED #126 all dates should be correctly displayed in all graphs. For example, evolution graph for days would show, on the X axis "Mon 29", "Wed 31". For months it would show "Aug 2009", etc. - ADDED: when hovering any of the sparklines, the UI makes it clear that clicking will refresh the evolution graph. This feature was in Piwik for months, and even Google Analytics implemented this UI feature after Piwik. However in Piwik it wasn't clear to the user that the sparklines were clickable. - ADDED: now widgets can be created with custom parameters. This makes it possible to create a widget that calls a controller->action with other custom parameters, this is used in Piwik to draw an evolution graph (module=VisitsSummary & action=getEvolutionGraph) for a given metric (&columns[]=nb_visits). These custom parameters are automatically forwarded to the sparkline url, the flash graph when clicked on sparkline, etc. - The widget layout is now saved as a JSON string rather than a custom data structure. The dashboard code should be able to read & restore most of the layouts from the old format (except the evolution graphs widgets). Simplified the Dashboard.js, widgetMenu.js, cleaned up what was a messy code. - Added sentence in Widgetize to let users know they can easily export the Piwik dashboard in an iframe. - Changed the way translations used in Javascript are loaded: all translations strings finishing by _js will be loaded to be used in the templates when calling {loadJavascriptTranslations plugins='YOUR_PLUGIN_NAME'} - Moved all templates in plugins under plugins/$PLUGIN/templates/ - 'Khtml (Konqueror, Safari)' now displayed as 'KHTML (Safari, Chrome)'
-rw-r--r--LICENSE2
-rw-r--r--core/API/ResponseBuilder.php13
-rw-r--r--core/Archive/Array/IndexedByDate.php5
-rw-r--r--core/Archive/Array/IndexedBySite.php1
-rw-r--r--core/Archive/Single.php5
-rw-r--r--core/ArchiveProcessing.php12
-rw-r--r--core/ArchiveProcessing/Day.php10
-rw-r--r--core/ArchiveProcessing/Period.php2
-rw-r--r--core/Controller.php29
-rw-r--r--core/DataTable/Array.php10
-rw-r--r--core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php28
-rw-r--r--core/DataTable/Filter/SafeDecodeLabel.php9
-rw-r--r--core/DataTable/Renderer/Console.php15
-rw-r--r--core/DataTable/Renderer/Csv.php21
-rw-r--r--core/DataTable/Renderer/Html.php6
-rw-r--r--core/DataTable/Renderer/Php.php11
-rw-r--r--core/DataTable/Renderer/Rss.php6
-rw-r--r--core/DataTable/Renderer/Xml.php4
-rw-r--r--core/DataTable/Simple.php24
-rw-r--r--core/Date.php29
-rw-r--r--core/FrontController.php1
-rw-r--r--core/Period.php4
-rw-r--r--core/Period/Day.php14
-rw-r--r--core/Period/Month.php7
-rw-r--r--core/Period/Range.php12
-rw-r--r--core/Period/Week.php11
-rw-r--r--core/Period/Year.php7
-rw-r--r--core/Piwik.php9
-rw-r--r--core/PluginsFunctions/WidgetsList.php17
-rw-r--r--core/Site.php5
-rw-r--r--core/SmartyPlugins/function.loadJavascriptTranslations.php48
-rw-r--r--core/Translate.php19
-rw-r--r--core/Url.php4
-rw-r--r--core/ViewDataTable.php46
-rw-r--r--core/ViewDataTable/GenerateGraphData.php73
-rw-r--r--core/ViewDataTable/GenerateGraphData/ChartEvolution.php247
-rw-r--r--core/ViewDataTable/GenerateGraphHTML.php2
-rw-r--r--core/ViewDataTable/HtmlTable.php51
-rw-r--r--core/ViewDataTable/HtmlTable/AllColumns.php3
-rw-r--r--core/ViewDataTable/HtmlTable/Goals.php2
-rw-r--r--core/ViewDataTable/Sparkline.php95
-rw-r--r--core/Visualization/Chart.php180
-rw-r--r--core/Visualization/Chart/Evolution.php126
-rw-r--r--core/Visualization/Chart/Pie.php61
-rw-r--r--core/Visualization/Chart/VerticalBar.php56
-rw-r--r--core/Visualization/OpenFlashChart.php1637
-rw-r--r--core/Visualization/Sparkline.php44
-rw-r--r--lang/en.php78
-rw-r--r--libs/javascript/json2.js29
-rw-r--r--libs/open-flash-chart/open-flash-chart.swfbin64600 -> 271000 bytes
-rw-r--r--libs/open-flash-chart/php-ofc-library/README.txt16
-rw-r--r--libs/open-flash-chart/php-ofc-library/dot_base.php231
-rw-r--r--libs/open-flash-chart/php-ofc-library/json_format.php86
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_area_base.php40
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_area_hollow.php10
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_area_line.php10
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_bar.php34
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_bar_3d.php22
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_bar_base.php78
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_bar_filled.php39
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_bar_glass.php109
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_bar_sketch.php29
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_bar_stack.php50
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_hbar.php64
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_line.php115
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_line_base.php92
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_line_dot.php33
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_line_hollow.php9
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_line_style.php11
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_menu.php56
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_pie.php257
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_radar_axis.php47
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_radar_axis_labels.php15
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_radar_spoke_labels.php15
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_scatter.php47
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_scatter_line.php43
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_shape.php25
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_sugar.php43
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_title.php39
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_tooltip.php67
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_upload_image.php70
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_x_axis.php104
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_x_axis_label.php45
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_x_axis_labels.php46
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_x_legend.php15
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_y_axis.php16
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_y_axis_base.php131
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_y_axis_right.php6
-rw-r--r--libs/open-flash-chart/php-ofc-library/ofc_y_legend.php15
-rw-r--r--libs/open-flash-chart/php-ofc-library/open-flash-chart-object.php109
-rw-r--r--libs/open-flash-chart/php-ofc-library/open-flash-chart.php174
-rw-r--r--misc/widget_example_lastvisits.html2
-rw-r--r--plugins/Actions/Actions.php6
-rw-r--r--plugins/CoreHome/templates/calendar.js38
-rw-r--r--plugins/CoreHome/templates/datatable.css12
-rw-r--r--plugins/CoreHome/templates/datatable.js24
-rw-r--r--plugins/CoreHome/templates/datatable_footer.tpl1
-rw-r--r--plugins/CoreHome/templates/datatable_js.tpl1
-rw-r--r--plugins/CoreHome/templates/header_message.tpl4
-rw-r--r--plugins/CoreHome/templates/js_css_includes.tpl2
-rw-r--r--plugins/CoreHome/templates/piwik_tag.tpl1
-rw-r--r--plugins/CoreHome/templates/sparkline.js88
-rw-r--r--plugins/CoreHome/templates/styles.css20
-rw-r--r--plugins/Dashboard/Controller.php22
-rw-r--r--plugins/Dashboard/Dashboard.php1
-rw-r--r--plugins/Dashboard/templates/Dashboard.js424
-rw-r--r--plugins/Dashboard/templates/dashboard.css23
-rw-r--r--plugins/Dashboard/templates/header.tpl22
-rw-r--r--plugins/Dashboard/templates/index.tpl83
-rw-r--r--plugins/Dashboard/templates/standalone.tpl5
-rw-r--r--plugins/Dashboard/templates/widgetMenu.js453
-rw-r--r--plugins/ExampleFeedburner/ExampleFeedburner.php4
-rw-r--r--plugins/ExampleFeedburner/templates/feedburner.tpl (renamed from plugins/ExampleFeedburner/feedburner.tpl)0
-rw-r--r--plugins/ExamplePlugin/ExamplePlugin.php17
-rw-r--r--plugins/ExampleRssWidget/ExampleRssWidget.php6
-rw-r--r--plugins/ExampleRssWidget/templates/styles.css (renamed from plugins/ExampleRssWidget/styles.css)0
-rw-r--r--plugins/Feedback/Controller.php4
-rw-r--r--plugins/Feedback/templates/index.tpl (renamed from plugins/Feedback/index.tpl)0
-rw-r--r--plugins/Feedback/templates/sent.tpl (renamed from plugins/Feedback/sent.tpl)0
-rw-r--r--plugins/Goals/API.php36
-rw-r--r--plugins/Goals/Controller.php112
-rw-r--r--plugins/Goals/Goals.php1
-rw-r--r--plugins/Goals/templates/overview.tpl19
-rw-r--r--plugins/Goals/templates/release_notes.tpl4
-rw-r--r--plugins/Goals/templates/title_and_evolution_graph.tpl26
-rw-r--r--plugins/Live/API.php3
-rw-r--r--plugins/Live/Live.php2
-rw-r--r--plugins/Provider/Provider.php2
-rw-r--r--plugins/Referers/API.php2
-rw-r--r--plugins/Referers/Controller.php80
-rw-r--r--plugins/Referers/Referers.php10
-rw-r--r--plugins/Referers/templates/index.tpl42
-rw-r--r--plugins/SitesManager/templates/SitesManager.js2
-rw-r--r--plugins/UserCountry/API.php2
-rw-r--r--plugins/UserCountry/Controller.php2
-rw-r--r--plugins/UserCountry/UserCountry.php4
-rw-r--r--plugins/UserCountry/templates/index.tpl (renamed from plugins/UserCountry/index.tpl)0
-rw-r--r--plugins/UserSettings/Controller.php2
-rw-r--r--plugins/UserSettings/UserSettings.php16
-rw-r--r--plugins/UserSettings/templates/index.tpl (renamed from plugins/UserSettings/index.tpl)0
-rw-r--r--plugins/UsersManager/templates/UsersManager.js2
-rw-r--r--plugins/VisitFrequency/API.php35
-rw-r--r--plugins/VisitFrequency/Controller.php91
-rw-r--r--plugins/VisitFrequency/VisitFrequency.php4
-rw-r--r--plugins/VisitFrequency/sparklines.tpl13
-rw-r--r--plugins/VisitFrequency/templates/index.tpl (renamed from plugins/VisitFrequency/index.tpl)4
-rw-r--r--plugins/VisitFrequency/templates/sparklines.tpl11
-rw-r--r--plugins/VisitTime/Controller.php2
-rw-r--r--plugins/VisitTime/VisitTime.php6
-rw-r--r--plugins/VisitTime/templates/index.tpl (renamed from plugins/VisitTime/index.tpl)0
-rw-r--r--plugins/VisitorInterest/Controller.php2
-rw-r--r--plugins/VisitorInterest/VisitorInterest.php5
-rw-r--r--plugins/VisitorInterest/templates/index.tpl (renamed from plugins/VisitorInterest/index.tpl)0
-rw-r--r--plugins/VisitsSummary/API.php51
-rw-r--r--plugins/VisitsSummary/Controller.php103
-rw-r--r--plugins/VisitsSummary/VisitsSummary.php7
-rw-r--r--plugins/VisitsSummary/sparklines.tpl13
-rw-r--r--plugins/VisitsSummary/templates/index.tpl (renamed from plugins/VisitsSummary/index.tpl)7
-rw-r--r--plugins/VisitsSummary/templates/sparklines.tpl13
-rw-r--r--plugins/Widgetize/templates/iframe.tpl15
-rw-r--r--plugins/Widgetize/templates/index.tpl57
-rw-r--r--plugins/Widgetize/templates/js.tpl2
-rw-r--r--plugins/Widgetize/templates/widgetize.js123
-rw-r--r--tests/core/DataTable/Renderer.test.php25
-rw-r--r--tests/core/Url.test.php12
-rw-r--r--themes/default/common.js34
166 files changed, 4474 insertions, 3386 deletions
diff --git a/LICENSE b/LICENSE
index 6d5606bb24..5e08270fef 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,2 +1,2 @@
-# GNU/GPL v3 or later
+# GNU/GPL v3 or later
see misc/license.txt
diff --git a/core/API/ResponseBuilder.php b/core/API/ResponseBuilder.php
index 52e2d0ee14..1f6f04c8fb 100644
--- a/core/API/ResponseBuilder.php
+++ b/core/API/ResponseBuilder.php
@@ -156,11 +156,16 @@ class Piwik_API_ResponseBuilder
// if asked for original dataStructure
if($format == 'original')
{
- // if the original dataStructure is a simpleDataTable and has only one row, we return the value
- if($dataTable instanceof Piwik_DataTable_Simple
- && $dataTable->getRowsCount() == 1)
+ // if the original dataStructure is a simpleDataTable
+ // and has only one column, we return the value
+ if($dataTable instanceof Piwik_DataTable_Simple)
{
- return $dataTable->getRowFromId(0)->getColumn('value');
+ $columns = $dataTable->getFirstRow()->getColumns();
+ if(count($columns) == 1)
+ {
+ $values = array_values($columns);
+ return $values[0];
+ }
}
// by default "original" data is not serialized
diff --git a/core/Archive/Array/IndexedByDate.php b/core/Archive/Array/IndexedByDate.php
index 57ab78bb1c..f9fe5eb3a1 100644
--- a/core/Archive/Array/IndexedByDate.php
+++ b/core/Archive/Array/IndexedByDate.php
@@ -34,6 +34,7 @@ class Piwik_Archive_Array_IndexedByDate extends Piwik_Archive_Array
$table->metadata[$archive->getPrettyDate()] = array(
'timestamp' => $archive->getTimestampStartDate(),
'site' => $archive->getSite(),
+ 'period' => $archive->getPeriod(),
);
}
@@ -78,7 +79,7 @@ class Piwik_Archive_Array_IndexedByDate extends Piwik_Archive_Array
foreach($queries as $table => $aIds)
{
$inIds = implode(', ', $aIds);
- $sql = "SELECT value, name, idarchive, UNIX_TIMESTAMP(date1) as timestamp
+ $sql = "SELECT value, name, UNIX_TIMESTAMP(date1) as timestamp
FROM $table
WHERE idarchive IN ( $inIds )
AND name IN ( $inNames )";
@@ -87,7 +88,7 @@ class Piwik_Archive_Array_IndexedByDate extends Piwik_Archive_Array
foreach($values as $value)
{
- $arrayValues[$value['timestamp']][$value['name']] = $value['value'];
+ $arrayValues[$value['timestamp']][$value['name']] = (float)$value['value'];
}
}
diff --git a/core/Archive/Array/IndexedBySite.php b/core/Archive/Array/IndexedBySite.php
index 1a27c10ce5..7dbf0f5a30 100644
--- a/core/Archive/Array/IndexedBySite.php
+++ b/core/Archive/Array/IndexedBySite.php
@@ -66,6 +66,7 @@ class Piwik_Archive_Array_IndexedBySite extends Piwik_Archive_Array
private function getValues($fields)
{
+ $arrayValues = array();
foreach($this->loadValuesFromDB($fields) as $value)
{
$arrayValues[$value['idsite']][$value['name']] = $value['value'];
diff --git a/core/Archive/Single.php b/core/Archive/Single.php
index e4d6c4d472..475d5319eb 100644
--- a/core/Archive/Single.php
+++ b/core/Archive/Single.php
@@ -107,6 +107,11 @@ class Piwik_Archive_Single extends Piwik_Archive
$this->period = $period;
}
+ public function getPeriod()
+ {
+ return $this->period;
+ }
+
/**
* Returns the timestamp of the first date in the period for this Archive.
* This is used to sort archives by date when working on a Archive_Array
diff --git a/core/ArchiveProcessing.php b/core/ArchiveProcessing.php
index 3418447d10..d2b5c6f72f 100644
--- a/core/ArchiveProcessing.php
+++ b/core/ArchiveProcessing.php
@@ -174,6 +174,13 @@ abstract class Piwik_ArchiveProcessing
protected $debugAlwaysArchive = false;
/**
+ * If the archive has at least 1 visit, this is set to true.
+ *
+ * @var bool
+ */
+ public $isThereSomeVisits = false;
+
+ /**
* Constructor
*/
public function __construct()
@@ -290,11 +297,6 @@ abstract class Piwik_ArchiveProcessing
{
return null;
}
- else
- {
- $this->isThereSomeVisits = true;
- }
-
return $this->idArchive;
}
diff --git a/core/ArchiveProcessing/Day.php b/core/ArchiveProcessing/Day.php
index 7fcc512c46..1b0a21c19b 100644
--- a/core/ArchiveProcessing/Day.php
+++ b/core/ArchiveProcessing/Day.php
@@ -22,16 +22,6 @@
*/
class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing
{
- /**
- * If the archive has at least 1 visit, this is set to true.
- *
- * @var bool
- */
- public $isThereSomeVisits = false;
-
- /**
- * Constructor
- */
function __construct()
{
parent::__construct();
diff --git a/core/ArchiveProcessing/Period.php b/core/ArchiveProcessing/Period.php
index e2bcfda5c9..06cd6ab894 100644
--- a/core/ArchiveProcessing/Period.php
+++ b/core/ArchiveProcessing/Period.php
@@ -267,7 +267,7 @@ class Piwik_ArchiveProcessing_Period extends Piwik_ArchiveProcessing
$nbVisits = $record['nb_visits']->value;
$nbVisitsConverted = $record['nb_visits_converted']->value;
- $this->isThereSomeVisits = ( $nbVisits!= 0);
+ $this->isThereSomeVisits = ( $nbVisits > 0);
if($this->isThereSomeVisits === false)
{
return;
diff --git a/core/Controller.php b/core/Controller.php
index ed615103a9..8718b20cf2 100644
--- a/core/Controller.php
+++ b/core/Controller.php
@@ -68,6 +68,21 @@ abstract class Piwik_Controller
return 'index';
}
+ protected $standardColumnNameToTranslation = array(
+ 'label' => 'General_ColumnLabel',
+ 'nb_visits' => 'General_ColumnNbVisits',
+ 'nb_actions' => 'General_ColumnNbActions',
+ 'max_actions' => 'General_ColumnMaxActions',
+ 'sum_visit_length' => 'General_ColumnSumVisitLength',
+ 'nb_uniq_visitors' => 'General_ColumnNbUniqVisitors',
+ 'nb_actions_per_visit' => 'General_ColumnActionsPerVisit',
+ 'avg_time_on_site' => 'General_ColumnAvgTimeOnSite',
+ 'bounce_rate' => 'General_ColumnBounceRate',
+
+ 'revenue_per_visit' => 'General_ColumnValuePerVisit',
+ 'goals_conversion_rate' => 'General_ColumnVisitsWithConversions',
+ );
+
/**
* Given an Object implementing Piwik_iView interface, we either:
* - echo the output of the rendering if fetch = false
@@ -88,6 +103,9 @@ abstract class Piwik_Controller
'controllerActionCalledWhenRequestSubTable' => $view->getControllerActionCalledWhenRequestSubTable(),
)
);
+
+ $standardColumnNameToTranslation = array_map('Piwik_Translate', $this->standardColumnNameToTranslation);
+ $view->setColumnsTranslations($standardColumnNameToTranslation);
$view->main();
$rendered = $view->getView()->render();
if($fetch)
@@ -118,7 +136,7 @@ abstract class Piwik_Controller
if( !is_null($this->date))
{
$view->setParametersToModify(
- $this->getGraphParamsModified( array('date'=>$this->strDate))
+ $this->getGraphParamsModified( array('date' => $this->strDate))
);
}
@@ -192,20 +210,22 @@ abstract class Piwik_Controller
}
/**
- * Returns the current URL to use in a <img src=X> to display a sparkline.
+ * Returns the current URL to use in a img src=X to display a sparkline.
* $action must be the name of a Controller method that requests data using the Piwik_ViewDataTable::factory
* It will automatically build a sparkline by setting the viewDataTable=sparkline parameter in the URL.
* It will also computes automatically the 'date' for the 'last30' days/weeks/etc.
*
* @param string $action, eg. method name of the controller to call in the img src
+ * @param array array of name => value of parameters to set in the generated GET url
* @return string the generated URL
*/
- protected function getUrlSparkline( $action )
+ protected function getUrlSparkline( $action, $customParameters = array() )
{
$params = $this->getGraphParamsModified(
array( 'viewDataTable' => 'sparkline',
'action' => $action,
'module' => $this->pluginName)
+ + $customParameters
);
$url = Piwik_Url::getCurrentQueryStringWithParametersModified($params);
return $url;
@@ -214,7 +234,8 @@ abstract class Piwik_Controller
protected function setGeneralVariablesView($view)
{
$oDate = Piwik_Date::factory($this->strDate);
- $localizedDateFormat = Piwik_Translate('CoreHome_LocalizedDateFormat');
+ //TODO TO FIX
+ $localizedDateFormat = Piwik_Translate('CoreHome_DayFormat');
$view->prettyDate = $oDate->getLocalized($localizedDateFormat);
$view->date = $this->strDate;
diff --git a/core/DataTable/Array.php b/core/DataTable/Array.php
index 63bbd6704b..11b812e894 100644
--- a/core/DataTable/Array.php
+++ b/core/DataTable/Array.php
@@ -111,7 +111,7 @@ class Piwik_DataTable_Array
*/
public function filter($className, $parameters = array())
{
- foreach($this->array as $table)
+ foreach($this->array as $id => $table)
{
$table->filter($className, $parameters);
}
@@ -161,6 +161,14 @@ class Piwik_DataTable_Array
$table->enableRecursiveSort();
}
}
+
+ public function deleteColumns($columns)
+ {
+ foreach($this->array as $table)
+ {
+ $table->deleteColumns($columns);
+ }
+ }
}
diff --git a/core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php b/core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php
index 7032a3a873..15ffab66c5 100644
--- a/core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php
+++ b/core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php
@@ -16,22 +16,32 @@ class Piwik_DataTable_Filter_ColumnCallbackAddColumnPercentage extends Piwik_Dat
{
private $columnValueToRead;
private $columnNamePercentageToAdd;
- private $totalValueUsedToComputePercentage;
+ private $columnNameUsedAsDivisor;
+ private $totalValueUsedAsDivisor;
private $percentagePrecision;
/**
* @param Piwik_DataTable $table
* @param string $columnValueToRead
* @param string $columnNamePercentageToAdd
- * @param double $totalValueUsedToComputePercentage
+ * @param numeric|string $totalValueUsedToComputePercentageOrColumnName
+ * if a numeric value is given, we use this value as the divisor to process the percentage.
+ * if a string is given, this string is the column name's value used as the divisor.
* @param int $percentagePrecision precision 0 means "11", 1 means "11.2"
*/
- public function __construct( $table, $columnValueToRead, $columnNamePercentageToAdd, $totalValueUsedToComputePercentage, $percentagePrecision = 0 )
+ public function __construct( $table, $columnValueToRead, $columnNamePercentageToAdd, $totalValueUsedToComputePercentageOrColumnName, $percentagePrecision = 0 )
{
parent::__construct($table);
$this->columnValueToRead = $columnValueToRead;
$this->columnNamePercentageToAdd = $columnNamePercentageToAdd;
- $this->totalValueUsedToComputePercentage = $totalValueUsedToComputePercentage;
+ if(is_numeric($totalValueUsedToComputePercentageOrColumnName))
+ {
+ $this->totalValueUsedAsDivisor = $totalValueUsedToComputePercentageOrColumnName;
+ }
+ else
+ {
+ $this->columnNameUsedAsDivisor = $totalValueUsedToComputePercentageOrColumnName;
+ }
$this->percentagePrecision = $percentagePrecision;
$this->filter();
}
@@ -41,7 +51,15 @@ class Piwik_DataTable_Filter_ColumnCallbackAddColumnPercentage extends Piwik_Dat
foreach($this->table->getRows() as $key => $row)
{
$value = $row->getColumn($this->columnValueToRead);
- $percentage = round( 100 * $value / $this->totalValueUsedToComputePercentage, $this->percentagePrecision);
+ if(!is_null($this->totalValueUsedAsDivisor))
+ {
+ $divisor = $this->totalValueUsedAsDivisor;
+ }
+ else
+ {
+ $divisor = $row->getColumn($this->columnNameUsedAsDivisor);
+ }
+ $percentage = Piwik::getPercentageSafe($value, $divisor, $this->percentagePrecision);
$row->addColumn($this->columnNamePercentageToAdd, $percentage);
}
}
diff --git a/core/DataTable/Filter/SafeDecodeLabel.php b/core/DataTable/Filter/SafeDecodeLabel.php
index fc293d9107..454d4599f4 100644
--- a/core/DataTable/Filter/SafeDecodeLabel.php
+++ b/core/DataTable/Filter/SafeDecodeLabel.php
@@ -28,13 +28,18 @@ class Piwik_DataTable_Filter_SafeDecodeLabel extends Piwik_DataTable_Filter
{
foreach($this->table->getRows() as $row)
{
- $row->setColumn( $this->columnToDecode,
+ $value = $row->getColumn($this->columnToDecode);
+ if($value !== false)
+ {
+ $row->setColumn(
+ $this->columnToDecode,
htmlspecialchars(
htmlspecialchars_decode(
- urldecode($row->getColumn($this->columnToDecode)),
+ urldecode($value),
ENT_QUOTES),
ENT_QUOTES)
);
+ }
}
}
}
diff --git a/core/DataTable/Renderer/Console.php b/core/DataTable/Renderer/Console.php
index b0c00e3f6f..d324370024 100644
--- a/core/DataTable/Renderer/Console.php
+++ b/core/DataTable/Renderer/Console.php
@@ -29,16 +29,27 @@ class Piwik_DataTable_Renderer_Console extends Piwik_DataTable_Renderer
$this->prefixRows = $str;
}
- protected function renderDataTableArray(Piwik_DataTable_Array $table, $prefix )
+ protected function renderDataTableArray(Piwik_DataTable_Array $tableArray, $prefix )
{
$output = "Piwik_DataTable_Array<hr>";
$prefix = $prefix . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
- foreach($table->getArray() as $descTable => $table)
+ foreach($tableArray->getArray() as $descTable => $table)
{
$output .= $prefix . "<b>". $descTable. "</b><br>";
$output .= $prefix . $this->renderTable($table, $prefix . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
$output .= "<hr>";
}
+ $output .= "Metadata<br>";
+ foreach($tableArray->metadata as $id => $metadata)
+ {
+ $output .= "<br>";
+ $output .= $prefix . " <b>$id</b> <br>";
+ foreach($metadata as $name => $value)
+ {
+ $output .= $prefix . $prefix . "$name => $value";
+ }
+ }
+ $output .= "<hr>";
return $output;
}
diff --git a/core/DataTable/Renderer/Csv.php b/core/DataTable/Renderer/Csv.php
index 55a4887370..53dbc25a8d 100644
--- a/core/DataTable/Renderer/Csv.php
+++ b/core/DataTable/Renderer/Csv.php
@@ -110,16 +110,21 @@ class Piwik_DataTable_Renderer_Csv extends Piwik_DataTable_Renderer
protected function renderDataTable( $table )
{
- if($table instanceof Piwik_DataTable_Simple
- && $table->getRowsCount() == 1)
+ if($table instanceof Piwik_DataTable_Simple)
{
- $str = 'value' . $this->lineEnd . $this->formatValue($table->getRowFromId(0)->getColumn('value'));
- return $str;
+ $row = $table->getFirstRow();
+ if($row !== false)
+ {
+ $columnNameToValue = $row->getColumns();
+ if(count($columnNameToValue) == 1)
+ {
+ $value = array_values($columnNameToValue);
+ $str = 'value' . $this->lineEnd . $this->formatValue($value[0]);
+ return $str;
+ }
+ }
}
-
- $csv = array();
-
- $allColumns = array();
+ $csv = $allColumns = array();
foreach($table->getRows() as $row)
{
$csvRow = array();
diff --git a/core/DataTable/Renderer/Html.php b/core/DataTable/Renderer/Html.php
index ef9664ba23..6601a6c7ad 100644
--- a/core/DataTable/Renderer/Html.php
+++ b/core/DataTable/Renderer/Html.php
@@ -51,12 +51,6 @@ class Piwik_DataTable_Renderer_Html extends Piwik_DataTable_Renderer
{
return "<b><i>Empty table</i></b> <br>\n";
}
- if($table instanceof Piwik_DataTable_Simple
- && $table->getRowsCount() ==1)
- {
- $table->deleteColumn('label');
- }
-
static $depth=0;
$i = 1;
$someMetadata = false;
diff --git a/core/DataTable/Renderer/Php.php b/core/DataTable/Renderer/Php.php
index b098fedeb8..1fcfea5d3b 100644
--- a/core/DataTable/Renderer/Php.php
+++ b/core/DataTable/Renderer/Php.php
@@ -97,7 +97,6 @@ class Piwik_DataTable_Renderer_Php extends Piwik_DataTable_Renderer
}
}
- // A DataTable_Simple is already flattened so no need to do some crazy stuff to convert it
else if($dataTable instanceof Piwik_DataTable_Simple)
{
$flatArray = $this->renderSimpleTable($dataTable);
@@ -198,9 +197,15 @@ class Piwik_DataTable_Renderer_Php extends Piwik_DataTable_Renderer
protected function renderSimpleTable($table)
{
$array = array();
- foreach($table->getRows() as $row)
+
+ $row = $table->getFirstRow();
+ if($row === false)
+ {
+ return $array;
+ }
+ foreach($row->getColumns() as $columnName => $columnValue)
{
- $array[$row->getColumn('label')] = $row->getColumn('value');
+ $array[$columnName] = $columnValue;
}
return $array;
}
diff --git a/core/DataTable/Renderer/Rss.php b/core/DataTable/Renderer/Rss.php
index 311925a9e7..fc8565bf66 100644
--- a/core/DataTable/Renderer/Rss.php
+++ b/core/DataTable/Renderer/Rss.php
@@ -95,16 +95,10 @@ class Piwik_DataTable_Renderer_Rss extends Piwik_DataTable_Renderer
protected function renderDataTable($table)
{
-
if($table->getRowsCount() == 0)
{
return "<b><i>Empty table</i></b> <br>\n";
}
- if($table instanceof Piwik_DataTable_Simple
- && $table->getRowsCount() ==1)
- {
- $table->deleteColumn('label');
- }
$i = 1;
$tableStructure = array();
diff --git a/core/DataTable/Renderer/Xml.php b/core/DataTable/Renderer/Xml.php
index f509c3e9bf..5d70a44bf8 100644
--- a/core/DataTable/Renderer/Xml.php
+++ b/core/DataTable/Renderer/Xml.php
@@ -160,9 +160,9 @@ class Piwik_DataTable_Renderer_Xml extends Piwik_DataTable_Renderer
{
if(is_array($dataTableSimple))
{
- $dataTableSimple = "\n" . $this->renderDataTableSimple($dataTableSimple, $prefixLines . "\t") . "\t" ;
+ $dataTableSimple = "\n" . $this->renderDataTableSimple($dataTableSimple, $prefixLines . "\t") . $prefixLines . "\t";
}
- $xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$valueAttribute\">".$dataTableSimple. $prefixLines . "</result>\n";
+ $xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$valueAttribute\">".$dataTableSimple. "</result>\n";
}
}
return $xml;
diff --git a/core/DataTable/Simple.php b/core/DataTable/Simple.php
index 33c9f87b79..8dfdbaefec 100644
--- a/core/DataTable/Simple.php
+++ b/core/DataTable/Simple.php
@@ -34,28 +34,6 @@ class Piwik_DataTable_Simple extends Piwik_DataTable
*/
function addRowsFromArray($array)
{
- foreach($array as $label => $value)
- {
- $row = new Piwik_DataTable_Row;
- $row->addColumn('label', $label);
- $row->addColumn('value', $value);
- $this->addRow($row);
- }
- }
-
- /**
- * Returns the 'value' column of the row that has a label '$label'.
- *
- * @param string Label of the row we want the value
- * @return false|mixed The 'value' column of the row labelled $label
- */
- function getColumn( $label )
- {
- $row = $this->getRowFromLabel($label);
- if($row === false)
- {
- return false;
- }
- return $row->getColumn('value');
+ $this->addRowsFromSimpleArray(array($array));
}
}
diff --git a/core/Date.php b/core/Date.php
index fc708ffd86..394adab8d4 100644
--- a/core/Date.php
+++ b/core/Date.php
@@ -237,20 +237,23 @@ class Piwik_Date
return date($part, $this->getTimestamp());
}
- /**
- * Returns a localized representation of a date or datepart
- *
- * @see Windows compatible arguments http://msdn.microsoft.com/en-us/library/fe06s4ak(VS.71).aspx
- * @param string OPTIONAL Part of the date to return (in strftime format), if null timestamp is returned
- * @return integer|string date or datepart
- */
- public function getLocalized($part = null)
+ //TODO to test
+ public function getLocalized($template)
{
- if(is_null($part))
- {
- return $this->getTimestamp();
- }
- return strftime($part, $this->getTimestamp());
+ $day = $this->toString('j');
+ $dayOfWeek = $this->toString('N');
+ $monthOfYear = $this->toString('n');
+ $patternToValue = array(
+ "%day%" => $day,
+ "%shortMonth%" => Piwik_Translate('General_ShortMonth_'.$monthOfYear),
+ "%longMonth%" => Piwik_Translate('General_LongMonth_'.$monthOfYear),
+ "%shortDay%" => Piwik_Translate('General_ShortDay_'.$dayOfWeek),
+ "%longDay%" => Piwik_Translate('General_LongDay_'.$dayOfWeek),
+ "%longYear%" => $this->toString('Y'),
+ "%shortYear%" => $this->toString('y'),
+ );
+ $out = str_replace(array_keys($patternToValue), array_values($patternToValue), $template);
+ return $out;
}
/**
diff --git a/core/FrontController.php b/core/FrontController.php
index bccd477520..8270f53212 100644
--- a/core/FrontController.php
+++ b/core/FrontController.php
@@ -235,6 +235,7 @@ class Piwik_FrontController
Piwik::createAccessObject();
require_once "CoreUpdater/Controller.php";
+ //TODO should not be a controller!
$updaterController = new Piwik_CoreUpdater_Controller();
$updaterController->checkForCoreAndPluginsUpdates();
diff --git a/core/Period.php b/core/Period.php
index 50201bf583..b5fbd33e0e 100644
--- a/core/Period.php
+++ b/core/Period.php
@@ -221,7 +221,8 @@ abstract class Piwik_Period
public function __toString()
{
- return $this->toString();
+ $elements = $this->toString();
+ return implode(",", $elements);
}
public function get( $part= null )
@@ -234,6 +235,7 @@ abstract class Piwik_Period
}
abstract public function getPrettyString();
+ abstract public function getLocalizedShortString();
}
diff --git a/core/Period/Day.php b/core/Period/Day.php
index e4597945de..55f158a796 100644
--- a/core/Period/Day.php
+++ b/core/Period/Day.php
@@ -7,12 +7,20 @@
class Piwik_Period_Day extends Piwik_Period
{
protected $label = 'day';
-
+
public function getPrettyString()
{
$out = $this->getDateStart()->toString() ;
return $out;
}
+ public function getLocalizedShortString()
+ {
+ //"Mon 15 Aug"
+ $date = $this->getDateStart();
+ $template = "%shortDay% %day% %shortMonth%";
+ $out = $date->getLocalized($template);
+ return $out;
+ }
public function isFinished()
{
@@ -37,4 +45,8 @@ class Piwik_Period_Day extends Piwik_Period
{
return $this->date->toString("Y-m-d");
}
+ public function __toString()
+ {
+ return $this->toString();
+ }
}
diff --git a/core/Period/Month.php b/core/Period/Month.php
index 57fd1d25c5..3d6e9f9d77 100644
--- a/core/Period/Month.php
+++ b/core/Period/Month.php
@@ -7,6 +7,13 @@ class Piwik_Period_Month extends Piwik_Period
{
protected $label = 'month';
+ public function getLocalizedShortString()
+ {
+ //"Aug 09"
+ $out = $this->getDateStart()->getLocalized("%shortMonth% %shortYear%");
+ return $out;
+ }
+
public function getPrettyString()
{
$out = $this->getDateStart()->toString('Y-m');
diff --git a/core/Period/Range.php b/core/Period/Range.php
index d3cdc1982a..dea4ed73ad 100644
--- a/core/Period/Range.php
+++ b/core/Period/Range.php
@@ -12,7 +12,17 @@ class Piwik_Period_Range extends Piwik_Period
$this->strDate = $strDate;
$this->defaultEndDate = null;
}
-
+ public function getLocalizedShortString()
+ {
+ //"30 Dec 08 - 26 Feb 09"
+ $dateStart = $this->getDateStart();
+ $dateEnd = $this->getDateEnd();
+ $template = "%day% %shortMonth% %shortYear%";
+ $shortDateStart = $dateStart->getLocalized($template);
+ $shortDateEnd = $dateEnd->getLocalized($template);
+ $out = "$shortDateStart - $shortDateEnd";
+ return $out;
+ }
public function getPrettyString()
{
$out = "From ".$this->getDateStart()->toString() . " to " . $this->getDateEnd()->toString();
diff --git a/core/Period/Week.php b/core/Period/Week.php
index f24002c878..f0c682241a 100644
--- a/core/Period/Week.php
+++ b/core/Period/Week.php
@@ -7,6 +7,17 @@
class Piwik_Period_Week extends Piwik_Period
{
protected $label = 'week';
+
+ public function getLocalizedShortString()
+ {
+ //"Week 30 Dec - 6 Jan 09"
+ $dateStart = $this->getDateStart();
+ $dateEnd = $this->getDateEnd();
+ $shortDateStart = $dateStart->getLocalized("%day% %shortMonth%");
+ $shortDateEnd = $dateEnd->getLocalized("%day% %shortMonth% %shortYear%");
+ $out = "$shortDateStart - $shortDateEnd";
+ return $out;
+ }
public function getPrettyString()
{
diff --git a/core/Period/Year.php b/core/Period/Year.php
index 5ff4f083a7..c916e5ca7a 100644
--- a/core/Period/Year.php
+++ b/core/Period/Year.php
@@ -9,6 +9,13 @@ class Piwik_Period_Year extends Piwik_Period
{
protected $label = 'year';
+ public function getLocalizedShortString()
+ {
+ //"2009"
+ $out = $this->getDateStart()->getLocalized("%longYear%");
+ return $out;
+ }
+
public function getPrettyString()
{
$out = $this->getDateStart()->toString('Y');
diff --git a/core/Piwik.php b/core/Piwik.php
index ae7360c375..8f928ccf3f 100644
--- a/core/Piwik.php
+++ b/core/Piwik.php
@@ -407,6 +407,15 @@ class Piwik
return sprintf("$symbol%.2f", $value);
}
+ static public function getPercentageSafe($dividend, $divisor, $precision = 0)
+ {
+ if($divisor == 0)
+ {
+ return 0;
+ }
+ return round(100 * $dividend / $divisor, $precision);
+ }
+
static public function getPrettyTimeFromSeconds($numberOfSeconds)
{
$numberOfSeconds = (double)$numberOfSeconds;
diff --git a/core/PluginsFunctions/WidgetsList.php b/core/PluginsFunctions/WidgetsList.php
index d06f8e8aef..e8339543f7 100644
--- a/core/PluginsFunctions/WidgetsList.php
+++ b/core/PluginsFunctions/WidgetsList.php
@@ -4,9 +4,9 @@ function Piwik_GetWidgetsList()
return Piwik_WidgetsList::get();
}
-function Piwik_AddWidget( $pluginName, $controllerMethodToCall, $widgetTitle )
+function Piwik_AddWidget( $widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array())
{
- Piwik_WidgetsList::add($pluginName, $controllerMethodToCall, $widgetTitle);
+ Piwik_WidgetsList::add($widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters);
}
class Piwik_WidgetsList
@@ -19,8 +19,17 @@ class Piwik_WidgetsList
return self::$widgets;
}
- static function add($pluginName, $controllerMethodToCall, $widgetTitle)
+ static function add($widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters)
{
- self::$widgets[$pluginName][] = array( $widgetTitle, $controllerMethodToCall );
+ $widgetCategory = Piwik_Translate($widgetCategory);
+ $widgetName = Piwik_Translate($widgetName);
+ $widgetUniqueId = 'widget' . $controllerName . $controllerAction;
+ self::$widgets[$widgetCategory][] = array(
+ 'name' => $widgetName,
+ 'uniqueId' => $widgetUniqueId,
+ 'parameters' => array ( 'module' => $controllerName,
+ 'action' => $controllerAction
+ ) + $customParameters
+ );
}
}
diff --git a/core/Site.php b/core/Site.php
index eeb7ef68c0..4b04df8915 100644
--- a/core/Site.php
+++ b/core/Site.php
@@ -28,6 +28,11 @@ class Piwik_Site
}
}
+ function __toString()
+ {
+ return "site id=".$this->getId().", name=".$this->getName();
+ }
+
function getName()
{
return self::$infoSites[$this->id]['name'];
diff --git a/core/SmartyPlugins/function.loadJavascriptTranslations.php b/core/SmartyPlugins/function.loadJavascriptTranslations.php
index 64d218160b..bd1a7fc634 100644
--- a/core/SmartyPlugins/function.loadJavascriptTranslations.php
+++ b/core/SmartyPlugins/function.loadJavascriptTranslations.php
@@ -1,38 +1,24 @@
<?php
/**
- * inserts javascript translation array into the template from given plugins
- * must be called with 'plugins' argument which consists of space-separated module names (i.e. plugins)
- *
- *
- * Example (use in template):
+ * Load translation strings suffixed with _js for a given list of modules.
+ * This function needs to be called when you want to i18n the user interface.
*
+ * How to use the function in smarty templates:
* {loadJavascriptTranslations plugins='SitesManager CoreHome General'}
*
- * loads javascript array translations from main translation file ('General')
- * and both 'CoreHome' and 'SitesManager' plugins translations
- *
- * Note: You can put noHtml=1 option in order to output pure JS code
- *
- * only translations with '_fs' suffix will be loaded
+ * This will load the javascript translations array for the modules specified as parameters.
+ * Only translations string with their ids suffixed with '_js' will be loaded
+ * Note: You can specify disableOutputScriptTag=1 and the returned value won't be enclosed in Javascript tags.
*
- * in order to use translation in your javascript use _pk_translate function
- * (it is always loaded with translations):
+ * You can then translate strings in javascript by calling the javascript function:
+ * _pk_translate('MY_TRANSLATION_STRING_js')
*
- * <script type="text/javascript">
- * alert(_pk_translate('MY_TRANSLATION_STRING'))
- * </script>
- *
- * Note: Use translation string from your translation file WITHOUT '_js' suffix.
- *
- * _pk_translate DOES NOT support printf() arguments, but you can call:
- *
- * sprintf(_pk_translate('_NB_OF_EGGS'),'ten')
- * (where _NB_OF_EGGS is defined in translation file as i.e. 'There is %s eggs on the table')
- *
- * sprintf() function is by default included when loading translations
+ * _pk_translate does NOT support printf() arguments, but you can call:
+ * sprintf(_pk_translate('MyPlugin_numberOfEggs_js'),'ten')
+ * where you would have the following in your translation file plugins/MyPlugin/lang/en.php:
+ * 'MyPlugin_numberOfEggs_js' => 'There are %s eggs.'
*/
-
function smarty_function_loadJavascriptTranslations($params, &$smarty)
{
static $pluginTranslationsAlreadyLoaded = array();
@@ -45,12 +31,9 @@ function smarty_function_loadJavascriptTranslations($params, &$smarty)
return;
}
$pluginTranslationsAlreadyLoaded[] = $params['plugins'];
- $translate = Piwik_Translate::getInstance();
- $jsTranslations = $translate->getJavascriptTranslations(explode(' ',$params['plugins']));
-
- $jsCode = "";
-
- if( isset($params['noHtml']) )
+ $jsTranslations = Piwik_Translate::getInstance()->getJavascriptTranslations(explode(' ',$params['plugins']));
+ $jsCode = '';
+ if( isset($params['disableOutputScriptTag']) )
{
$jsCode .= $jsTranslations;
}
@@ -60,6 +43,5 @@ function smarty_function_loadJavascriptTranslations($params, &$smarty)
$jsCode .= $jsTranslations;
$jsCode .= '</script>';
}
-
return $jsCode;
}
diff --git a/core/Translate.php b/core/Translate.php
index 48b53029c6..3917bca56f 100644
--- a/core/Translate.php
+++ b/core/Translate.php
@@ -113,24 +113,17 @@ class Piwik_Translate
foreach($GLOBALS['Piwik_translations'] as $key => $value)
{
- $matches = array();
-
- if( preg_match($moduleRegex,$key,$matches) ) {
- $varName = $matches[1].'_'.$matches[2];
- $varValue = $value;
-
- $js .= "".$varName.": '".str_replace("'","\\'",$varValue)."',";
+ if( preg_match($moduleRegex,$key) ) {
+ $js .= '"'.$key.'": "'.str_replace('"','\"',$value).'",';
}
-
- $matches = null;
}
$js = substr($js,0,-1);
$js .= '};';
$js .= 'if(typeof(piwik_translations) == \'undefined\') { var piwik_translations = new Object; }'.
'for(var i in translations) { piwik_translations[i] = translations[i];} ';
- $js .= 'function _pk_translate(tvar, str) { '.
- 'var s = str; if( typeof(piwik_translations[tvar]) != \'undefined\' ){ s = piwik_translations[tvar]; }'.
- 'return s;}';
+ $js .= 'function _pk_translate(translationStringId) { '.
+ 'if( typeof(piwik_translations[translationStringId]) != \'undefined\' ){ return piwik_translations[translationStringId]; }'.
+ 'return "The string "+translationStringId+" was not loaded in javascript. Make sure it is prefixed with _js";}';
return $js;
}
@@ -175,5 +168,3 @@ function Piwik_TranslateException($message, $args = array())
return $message;
}
}
-
-
diff --git a/core/Url.php b/core/Url.php
index e0e221e06f..27b57310ec 100644
--- a/core/Url.php
+++ b/core/Url.php
@@ -174,6 +174,10 @@ class Piwik_Url
$query = '';
foreach($urlValues as $name => $value)
{
+ if(empty($value))
+ {
+ continue;
+ }
if(is_array($value))
{
foreach($value as $theValue)
diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php
index 9854c2b081..c30cb185d6 100644
--- a/core/ViewDataTable.php
+++ b/core/ViewDataTable.php
@@ -110,6 +110,13 @@ abstract class Piwik_ViewDataTable
protected $view = null;
/**
+ * Array of columns names translations
+ *
+ * @var array
+ */
+ protected $columnsTranslations = array();
+
+ /**
* Method to be implemented by the ViewDataTable_*.
* This method should create and initialize a $this->view object @see Piwik_iView
* @return mixed either prints the result or returns the output string
@@ -755,6 +762,45 @@ abstract class Piwik_ViewDataTable
$this->variablesDefault['filter_sort_order'] = $order;
}
+
+ /**
+ * Sets translation string for given column
+ *
+ * @param string $columnName column name
+ * @param string $columnTranslation column name translation
+ */
+ public function setColumnTranslation( $columnName, $columnTranslation )
+ {
+ $this->columnsTranslations[$columnName] = $columnTranslation;
+ }
+
+ /**
+ * Returns column translation if available, in other case given column name
+ *
+ * @param string $columnName column name
+ */
+ public function getColumnTranslation( $columnName )
+ {
+ if( isset($this->columnsTranslations[$columnName]) )
+ {
+ return $this->columnsTranslations[$columnName];
+ }
+ else
+ {
+ return $columnName;
+ }
+ }
+
+ /**
+ * Sets columns translations array.
+ *
+ * @param array $columnsTranslations An associative array indexed by column names, eg. array('nb_visit'=>"Numer of visits")
+ */
+ public function setColumnsTranslations( $columnsTranslations )
+ {
+ $this->columnsTranslations += $columnsTranslations;
+ }
+
/**
* Sets a custom parameter, that will be printed in the javascript array associated with each datatable
*
diff --git a/core/ViewDataTable/GenerateGraphData.php b/core/ViewDataTable/GenerateGraphData.php
index c041ed75ed..bf5285cca9 100644
--- a/core/ViewDataTable/GenerateGraphData.php
+++ b/core/ViewDataTable/GenerateGraphData.php
@@ -37,13 +37,25 @@ abstract class Piwik_ViewDataTable_GenerateGraphData extends Piwik_ViewDataTable
*/
protected $graphLimit = null;
+ protected $columnsToDisplay = array();
+
+ public function setColumnsToDisplay($columns)
+ {
+ $this->columnsToDisplay = $columns;
+ }
+
+ public function getColumnsToDisplay()
+ {
+ return $this->columnsToDisplay;
+ }
+
/**
* Sets the number max of elements to display (number of pie slice, vertical bars, etc.)
* If the data has more elements than $limit then the last part of the data will be the sum of all the remaining data.
*
* @param int $limit
*/
- function setGraphLimit( $limit )
+ public function setGraphLimit( $limit )
{
$this->graphLimit = $limit;
}
@@ -57,7 +69,7 @@ abstract class Piwik_ViewDataTable_GenerateGraphData extends Piwik_ViewDataTable
{
return $this->graphLimit;
}
-
+
public function main()
{
if($this->mainAlreadyExecuted)
@@ -82,52 +94,41 @@ abstract class Piwik_ViewDataTable_GenerateGraphData extends Piwik_ViewDataTable
)
);
}
- $this->dataAvailable = $this->dataTable->getRowsCount() != 0;
-
- if(!$this->dataAvailable)
+ $this->isDataAvailable = $this->dataTable->getRowsCount() != 0;
+
+ if(!$this->isDataAvailable)
{
- $this->view->customizeGraph();
- $this->view->title(Piwik_Translate('General_NoDataForGraph'), '{font-size: 25px;}');
+ $this->view->setTitle(Piwik_Translate('General_NoDataForGraph'), '{font-size: 25px;}');
}
else
{
- $data = $this->generateDataFromDataTable();
- $this->view->setData($data);
- $this->view->customizeGraph();
+ $this->generateDataFromDataTable();
}
+ //TODO rename
+ $this->view->customizeGraph();
}
-
- /**
- * Returns a format friendly array from the dataTable
- *
- * @return array
- */
+
+ //TODO rename
protected function generateDataFromDataTable()
{
$this->dataTable->applyQueuedFilters();
+
// We apply a filter to the DataTable, decoding the label column (useful for keywords for example)
- $this->dataTable->filter('ColumnCallbackReplace',
- array('label','urldecode')
- );
- $data = array();
- foreach($this->dataTable->getRows() as $row)
+ $this->dataTable->filter('ColumnCallbackReplace', array('label','urldecode') );
+
+ $xLabels = $this->dataTable->getColumn('label');
+ $columnNames = array_keys($this->dataTable->getFirstRow()->getColumns());
+ unset($columnNames[array_search('label',$columnNames)]);
+
+ $columnNameToTranslation = $columnNameToValue = array();
+ foreach($columnNames as $columnName)
{
- $label = $row->getColumn('label');
- $value = $row->getColumn('nb_uniq_visitors');
-
- // case no unique visitors
- if($value === false)
- {
- $value = $row->getColumn('nb_visits');
- }
-
- $data[] = array(
- 'label' => $label,
- 'value' => $value,
- 'url' => $row->getMetadata('url'),
- );
+ $columnNameToTranslation[$columnName] = $this->getColumnTranslation($columnName);
+ $columnNameToValue[$columnName] = $this->dataTable->getColumn($columnName);
}
- return $data;
+ $this->view->setAxisXLabels($xLabels);
+ $this->view->setAxisYValues($columnNameToValue);
+ $this->view->setAxisYLabels($columnNameToTranslation);
}
}
diff --git a/core/ViewDataTable/GenerateGraphData/ChartEvolution.php b/core/ViewDataTable/GenerateGraphData/ChartEvolution.php
index 0dd6c56468..30ee37fd1f 100644
--- a/core/ViewDataTable/GenerateGraphData/ChartEvolution.php
+++ b/core/ViewDataTable/GenerateGraphData/ChartEvolution.php
@@ -12,196 +12,133 @@ class Piwik_ViewDataTable_GenerateGraphData_ChartEvolution extends Piwik_ViewDat
{
return 'generateDataChartEvolution';
}
+
function __construct()
{
require_once "Visualization/Chart/Evolution.php";
$this->view = new Piwik_Visualization_Chart_Evolution;
}
- var $lineLabels = array();
- var $data = array();
-
- private function generateLine( $dataArray, $columns, $schema = "##label## ##column##" )
+ protected function generateDataFromDataTable()
{
- $data = array();
- foreach($dataArray as $keyName => $table)
+ $this->dataTable->applyQueuedFilters();
+ if(!($this->dataTable instanceof Piwik_DataTable_Array))
{
- $table->applyQueuedFilters();
- // initialize data (default values for all lines is 0)
- $dataRow = array();
- $rows = $table->getRows();
- foreach($rows as $row)
- {
- $rowLabel = $schema;
- if( strpos($rowLabel, "##label##") !== false )
- {
- $rowLabel = str_replace("##label##", $row->getColumn('label'), $rowLabel);
- }
- foreach($columns as $col)
- {
- $label = $rowLabel;
- if( strpos($label, "##column##") !== false )
- {
- $label = str_replace("##column##", $col, $label);
- }
- if( !isset($this->lineLabels[$label]) )
- {
- $this->lineLabels[$label] = count($this->lineLabels);
- }
- $lineNb = $this->lineLabels[$label];
-
- $value = $row->getColumn($col);
-
- $dataRow['value'.$lineNb] = $value;
- }
- }
- $data[] = $dataRow;
+ throw new Exception("Expecting a DataTable_Array with custom format to draw an evolution chart");
}
- return $data;
- }
-
- private function generateLabels( $dataArray )
- {
- $data = array();
-
- foreach($dataArray as $keyName => $table)
+ $xLabels = $uniqueIdsDataTable = array();
+ foreach($this->dataTable->metadata as $idDataTable => $metadataDataTable)
{
- $table->applyQueuedFilters();
-
- $data[] = array('label' => $keyName);
+ $xLabels[] = $metadataDataTable['period']->getLocalizedShortString();
+ $uniqueIdsDataTable[] = $idDataTable;
}
- return $data;
- }
-
- private function addArray( &$data, $newData )
- {
- for($i = 0; $i < count($newData); $i++)
+ // list of column names requested to be plotted, we only need to forward these to the Graph object
+ $columnNameRequested = $this->getColumnsToDisplay();
+
+ $columnNameToValue = array();
+ foreach($this->dataTable->getArray() as $idDataTable => $dataTable)
{
- foreach($newData[$i] as $key => $value)
+ if($dataTable->getRowsCount() > 1)
{
- $data[$i][$key] = $value;
+ throw new Exception("Expecting only one row per DataTable");
}
- }
- }
-
- private function fillValues( &$data )
- {
- $nbLines = count($this->lineLabels);
-
- for($i = 0; $i < count($data); $i++)
- {
- for($j = 0; $j < $nbLines; $j++)
+ $row = $dataTable->getFirstRow();
+ if($row !== false)
{
- if( !isset($data[$i]['value'.$j]) )
+ foreach($row->getColumns() as $columnName => $columnValue)
{
- $data[$i]['value'.$j] = 0;
+ if(array_search($columnName, $columnNameRequested) !== false)
+ {
+ $columnNameToValue[$columnName][$idDataTable] = $columnValue;
+ }
}
}
}
- }
-
- /*
- * generates data for evolution graph from a numeric DataTable (DataTable that has only 'label' and 'value' columns)
- */
- protected function generateDataFromNumericDataTable($dataArray, $siteLabel = "")
- {
- $columnsToDisplay = Piwik_Common::getRequestVar('columns', array(), 'array');
-
- // for numeric we want to have only one column name
- if( count($columnsToDisplay) != 1 )
- {
- $columnsToDisplay = array( 'nb_visits' );
- }
- $label = $siteLabel . array_shift($columnsToDisplay);
- $this->addArray($this->data, $this->generateLabels($dataArray));
- $this->addArray($this->data, $this->generateLine($dataArray,array('value'),$label));
- $this->fillValues($this->data);
- }
-
- /*
- * generates data for evolution graph from a DataTable that has named columns (i.e. 'nb_hits', 'nb_visits')
- */
- protected function generateDataFromRegularDataTable($dataArray, $siteLabel = "")
- {
- // get list of columns to display i.e. array('nb_hits','nb_visits')
- $columnsToDisplay = Piwik_Common::getRequestVar('columns', array(), 'array');
-
- // default column
- if( count($columnsToDisplay) == 0 )
+ // make sure all column values are set (at least zero) in order for all unique idDataTable
+ $columnNameToValueCleaned = array();
+ foreach($uniqueIdsDataTable as $uniqueIdDataTable)
{
- $columnsToDisplay = array( 'nb_visits' );
- }
-
- $this->addArray($this->data, $this->generateLabels($dataArray));
- $this->addArray($this->data, $this->generateLine($dataArray, $columnsToDisplay, $siteLabel."##label## ##column##"));
- $this->fillValues($this->data);
- }
-
- protected function handleSiteGenerateDataFromDataTable($dataArray, $siteLabel = "")
- {
- // detect if we got numeric Datatable or regular DataTable
- foreach($dataArray as $table)
- {
- $row = $table->getFirstRow();
-
- if( $row != null )
+ foreach($columnNameToValue as $columnName => $idDataTableToColumnValue)
{
- $columns = $row->getColumns();
-
- // if we got 2 columns - 'label' and 'value' this is numeric DataTable
- if( count($columns) == 2 && isset($columns['label']) && isset($columns['value']) )
+ if(isset($idDataTableToColumnValue[$uniqueIdDataTable]))
{
- $this->generateDataFromNumericDataTable($dataArray, $siteLabel);
+ $columnValue = $idDataTableToColumnValue[$uniqueIdDataTable];
}
else
{
- $this->generateDataFromRegularDataTable($dataArray, $siteLabel);
+ $columnValue = 0;
}
- break;
+ $columnNameToValueCleaned[$columnName][] = $columnValue;
}
}
- }
-
- public function generateDataFromDataTable()
- {
- $data = array();
-
- if( $this->dataTable->getRowsCount() )
+ $columnNames = array_keys($columnNameToValueCleaned);
+ $columnNameToTranslation = array();
+ $columnNameToType = array();
+ $nameToType = array(
+ '_rate' => '%',
+ '_revenue' => Piwik::getCurrency(),
+ );
+ foreach($columnNames as $columnName)
{
- $row = null;
-
- // find first table with rows
- foreach($this->dataTable->getArray() as $idsite => $table)
+ $columnNameToTranslation[$columnName] = $this->getColumnTranslation($columnName);
+ $columnNameToType[$columnName] = false;
+ foreach($nameToType as $pattern => $type)
{
- // detect if we got data from more than one site
- if( $table instanceof Piwik_DataTable_Array)
- {
- // multiple sites
- $site = new Piwik_Site($idsite);
-
- $this->handleSiteGenerateDataFromDataTable($table->getArray(), $site->getName()." ");
- }
- else if( $table instanceof Piwik_DataTable_Simple && $this->dataTable->getKeyName() == 'idSite')
- {
- // multiple sites (when numeric DataTable)
- $site = new Piwik_Site($idsite);
-
- $this->handleSiteGenerateDataFromDataTable($table->getFirstRow()->getColumn('value')->getArray(), $site->getName()." ");
- }
- else
+ if(strpos($columnName, $pattern) !== false)
{
- // single site
- $this->handleSiteGenerateDataFromDataTable($this->dataTable->getArray());
+ $columnNameToType[$columnName] = $type;
break;
- }
- }
+ }
+ }
+ }
+ $this->view->setAxisXLabels($xLabels);
+ $this->view->setAxisYValues($columnNameToValueCleaned);
+ $this->view->setAxisYLabels($columnNameToTranslation);
+ $this->view->setAxisYValuesTypes($columnNameToType);
+
+ $firstDatatable = reset($this->dataTable->metadata);
+ $period = $firstDatatable['period'];
+ switch($period->getLabel()) {
+ case 'day': $steps = 7; break;
+ case 'week': $steps = 10; break;
+ case 'month': $steps = 6; break;
+ case 'year': $steps = 2; break;
+ default: $steps = 10; break;
+ }
+ $this->view->setXSteps($steps);
+
+ if($this->isLinkEnabled())
+ {
+ $axisXOnClick = array();
+ foreach($this->dataTable->metadata as $idDataTable => $metadataDataTable)
+ {
+ $period = $metadataDataTable['period'];
+ $dateInUrl = $period->getDateStart();
+ $link = Piwik_Url::getCurrentUrlWithoutQueryString() .
+ Piwik_Url::getCurrentQueryStringWithParametersModified( array(
+ 'date' => $dateInUrl,
+ 'module' => 'CoreHome',
+ 'action' => 'index',
+ 'viewDataTable' => null, // we reset the viewDataTable parameter (useless in the link)
+ 'idGoal' => null, // we reset idGoal
+ 'columns' => null,
+ ));
+ $axisXOnClick[] = $link;
+ }
+ $this->view->setAxisXOnClick($axisXOnClick);
+ }
+ }
- }
- array_unshift($this->data, array_keys($this->lineLabels));
-
- return $this->data;
+ private function isLinkEnabled()
+ {
+ static $linkEnabled;
+ if(!isset($linkEnabled))
+ {
+ $linkEnabled = !Piwik_Common::getRequestVar('disableLink', 0, 'int');
+ }
+ return $linkEnabled;
}
}
diff --git a/core/ViewDataTable/GenerateGraphHTML.php b/core/ViewDataTable/GenerateGraphHTML.php
index 90ccfa54e7..0523531a82 100644
--- a/core/ViewDataTable/GenerateGraphHTML.php
+++ b/core/ViewDataTable/GenerateGraphHTML.php
@@ -127,7 +127,7 @@ abstract class Piwik_ViewDataTable_GenerateGraphHTML extends Piwik_ViewDataTable
$return .= '
</noscript></div></div>
<script type="text/javascript">
-swfobject.embedSWF("'.$pathToLibraryOpenChart.'open-flash-chart.swf", "'. $obj_id .'_swf", "'. $width . '", "' . $height . '", "9.0.0", false, {"data":"'.$url.'"}, {"allowScriptAccess":"sameDomain","wmode":"opaque"}, {"bgcolor":"#FFFFFF"});
+swfobject.embedSWF("'.$pathToLibraryOpenChart.'open-flash-chart.swf", "'. $obj_id .'_swf", "'. $width . '", "' . $height . '", "9.0.0", false, {"data-file":"'.$url.'"}, {"allowScriptAccess":"sameDomain","wmode":"opaque"}, {"bgcolor":"#FFFFFF"});
</script>';
}
diff --git a/core/ViewDataTable/HtmlTable.php b/core/ViewDataTable/HtmlTable.php
index 7eb9e5160e..ac6d56ca44 100644
--- a/core/ViewDataTable/HtmlTable.php
+++ b/core/ViewDataTable/HtmlTable.php
@@ -25,13 +25,6 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable
* @var array
*/
protected $columnsToDisplay = array();
-
- /**
- * Array of columns names translations
- *
- * @var array
- */
- protected $columnsTranslations = array();
/**
* Set to true when the DataTable must be loaded along with all its children subtables
@@ -63,11 +56,6 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable
$this->dataTableTemplate = 'CoreHome/templates/datatable.tpl';
$this->variablesDefault['enable_sort'] = '1';
- // load general columns translations
- $this->setColumnTranslation('nb_visits', Piwik_Translate('General_ColumnNbVisits'));
- $this->setColumnTranslation('label', Piwik_Translate('General_ColumnLabel'));
- $this->setColumnTranslation('nb_uniq_visitors', Piwik_Translate('General_ColumnNbUniqVisitors'));
-
$this->handleLowPopulation();
}
@@ -175,44 +163,6 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable
}
/**
- * Sets translation string for given column
- *
- * @param string $columnName column name
- * @param string $columnTranslation column name translation
- */
- public function setColumnTranslation( $columnName, $columnTranslation )
- {
- $this->columnsTranslations[$columnName] = $columnTranslation;
- }
-
- /**
- * Returns column translation if available, in other case given column name
- *
- * @param string $columnName column name
- */
- public function getColumnTranslation( $columnName )
- {
- if( isset($this->columnsTranslations[$columnName]) )
- {
- return $this->columnsTranslations[$columnName];
- }
- else
- {
- return $columnName;
- }
- }
-
- /**
- * Sets columns translations array.
- *
- * @param array $columnsTranslations An associative array indexed by column names, eg. array('nb_visit'=>"Numer of visits")
- */
- public function setColumnsTranslations( $columnsTranslations )
- {
- $this->columnsTranslations = $columnsTranslations;
- }
-
- /**
* Returns array(
* array('name' => 'nb_visits', 'displayName' => 'Visits'),
* array('name' => 'nb_uniq_visitors', 'displayName' => 'Unique Visitors'),
@@ -281,6 +231,7 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable
}
return $requestString;
}
+
/**
* Set the flag to load the datatable recursively so we can search on subtables as well
*
diff --git a/core/ViewDataTable/HtmlTable/AllColumns.php b/core/ViewDataTable/HtmlTable/AllColumns.php
index 786763abf1..2efdfbf129 100644
--- a/core/ViewDataTable/HtmlTable/AllColumns.php
+++ b/core/ViewDataTable/HtmlTable/AllColumns.php
@@ -37,8 +37,5 @@ class Piwik_ViewDataTable_HtmlTable_AllColumns extends Piwik_ViewDataTable_HtmlT
'bounce_rate'));
$this->dataTable->filter('ColumnCallbackReplace', array('avg_time_on_site', create_function('$averageTimeOnSite', 'return Piwik::getPrettyTimeFromSeconds($averageTimeOnSite);')));
$this->dataTable->filter('ColumnCallbackReplace', array('bounce_rate', create_function('$bounceRate', 'return $bounceRate."%";')));
- $this->setColumnTranslation('nb_actions_per_visit', Piwik_Translate('General_ColumnActionsPerVisit'));
- $this->setColumnTranslation('avg_time_on_site', Piwik_Translate('General_ColumnAvgTimeOnSite'));
- $this->setColumnTranslation('bounce_rate', Piwik_Translate('General_ColumnBounceRate'));
}
}
diff --git a/core/ViewDataTable/HtmlTable/Goals.php b/core/ViewDataTable/HtmlTable/Goals.php
index 1bc961940e..6f4f46ad65 100644
--- a/core/ViewDataTable/HtmlTable/Goals.php
+++ b/core/ViewDataTable/HtmlTable/Goals.php
@@ -70,8 +70,6 @@ class Piwik_ViewDataTable_HtmlTable_Goals extends Piwik_ViewDataTable_HtmlTable
protected function postDataTableLoadedFromAPI()
{
parent::postDataTableLoadedFromAPI();
- $this->setColumnTranslation('revenue_per_visit', 'Value per Visit');
- $this->setColumnTranslation('goals_conversion_rate', 'Visits with Conversions');
$this->columnsToPercentageFilter[] = 'goals_conversion_rate';
foreach($this->columnsToPercentageFilter as $columnName)
{
diff --git a/core/ViewDataTable/Sparkline.php b/core/ViewDataTable/Sparkline.php
index 8b694468ee..1982cba555 100644
--- a/core/ViewDataTable/Sparkline.php
+++ b/core/ViewDataTable/Sparkline.php
@@ -22,6 +22,18 @@ class Piwik_ViewDataTable_Sparkline extends Piwik_ViewDataTable
{
return 'sparkline';
}
+
+ protected $columnsToDisplay = array();
+
+ public function setColumnsToDisplay($columns)
+ {
+ $this->columnsToDisplay = $columns;
+ }
+
+ public function getColumnsToDisplay()
+ {
+ return $this->columnsToDisplay;
+ }
/**
* @see Piwik_ViewDataTable::main()
@@ -37,82 +49,55 @@ class Piwik_ViewDataTable_Sparkline extends Piwik_ViewDataTable
// we load the data with the filters applied
$this->loadDataTableFromAPI();
- $this->dataAvailable = $this->dataTable->getRowsCount() != 0;
- if(!$this->dataAvailable)
+ $this->isDataAvailable = $this->dataTable->getRowsCount() != 0;
+ if(!$this->isDataAvailable)
{
throw new Exception(Piwik_Translate('General_NoDataForGraph'));
}
- $data = $this->generateDataFromDataTableArray($this->dataTable);
+ $values = $this->getValuesFromDataTable($this->dataTable);
$graph = new Piwik_Visualization_Sparkline;
- $graph->setData($data);
+ $graph->setValues($values);
$graph->main();
$this->view = $graph;
}
- /**
- * Given a Piwik_DataTable_Array made of DataTable_Simple rows, returns a php array with the structure:
- * array(
- * array( label => X, value => Y),
- * array( label => A, value => B),
- * ...
- * )
- *
- * This is used for example for the evolution graph (last 30 days visits) or the sparklines.
- *
- * @param Piwik_DataTable_Array $dataTableArray
- * @return array
- */
- protected function generateDataFromDataTableArray( Piwik_DataTable_Array $dataTableArray)
+ protected function getValuesFromDataTable( Piwik_DataTable_Array $dataTableArray)
{
- $data = array();
+ $dataTableArray->applyQueuedFilters();
+
+ $columns = $this->getColumnsToDisplay();
+ $columnToPlot = false;
+ if(!empty($columns))
+ {
+ $columnToPlot = $columns[0];
+ }
+ $values = array();
foreach($dataTableArray->getArray() as $keyName => $table)
{
- if($table instanceof Piwik_DataTable_Array)
+ $value = 0;
+ if($table->getRowsCount() > 1)
{
- throw new Exception("Operation not supported (yet)");
+ throw new Exception("Expecting only one row per DataTable");
}
- $value = false;
-
$onlyRow = $table->getFirstRow();
if($onlyRow !== false)
{
- $value = $onlyRow->getColumn('value');
- if($value == false)
+ if(!empty($columnToPlot))
{
- // TEMP
- // quite a hack, useful in the case at this point we do have a normal row with nb_visits, nb_actions, nb_uniq_visitors, etc.
- // instead of the dataTable_Simple row (label, value)
- // to do it properly we'd need to
- // - create a filter that removes columns
- // - apply this filter to keep only the column called nb_uniq_visitors
- // - rename this column as 'value'
- // and at this point the getcolumn('value') would have worked
- // this code is executed eg. when displaying a sparkline for the last 30 days displaying the number of unique visitors coming from search engines
-
- //TODO solution: use a filter rename column etc.
-
- // another solution would be to add a method to the Referers API giving directly the integer 'visits from search engines'
- // and we would build automatically the dataTable_array of datatatble_simple from these integers
- // but we'd have to add this integer to be recorded during archiving etc.
- $value = $onlyRow->getColumn('nb_uniq_visitors');
- if($value === false)
- {
- $value = $onlyRow->getColumn('nb_visits');
- }
+ $value = $onlyRow->getColumn($columnToPlot);
+ }
+ // if not specified, we load by default the first column found
+ // eg. case of getLastDistinctCountriesGraph
+ else
+ {
+ $columns = $onlyRow->getColumns();
+ $value = current($columns);
}
}
-
- if($value === false)
- {
- $value = 0;
- }
- $data[] = array(
- 'label' => $keyName,
- 'value' => $value
- );
+ $values[] = $value;
}
- return $data;
+ return $values;
}
}
diff --git a/core/Visualization/Chart.php b/core/Visualization/Chart.php
index c86e80a933..2f12137255 100644
--- a/core/Visualization/Chart.php
+++ b/core/Visualization/Chart.php
@@ -9,78 +9,160 @@
* @package Piwik_Visualization
*/
-require_once "Visualization/OpenFlashChart.php";
+require_once "libs/open-flash-chart/php-ofc-library/open-flash-chart.php";
+
/**
* Generates the data in the Open Flash Chart format, from the given data.
- * Uses Open flash chart PHP library @see Piwik_Visualization_OpenFlashChart
*
* @package Piwik_Visualization
*/
-abstract class Piwik_Visualization_Chart extends Piwik_Visualization_OpenFlashChart
+abstract class Piwik_Visualization_Chart implements Piwik_iView
{
- protected $dataGraph = array();
+ /**
+ * @var Piwik_Visualization_OpenFlashChart
+ */
+ protected $chart = null;
+
+ protected $xLabels = array();
+ protected $xOnClick = array();
+ protected $xSteps = 2;
+
+ protected $yLabels = array();
+ protected $yValues = array();
- function setData($data)
+ function __construct()
{
- $this->dataGraph = $data;
+ $this->chart = new open_flash_chart();
}
- function getCount()
+ public function setAxisXLabels($xLabels)
{
- return count($this->dataGraph);
+ $this->xLabels = $xLabels;
}
- function customizeGraph()
+ public function setAxisYValues($values)
{
- $this->set_num_decimals ( 0 );
- $this->set_is_decimal_separator_comma( false );
- $this->set_is_thousand_separator_disabled( true );
- $this->y_axis_colour = '#ffffff';
- $this->x_axis_colour = '#596171';
- $this->x_grid_colour = $this->y_grid_colour = '#E0E1E4';
-
- // approx 5 x labels on the graph
- $steps = ceil($this->getCount() / 5);
- $steps = $steps + $steps % 2; // make sure modulo 2
-
- $this->set_x_label_style( 10, $this->x_axis_colour, 0, $steps, $this->x_grid_colour );
- $this->set_x_axis_steps( $steps / 2 );
-
-
- $stepsY = ceil($this->getCount() / 4);
- $this->y_label_steps( $stepsY / 3 );
- $this->y_label_steps( 4 );
-
- $this->bg_colour = '#ffffff';
- $this->set_inner_background('#ffffff');
-
- $this->set_tool_tip( '#x_label# <br>#val# #key# ' );
+ $this->yValues = $values;
+ }
+
+ public function setAxisYLabels($labels)
+ {
+ $this->yLabels = $labels;
+ }
+
+ public function setAxisXOnClick($onClick)
+ {
+ $this->xOnClick = $onClick;
+ }
+
+ //TODO call + make sure matches beginning of period? (hard..)
+ // day -> every 7 days
+ // week & year -> 1, plot last
+ // month -> every 12 months, plot last 24
+ public function setXSteps($steps)
+ {
+ $this->xSteps = $steps;
+ }
+
+ protected function getDataSetsToDisplay()
+ {
+ if(empty($this->yValues)) {
+ return false;
+ }
+ return array_keys($this->yValues);
}
- function prepareData()
- {
- $label = $data = array();
- $max = 0;
- foreach($this->dataGraph as $row)
+ public function getMaxValue()
+ {
+ $datasetsIds = $this->getDataSetsToDisplay();
+ if($datasetsIds === false)
+ {
+ return 0;
+ }
+ $maxCrossDataSets = false;
+ foreach($datasetsIds as $dataset)
{
- $label[] = $row['label'];
- $data[] = $row['value'];
-
- if($row['value'] > $max)
+ $maxValue = max($this->yValues[$dataset]);
+ if($maxCrossDataSets === false
+ || $maxValue > $maxCrossDataSets)
{
- $max = $row['value'];
+ $maxCrossDataSets = $maxValue;
}
}
- $this->arrayData = $data;
- $this->arrayLabel = $label;
+ if($maxCrossDataSets > 10)
+ {
+ $maxCrossDataSets = $maxCrossDataSets + 10 - $maxCrossDataSets % 10;
+ }
+ return $maxCrossDataSets;
+ }
+
+ public function setTitle($text, $css)
+ {
+ $title = new title($text);
+ $title->set_style($css);
+ $this->chart->set_title($title);
+ }
+
+ public function render()
+ {
+ return $this->chart->toPrettyString();
+ }
+
+ function customizeGraph()
+ {
+ $this->chart->set_number_format($num_decimals = 0,
+ $is_fixed_num_decimals_forced = true,
+ $is_decimal_separator_comma = false,
+ $is_thousand_separator_disabled = false);
+
+ $gridColour = '#E0E1E4';
+ $countValues = count($this->xLabels);
+ $maxValue = $this->getMaxValue();
+ $minValue = 0;
- $this->arrayLabel = str_replace(","," -",$this->arrayLabel);
+ // X Axis
+ $this->x = new x_axis();
+ $this->x->set_colour( '#596171' );
+ $this->x->set_grid_colour( $gridColour );
+ $this->x->set_steps($this->xSteps);
- $this->maxData = $max;
- if($this->maxData > 10)
+ // X Axis Labels
+ $this->x_labels = new x_axis_labels();
+ $this->x_labels->set_size(11);
+ //manually fix the x labels step as this doesn't work in this OFC release..
+ $xLabelsStepped = $this->xLabels;
+ foreach($xLabelsStepped as $i => &$xLabel)
{
- $this->maxData = $max + 10 - $max % 10;
+ if(($i % $this->xSteps) != 0)
+ {
+ $xLabel = '';
+ }
}
+ $this->x_labels->set_labels($xLabelsStepped);
+ $this->x_labels->set_steps(2);
+ $this->x->set_labels($this->x_labels);
+
+ // Y Axis
+ $this->y = new y_axis();
+ $this->y->set_colour('#ffffff');
+ $this->y->set_grid_colour($gridColour);
+ $stepsCount = 2;
+ $stepsEveryNLabel = ceil(($maxValue - $minValue) / $stepsCount);
+ if($maxValue == 0)
+ {
+ $maxValue = 1;
+ }
+ $this->y->set_range( $minValue, $maxValue, $stepsEveryNLabel);
+
+ // Tooltip
+ $this->tooltip = new tooltip();
+ $this->tooltip->set_shadow( true );
+ $this->tooltip->set_stroke( 1 );
+
+ // Attach elements to the graph
+ $this->chart->set_x_axis($this->x);
+ $this->chart->set_y_axis($this->y);
+ $this->chart->set_tooltip($this->tooltip);
+ $this->chart->set_bg_colour('#ffffff');
}
-
}
diff --git a/core/Visualization/Chart/Evolution.php b/core/Visualization/Chart/Evolution.php
index 66005ca6a9..6cef02f6e0 100644
--- a/core/Visualization/Chart/Evolution.php
+++ b/core/Visualization/Chart/Evolution.php
@@ -16,94 +16,90 @@ require_once "Visualization/Chart.php";
*
* @package Piwik_Visualization
*/
-class Piwik_Visualization_Chart_Evolution extends Piwik_Visualization_Chart
+class Piwik_Visualization_Chart_Evolution extends Piwik_Visualization_Chart
{
+ protected $yValuesType = array();
+ function setAxisYValuesTypes($yValuesTypes)
+ {
+ $this->yValuesTypes = $yValuesTypes;
+ }
+
function customizeGraph()
{
parent::customizeGraph();
-
+ $dataSetsToDisplay = $this->getDataSetsToDisplay();
+ if($dataSetsToDisplay === false)
+ {
+ return;
+ }
+
$colors = array(
"0x3357A0",
- "0x9933CC",
"0xCC3399",
+ "0x9933CC",
"0x80a033",
"0xFD9816",
"0x246AD2",
"0xFD16EA",
"0x49C100",
- );
-
- // first row in array contains line labels (legend)
- $legendLabels = array_shift($this->dataGraph);
-
- $line = array();
-
- // define labels
- foreach($legendLabels as $nbLabel => $labelName)
- {
- $line[$nbLabel] = new line_hollow( 1, 3, $colors[$nbLabel] );
- $line[$nbLabel]->key( $labelName, 10 );
- }
-
- $maxData = 0;
- $xLabels = array();
- $cnt = count($this->dataGraph);
+ );
- // loop over data
- foreach($this->dataGraph as $values)
+ $i = 0;
+ foreach($dataSetsToDisplay as $dataSetToDisplay)
{
- // add x axis value (label)
- array_push($xLabels, $values['label']);
+ $color = $colors[$i];
+
+ $labelName = $this->yLabels[$dataSetToDisplay];
+ $d = new hollow_dot();
+ $d->size(3)->halo_size(0)->colour($color);
+
+ $line = new line();
+ $line->set_default_dot_style($d);
+ $line->set_key($labelName, 11);
+ $line->set_width( 1 );
+ $line->set_colour( $color );
- // loop over values for all lines (y axis values)
- for($j = 0; $j < count($legendLabels); $j++)
- {
- // get the y axis value for line $j
- $dotValue = $values['value'.$j];
+ // Line Values
+ // Note: we have to manually create the dot values as the steps feature doens't work on X axis
+ // when it's working again, we can remove code below and set generic tooltip above: // ->tooltip('#x_label#<br>#val# '.$labelName)
+ $yValues = $this->yValues[$dataSetToDisplay];
+ $labelName = $this->yLabels[$dataSetToDisplay];
+ $lineValues = array();
+ $j = 0;
+ foreach($this->xLabels as $label) {
+ $value = $yValues[$j];
+ $lineValue = new hollow_dot($value);
- // find maximum y axis value
- if( $dotValue > $maxData )
- {
- $maxData = $dotValue;
- }
-
- $link = null;
- if($this->isLinkEnabled())
+ $unit = '';
+ if(!empty($this->yValuesTypes[$dataSetToDisplay]))
{
- $spacePosition = strpos($values['label'],' ');
- if($spacePosition === false)
- {
- $spacePosition = strlen($values['label']);
- }
- $link = Piwik_Url::getCurrentScriptName() .
- Piwik_Url::getCurrentQueryStringWithParametersModified( array(
- 'date' => substr($values['label'],0,$spacePosition),
- 'module' => 'CoreHome',
- 'action' => 'index',
- 'viewDataTable' => null, // we reset the viewDataTable parameter (useless in the link)
- 'idGoal' => null, // we reset idGoal
- ));
- // add the dot on the chart and link it
- $line[$j]->add_link($dotValue, $link);
+ $unit = $this->yValuesTypes[$dataSetToDisplay];
}
- else
+ // set the Y Label to display the right unit
+ $this->y->set_label_text("#val#$unit");
+
+ $lineValue->tooltip("$label<br>$value$unit $labelName");
+ if(!empty($this->xOnClick))
{
- $line[$j]->add($dotValue);
+ $lineValue->on_click('redirectToUrl("'.$this->xOnClick[$j].'")');
}
+ $lineValues[] = $lineValue;
+ $j++;
}
+ $line->set_values( $lineValues );
+ $lines[] = $line;
+ $i++;
}
- $this->data_sets = $line;
- $this->set_y_max( $maxData );
- $this->set_x_labels( $xLabels );
- }
-
- private function isLinkEnabled()
- {
- static $linkEnabled;
- if(!isset($linkEnabled))
+ foreach($lines as $line)
+ {
+ $this->chart->add_element($line);
+ }
+ // if one column is a percentage we set the grid accordingly
+ // note: it is invalid to plot a percentage dataset along with a numeric dataset
+ //TODO only if the max was 100!!
+ if(array_search('%', $this->yValuesTypes) !== false)
{
- $linkEnabled = !Piwik_Common::getRequestVar('disableLink', 0, 'int');
+ $this->y->set_range( 0, 100, 50);
}
- return $linkEnabled;
}
}
diff --git a/core/Visualization/Chart/Pie.php b/core/Visualization/Chart/Pie.php
index 46b5aace60..8ea8e7e2ec 100644
--- a/core/Visualization/Chart/Pie.php
+++ b/core/Visualization/Chart/Pie.php
@@ -11,28 +11,61 @@
require_once "Visualization/Chart.php";
/**
- *
- * Customize the Pie chart style for the flash graph
+ * Customize & set values for the Flash Pie chart
*
* @package Piwik_Visualization
*/
class Piwik_Visualization_Chart_Pie extends Piwik_Visualization_Chart
{
+ // return the first dataset id from the list
+ protected function getDataSetsToDisplay()
+ {
+ $dataSetsToDisplay = parent::getDataSetsToDisplay();
+ if($dataSetsToDisplay === false)
+ {
+ return false;
+ }
+ return array_slice($dataSetsToDisplay, 0, 1);
+ }
+
function customizeGraph()
{
parent::customizeGraph();
- $this->prepareData();
-
- for($i = 0, $cnt = count($this->arrayLabel); $i < $cnt; $i++)
- {
- $label = $this->arrayLabel[$i];
- $this->arrayLabel[$i] = (strlen($label) > 20 ? substr($label, 0, 20).'...' : $label);
- }
- $this->set_x_label_style( 12, $this->x_axis_colour, 0, 2, $this->bg_colour );
- $this->pie(60,'#505050','{font-size: 12px; color: #142448}', true);
- $this->pie_values( $this->arrayData, $this->arrayLabel );
- $this->pie_slice_colours( array('#3C5A69','#679BB5','#695A3C','#B58E67','#969696') );
+ $dataSetsToDisplay = $this->getDataSetsToDisplay();
+ if($dataSetsToDisplay === false)
+ {
+ return;
+ }
+ $dataSetToDisplay = current($dataSetsToDisplay);
+
+ // create the Pie
+ $pie = new pie();
+ $pie->set_alpha(0.6);
+ $pie->set_start_angle( 35 );
+ $pie->add_animation( new pie_fade() );
+ $pie->set_label_colour('#142448');
+ $pie->set_colours( array('#3C5A69','#679BB5','#695A3C','#B58E67','#969696') );
+
+ // create the Pie values
+ $yValues = $this->yValues[$dataSetToDisplay];
+ $labelName = $this->yLabels[$dataSetToDisplay];
+ $sum = array_sum($yValues);
+ $pieValues = array();
+ $i = 0;
+ foreach($this->xLabels as $label) {
+ $value = $yValues[$i];
+ $i++;
+ // we never plot empty pie slices (eg. visits by server time pie chart)
+ if($value <= 0) {
+ continue;
+ }
+ $pieValue = new pie_value($value, $label);
+ $percentage = round(100 * $value / $sum);
+ $pieValue->set_tooltip("$label <br>$percentage% ($value $labelName)");
+ $pieValues[] = $pieValue;
+ }
+ $pie->set_values($pieValues);
- $this->set_tool_tip( '#x_label# <br>#val# ' );
+ $this->chart->add_element($pie);
}
}
diff --git a/core/Visualization/Chart/VerticalBar.php b/core/Visualization/Chart/VerticalBar.php
index d94272df9b..a87487bb51 100644
--- a/core/Visualization/Chart/VerticalBar.php
+++ b/core/Visualization/Chart/VerticalBar.php
@@ -12,25 +12,59 @@
require_once "Visualization/Chart.php";
/**
- *
- * Customize the Vertical bar chart style for the flash graph
+ * Customize & set values for the flash Vertical bar chart
*
* @package Piwik_Visualization
- *
*/
class Piwik_Visualization_Chart_VerticalBar extends Piwik_Visualization_Chart
{
+ // return the first dataset id from the list
+ protected function getDataSetsToDisplay()
+ {
+ $dataSetsToDisplay = parent::getDataSetsToDisplay();
+ if($dataSetsToDisplay === false)
+ {
+ return false;
+ }
+ return array_slice($dataSetsToDisplay, 0, 1);
+ }
+
function customizeGraph()
{
parent::customizeGraph();
- $this->prepareData();
- $this->set_data( $this->arrayData );
- $this->set_x_labels( $this->arrayLabel );
- $this->set_x_label_style( 12, $this->x_axis_colour, 0, 2, $this->bg_colour );
- $this->set_x_axis_steps( 2 );
- $this->set_y_max( $this->maxData );
- $this->y_label_steps( 2 );
- $this->bar_filled( 50, '#3B5AA9', '#063E7E', 'visits', 10 );
+ $dataSetsToDisplay = $this->getDataSetsToDisplay();
+ if($dataSetsToDisplay === false)
+ {
+ return;
+ }
+ $dataSetToDisplay = current($dataSetsToDisplay);
+
+ $this->x->set_grid_colour('#ffffff');
+ $this->x_labels->set_steps(2);
+ $this->x->set_stroke(1);
+
+ // create the Bar object
+ $bar = new bar_filled('#3B5AA9', '#063E7E');
+ $bar->set_alpha(0.5);
+ $bar->set_key($this->yLabels[$dataSetToDisplay], 12);
+ $bar->set_tooltip( '#val# #key#');
+
+ // create the bar values
+ $yValues = $this->yValues[$dataSetToDisplay];
+ $labelName = $this->yLabels[$dataSetToDisplay];
+ $sum = array_sum($yValues);
+ $barValues = array();
+ $i = 0;
+ foreach($this->xLabels as $label) {
+ $value = $yValues[$i];
+ $barValue = new bar_value($value);
+ $percentage = round(100 * $value / $sum);
+ $barValue->set_tooltip("$label <br>$value $labelName ($percentage%)");
+ $barValues[] = $barValue;
+ $i++;
+ }
+ $bar->set_values($barValues);
+ $this->chart->add_element($bar);
}
}
diff --git a/core/Visualization/OpenFlashChart.php b/core/Visualization/OpenFlashChart.php
deleted file mode 100644
index 1b65f3a0fa..0000000000
--- a/core/Visualization/OpenFlashChart.php
+++ /dev/null
@@ -1,1637 +0,0 @@
-<?php
-/**
- * Piwik - Open source web analytics
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
- * @version $Id: OpenFlashChart.php 566 2008-07-21 00:34:43Z matt $
- *
- * @package Piwik_Visualization
- * @subpackage OFC
- */
-
-require_once "iView.php";
-
-
-/**
- * Original class provided by Open Flash Chart
- *
- * @package Piwik_Visualization
- */
-abstract class Piwik_Visualization_OpenFlashChart implements Piwik_iView
-{
- function __construct()
- {
- $this->data_sets = array();
- $this->data = array();
- $this->links = array();
- $this->width = 250;
- $this->height = 200;
- $this->js_path = 'js/';
- $this->swf_path = '';
- $this->x_labels = array();
- $this->y_min = '';
- $this->y_max = '';
- $this->x_min = '';
- $this->x_max = '';
- $this->y_steps = '';
- $this->title = '';
- $this->title_style = '';
- $this->occurence = 0;
-
- $this->x_offset = '';
-
- $this->x_tick_size = -1;
-
- $this->y2_max = '';
- $this->y2_min = '';
-
- // GRID styles:
- $this->x_axis_colour = '';
- $this->x_axis_3d = '';
- $this->x_grid_colour = '';
- $this->x_axis_steps = 1;
- $this->y_axis_colour = '';
- $this->y_grid_colour = '';
- $this->y2_axis_colour = '';
-
- // AXIS LABEL styles:
- $this->x_label_style = '';
- $this->y_label_style = '';
- $this->y_label_style_right = '';
-
-
- // AXIS LEGEND styles:
- $this->x_legend = '';
- $this->x_legend_size = 20;
- $this->x_legend_colour = '#000000';
-
- $this->y_legend = '';
- $this->y_legend_right = '';
- //$this->y_legend_size = 20;
- //$this->y_legend_colour = '#000000';
-
- $this->lines = array();
- $this->line_default['type'] = 'line';
- $this->line_default['values'] = '3,#87421F';
- //$this->js_line_default = 'flashvars["line"] = "3,#87421F";';
-
- $this->bg_colour = '';
- $this->bg_image = '';
-
- $this->inner_bg_colour = '';
- $this->inner_bg_colour_2 = '';
- $this->inner_bg_angle = '';
-
- // PIE chart ------------
- $this->pie = '';
- $this->pie_values = '';
- $this->pie_colours = '';
- $this->pie_labels = '';
-
- $this->tool_tip = '';
-
- // which data lines are attached to the
- // right Y axis?
- $this->y2_lines = array();
-
- // Number formatting:
- $this->y_format='';
- $this->num_decimals='';
- $this->is_fixed_num_decimals_forced='';
- $this->is_decimal_separator_comma='';
- $this->is_thousand_separator_disabled='';
-
- $this->output_type = '';
-
- //
- // set some default value incase the user forgets
- // to set them, so at least they see *something*
- // even is it is only the axis and some ticks
- //
- $this->set_y_min( 0 );
- $this->set_y_max( 20 );
- $this->set_x_axis_steps( 1 );
- $this->y_label_steps( 5 );
- }
-
- /**
- * Set the unique_id to use for the flash object id.
- */
- function set_unique_id()
- {
- $this->unique_id = uniqid(rand(), true);
- }
-
- /**
- * Get the flash object ID for the last rendered object.
- */
- function get_unique_id()
- {
- return ($this->unique_id);
- }
-
- /**
- * Set the base path for the swfobject.js
- *
- * @param base_path a string argument.
- * The path to the swfobject.js file
- */
- function set_js_path($path)
- {
- $this->js_path = $path;
- }
-
- /**
- * Set the base path for the open-flash-chart.swf
- *
- * @param path a string argument.
- * The path to the open-flash-chart.swf file
- */
- function set_swf_path($path)
- {
- $this->swf_path = $path;
- }
-
- /**
- * Set the type of output data.
- *
- * @param type a string argument.
- * The type of data. Currently only type is js, or nothing.
- */
- function set_output_type($type)
- {
- $this->output_type = $type;
- }
-
- /**
- * returns the next line label for multiple lines.
- */
- function next_line()
- {
- $line_num = '';
- if( count( $this->lines ) > 0 )
- $line_num = '_'. (count( $this->lines )+1);
-
- return $line_num;
- }
-
- // escape commas (,)
- static function esc( $text )
- {
- // we replace the comma so it is not URL escaped
- // if it is, flash just thinks it is a comma
- // which is no good if we are splitting the
- // string on commas.
- $tmp = str_replace( ',', '#comma#', $text );
- //$tmp = utf8_encode( $tmp );
- // now we urlescape all dodgy characters (like & % $ etc..)
- return urlencode( $tmp );
- }
-
- /**
- * Format the text to the type of output.
- */
- function format_output($function,$values)
- {
- if($this->output_type == 'js')
- {
- $tmp = 'flashvars["' . $function . '"] = "' . $values . '";';
- }
- else
- {
- $tmp = '&'. $function .'='. $values .'&';
- }
-
- return $tmp;
- }
-
- /**
- * Set the text and style of the title.
- *
- * @param title a string argument.
- * The text of the title.
- * @param style a string.
- * CSS styling of the title.
- */
- function set_title( $title, $style='' )
- {
- $this->title = $this->esc( $title );
- if( strlen( $style ) > 0 )
- $this->title_style = $style;
- }
-
- /**
- * Set the width of the chart.
- *
- * @param width an int argument.
- * The width of the chart frame.
- */
- function set_width( $width )
- {
- $this->width = $width;
- }
-
- /**
- * Set the height of the chart.
- *
- * @param height an int argument.
- * The height of the chart frame.
- */
- function set_height( $height )
- {
- $this->height = $height;
- }
-
- /**
- * Set the base path of the swfobject.
- *
- * @param base a string argument.
- * The base path of the swfobject.
- */
- function set_base( $base='js/' )
- {
- $this->base = $base;
- }
-
- // Number formatting:
- function set_y_format( $val )
- {
- $this->y_format = $val;
- }
-
- function set_num_decimals( $val )
- {
- $this->num_decimals = $val;
- }
-
- function set_is_fixed_num_decimals_forced( $val )
- {
- $this->is_fixed_num_decimals_forced = $val?'true':'false';
- }
-
- function set_is_decimal_separator_comma( $val )
- {
- $this->is_decimal_separator_comma = $val?'true':'false';
- }
-
- function set_is_thousand_separator_disabled( $val )
- {
- $this->is_thousand_separator_disabled = $val?'true':'false';
- }
-
- /**
- * Set the data for the chart
- * @param a an array argument.
- * An array of the data to add to the chart.
- */
- function set_data( $a )
- {
- $this->data[] = implode(',',$a);
- }
-
- // UGH, these evil functions are making me fell ill
- function set_links( $links )
- {
- // TO DO escape commas:
- $this->links[] = implode(',',$links);
- }
-
- // $val is a boolean
- function set_x_offset( $val )
- {
- $this->x_offset = $val?'true':'false';
- }
-
- /**
- * Set the tooltip to be displayed on each chart item.\n
- * \n
- * Replaceable tokens that can be used in the string include: \n
- * #val# - The actual value of whatever the mouse is over. \n
- * #key# - The key string. \n
- * \<br> - New line. \n
- * #x_label# - The X label string. \n
- * #x_legend# - The X axis legend text. \n
- * Default string is: "#x_label#<br>#val#" \n
- *
- * @param tip a string argument.
- * A formatted string to show as the tooltip.
- */
- function set_tool_tip( $tip )
- {
- $this->tool_tip = $this->esc( $tip );
- }
-
- /**
- * Set the x axis labels
- *
- * @param a an array argument.
- * An array of the x axis labels.
- */
- function set_x_labels( $a )
- {
- $tmp = array();
- foreach( $a as $item )
- $tmp[] = $this->esc( $item );
- $this->x_labels = $tmp;
- }
-
- /**
- * Set the look and feel of the x axis labels
- *
- * @param font_size an int argument.
- * The font size.
- * @param colour a string argument.
- * The hex colour value.
- * @param orientation an int argument.
- * The orientation of the x-axis text.
- * 0 - Horizontal
- * 1 - Vertical
- * 2 - 45 degrees
- * @param step an int argument.
- * Show the label on every $step label.
- * @param grid_colour a string argument.
- */
- function set_x_label_style( $size, $colour='', $orientation=0, $step=-1, $grid_colour='' )
- {
- $this->x_label_style = $size;
-
- if( strlen( $colour ) > 0 )
- $this->x_label_style .= ','. $colour;
-
- if( $orientation > -1 )
- $this->x_label_style .= ','. $orientation;
-
- if( $step > 0 )
- $this->x_label_style .= ','. $step;
-
- if( strlen( $grid_colour ) > 0 )
- $this->x_label_style .= ','. $grid_colour;
- }
-
- /**
- * Set the background colour.
- * @param colour a string argument.
- * The hex colour value.
- */
- function set_bg_colour( $colour )
- {
- $this->bg_colour = $colour;
- }
-
- /**
- * Set a background image.
- * @param url a string argument.
- * The location of the image.
- * @param x a string argument.
- * The x location of the image. 'Right', 'Left', 'Center'
- * @param y a string argument.
- * The y location of the image. 'Top', 'Bottom', 'Middle'
- */
- function set_bg_image( $url, $x='center', $y='center' )
- {
- $this->bg_image = $url;
- $this->bg_image_x = $x;
- $this->bg_image_y = $y;
- }
-
- /**
- * Attach a set of data (a line, area or bar chart) to the right Y axis.
- * @param data_number an int argument.
- * The numbered order the data was attached using set_data.
- */
- function attach_to_y_right_axis( $data_number )
- {
- $this->y2_lines[] = $data_number;
- }
-
- /**
- * Set the background colour of the grid portion of the chart.
- * @param col a string argument.
- * The hex colour value of the background.
- * @param col2 a string argument.
- * The hex colour value of the second colour if you want a gradient.
- * @param angle an int argument.
- * The angle in degrees to make the gradient.
- */
- function set_inner_background( $col, $col2='', $angle=-1 )
- {
- $this->inner_bg_colour = $col;
-
- if( strlen($col2) > 0 )
- $this->inner_bg_colour_2 = $col2;
-
- if( $angle != -1 )
- $this->inner_bg_angle = $angle;
- }
-
- /**
- * Internal function to build the y label style for y and y2
- */
- function _set_y_label_style( $size, $colour )
- {
- $tmp = $size;
-
- if( strlen( $colour ) > 0 )
- $tmp .= ','. $colour;
- return $tmp;
- }
-
- /**
- * Set the look and feel of the y axis labels
- *
- * @param font_size an int argument.
- * The font size.
- * @param colour a string argument.
- * The hex colour value.
- */
- function set_y_label_style( $size, $colour='' )
- {
- $this->y_label_style = $this->_set_y_label_style( $size, $colour );
- }
-
- /**
- * Set the look and feel of the right y axis labels
- *
- * @param font_size an int argument.
- * The font size.
- * @param colour a string argument.
- * The hex colour value.
- */
- function set_y_right_label_style( $size, $colour='' )
- {
- $this->y_label_style_right = $this->_set_y_label_style( $size, $colour );
- }
-
- function set_x_max( $max )
- {
- $this->x_max = floatval( $max );
- }
-
- function set_x_min( $min )
- {
- $this->x_min = floatval( $min );
- }
-
- /**
- * Set the maximum value of the y axis.
- *
- * @param max an float argument.
- * The maximum value.
- */
- function set_y_max( $max )
- {
- $this->y_max = floatval( $max );
- }
-
- /**
- * Set the minimum value of the y axis.
- *
- * @param min an float argument.
- * The minimum value.
- */
- function set_y_min( $min )
- {
- $this->y_min = floatval( $min );
- }
-
- /**
- * Set the maximum value of the right y axis.
- *
- * @param max an float argument.
- * The maximum value.
- */
- function set_y_right_max( $max )
- {
- $this->y2_max = floatval($max);
- }
-
- /**
- * Set the minimum value of the right y axis.
- *
- * @param min an float argument.
- * The minimum value.
- */
- function set_y_right_min( $min )
- {
- $this->y2_min = floatval($min);
- }
-
- /**
- * Show the y label on every $step label.
- *
- * @param val an int argument.
- * Show the label on every $step label.
- */
- function y_label_steps( $val )
- {
- $this->y_steps = intval( $val );
- }
-
- function title( $title, $style='' )
- {
- $this->title = $this->esc( $title );
- if( strlen( $style ) > 0 )
- $this->title_style = $style;
- }
-
- /**
- * Set the parameters of the x legend.
- *
- * @param text a string argument.
- * The text of the x legend.
- * @param font_size an int argument.
- * The font size of the x legend text.
- * @param colour a string argument
- * The hex value of the font colour.
- */
- function set_x_legend( $text, $size=-1, $colour='' )
- {
- $this->x_legend = $this->esc( $text );
- if( $size > -1 )
- $this->x_legend_size = $size;
-
- if( strlen( $colour )>0 )
- $this->x_legend_colour = $colour;
- }
-
- /**
- * Set the size of the x label ticks.
- *
- * @param size an int argument.
- * The size of the ticks in pixels.
- */
- function set_x_tick_size( $size )
- {
- if( $size > 0 )
- $this->x_tick_size = $size;
- }
-
- /**
- * Set how often you would like to show a tick on the x axis.
- *
- * @param steps an int argument.
- * Show a tick ever $steps.
- */
- function set_x_axis_steps( $steps )
- {
- if ( $steps > 0 )
- $this->x_axis_steps = $steps;
- }
-
- /**
- * Set the depth in pixels of the 3D X axis slab.
- *
- * @param size an int argument.
- * The depth in pixels of the 3D X axis.
- */
- function set_x_axis_3d( $size )
- {
- if( $size > 0 )
- $this->x_axis_3d = intval($size);
- }
-
- /**
- * The private method of building the y legend output.
- */
- function _set_y_legend( $text, $size, $colour )
- {
- $tmp = $text;
-
- if( $size > -1 )
- $tmp .= ','. $size;
-
- if( strlen( $colour )>0 )
- $tmp .= ','. $colour;
-
- return $tmp;
- }
-
- /**
- * Set the parameters of the y legend.
- *
- * @param text a string argument.
- * The text of the y legend.
- * @param font_size an int argument.
- * The font size of the y legend text.
- * @param colour a string argument
- * The hex colour value of the font colour.
- */
- function set_y_legend( $text, $size=-1, $colour='' )
- {
- $this->y_legend = $this->_set_y_legend( $text, $size, $colour );
- }
-
- /**
- * Set the parameters of the right y legend.
- *
- * @param text a string argument.
- * The text of the right y legend.
- * @param font_size an int argument.
- * The font size of the right y legend text.
- * @param colour a string argument
- * The hex value of the font colour.
- */
- function set_y_right_legend( $text, $size=-1, $colour='' )
- {
- $this->y_legend_right = $this->_set_y_legend( $text, $size, $colour );
- }
-
- /**
- * Set the colour of the x axis line and grid.
- *
- * @param axis a string argument.
- * The hex colour value of the x axis line.
- * @param grid a string argument.
- * The hex colour value of the x axis grid.
- */
- function x_axis_colour( $axis, $grid='' )
- {
- $this->x_axis_colour = $axis;
- $this->x_grid_colour = $grid;
- }
-
- /**
- * Set the colour of the y axis line and grid.
- *
- * @param axis a string argument.
- * The hex colour value of the y axis line.
- * @param grid a string argument.
- * The hex colour value of the y axis grid.
- */
- function y_axis_colour( $axis, $grid='' )
- {
- $this->y_axis_colour = $axis;
-
- if( strlen( $grid ) > 0 )
- $this->y_grid_colour = $grid;
- }
-
- /**
- * Set the colour of the right y axis line.
- *
- * @param colour a string argument.
- * The hex colour value of the right y axis line.
- */
- function y_right_axis_colour( $colour )
- {
- $this->y2_axis_colour = $colour;
- }
-
- /**
- * Draw a line without markers on values.
- *
- * @param width an int argument.
- * The width of the line in pixels.
- * @param colour a string argument.
- * The hex colour value of the line.
- * @param text a string argument.
- * The label of the line.
- * @param font_size an int argument.
- * Font size of the label
- * @param circles an int argument
- * Need to find out.
- */
- function line( $width, $colour='', $text='', $size=-1, $circles=-1 )
- {
- $type = 'line'. $this->next_line();
-
- $description = '';
- if( $width > 0 )
- {
- $description .= $width;
- $description .= ','. $colour;
- }
-
- if( strlen( $text ) > 0 )
- {
- $description.= ','. $text;
- $description .= ','. $size;
- }
-
- if( $circles > 0 )
- $description .= ','. $circles;
-
- $this->lines[$type] = $description;
- }
-
- /**
- * Draw a line with solid dot markers on values.
- *
- * @param width an int argument.
- * The width of the line in pixels.
- * @param dot_size an int argument.
- * Size in pixels of the dot.
- * @param colour a string argument.
- * The hex colour value of the line.
- * @param text a string argument.
- * The label of the line.
- * @param font_size an int argument.
- * Font size of the label.
- */
- function line_dot( $width, $dot_size, $colour, $text='', $font_size='' )
- {
- $type = 'line_dot'. $this->next_line();
-
- $description = "$width,$colour,$text";
-
- if( strlen( $font_size ) > 0 )
- $description .= ",$font_size,$dot_size";
-
- $this->lines[$type] = $description;
- }
-
- /**
- * Draw a line with hollow dot markers on values.
- *
- * @param width an int argument.
- * The width of the line in pixels.
- * @param dot_size an int argument.
- * Size in pixels of the dot.
- * @param colour a string argument.
- * The hex colour value of the line.
- * @param text a string argument.
- * The label of the line.
- * @param font_size an int argument.
- * Font size of the label.
- */
- function line_hollow( $width, $dot_size, $colour, $text='', $font_size='' )
- {
- $type = 'line_hollow'. $this->next_line();
-
- $description = "$width,$colour,$text";
-
- if( strlen( $font_size ) > 0 )
- $description .= ",$font_size,$dot_size";
-
- $this->lines[$type] = $description;
- }
-
- /**
- * Draw an area chart.
- *
- * @param width an int argument.
- * The width of the line in pixels.
- * @param dot_size an int argument.
- * Size in pixels of the dot.
- * @param colour a string argument.
- * The hex colour value of the line.
- * @param alpha an int argument.
- * The percentage of transparency of the fill colour.
- * @param text a string argument.
- * The label of the line.
- * @param font_size an int argument.
- * Font size of the label.
- * @param fill_colour a string argument.
- * The hex colour value of the fill colour.
- */
- function area_hollow( $width, $dot_size, $colour, $alpha, $text='', $font_size='', $fill_colour='' )
- {
- $type = 'area_hollow'. $this->next_line();
-
- $description = "$width,$dot_size,$colour,$alpha";
-
- if( strlen( $text ) > 0 )
- $description .= ",$text,$font_size";
-
- if( strlen( $fill_colour ) > 0 )
- $description .= ','. $fill_colour;
-
- $this->lines[$type] = $description;
- }
-
- /**
- * Draw a bar chart.
- *
- * @param alpha an int argument.
- * The percentage of transparency of the bar colour.
- * @param colour a string argument.
- * The hex colour value of the line.
- * @param text a string argument.
- * The label of the line.
- * @param font_size an int argument.
- * Font size of the label.
- */
- function bar( $alpha, $colour='', $text='', $size=-1 )
- {
- $type = 'bar'. $this->next_line();
-
- $description = $alpha .','. $colour .','. $text .','. $size;
-
- $this->lines[$type] = $description;
- }
-
- /**
- * Draw a bar chart with an outline.
- *
- * @param alpha an int argument.
- * The percentage of transparency of the bar colour.
- * @param colour a string argument.
- * The hex colour value of the line.
- * @param colour_outline a strng argument.
- * The hex colour value of the outline.
- * @param text a string argument.
- * The label of the line.
- * @param font_size an int argument.
- * Font size of the label.
- */
- function bar_filled( $alpha, $colour, $colour_outline, $text='', $size=-1 )
- {
- $type = 'filled_bar'. $this->next_line();
-
- $description = "$alpha,$colour,$colour_outline,$text,$size";
-
- $this->lines[$type] = $description;
- }
-
- function bar_sketch( $alpha, $offset, $colour, $colour_outline, $text='', $size=-1 )
- {
- $type = 'bar_sketch'. $this->next_line();
-
- $description = "$alpha,$offset,$colour,$colour_outline,$text,$size";
-
- $this->lines[$type] = $description;
- }
-
- /**
- * Draw a 3D bar chart.
- *
- * @param alpha an int argument.
- * The percentage of transparency of the bar colour.
- * @param colour a string argument.
- * The hex colour value of the line.
- * @param text a string argument.
- * The label of the line.
- * @param font_size an int argument.
- * Font size of the label.
- */
- function bar_3D( $alpha, $colour='', $text='', $size=-1 )
- {
- $type = 'bar_3d'. $this->next_line();
-
- $description = $alpha .','. $colour .','. $text .','. $size;
-
- $this->lines[$type] = $description;
- }
-
- /**
- * Draw a 3D bar chart that looks like glass.
- *
- * @param alpha an int argument.
- * The percentage of transparency of the bar colour.
- * @param colour a string argument.
- * The hex colour value of the line.
- * @param outline_colour a string argument.
- * The hex colour value of the outline.
- * @param text a string argument.
- * The label of the line.
- * @param font_size an int argument.
- * Font size of the label.
- */
- function bar_glass( $alpha, $colour, $outline_colour, $text='', $size=-1 )
- {
- $type = 'bar_glass'. $this->next_line();
-
- $description = $alpha .','. $colour .','. $outline_colour .','. $text .','. $size;
-
- $this->lines[$type] = $description;
- }
-
- /**
- * Draw a faded bar chart.
- *
- * @param alpha an int argument.
- * The percentage of transparency of the bar colour.
- * @param colour a string argument.
- * The hex colour value of the line.
- * @param text a string argument.
- * The label of the line.
- * @param font_size an int argument.
- * Font size of the label.
- */
- function bar_fade( $alpha, $colour='', $text='', $size=-1 )
- {
- $type = 'bar_fade'. $this->next_line();
-
- $description = $alpha .','. $colour .','. $text .','. $size;
-
- $this->lines[$type] = $description;
- }
-
- function candle( $data, $alpha, $line_width, $colour, $text='', $size=-1 )
- {
- $type = 'candle'. $this->next_line();
-
- $description = $alpha .','. $line_width .','. $colour .','. $text .','. $size;
-
- $this->lines[$type] = $description;
-
- $a = array();
- foreach( $data as $can )
- $a[] = $can->toString();
-
- $this->data[] = implode(',',$a);
- }
-
- function hlc( $data, $alpha, $line_width, $colour, $text='', $size=-1 )
- {
- $type = 'hlc'. $this->next_line();
-
- $description = $alpha .','. $line_width .','. $colour .','. $text .','. $size;
-
- $this->lines[$type] = $description;
-
- $a = array();
- foreach( $data as $can )
- $a[] = $can->toString();
-
- $this->data[] = implode(',',$a);
- }
-
- function scatter( $data, $line_width, $colour, $text='', $size=-1 )
- {
- $type = 'scatter'. $this->next_line();
-
- $description = $line_width .','. $colour .','. $text .','. $size;
-
- $this->lines[$type] = $description;
-
- $a = array();
- foreach( $data as $can )
- $a[] = $can->toString();
-
- $this->data[] = implode(',',$a);
- }
-
-
- //
- // Patch by, Jeremy Miller (14th Nov, 2007)
- //
- /**
- * Draw a pie chart.
- *
- * @param alpha an int argument.
- * The percentage of transparency of the pie colour.
- * @param $style a string argument.
- * CSS style string
- * @param label_colour a string argument.
- * The hex colour value of the label.
- * @param gradient a boolean argument.
- * Use a gradient true or false.
- * @param border_size an int argument.
- * Size of the border in pixels.
- */
- function pie( $alpha, $line_colour, $style, $gradient = true, $border_size = false )
- {
- $this->pie = $alpha.','.$line_colour.','.$style;
- if( !$gradient )
- {
- $this->pie .= ','.!$gradient;
- }
- if ($border_size)
- {
- if ($gradient === false)
- {
- $this->pie .= ',';
- }
- $this->pie .= ','.$border_size;
- }
- }
-
- /**
- * Set the values of the pie chart.
- *
- * @param values an array argument.
- * An array of the values for the pie chart.
- * @param labels an array argument.
- * An array of the labels for the pie pieces.
- * @param links an array argument.
- * An array of the links to the pie pieces.
- */
- function pie_values( $values, $labels=array(), $links=array() )
- {
- $this->pie_values = implode(',',$values);
- $this->pie_labels = implode(',',$labels);
- $this->pie_links = implode(",",$links);
- }
-
- /**
- * Set the pie slice colours.
- *
- * @param colours an array argument.
- * The hex colour values of the pie pieces.
- */
- function pie_slice_colours( $colours )
- {
- $this->pie_colours = implode(',',$colours);
- }
-
-
- /**
- * Render the output.
- */
- function render()
- {
- $tmp = array();
-
- //echo headers_sent() ?'yes':'no';
- if( !headers_sent() )
- header('content-type: text; charset: utf-8');
-
- if($this->output_type == 'js')
- {
- $this->set_unique_id();
-
- // alternate content (<p></p>) is empty for browsers without Flash
- $tmp[] = '<div id="' . $this->unique_id . '"><p></p></div>';
- $tmp[] = '<script type="text/javascript" src="' . $this->js_path . 'swfobject.js"></script>';
- $tmp[] = '<script type="text/javascript">';
- $tmp[] = 'var flashvars = [];';
- }
-
- if( strlen( $this->title ) > 0 )
- {
- $values = $this->title;
- $values .= ','. $this->title_style;
- $tmp[] = $this->format_output('title',$values);
- }
-
- if( strlen( $this->x_legend ) > 0 )
- {
- $values = $this->x_legend;
- $values .= ','. $this->x_legend_size;
- $values .= ','. $this->x_legend_colour;
- $tmp[] = $this->format_output('x_legend',$values);
- }
-
- if( strlen( $this->x_label_style ) > 0 )
- $tmp[] = $this->format_output('x_label_style',$this->x_label_style);
-
- if( $this->x_tick_size > 0 )
- $tmp[] = $this->format_output('x_ticks',$this->x_tick_size);
-
- if( $this->x_axis_steps > 0 )
- $tmp[] = $this->format_output('x_axis_steps',$this->x_axis_steps);
-
- if( strlen( $this->x_axis_3d ) > 0 )
- $tmp[] = $this->format_output('x_axis_3d',$this->x_axis_3d);
-
- if( strlen( $this->y_legend ) > 0 )
- $tmp[] = $this->format_output('y_legend',$this->y_legend);
-
- if( strlen( $this->y_legend_right ) > 0 )
- $tmp[] = $this->format_output('y2_legend',$this->y_legend_right);
-
- if( strlen( $this->y_label_style ) > 0 )
- $tmp[] = $this->format_output('y_label_style',$this->y_label_style);
-
- $values = '5,10,'. $this->y_steps;
- $tmp[] = $this->format_output('y_ticks',$values);
-
- if( count( $this->lines ) == 0 && count($this->data_sets)==0 )
- {
- $tmp[] = $this->format_output($this->line_default['type'],$this->line_default['values']);
- }
- else
- {
- foreach( $this->lines as $type=>$description )
- $tmp[] = $this->format_output($type,$description);
- }
-
- $num = 1;
- foreach( $this->data as $data )
- {
- if( $num==1 )
- {
- $tmp[] = $this->format_output( 'values', $data);
- }
- else
- {
- $tmp[] = $this->format_output('values_'. $num, $data);
- }
-
- $num++;
- }
-
- $num = 1;
- foreach( $this->links as $link )
- {
- if( $num==1 )
- {
- $tmp[] = $this->format_output( 'links', $link);
- }
- else
- {
- $tmp[] = $this->format_output('links_'. $num, $link);
- }
-
- $num++;
- }
-
- if( count( $this->y2_lines ) > 0 )
- {
- $tmp[] = $this->format_output('y2_lines',implode( ',', $this->y2_lines ));
- //
- // Should this be an option? I think so...
- //
- $tmp[] = $this->format_output('show_y2','true');
- }
-
- if( count( $this->x_labels ) > 0 )
- $tmp[] = $this->format_output('x_labels',implode(',',$this->x_labels));
- else
- {
- if( strlen($this->x_min) > 0 )
- $tmp[] = $this->format_output('x_min',$this->x_min);
-
- if( strlen($this->x_max) > 0 )
- $tmp[] = $this->format_output('x_max',$this->x_max);
- }
-
- $tmp[] = $this->format_output('y_min',$this->y_min);
- $tmp[] = $this->format_output('y_max',$this->y_max);
-
- if( strlen($this->y2_min) > 0 )
- $tmp[] = $this->format_output('y2_min',$this->y2_min);
-
- if( strlen($this->y2_max) > 0 )
- $tmp[] = $this->format_output('y2_max',$this->y2_max);
-
- if( strlen( $this->bg_colour ) > 0 )
- $tmp[] = $this->format_output('bg_colour',$this->bg_colour);
-
- if( strlen( $this->bg_image ) > 0 )
- {
- $tmp[] = $this->format_output('bg_image',$this->bg_image);
- $tmp[] = $this->format_output('bg_image_x',$this->bg_image_x);
- $tmp[] = $this->format_output('bg_image_y',$this->bg_image_y);
- }
-
- if( strlen( $this->x_axis_colour ) > 0 )
- {
- $tmp[] = $this->format_output('x_axis_colour',$this->x_axis_colour);
- $tmp[] = $this->format_output('x_grid_colour',$this->x_grid_colour);
- }
-
- if( strlen( $this->y_axis_colour ) > 0 )
- $tmp[] = $this->format_output('y_axis_colour',$this->y_axis_colour);
-
- if( strlen( $this->y_grid_colour ) > 0 )
- $tmp[] = $this->format_output('y_grid_colour',$this->y_grid_colour);
-
- if( strlen( $this->y2_axis_colour ) > 0 )
- $tmp[] = $this->format_output('y2_axis_colour',$this->y2_axis_colour);
-
- if( strlen( $this->x_offset ) > 0 )
- $tmp[] = $this->format_output('x_offset',$this->x_offset);
-
- if( strlen( $this->inner_bg_colour ) > 0 )
- {
- $values = $this->inner_bg_colour;
- if( strlen( $this->inner_bg_colour_2 ) > 0 )
- {
- $values .= ','. $this->inner_bg_colour_2;
- $values .= ','. $this->inner_bg_angle;
- }
- $tmp[] = $this->format_output('inner_background',$values);
- }
-
- if( strlen( $this->pie ) > 0 )
- {
- $tmp[] = $this->format_output('pie',$this->pie);
- $tmp[] = $this->format_output('values',$this->pie_values);
- $tmp[] = $this->format_output('pie_labels',$this->pie_labels);
- $tmp[] = $this->format_output('colours',$this->pie_colours);
- $tmp[] = $this->format_output('links',$this->pie_links);
- }
-
- if( strlen( $this->tool_tip ) > 0 )
- $tmp[] = $this->format_output('tool_tip',$this->tool_tip);
-
-
-
- if( strlen( $this->y_format ) > 0 )
- $tmp[] = $this->format_output('y_format',$this->y_format);
-
- if( strlen( $this->num_decimals ) > 0 )
- $tmp[] = $this->format_output('num_decimals',$this->num_decimals);
-
- if( strlen( $this->is_fixed_num_decimals_forced ) > 0 )
- $tmp[] = $this->format_output('is_fixed_num_decimals_forced',$this->is_fixed_num_decimals_forced);
-
- if( strlen( $this->is_decimal_separator_comma ) > 0 )
- $tmp[] = $this->format_output('is_decimal_separator_comma',$this->is_decimal_separator_comma);
-
- if( strlen( $this->is_thousand_separator_disabled ) > 0 )
- $tmp[] = $this->format_output('is_thousand_separator_disabled',$this->is_thousand_separator_disabled);
-
-
- $count = 1;
- foreach( $this->data_sets as $set )
- {
- $tmp[] = $set->toString( $this->output_type, $count>1?'_'.$count:'' );
- $count++;
- }
-
- if($this->output_type == 'js')
- {
- $tmp[] = 'swfobject.embedSWF("' . $this->swf_path . 'open-flash-chart.swf", "' . $this->unique_id . '", "'. $this->width . '", "' . $this->height . '", "9.0.0", false, flashvars, {bgcolor:"#FFFFFF"}, {id:"ofc",name:"ofc"});';
- $tmp[] = '</script>';
- }
-
- return implode("\r\n",$tmp);
- }
-}
-
-class line
-{
- var $line_width;
- var $colour;
- var $_key;
- var $key;
- var $key_size;
- // hold the data
- var $data;
- // extra tool tip info:
- var $tips;
-
- function line( $line_width, $colour )
- {
- $this->var = 'line';
-
- $this->line_width = $line_width;
- $this->colour = $colour;
- $this->data = array();
- $this->links = array();
- $this->tips = array();
- $this->_key = false;
- }
-
- function key( $key, $size )
- {
- $this->_key = true;
- $this->key = graph::esc( $key );
- $this->key_size = $size;
- }
-
- function add( $data )
- {
- $this->data[] = $data;
- }
-
- function add_link( $data, $link )
- {
- $this->data[] = $data;
- $this->links[] = graph::esc( $link );
- }
-
- function add_data_tip( $data, $tip )
- {
- $this->data[] = $data;
- $this->tips[] = graph::esc( $tip );
- }
-
- function add_data_link_tip( $data, $link, $tip )
- {
- $this->data[] = $data;
- $this->links[] = graph::esc( $link );
- $this->tips[] = graph::esc( $tip );
- }
-
- // return the variables for this chart
- function _get_variable_list()
- {
- $values = array();
- $values[] = $this->line_width;
- $values[] = $this->colour;
-
- if( $this->_key )
- {
- $values[] = $this->key;
- $values[] = $this->key_size;
- }
-
- return $values;
- }
-
- function toString( $output_type, $set_num )
- {
- $values = implode( ',', $this->_get_variable_list() );
-
- $tmp = array();
-
- if( $output_type == 'js' )
- {
- $tmp[] = 'flashvars["'. $this->var.$set_num .'"] = "'. $values .'";';
- $tmp[] = 'flashvars["values'. $set_num .'"] = "'. implode( ',', $this->data ) .'";';
- if( count( $this->links ) > 0 )
- $tmp[] = 'flashvars["links'. $set_num .'"] = "'. implode( ',', $this->links ) .'";';
- if( count( $this->tips ) > 0 )
- $tmp[] = 'flashvars["tool_tips_set'. $set_num .'"] = "'. implode( ',', $this->tips ) .'";';
- }
- else
- {
- $tmp[] = '&'. $this->var. $set_num .'='. $values .'&';
- $tmp[] = '&values'. $set_num .'='. implode( ',', $this->data ) .'&';
-
- if( count( $this->links ) > 0 )
- $tmp[] = '&links'. $set_num .'='. implode( ',', $this->links ) .'&';
-
- if( count( $this->tips ) > 0 )
- $tmp[] = '&tool_tips_set'. $set_num .'='. implode( ',', $this->tips ) .'&';
- }
-
- return implode( "\r\n", $tmp );
- }
-}
-
-class line_hollow extends line
-{
- var $dot_size;
-
- function line_hollow( $line_width, $dot_size, $colour )
- {
- parent::line( $line_width, $colour );
- $this->var = 'line_hollow';
- $this->dot_size = $dot_size;
- }
-
- // return the variables for this chart
- function _get_variable_list()
- {
- $values = array();
- $values[] = $this->line_width;
- $values[] = $this->colour;
-
- if( $this->_key )
- {
- $values[] = $this->key;
- $values[] = $this->key_size;
- }
- else
- {
- $values[] = '';
- $values[] = '';
- }
- $values[] = $this->dot_size;
-
- return $values;
- }
-}
-
-class line_dot extends line_hollow
-{
- function line_dot( $line_width, $dot_size, $colour )
- {
- parent::line_hollow( $line_width, $dot_size,$colour );
- $this->var = 'line_dot';
- }
-}
-
-class bar
-{
- var $colour;
- var $alpha;
- var $data;
- var $links;
- var $_key;
- var $key;
- var $key_size;
- var $var;
- // extra tool tip info:
- var $tips;
-
- function bar( $alpha, $colour )
- {
- $this->var = 'bar';
-
- $this->alpha = $alpha;
- $this->colour = $colour;
- $this->data = array();
- $this->links = array();
- $this->tips = array();
- $this->_key = false;
- }
-
- function key( $key, $size )
- {
- $this->_key = true;
- $this->key = graph::esc( $key );
- $this->key_size = $size;
- }
-
- function add( $data )
- {
- $this->data[] = $data;
- }
-
- function add_link( $data, $link )
- {
- $this->data[] = $data;
- $this->links[] = graph::esc( $link );
- }
-
- function add_data_tip( $data, $tip )
- {
- $this->data[] = $data;
- $this->tips[] = graph::esc( $tip );
- }
-
- // return the variables for this
- // bar chart
- function _get_variable_list()
- {
- $values = array();
- $values[] = $this->alpha;
- $values[] = $this->colour;
-
- if( $this->_key )
- {
- $values[] = $this->key;
- $values[] = $this->key_size;
- }
-
- return $values;
- }
-
- function toString( $output_type, $set_num )
- {
- $values = implode( ',', $this->_get_variable_list() );
-
- $tmp = array();
-
- if( $output_type == 'js' )
- {
- $tmp[] = 'flashvars["'. $this->var.$set_num .'"] = "'. $values . '";';
- $tmp[] = 'flashvars["values'. $set_num .'"] = "'. implode( ',', $this->data ) .'";';
-
- if( count( $this->links ) > 0 )
- $tmp[] = 'flashvars["links'. $set_num .'"] = "'. implode( ',', $this->links ) .'";';
-
- if( count( $this->tips ) > 0 )
- $tmp[] = 'flashvars["tool_tips_set'. $set_num .'"] = "'. implode( ',', $this->tips ) .'";';
- }
- else
- {
- $tmp[] = '&'. $this->var. $set_num .'='. $values .'&';
- $tmp[] = '&values'. $set_num .'='. implode( ',', $this->data ) .'&';
-
- if( count( $this->links ) > 0 )
- $tmp[] = '&links'. $set_num .'='. implode( ',', $this->links ) .'&';
-
- if( count( $this->tips ) > 0 )
- $tmp[] = '&tool_tips_set'. $set_num .'='. implode( ',', $this->tips ) .'&';
- }
-
- return implode( "\r\n", $tmp );
- }
-
-}
-
-class bar_3d extends bar
-{
- function bar_3d( $alpha, $colour )
- {
- parent::bar( $alpha, $colour );
- $this->var = 'bar_3d';
- }
-}
-
-class bar_fade extends bar
-{
- function bar_fade( $alpha, $colour )
- {
- parent::bar( $alpha, $colour );
- $this->var = 'bar_fade';
- }
-}
-
-class bar_outline extends bar
-{
- var $outline_colour;
-
- function bar_outline( $alpha, $colour, $outline_colour )
- {
- parent::bar( $alpha, $colour );
- $this->var = 'filled_bar';
- $this->outline_colour = $outline_colour;
- }
-
- // override the base method
- function _get_variable_list()
- {
- $values = array();
- $values[] = $this->alpha;
- $values[] = $this->colour;
- $values[] = $this->outline_colour;
-
- if( $this->_key )
- {
- $values[] = $this->key;
- $values[] = $this->key_size;
- }
-
- return $values;
- }
-}
-
-class bar_glass extends bar_outline
-{
- function bar_glass( $alpha, $colour, $outline_colour )
- {
- parent::bar_outline( $alpha, $colour, $outline_colour );
- $this->var = 'bar_glass';
- }
-}
-
-//
-// this has an outline colour and a 'jiggle' parameter
-// called offset
-//
-class bar_sketch extends bar_outline
-{
- var $offset;
-
- function bar_sketch( $alpha, $offset, $colour, $outline_colour )
- {
- parent::bar_outline( $alpha, $colour, $outline_colour );
- $this->var = 'bar_sketch';
- $this->offset = $offset;
- }
-
- // override the base method
- function _get_variable_list()
- {
- $values = array();
- $values[] = $this->alpha;
- $values[] = $this->offset;
- $values[] = $this->colour;
- $values[] = $this->outline_colour;
-
- if( $this->_key )
- {
- $values[] = $this->key;
- $values[] = $this->key_size;
- }
-
- return $values;
- }
-}
-
-class candle
-{
- var $out;
-
- function candle( $high, $open, $close, $low )
- {
- $this->out = array();
- $this->out[] = $high;
- $this->out[] = $open;
- $this->out[] = $close;
- $this->out[] = $low;
- }
-
- function toString()
- {
- return '['. implode( ',', $this->out ) .']';
- }
-}
-
-class hlc
-{
- var $out;
-
- function hlc( $high, $low, $close )
- {
- $this->out = array();
- $this->out[] = $high;
- $this->out[] = $low;
- $this->out[] = $close;
- }
-
- function toString()
- {
- return '['. implode( ',', $this->out ) .']';
- }
-}
-
-class point
-{
- var $out;
-
- function point( $x, $y, $size_px )
- {
- $this->out = array();
- $this->out[] = $x;
- $this->out[] = $y;
- $this->out[] = $size_px;
- }
-
- function toString()
- {
- return '['. implode( ',', $this->out ) .']';
- }
-}
-
-// PIWIK SPECIAL ALIAS HACK - when updating Open Flash Chart, leave this line unchanged
-class graph extends Piwik_Visualization_OpenFlashChart {}
diff --git a/core/Visualization/Sparkline.php b/core/Visualization/Sparkline.php
index b0e60dbcbd..5dba26696a 100644
--- a/core/Visualization/Sparkline.php
+++ b/core/Visualization/Sparkline.php
@@ -21,15 +21,12 @@ require_once 'sparkline/lib/Sparkline_Line.php';
class Piwik_Visualization_Sparkline implements Piwik_iView
{
/**
- * Sets data. Must have format: array( array('value' => X),array('value' =>Y ), ...)
- *
+ * Array with format: array( x, y, z, ... )
* @param array $data
*/
- function setData($data)
+ function setValues($data)
{
- $this->data = $data;
- $this->width = self::getWidth();
- $this->height = self::getHeight();
+ $this->values = $data;
}
static public function getWidth()
@@ -39,14 +36,17 @@ class Piwik_Visualization_Sparkline implements Piwik_iView
static public function getHeight()
{
- return 20;
+ return 25;
}
function main()
{
- $data = $this->data;
+ $width = self::getWidth();
+ $height = self::getHeight();
+
+ $data = $this->values;
$sparkline = new Sparkline_Line();
- $sparkline->SetColor('lineColor', 22,44,74); // dark blue
+ $sparkline->SetColor('lineColor', 22, 44, 74); // dark blue
$sparkline->SetColorHtml('red', '#FF7F7F');
$sparkline->SetColorHtml('blue', '#55AAFF');
$sparkline->SetColorHtml('green', '#75BF7C');
@@ -54,37 +54,31 @@ class Piwik_Visualization_Sparkline implements Piwik_iView
$data = array_reverse($data);
$min = $max = $last = null;
$i = 0;
-
- foreach($this->data as $row)
+ foreach($this->values as $value)
{
- $value = $row['value'];
$sparkline->SetData($i, $value);
if( null == $min || $value <= $min[1])
{
$min = array($i, $value);
}
-
if(null == $max || $value >= $max[1])
{
$max = array($i, $value);
}
-
$last = array($i, $value);
- $i++;
+ $i++;
}
-
$sparkline->SetYMin(0);
- $sparkline->SetPadding(2); // setpadding is additive
- $sparkline->SetPadding(0,//13 font height
- 3, //4 * (strlen("$last[1]")),
- 0, //imagefontheight(FONT_2),
- 0);
+ $sparkline->setYMax($max[1] + 1); // the +1 seems to be mandatory to not lose some pixels when value = max
+ $sparkline->SetPadding( 3, 0, 2, 0);
$font = FONT_2;
- $sparkline->SetFeaturePoint($min[0]-1, $min[1], 'red', 5);
- $sparkline->SetFeaturePoint($max[0]-1, $max[1], 'green', 5);
- $sparkline->SetFeaturePoint($last[0]-1, $last[1], 'blue',5);
+ // the -0.5 is a hack as the sparkline samping rendering is obviously slightly bugged
+ // (see also fix marked as //FIX FROM PIWIK in libs/sparkline/lib/Sparkline.php)
+ $sparkline->SetFeaturePoint($min[0] -0.5, $min[1], 'red', 5);
+ $sparkline->SetFeaturePoint($max[0] -0.5, $max[1], 'green', 5);
+ $sparkline->SetFeaturePoint($last[0] -0.5, $last[1], 'blue', 5);
$sparkline->SetLineSize(3); // for renderresampled, linesize is on virtual image
- $sparkline->RenderResampled($this->width, $this->height, 'lineColor');
+ $sparkline->RenderResampled($width, $height);
$this->sparkline = $sparkline;
}
diff --git a/lang/en.php b/lang/en.php
index 0db6022f04..26e63e35ad 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -40,12 +40,17 @@ $translations = array(
'General_Visitors' => 'Visitors',
'General_ColumnNbUniqVisitors' => 'Unique visitors',
'General_ColumnNbVisits' => 'Visits',
+ 'General_ColumnNbActions' => 'Actions',
+ 'General_ColumnMaxActions' => 'Maximum actions in one visit',
+ 'General_ColumnSumVisitLength' => 'Total time spent by visitors (in seconds)',
'General_ColumnLabel' => 'Label',
'General_ColumnActionsPerVisit' => 'Actions per Visit',
'General_ColumnAvgTimeOnSite' => 'Avg. Time on Site',
'General_ColumnBounceRate' => 'Bounce Rate',
'General_ColumnPageviews' => 'Pageviews',
'General_ColumnUniquePageviews' => 'Unique Pageviews',
+ 'General_ColumnValuePerVisit' => 'Value per Visit',
+ 'General_ColumnVisitsWithConversions' => 'Visits with Conversions',
'General_Save' => 'Save',
'General_Website' => 'Website',
'General_NoDataForGraph' => 'No data for this graph',
@@ -56,6 +61,44 @@ $translations = array(
'General_YouAreCurrentlyViewingDemoOfPiwik' => "You are currently viewing the demo of %s; %sdownload%s the full version! Check out %s",
'General_PiwikXIsAvailablePleaseUpdateNow' => "Piwik %s is available. %s Please update now!%s (see %s changes%s).",
'General_BackToPiwik' => "Back to Piwik",
+ 'General_ShortMonth_1' => "Jan",
+ 'General_ShortMonth_2' => "Feb",
+ 'General_ShortMonth_3' => "Mar",
+ 'General_ShortMonth_4' => "Apr",
+ 'General_ShortMonth_5' => "May",
+ 'General_ShortMonth_6' => "Jun",
+ 'General_ShortMonth_7' => "Jul",
+ 'General_ShortMonth_8' => "Aug",
+ 'General_ShortMonth_9' => "Sep",
+ 'General_ShortMonth_10' => "Oct",
+ 'General_ShortMonth_11' => "Nov",
+ 'General_ShortMonth_12' => "Dec",
+ 'General_LongMonth_1' => "January",
+ 'General_LongMonth_2' => "February",
+ 'General_LongMonth_3' => "March",
+ 'General_LongMonth_4' => "April",
+ 'General_LongMonth_5' => "May",
+ 'General_LongMonth_6' => "June",
+ 'General_LongMonth_7' => "July",
+ 'General_LongMonth_8' => "August",
+ 'General_LongMonth_9' => "September",
+ 'General_LongMonth_10' => "October",
+ 'General_LongMonth_11' => "November",
+ 'General_LongMonth_12' => "December",
+ 'General_ShortDay_1' => "Mon",
+ 'General_ShortDay_2' => "Tue",
+ 'General_ShortDay_3' => "Wed",
+ 'General_ShortDay_4' => "Thu",
+ 'General_ShortDay_5' => "Fri",
+ 'General_ShortDay_6' => "Sat",
+ 'General_ShortDay_7' => "Sun",
+ 'General_LongDay_1' => "Monday",
+ 'General_LongDay_2' => "Tuesday",
+ 'General_LongDay_3' => "Wednesday",
+ 'General_LongDay_4' => "Thursday",
+ 'General_LongDay_5' => "Friday",
+ 'General_LongDay_6' => "Saturday",
+ 'General_LongDay_7' => "Sunday",
'CorePluginsAdmin_Plugins' => 'Plugins',
'CorePluginsAdmin_PluginsManagement' => 'Plugins Management',
'CorePluginsAdmin_MainDescription' => 'Plugins extend and expand the functionality of Piwik. Once a plugin is installed, you may activate it or deactivate it here.',
@@ -83,7 +126,7 @@ $translations = array(
'CoreHome_ExcludeLowPopulation_js' => 'Exclude low population',
'CoreHome_PageOf_js' => '%s of %s',
'CoreHome_Loading_js' => 'Loading...',
- 'CoreHome_LocalizedDateFormat' => '%A %d %B %Y',
+ 'CoreHome_DayFormat' => '%longDay% %day% %longMonth% %longYear%',
'CoreHome_PeriodDay' => 'Day',
'CoreHome_PeriodWeek' => 'Week',
'CoreHome_PeriodMonth' => 'Month',
@@ -151,11 +194,11 @@ $translations = array(
'Dashboard_AddWidget' => 'Add a widget...',
'Dashboard_DeleteWidgetConfirm' => 'Are you sure you want to delete this widget from the dashboard?',
'Dashboard_SelectWidget' => 'Select the widget to add in the dashboard',
- 'Dashboard_AddPreviewedWidget' => 'Add previewed widget to the dashboard',
- 'Dashboard_WidgetPreview' => 'Widget preview',
+ 'Dashboard_AddPreviewedWidget_js' => 'Add previewed widget to the dashboard',
+ 'Dashboard_WidgetPreview_js' => 'Widget preview',
+ 'Dashboard_Close_js' => 'Close',
'Dashboard_TitleWidgetInDashboard_js' => 'Widget already in dashboard',
'Dashboard_TitleClickToAdd_js' => 'Click to add to dashboard',
- 'Dashboard_LoadingPreview_js' => 'Loading preview, please wait...',
'Dashboard_LoadingWidget_js' => 'Loading widget, please wait...',
'Dashboard_WidgetNotFound_js' => 'Widget not found',
'Referers_Referers' => 'Referers',
@@ -164,6 +207,7 @@ $translations = array(
'Referers_DirectEntry' => 'Direct Entry',
'Referers_Websites' => 'Websites',
'Referers_Campaigns' => 'Campaigns',
+ 'Referers_MetricsFromRefererTypeGraphLegend' => '%1s (from %2s)',
'Referers_Evolution' => 'Evolution over the period',
'Referers_Type' => 'Referer Type',
'Referers_DetailsByRefererType' => 'Details by Referer Type',
@@ -171,11 +215,12 @@ $translations = array(
'Referers_TypeSearchEngines' => '%s from search engines',
'Referers_TypeWebsites' => '%s from websites',
'Referers_TypeCampaigns' => '%s from campaigns',
- 'Referers_Other' => 'Other',
- 'Referers_OtherDistinctSearchEngines' => '%s distinct search engines',
- 'Referers_OtherDistinctKeywords' => '%s distinct keywords',
- 'Referers_OtherDistinctWebsites' => '%1s distinct websites (using %2s distinct urls)',
- 'Referers_OtherDistinctCampaigns' => '%s distinct campaigns',
+ 'Referers_Distinct' => 'Distinct Referers by Referer Type',
+ 'Referers_DistinctSearchEngines' => 'distinct search engines',
+ 'Referers_DistinctKeywords' => 'distinct keywords',
+ 'Referers_DistinctCampaigns' => 'distinct campaigns',
+ 'Referers_DistinctWebsites' => 'distinct websites',
+ 'Referers_UsingNDistinctUrls' => ' (using %2s distinct urls)',
'Referers_SubmenuEvolution' => 'Evolution',
'Referers_SubmenuSearchEngines' => 'Search engines & keywords',
'Referers_SubmenuWebsites' => 'Websites',
@@ -185,6 +230,7 @@ $translations = array(
'Referers_WidgetExternalWebsites' => 'List of external Websites',
'Referers_WidgetSearchEngines' => 'Best search engines',
'Referers_WidgetOverview' => 'Overview',
+ 'UserSettings_VisitorSettings' => 'Visitor Settings',
'UserSettings_BrowserFamilies' => 'Browser families',
'UserSettings_Browsers' => 'Browsers',
'UserSettings_Plugins' => 'Plugins',
@@ -480,8 +526,8 @@ $translations = array(
'VisitsSummary_NbActions' => '%s actions (page views)',
'VisitsSummary_TotalTime' => '%s total time spent by the visitors',
'VisitsSummary_MaxNbActions' => '%s max actions in one visit',
- 'VisitsSummary_NbBounced' => '%s visitors have bounced (left the site after one page)',
- 'VisitsSummary_EvolutionPeriods' => 'Evolution on the last 30 %s',
+ 'VisitsSummary_NbVisitsBounced' => '%s visits have bounced (left the site after one page)',
+ 'VisitsSummary_EvolutionOverLastPeriods' => 'Evolution over the last %s',
'VisitsSummary_Report' => 'Report',
'VisitsSummary_GenerateTime' => '%s seconds to generate the page',
'VisitsSummary_GenerateQueries' => '%s queries executed',
@@ -491,11 +537,16 @@ $translations = array(
'VisitsSummary_WidgetOverviewGraph' => 'Overview with graph',
'VisitsSummary_SubmenuOverview' => 'Overview',
'VisitFrequency_Evolution' => 'Evolution over the period',
+ 'VisitFrequency_ColumnReturningVisits' => 'Returning Visits',
+ 'VisitFrequency_ColumnActionsByReturningVisits' => 'Actions by Returning Visits',
+ 'VisitFrequency_ColumnMaximumActionsByAReturningVisit' => 'Maximum Actions by a Returning Visit',
+ 'VisitFrequency_ColumnTotalTimeSpentByReturningVisits' => 'Total time spent by Returning Visits (in seconds)',
+ 'VisitFrequency_ColumnBounceRateForReturningVisits' => 'Bounce rate for Returning Visits',
'VisitFrequency_ReturnVisits' => '%s returning visits',
'VisitFrequency_ReturnActions' => '%s actions by the returning visits',
'VisitFrequency_ReturnMaxActions' => '%s maximum actions by a returning visit',
'VisitFrequency_ReturnTotalTime' => '%s total time spent by returning visits',
- 'VisitFrequency_ReturnBounces' => '%s times that a returning visit has bounced (left the site after one page)',
+ 'VisitFrequency_ReturnBounceRate' => '%s returning visits have bounced (left the site after one page)',
'VisitFrequency_WidgetOverview' => 'Frequency overview',
'VisitFrequency_WidgetGraphReturning' => 'Graph returning visits',
'VisitFrequency_SubmenuFrequency' => 'Frequency',
@@ -634,6 +685,9 @@ $translations = array(
'Installation_ErrorInvalidState' => 'Error: it seems you try to skip a step of the Installation process, or your cookies are disabled, or the Piwik configuration file is already created. %sMake sure your cookies are enabled%s and go back %s to the first page of the installation %s.',
'Provider_WidgetProviders' => 'Providers',
'Provider_SubmenuLocationsProvider' => 'Locations & provider',
+ 'Goals_ColumnConversions' => 'Conversions',
+ 'Goals_ColumnConversionRate' => 'Conversion Rate',
+ 'Goals_ColumnRevenue' => 'Revenue',
'DBStats_DatabaseUsage' => 'Database usage',
'DBStats_MainDescription' => 'Piwik is storing all your web analytics data in the Mysql database. Currently, Piwik tables are using %s.',
'DBStats_Table' => 'Table',
diff --git a/libs/javascript/json2.js b/libs/javascript/json2.js
new file mode 100644
index 0000000000..d7c3fb5d13
--- /dev/null
+++ b/libs/javascript/json2.js
@@ -0,0 +1,29 @@
+// see http://www.json.org/js.html
+if(!this.JSON){JSON={};}
+(function(){function f(n){return n<10?'0'+n:n;}
+if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return this.getUTCFullYear()+'-'+
+f(this.getUTCMonth()+1)+'-'+
+f(this.getUTCDate())+'T'+
+f(this.getUTCHours())+':'+
+f(this.getUTCMinutes())+':'+
+f(this.getUTCSeconds())+'Z';};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
+var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
+function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
+if(typeof rep==='function'){value=rep.call(holder,key,value);}
+switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
+gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
+v=partial.length===0?'[]':gap?'[\n'+gap+
+partial.join(',\n'+gap)+'\n'+
+mind+']':'['+partial.join(',')+']';gap=mind;return v;}
+if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
+v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
+if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
+rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
+return str('',{'':value});};}
+if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
+return reviver.call(holder,key,value);}
+cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
+('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
+if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
+throw new SyntaxError('JSON.parse');};}}()); \ No newline at end of file
diff --git a/libs/open-flash-chart/open-flash-chart.swf b/libs/open-flash-chart/open-flash-chart.swf
index 85b590a28f..9496b1a5c0 100644
--- a/libs/open-flash-chart/open-flash-chart.swf
+++ b/libs/open-flash-chart/open-flash-chart.swf
Binary files differ
diff --git a/libs/open-flash-chart/php-ofc-library/README.txt b/libs/open-flash-chart/php-ofc-library/README.txt
new file mode 100644
index 0000000000..012fbfd52f
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/README.txt
@@ -0,0 +1,16 @@
+Open Flash Chart - PHP libraries. These help create data files for Open Flash Chart.
+Copyright (C) 2007
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/dot_base.php b/libs/open-flash-chart/php-ofc-library/dot_base.php
new file mode 100644
index 0000000000..5772efcd9f
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/dot_base.php
@@ -0,0 +1,231 @@
+<?php
+
+/**
+ * A private class. All the other line-dots inherit from this.
+ * Gives them all some common methods.
+ */
+class dot_base
+{
+ /**
+ * @param $type string
+ * @param $value integer
+ */
+ function dot_base($type, $value=null)
+ {
+ $this->type = $type;
+ if( isset( $value ) )
+ $this->value( $value );
+ }
+
+ /**
+ * For line charts that only require a Y position
+ * for each point.
+ * @param $value as integer, the Y position
+ */
+ function value( $value )
+ {
+ $this->value = $value;
+ }
+
+ /**
+ * For scatter charts that require an X and Y position for
+ * each point.
+ *
+ * @param $x as integer
+ * @param $y as integer
+ */
+ function position( $x, $y )
+ {
+ $this->x = $x;
+ $this->y = $y;
+ }
+
+ /**
+ * @param $colour is a string, HEX colour, e.g. '#FF0000' red
+ */
+ function colour($colour)
+ {
+ $this->colour = $colour;
+ return $this;
+ }
+
+ /**
+ * The tooltip for this dot.
+ */
+ function tooltip( $tip )
+ {
+ $this->tip = $tip;
+ return $this;
+ }
+
+ /**
+ * @param $size is an integer. Size of the dot.
+ */
+ function size($size)
+ {
+ $tmp = 'dot-size';
+ $this->$tmp = $size;
+ return $this;
+ }
+
+ /**
+ * a private method
+ */
+ function type( $type )
+ {
+ $this->type = $type;
+ return $this;
+ }
+
+ /**
+ * @param $size is an integer. The size of the hollow 'halo' around the dot that masks the line.
+ */
+ function halo_size( $size )
+ {
+ $tmp = 'halo-size';
+ $this->$tmp = $size;
+ return $this;
+ }
+
+ /**
+ * @param $do as string. One of three options (examples):
+ * - "http://example.com" - browse to this URL
+ * - "https://example.com" - browse to this URL
+ * - "trace:message" - print this message in the FlashDevelop debug pane
+ * - all other strings will be called as Javascript functions, so a string "hello_world"
+ * will call the JS function "hello_world(index)". It passes in the index of the
+ * point.
+ */
+ function on_click( $do )
+ {
+ $tmp = 'on-click';
+ $this->$tmp = $do;
+ }
+}
+
+/**
+ * Draw a hollow dot
+ */
+class hollow_dot extends dot_base
+{
+ function hollow_dot($value=null)
+ {
+ parent::dot_base( 'hollow-dot', $value );
+ }
+}
+
+/**
+ * Draw a star
+ */
+class star extends dot_base
+{
+ /**
+ * The constructor, takes an optional $value
+ */
+ function star($value=null)
+ {
+ parent::dot_base( 'star', $value );
+ }
+
+ /**
+ * @param $angle is an integer.
+ */
+ function rotation($angle)
+ {
+ $this->rotation = $angle;
+ return $this;
+ }
+
+ /**
+ * @param $is_hollow is a boolean.
+ */
+ function hollow($is_hollow)
+ {
+ $this->hollow = $is_hollow;
+ }
+}
+
+/**
+ * Draw a 'bow tie' shape.
+ */
+class bow extends dot_base
+{
+ /**
+ * The constructor, takes an optional $value
+ */
+ function bow($value=null)
+ {
+ parent::dot_base( 'bow', $value );
+ }
+
+ /**
+ * Rotate the anchor object.
+ * @param $angle is an integer.
+ */
+ function rotation($angle)
+ {
+ $this->rotation = $angle;
+ return $this;
+ }
+}
+
+/**
+ * An <i><b>n</b></i> sided shape.
+ */
+class anchor extends dot_base
+{
+ /**
+ * The constructor, takes an optional $value
+ */
+ function anchor($value=null)
+ {
+ parent::dot_base( 'anchor', $value );
+ }
+
+ /**
+ * Rotate the anchor object.
+ * @param $angle is an integer.
+ */
+ function rotation($angle)
+ {
+ $this->rotation = $angle;
+ return $this;
+ }
+
+ /**
+ * @param $sides is an integer. Number of sides this shape has.
+ */
+ function sides($sides)
+ {
+ $this->sides = $sides;
+ return $this;
+ }
+}
+
+/**
+ * A simple dot
+ */
+class dot extends dot_base
+{
+ /**
+ * The constructor, takes an optional $value
+ */
+ function dot($value=null)
+ {
+ parent::dot_base( 'dot', $value );
+ }
+}
+
+/**
+ * A simple dot
+ */
+class solid_dot extends dot_base
+{
+ /**
+ * The constructor, takes an optional $value
+ */
+ function solid_dot($value=null)
+ {
+ parent::dot_base( 'solid-dot', $value );
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/json_format.php b/libs/open-flash-chart/php-ofc-library/json_format.php
new file mode 100644
index 0000000000..b8e3de5cb1
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/json_format.php
@@ -0,0 +1,86 @@
+<?php
+
+// Pretty print some JSON
+function json_format($json)
+{
+ $tab = " ";
+ $new_json = "";
+ $indent_level = 0;
+ $in_string = false;
+
+/*
+ commented out by monk.e.boy 22nd May '08
+ because my web server is PHP4, and
+ json_* are PHP5 functions...
+
+ $json_obj = json_decode($json);
+
+ if($json_obj === false)
+ return false;
+
+ $json = json_encode($json_obj);
+*/
+ $len = strlen($json);
+
+ for($c = 0; $c < $len; $c++)
+ {
+ $char = $json[$c];
+ switch($char)
+ {
+ case '{':
+ case '[':
+ if(!$in_string)
+ {
+ $new_json .= $char . "\n" . str_repeat($tab, $indent_level+1);
+ $indent_level++;
+ }
+ else
+ {
+ $new_json .= $char;
+ }
+ break;
+ case '}':
+ case ']':
+ if(!$in_string)
+ {
+ $indent_level--;
+ $new_json .= "\n" . str_repeat($tab, $indent_level) . $char;
+ }
+ else
+ {
+ $new_json .= $char;
+ }
+ break;
+ case ',':
+ if(!$in_string)
+ {
+ $new_json .= ",\n" . str_repeat($tab, $indent_level);
+ }
+ else
+ {
+ $new_json .= $char;
+ }
+ break;
+ case ':':
+ if(!$in_string)
+ {
+ $new_json .= ": ";
+ }
+ else
+ {
+ $new_json .= $char;
+ }
+ break;
+ case '"':
+ if($c > 0 && $json[$c-1] != '\\')
+ {
+ $in_string = !$in_string;
+ }
+ default:
+ $new_json .= $char;
+ break;
+ }
+ }
+
+ return $new_json;
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_area_base.php b/libs/open-flash-chart/php-ofc-library/ofc_area_base.php
new file mode 100644
index 0000000000..a6e811fd55
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_area_base.php
@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * inherits from line
+ */
+class area extends line
+{
+ function area()
+ {
+ $this->type = "area";
+ }
+
+ /**
+ * the fill colour
+ */
+ function set_fill_colour( $colour )
+ {
+ $this->fill = $colour;
+ }
+
+ /**
+ * sugar: see set_fill_colour
+ */
+ function fill_colour( $colour )
+ {
+ $this->set_fill_colour( $colour );
+ return $this;
+ }
+
+ function set_fill_alpha( $alpha )
+ {
+ $tmp = "fill-alpha";
+ $this->$tmp = $alpha;
+ }
+
+ function set_loop()
+ {
+ $this->loop = true;
+ }
+}
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_area_hollow.php b/libs/open-flash-chart/php-ofc-library/ofc_area_hollow.php
new file mode 100644
index 0000000000..4293af0b65
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_area_hollow.php
@@ -0,0 +1,10 @@
+<?php
+
+class area_hollow extends area_base
+{
+ function area_hollow()
+ {
+ $this->type = "area_hollow";
+ parent::area_base();
+ }
+}
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_area_line.php b/libs/open-flash-chart/php-ofc-library/ofc_area_line.php
new file mode 100644
index 0000000000..5731391a33
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_area_line.php
@@ -0,0 +1,10 @@
+<?php
+
+class area_line extends area_base
+{
+ function area_line()
+ {
+ $this->type = "area_line";
+ parent::area_base();
+ }
+}
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_bar.php b/libs/open-flash-chart/php-ofc-library/ofc_bar.php
new file mode 100644
index 0000000000..6ddda42749
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_bar.php
@@ -0,0 +1,34 @@
+<?php
+
+include_once 'ofc_bar_base.php';
+
+class bar_value
+{
+ function bar_value( $top, $bottom=null )
+ {
+ $this->top = $top;
+
+ if( isset( $bottom ) )
+ $this->bottom = $bottom;
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ function set_tooltip( $tip )
+ {
+ $this->tip = $tip;
+ }
+}
+
+class bar extends bar_base
+{
+ function bar()
+ {
+ $this->type = "bar";
+ parent::bar_base();
+ }
+}
+
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_bar_3d.php b/libs/open-flash-chart/php-ofc-library/ofc_bar_3d.php
new file mode 100644
index 0000000000..47552184ce
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_bar_3d.php
@@ -0,0 +1,22 @@
+<?php
+
+include_once 'ofc_bar_base.php';
+
+class bar_3d_value
+{
+ function bar_3d_value( $top )
+ {
+ $this->top = $top;
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ function set_tooltip( $tip )
+ {
+ $this->tip = $tip;
+ }
+}
+
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_bar_base.php b/libs/open-flash-chart/php-ofc-library/ofc_bar_base.php
new file mode 100644
index 0000000000..c0105fac4b
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_bar_base.php
@@ -0,0 +1,78 @@
+<?php
+
+/* this is a base class */
+
+class bar_base
+{
+ function bar_base(){}
+
+ /**
+ * @param $text as string the key text
+ * @param $size as integer, size in pixels
+ */
+ function set_key( $text, $size )
+ {
+ $this->text = $text;
+ $tmp = 'font-size';
+ $this->$tmp = $size;
+ }
+
+ /**
+ * syntatical sugar.
+ */
+ function key( $text, $size )
+ {
+ $this->set_key( $text, $size );
+ }
+
+ /**
+ * @param $v as an array, a mix of:
+ * - a bar_value class. You can use this to customise the paramters of each bar.
+ * - integer. This is the Y position of the top of the bar.
+ */
+ function set_values( $v )
+ {
+ $this->values = $v;
+ }
+
+ /**
+ * see set_values
+ */
+ function append_value( $v )
+ {
+ $this->values[] = $v;
+ }
+
+ /**
+ * @param $colour as string, a HEX colour, e.g. '#ff0000' red
+ */
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ /**
+ *syntatical sugar
+ */
+ function colour( $colour )
+ {
+ $this->set_colour( $colour );
+ }
+
+ /**
+ * @param $alpha as real number (range 0 to 1), e.g. 0.5 is half transparent
+ */
+ function set_alpha( $alpha )
+ {
+ $this->alpha = $alpha;
+ }
+
+ /**
+ * @param $tip as string, the tip to show. May contain various magic variables.
+ */
+ function set_tooltip( $tip )
+ {
+ $this->tip = $tip;
+ }
+}
+
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_bar_filled.php b/libs/open-flash-chart/php-ofc-library/ofc_bar_filled.php
new file mode 100644
index 0000000000..837c1fc458
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_bar_filled.php
@@ -0,0 +1,39 @@
+<?php
+
+include_once 'ofc_bar_base.php';
+
+class bar_filled_value extends bar_value
+{
+ function bar_filled_value( $top, $bottom=null )
+ {
+ parent::bar_value( $top, $bottom );
+ }
+
+ function set_outline_colour( $outline_colour )
+ {
+ $tmp = 'outline-colour';
+ $this->$tmp = $outline_colour;
+ }
+}
+
+class bar_filled extends bar_base
+{
+ function bar_filled( $colour=null, $outline_colour=null )
+ {
+ $this->type = "bar_filled";
+ parent::bar_base();
+
+ if( isset( $colour ) )
+ $this->set_colour( $colour );
+
+ if( isset( $outline_colour ) )
+ $this->set_outline_colour( $outline_colour );
+ }
+
+ function set_outline_colour( $outline_colour )
+ {
+ $tmp = 'outline-colour';
+ $this->$tmp = $outline_colour;
+ }
+}
+
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_bar_glass.php b/libs/open-flash-chart/php-ofc-library/ofc_bar_glass.php
new file mode 100644
index 0000000000..af829fe640
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_bar_glass.php
@@ -0,0 +1,109 @@
+<?php
+
+include_once 'ofc_bar_base.php';
+
+class bar_value
+{
+ /**
+ * @param $top as integer. The Y value of the top of the bar
+ * @param OPTIONAL $bottom as integer. The Y value of the bottom of the bar, defaults to Y min.
+ */
+ function bar_value( $top, $bottom=null )
+ {
+ $this->top = $top;
+
+ if( isset( $bottom ) )
+ $this->bottom = $bottom;
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ function set_tooltip( $tip )
+ {
+ $this->tip = $tip;
+ }
+}
+
+class bar extends bar_base
+{
+ function bar()
+ {
+ $this->type = "bar";
+ parent::bar_base();
+ }
+}
+
+class bar_glass extends bar_base
+{
+ function bar_glass()
+ {
+ $this->type = "bar_glass";
+ parent::bar_base();
+ }
+}
+
+class bar_cylinder extends bar_base
+{
+ function bar_cylinder()
+ {
+ $this->type = "bar_cylinder";
+ parent::bar_base();
+ }
+}
+
+class bar_cylinder_outline extends bar_base
+{
+ function bar_cylinder_outline()
+ {
+ $this->type = "bar_cylinder_outline";
+ parent::bar_base();
+ }
+}
+
+class bar_rounded_glass extends bar_base
+{
+ function bar_rounded_glass()
+ {
+ $this->type = "bar_round_glass";
+ parent::bar_base();
+ }
+}
+
+class bar_round extends bar_base
+{
+ function bar_round()
+ {
+ $this->type = "bar_round";
+ parent::bar_base();
+ }
+}
+
+class bar_dome extends bar_base
+{
+ function bar_dome()
+ {
+ $this->type = "bar_dome";
+ parent::bar_base();
+ }
+}
+
+class bar_round3d extends bar_base
+{
+ function bar_round3d()
+ {
+ $this->type = "bar_round3d";
+ parent::bar_base();
+ }
+}
+
+class bar_3d extends bar_base
+{
+ function bar_3d()
+ {
+ $this->type = "bar_3d";
+ parent::bar_base();
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_bar_sketch.php b/libs/open-flash-chart/php-ofc-library/ofc_bar_sketch.php
new file mode 100644
index 0000000000..ce1bcccf8a
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_bar_sketch.php
@@ -0,0 +1,29 @@
+<?php
+
+include_once 'ofc_bar_base.php';
+
+class bar_sketch extends bar_base
+{
+ /**
+ * @param $colour as string, HEX colour e.g. '#00ff00'
+ * @param $outline_colour as string, HEX colour e.g. '#ff0000'
+ * @param $fun_factor as integer, range 0 to 10. 0,1 and 2 are pretty boring.
+ * 4 to 6 is a bit fun, 7 and above is lots of fun.
+ */
+ function bar_sketch( $colour, $outline_colour, $fun_factor )
+ {
+ $this->type = "bar_sketch";
+ parent::bar_base();
+
+ $this->set_colour( $colour );
+ $this->set_outline_colour( $outline_colour );
+ $this->offset = $fun_factor;
+ }
+
+ function set_outline_colour( $outline_colour )
+ {
+ $tmp = 'outline-colour';
+ $this->$tmp = $outline_colour;
+ }
+}
+
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_bar_stack.php b/libs/open-flash-chart/php-ofc-library/ofc_bar_stack.php
new file mode 100644
index 0000000000..7b8d11e4ed
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_bar_stack.php
@@ -0,0 +1,50 @@
+<?php
+
+include_once 'ofc_bar_base.php';
+
+class bar_stack extends bar_base
+{
+ function bar_stack()
+ {
+ $this->type = "bar_stack";
+ parent::bar_base();
+ }
+
+ function append_stack( $v )
+ {
+ $this->append_value( $v );
+ }
+
+ // an array of HEX colours strings
+ // e.g. array( '#ff0000', '#00ff00' );
+ function set_colours( $colours )
+ {
+ $this->colours = $colours;
+ }
+
+ // an array of bar_stack_value
+ function set_keys( $keys )
+ {
+ $this->keys = $keys;
+ }
+}
+
+class bar_stack_value
+{
+ function bar_stack_value( $val, $colour )
+ {
+ $this->val = $val;
+ $this->colour = $colour;
+ }
+}
+
+class bar_stack_key
+{
+ function bar_stack_key( $colour, $text, $font_size )
+ {
+ $this->colour = $colour;
+ $this->text = $text;
+ $tmp = 'font-size';
+ $this->$tmp = $font_size;
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_hbar.php b/libs/open-flash-chart/php-ofc-library/ofc_hbar.php
new file mode 100644
index 0000000000..6f8c0e451f
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_hbar.php
@@ -0,0 +1,64 @@
+<?php
+
+class hbar_value
+{
+ function hbar_value( $left, $right=null )
+ {
+ if( isset( $right ) )
+ {
+ $this->left = $left;
+ $this->right = $right;
+ }
+ else
+ $this->right = $left;
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ function set_tooltip( $tip )
+ {
+ $this->tip = $tip;
+ }
+}
+
+class hbar
+{
+ function hbar( $colour )
+ {
+ $this->type = "hbar";
+ $this->values = array();
+ $this->set_colour( $colour );
+ }
+
+ function append_value( $v )
+ {
+ $this->values[] = $v;
+ }
+
+ function set_values( $v )
+ {
+ foreach( $v as $val )
+ $this->append_value( new hbar_value( $val ) );
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ function set_key( $text, $size )
+ {
+ $this->text = $text;
+ $tmp = 'font-size';
+ $this->$tmp = $size;
+ }
+
+ function set_tooltip( $tip )
+ {
+ $this->tip = $tip;
+ }
+}
+
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_line.php b/libs/open-flash-chart/php-ofc-library/ofc_line.php
new file mode 100644
index 0000000000..68ea03a5ce
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_line.php
@@ -0,0 +1,115 @@
+<?php
+
+class line
+{
+ function line()
+ {
+ $this->type = "line";
+ $this->values = array();
+ }
+
+ /**
+ * Set the default dot that all the real
+ * dots inherit their properties from. If you set the
+ * default dot to be red, all values in your chart that
+ * do not specify a colour will be red. Same for all the
+ * other attributes such as tooltip, on-click, size etc...
+ *
+ * @param $style as any class that inherits base_dot
+ */
+ function set_default_dot_style( $style )
+ {
+ $tmp = 'dot-style';
+ $this->$tmp = $style;
+ }
+
+ /**
+ * @param $v as array, can contain any combination of:
+ * - integer, Y position of the point
+ * - any class that inherits from dot_base
+ * - <b>null</b>
+ */
+ function set_values( $v )
+ {
+ $this->values = $v;
+ }
+
+ /**
+ * Append a value to the line.
+ *
+ * @param mixed $v
+ */
+ function append_value($v)
+ {
+ $this->values[] = $v;
+ }
+
+ function set_width( $width )
+ {
+ $this->width = $width;
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ /**
+ * sytnatical sugar for set_colour
+ */
+ function colour( $colour )
+ {
+ $this->set_colour( $colour );
+ return $this;
+ }
+
+ function set_halo_size( $size )
+ {
+ $tmp = 'halo-size';
+ $this->$tmp = $size;
+ }
+
+ function set_key( $text, $font_size )
+ {
+ $this->text = $text;
+ $tmp = 'font-size';
+ $this->$tmp = $font_size;
+ }
+
+ function set_tooltip( $tip )
+ {
+ $this->tip = $tip;
+ }
+
+ function set_on_click( $text )
+ {
+ $tmp = 'on-click';
+ $this->$tmp = $text;
+ }
+
+ function loop()
+ {
+ $this->loop = true;
+ }
+
+ function line_style( $s )
+ {
+ $tmp = "line-style";
+ $this->$tmp = $s;
+ }
+
+ /**
+ * Sets the text for the line.
+ *
+ * @param string $text
+ */
+ function set_text($text)
+ {
+ $this->text = $text;
+ }
+
+ function attach_to_right_y_axis()
+ {
+ $this->axis = 'right';
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_line_base.php b/libs/open-flash-chart/php-ofc-library/ofc_line_base.php
new file mode 100644
index 0000000000..fa45cbc899
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_line_base.php
@@ -0,0 +1,92 @@
+<?php
+
+class line_base
+{
+ function line_base()
+ {
+ $this->type = "line";
+ $this->text = "Page views";
+ $tmp = 'font-size';
+ $this->$tmp = 10;
+
+ $this->values = array();
+ }
+
+ function set_values( $v )
+ {
+ $this->values = $v;
+ }
+
+ /**
+ * Append a value to the line.
+ *
+ * @param mixed $v
+ */
+ function append_value($v)
+ {
+ $this->values[] = $v;
+ }
+
+ function set_width( $width )
+ {
+ $this->width = $width;
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ function set_dot_size( $size )
+ {
+ $tmp = 'dot-size';
+ $this->$tmp = $size;
+ }
+
+ function set_halo_size( $size )
+ {
+ $tmp = 'halo-size';
+ $this->$tmp = $size;
+ }
+
+ function set_key( $text, $font_size )
+ {
+ $this->text = $text;
+ $tmp = 'font-size';
+ $this->$tmp = $font_size;
+ }
+
+ function set_tooltip( $tip )
+ {
+ $this->tip = $tip;
+ }
+
+ function set_on_click( $text )
+ {
+ $tmp = 'on-click';
+ $this->$tmp = $text;
+ }
+
+ function loop()
+ {
+ $this->loop = true;
+ }
+
+ function line_style( $s )
+ {
+ $tmp = "line-style";
+ $this->$tmp = $s;
+ }
+
+ /**
+ * Sets the text for the line.
+ *
+ * @param string $text
+ */
+ function set_text($text)
+ {
+ $this->text = $text;
+ }
+
+
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_line_dot.php b/libs/open-flash-chart/php-ofc-library/ofc_line_dot.php
new file mode 100644
index 0000000000..146691173b
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_line_dot.php
@@ -0,0 +1,33 @@
+<?php
+
+class dot_value
+{
+ function dot_value( $value, $colour )
+ {
+ $this->value = $value;
+ $this->colour = $colour;
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ function set_size( $size )
+ {
+ $this->size = $size;
+ }
+
+ function set_tooltip( $tip )
+ {
+ $this->tip = $tip;
+ }
+}
+
+class line_dot extends line_base
+{
+ function line_dot()
+ {
+ $this->type = "line_dot";
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_line_hollow.php b/libs/open-flash-chart/php-ofc-library/ofc_line_hollow.php
new file mode 100644
index 0000000000..512bb07d97
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_line_hollow.php
@@ -0,0 +1,9 @@
+<?php
+
+class line_hollow extends line_base
+{
+ function line_hollow()
+ {
+ $this->type = "line_hollow";
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_line_style.php b/libs/open-flash-chart/php-ofc-library/ofc_line_style.php
new file mode 100644
index 0000000000..4f538cf9de
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_line_style.php
@@ -0,0 +1,11 @@
+<?php
+
+class line_style
+{
+ function line_style($on, $off)
+ {
+ $this->style = "dash";
+ $this->on = $on;
+ $this->off = $off;
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_menu.php b/libs/open-flash-chart/php-ofc-library/ofc_menu.php
new file mode 100644
index 0000000000..0750a09c2b
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_menu.php
@@ -0,0 +1,56 @@
+<?php
+
+class ofc_menu_item
+{
+ /**
+ * @param $text as string. The menu item text.
+ * @param $javascript_function_name as string. The javascript function name, the
+ * js function takes one parameter, the chart ID. See ofc_menu_item_camera for
+ * some example code.
+ */
+ function ofc_menu_item($text, $javascript_function_name)
+ {
+ $this->type = "text";
+ $this->text = $text;
+ $tmp = 'javascript-function';
+ $this->$tmp = $javascript_function_name;
+ }
+}
+
+class ofc_menu_item_camera
+{
+ /**
+ * @param $text as string. The menu item text.
+ * @param $javascript_function_name as string. The javascript function name, the
+ * js function takes one parameter, the chart ID. So for example, our js function
+ * could look like this:
+ *
+ * function save_image( chart_id )
+ * {
+ * alert( chart_id );
+ * }
+ *
+ * to make a menu item call this: ofc_menu_item_camera('Save chart', 'save_image');
+ */
+ function ofc_menu_item_camera($text, $javascript_function_name)
+ {
+ $this->type = "camera-icon";
+ $this->text = $text;
+ $tmp = 'javascript-function';
+ $this->$tmp = $javascript_function_name;
+ }
+}
+
+class ofc_menu
+{
+ function ofc_menu($colour, $outline_colour)
+ {
+ $this->colour = $colour;
+ $this->outline_colour = $outline_colour;
+ }
+
+ function values($values)
+ {
+ $this->values = $values;
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_pie.php b/libs/open-flash-chart/php-ofc-library/ofc_pie.php
new file mode 100644
index 0000000000..bf779c5541
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_pie.php
@@ -0,0 +1,257 @@
+<?php
+
+class pie_value
+{
+ function pie_value( $value, $label )
+ {
+ $this->value = $value;
+ $this->label = $label;
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ function set_label( $label, $label_colour, $font_size )
+ {
+ $this->label = $label;
+
+ $tmp = 'label-colour';
+ $this->$tmp = $label_colour;
+
+ $tmp = 'font-size';
+ $this->$tmp = $font_size;
+
+ }
+
+ function set_tooltip( $tip )
+ {
+ $this->tip = $tip;
+ }
+
+ function on_click( $event )
+ {
+ $tmp = 'on-click';
+ $this->$tmp = $event;
+ }
+
+
+ /**
+ * An object that inherits from base_pie_animation
+ */
+ function add_animation( $animation )
+ {
+ if( !isset( $this->animate ) )
+ $this->animate = array();
+
+ $this->animate[] = $animation;
+
+ return $this;
+ }
+}
+
+class base_pie_animation{}
+
+/**
+ * fade the pie slice from $alpha (pie set_alpha) to 100% opaque.
+ */
+class pie_fade extends base_pie_animation
+{
+ function pie_fade()
+ {
+ $this->type="fade";
+ }
+}
+
+/**
+ * Bounce the pie slice out a little
+ */
+class pie_bounce extends base_pie_animation
+{
+ /**
+ * @param $distance as integer, distance to bounce in pixels
+ */
+ function pie_bounce( $distance )
+ {
+ $this->type="bounce";
+ $this->distance = $distance;
+ }
+}
+
+/**
+ * Make a pie chart and fill it with pie slices
+ */
+class pie
+{
+ function pie()
+ {
+ $this->type = 'pie';
+ }
+
+ function set_colours( $colours )
+ {
+ $this->colours = $colours;
+ }
+
+ /**
+ * Sugar wrapped around set_colours
+ */
+ function colours( $colours )
+ {
+ $this->set_colours( $colours );
+ return $this;
+ }
+
+ /**
+ * @param $alpha as float (0-1) 0.75 = 3/4 visible
+ */
+ function set_alpha( $alpha )
+ {
+ $this->alpha = $alpha;
+ }
+
+ /**
+ *sugar wrapped set_alpha
+ **/
+ function alpha( $alpha )
+ {
+ $this->set_alpha( $alpha );
+ return $this;
+ }
+
+ /**
+ * @param $v as array containing one of
+ * - null
+ * - real or integer number
+ * - a pie_value object
+ */
+ function set_values( $v )
+ {
+ $this->values = $v;
+ }
+
+ /**
+ * sugar for set_values
+ */
+ function values( $v )
+ {
+ $this->set_values( $v );
+ return $this;
+ }
+
+ /**
+ * HACK to keep old code working.
+ */
+ function set_animate( $bool )
+ {
+ if( $bool )
+ $this->add_animation( new pie_fade() );
+
+ }
+
+ /**
+ * An object that inherits from base_pie_animation
+ */
+ function add_animation( $animation )
+ {
+ if( !isset( $this->animate ) )
+ $this->animate = array();
+
+ $this->animate[] = $animation;
+
+ return $this;
+ }
+
+ /**
+ * @param $angle as real number
+ */
+ function set_start_angle( $angle )
+ {
+ $tmp = 'start-angle';
+ $this->$tmp = $angle;
+ }
+
+ /**
+ * sugar for set_start_angle
+ */
+ function start_angle($angle)
+ {
+ $this->set_start_angle( $angle );
+ return $this;
+ }
+
+ /**
+ * @param $tip as string. The tooltip text. May contain magic varibles
+ */
+ function set_tooltip( $tip )
+ {
+ $this->tip = $tip;
+ }
+
+ /**
+ * sugar for set_tooltip
+ */
+ function tooltip( $tip )
+ {
+ $this->set_tooltip( $tip );
+ return $this;
+ }
+
+ function set_gradient_fill()
+ {
+ $tmp = 'gradient-fill';
+ $this->$tmp = true;
+ }
+
+ function gradient_fill()
+ {
+ $this->set_gradient_fill();
+ return $this;
+ }
+
+ /**
+ * By default each label is the same colour as the slice,
+ * but you can ovveride that behaviour using this method.
+ *
+ * @param $label_colour as string HEX colour;
+ */
+ function set_label_colour( $label_colour )
+ {
+ $tmp = 'label-colour';
+ $this->$tmp = $label_colour;
+ }
+
+ function label_colour( $label_colour )
+ {
+ $this->set_label_colour( $label_colour );
+ return $this;
+ }
+
+ /**
+ * Turn off the labels
+ */
+ function set_no_labels()
+ {
+ $tmp = 'no-labels';
+ $this->$tmp = true;
+ }
+
+ function on_click( $event )
+ {
+ $tmp = 'on-click';
+ $this->$tmp = $event;
+ }
+
+ /**
+ * Fix the radius of the pie chart. Take a look at the magic variable #radius#
+ * for helping figure out what radius to set it to.
+ *
+ * @param $radius as number
+ */
+ function radius( $radius )
+ {
+ $this->radius = $radius;
+ return $this;
+ }
+}
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_radar_axis.php b/libs/open-flash-chart/php-ofc-library/ofc_radar_axis.php
new file mode 100644
index 0000000000..909c41af8f
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_radar_axis.php
@@ -0,0 +1,47 @@
+<?php
+
+class radar_axis
+{
+ function radar_axis( $max )
+ {
+ $this->set_max( $max );
+ }
+
+ function set_max( $max )
+ {
+ $this->max = $max;
+ }
+
+ function set_steps( $steps )
+ {
+ $this->steps = $steps;
+ }
+
+ function set_stroke( $s )
+ {
+ $this->stroke = $s;
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ function set_grid_colour( $colour )
+ {
+ $tmp = 'grid-colour';
+ $this->$tmp = $colour;
+ }
+
+ function set_labels( $labels )
+ {
+ $this->labels = $labels;
+ }
+
+ function set_spoke_labels( $labels )
+ {
+ $tmp = 'spoke-labels';
+ $this->$tmp = $labels;
+ }
+}
+
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_radar_axis_labels.php b/libs/open-flash-chart/php-ofc-library/ofc_radar_axis_labels.php
new file mode 100644
index 0000000000..22d485e4e6
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_radar_axis_labels.php
@@ -0,0 +1,15 @@
+<?php
+
+class radar_axis_labels
+{
+ // $labels : array
+ function radar_axis_labels( $labels )
+ {
+ $this->labels = $labels;
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_radar_spoke_labels.php b/libs/open-flash-chart/php-ofc-library/ofc_radar_spoke_labels.php
new file mode 100644
index 0000000000..51ba25e9a7
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_radar_spoke_labels.php
@@ -0,0 +1,15 @@
+<?php
+
+class radar_spoke_labels
+{
+ // $labels : array
+ function radar_spoke_labels( $labels )
+ {
+ $this->labels = $labels;
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_scatter.php b/libs/open-flash-chart/php-ofc-library/ofc_scatter.php
new file mode 100644
index 0000000000..7159a3a64f
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_scatter.php
@@ -0,0 +1,47 @@
+<?php
+
+class scatter_value
+{
+ function scatter_value( $x, $y, $dot_size=-1 )
+ {
+ $this->x = $x;
+ $this->y = $y;
+
+ if( $dot_size > 0 )
+ {
+ $tmp = 'dot-size';
+ $this->$tmp = $dot_size;
+ }
+ }
+}
+
+class scatter
+{
+ function scatter( $colour )
+ {
+ $this->type = "scatter";
+ $this->set_colour( $colour );
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ function set_default_dot_style( $style )
+ {
+ $tmp = 'dot-style';
+ $this->$tmp = $style;
+ }
+
+ /**
+ * @param $v as array, can contain any combination of:
+ * - integer, Y position of the point
+ * - any class that inherits from scatter_value
+ * - <b>null</b>
+ */
+ function set_values( $values )
+ {
+ $this->values = $values;
+ }
+}
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_scatter_line.php b/libs/open-flash-chart/php-ofc-library/ofc_scatter_line.php
new file mode 100644
index 0000000000..bd6c27ecf0
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_scatter_line.php
@@ -0,0 +1,43 @@
+<?php
+
+class scatter_line
+{
+ function scatter_line( $colour )
+ {
+ $this->type = "scatter_line";
+ $this->set_colour( $colour );
+ }
+
+ function set_default_dot_style( $style )
+ {
+ $tmp = 'dot-style';
+ $this->$tmp = $style;
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ function set_values( $values )
+ {
+ $this->values = $values;
+ }
+
+ function set_step_horizontal()
+ {
+ $this->stepgraph = 'horizontal';
+ }
+
+ function set_step_vertical()
+ {
+ $this->stepgraph = 'vertical';
+ }
+
+ function set_key( $text, $font_size )
+ {
+ $this->text = $text;
+ $tmp = 'font-size';
+ $this->$tmp = $font_size;
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_shape.php b/libs/open-flash-chart/php-ofc-library/ofc_shape.php
new file mode 100644
index 0000000000..0cfe39f9bc
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_shape.php
@@ -0,0 +1,25 @@
+<?php
+
+class shape_point
+{
+ function shape_point( $x, $y )
+ {
+ $this->x = $x;
+ $this->y = $y;
+ }
+}
+
+class shape
+{
+ function shape( $colour )
+ {
+ $this->type = "shape";
+ $this->colour = $colour;
+ $this->values = array();
+ }
+
+ function append_value( $p )
+ {
+ $this->values[] = $p;
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_sugar.php b/libs/open-flash-chart/php-ofc-library/ofc_sugar.php
new file mode 100644
index 0000000000..a9e85555ee
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_sugar.php
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * Sugar: to make stars easier sometimes
+ */
+class s_star extends star
+{
+ /**
+ * I use this wrapper for default dot types,
+ * it just makes the code easier to read.
+ */
+ function s_star($colour, $size)
+ {
+ parent::star();
+ $this->colour($colour)->size($size);
+ }
+}
+
+class s_box extends anchor
+{
+ /**
+ * I use this wrapper for default dot types,
+ * it just makes the code easier to read.
+ */
+ function s_box($colour, $size)
+ {
+ parent::anchor();
+ $this->colour($colour)->size($size)->rotation(45)->sides(4);
+ }
+}
+
+class s_hollow_dot extends hollow_dot
+{
+ /**
+ * I use this wrapper for default dot types,
+ * it just makes the code easier to read.
+ */
+ function s_hollow_dot($colour, $size)
+ {
+ parent::hollow_dot();
+ $this->colour($colour)->size($size);
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_title.php b/libs/open-flash-chart/php-ofc-library/ofc_title.php
new file mode 100644
index 0000000000..cda1de0068
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_title.php
@@ -0,0 +1,39 @@
+<?php
+
+/**
+ * Set the title of a chart, make one of these and pass it into
+ * open_flash_chart set_title
+ */
+class title
+{
+ function title( $text='' )
+ {
+ $this->text = $text;
+ }
+
+ /**
+ * A css string. Can optionally contain:
+ * - font-size
+ * - font-family
+ * - font-weight
+ * - color
+ * - background-color
+ * - text-align
+ * - margin
+ * - margin-left
+ * - margin-right
+ * - margin-top
+ * - margin-bottom
+ * - padding
+ * - padding-left
+ * - padding-right
+ * - padding-top
+ * - padding-bottom
+ * just like the css we use all the time :-)
+ */
+ function set_style( $css )
+ {
+ $this->style = $css;
+ //"{font-size: 20px; color:#0000ff; font-family: Verdana; text-align: center;}";
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_tooltip.php b/libs/open-flash-chart/php-ofc-library/ofc_tooltip.php
new file mode 100644
index 0000000000..3104ee33b9
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_tooltip.php
@@ -0,0 +1,67 @@
+<?php
+
+include_once 'ofc_bar_base.php';
+
+class tooltip
+{
+ function tooltip(){}
+
+ /**
+ * @param $shadow as boolean. Enable drop shadow.
+ */
+ function set_shadow( $shadow )
+ {
+ $this->shadow = $shadow;
+ }
+
+ /**
+ * @param $stroke as integer, border width in pixels (e.g. 5 )
+ */
+ function set_stroke( $stroke )
+ {
+ $this->stroke = $stroke;
+ }
+
+ /**
+ * @param $colour as string, HEX colour e.g. '#0000ff'
+ */
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ /**
+ * @param $bg as string, HEX colour e.g. '#0000ff'
+ */
+ function set_background_colour( $bg )
+ {
+ $this->background = $bg;
+ }
+
+ /**
+ * @param $style as string. A css style.
+ */
+ function set_title_style( $style )
+ {
+ $this->title = $style;
+ }
+
+ /**
+ * @param $style as string. A css style.
+ */
+ function set_body_style( $style )
+ {
+ $this->body = $style;
+ }
+
+ function set_proximity()
+ {
+ $this->mouse = 1;
+ }
+
+ function set_hover()
+ {
+ $this->mouse = 2;
+ }
+}
+
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_upload_image.php b/libs/open-flash-chart/php-ofc-library/ofc_upload_image.php
new file mode 100644
index 0000000000..0261f9aeae
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_upload_image.php
@@ -0,0 +1,70 @@
+<?php
+
+//
+// In Open Flash Chart -> save_image debug mode, you
+// will see the 'echo' text in a new window.
+//
+
+/*
+
+print_r( $_GET );
+print_r( $_POST );
+print_r( $_FILES );
+
+print_r( $GLOBALS );
+print_r( $GLOBALS["HTTP_RAW_POST_DATA"] );
+
+*/
+
+
+// default path for the image to be stored //
+$default_path = '../tmp-upload-images/';
+
+if (!file_exists($default_path)) mkdir($default_path, 0777, true);
+
+// full path to the saved image including filename //
+$destination = $default_path . basename( $_GET[ 'name' ] );
+
+echo 'Saving your image to: '. $destination;
+// print_r( $_POST );
+// print_r( $_SERVER );
+// echo $HTTP_RAW_POST_DATA;
+
+//
+// POST data is usually string data, but we are passing a RAW .png
+// so PHP is a bit confused and $_POST is empty. But it has saved
+// the raw bits into $HTTP_RAW_POST_DATA
+//
+
+$jfh = fopen($destination, 'w') or die("can't open file");
+fwrite($jfh, $HTTP_RAW_POST_DATA);
+fclose($jfh);
+
+//
+// LOOK:
+//
+exit();
+
+
+//
+// PHP5:
+//
+
+
+// default path for the image to be stored //
+$default_path = 'tmp-upload-images/';
+
+if (!file_exists($default_path)) mkdir($default_path, 0777, true);
+
+// full path to the saved image including filename //
+$destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] );
+
+// move the image into the specified directory //
+if (move_uploaded_file($_FILES[ 'Filedata' ][ 'tmp_name' ], $destination)) {
+ echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";
+} else {
+ echo "FILE UPLOAD FAILED";
+}
+
+
+?>
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_x_axis.php b/libs/open-flash-chart/php-ofc-library/ofc_x_axis.php
new file mode 100644
index 0000000000..aa3187c5e3
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_x_axis.php
@@ -0,0 +1,104 @@
+<?php
+
+class x_axis
+{
+ function x_axis(){}
+
+ /**
+ * @param $stroke as integer, with of the line and ticks
+ */
+ function set_stroke( $stroke )
+ {
+ $this->stroke = $stroke;
+ }
+
+ /**
+ *@param $colour as string HEX colour
+ *@param $grid_colour as string HEX colour
+ */
+ function set_colours( $colour, $grid_colour )
+ {
+ $this->set_colour( $colour );
+ $this->set_grid_colour( $grid_colour );
+ }
+
+ /**
+ *@param $colour as string HEX colour
+ */
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ function set_tick_height( $height )
+ {
+ $tmp = 'tick-height';
+ $this->$tmp = $height;
+ }
+
+ function set_grid_colour( $colour )
+ {
+ $tmp = 'grid-colour';
+ $this->$tmp = $colour;
+ }
+
+ /**
+ * @param $o is a boolean. If true, the X axis start half a step in
+ * This defaults to True
+ */
+ function set_offset( $o )
+ {
+ $this->offset = $o?true:false;
+ }
+
+ /**
+ * @param $steps as integer. Which ticks are visible.
+ */
+ function set_steps( $steps )
+ {
+ $this->steps = $steps;
+ }
+
+ /**
+ * @param $val as an integer, the height in pixels of the 3D bar. Mostly
+ * used for the 3D bar chart.
+ */
+ function set_3d( $val )
+ {
+ $tmp = '3d';
+ $this->$tmp = $val;
+ }
+
+ /**
+ * @param $x_axis_labels as an x_axis_labels object
+ * Use this to customize the labels (colour, font, etc...)
+ */
+ function set_labels( $x_axis_labels )
+ {
+ //$this->labels = $v;
+ $this->labels = $x_axis_labels;
+ }
+
+ /**
+ * Sugar syntax: helper function to make the examples simpler.
+ * @param $a is an array of labels
+ */
+ function set_labels_from_array( $a )
+ {
+ $x_axis_labels = new x_axis_labels();
+ $x_axis_labels->set_labels( $a );
+ $this->labels = $x_axis_labels;
+
+ if( isset( $this->steps ) )
+ $x_axis_labels->set_steps( $this->steps );
+ }
+
+ /**
+ * min and max.
+ */
+ function set_range( $min, $max )
+ {
+ $this->min = $min;
+ $this->max = $max;
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_x_axis_label.php b/libs/open-flash-chart/php-ofc-library/ofc_x_axis_label.php
new file mode 100644
index 0000000000..cf116f15f0
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_x_axis_label.php
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * x_axis_label see x_axis_labels
+ */
+class x_axis_label
+{
+ function x_axis_label( $text, $colour, $size, $rotate )
+ {
+ $this->set_text( $text );
+ $this->set_colour( $colour );
+ $this->set_size( $size );
+ $this->set_rotate( $rotate );
+ }
+
+ function set_text( $text )
+ {
+ $this->text = $text;
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ function set_size( $size )
+ {
+ $this->size = $size;
+ }
+
+ function set_rotate( $rotate )
+ {
+ $this->rotate = $rotate;
+ }
+
+ function set_vertical()
+ {
+ $this->rotate = "vertical";
+ }
+
+ function set_visible()
+ {
+ $this->visible = true;
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_x_axis_labels.php b/libs/open-flash-chart/php-ofc-library/ofc_x_axis_labels.php
new file mode 100644
index 0000000000..860dfd5f12
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_x_axis_labels.php
@@ -0,0 +1,46 @@
+<?php
+
+class x_axis_labels
+{
+ function x_axis_labels(){}
+
+ function set_steps( $steps )
+ {
+ $this->steps = $steps;
+ }
+
+ /**
+ *
+ * @param $labels as an array of [x_axis_label or string]
+ */
+ function set_labels( $labels )
+ {
+ $this->labels = $labels;
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ /**
+ * font size in pixels
+ */
+ function set_size( $size )
+ {
+ $this->size = $size;
+ }
+
+ /**
+ * rotate labels
+ */
+ function set_vertical()
+ {
+ $this->rotate = 270;
+ }
+
+ function rotate( $angle )
+ {
+ $this->rotate = $angle;
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_x_legend.php b/libs/open-flash-chart/php-ofc-library/ofc_x_legend.php
new file mode 100644
index 0000000000..7a25af0c28
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_x_legend.php
@@ -0,0 +1,15 @@
+<?php
+
+class x_legend
+{
+ function x_legend( $text='' )
+ {
+ $this->text = $text;
+ }
+
+ function set_style( $css )
+ {
+ $this->style = $css;
+ //"{font-size: 20px; color:#0000ff; font-family: Verdana; text-align: center;}";
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_y_axis.php b/libs/open-flash-chart/php-ofc-library/ofc_y_axis.php
new file mode 100644
index 0000000000..f8532e1573
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_y_axis.php
@@ -0,0 +1,16 @@
+<?php
+
+class y_axis extends y_axis_base
+{
+ function y_axis(){}
+
+ /**
+ * @param $colour as string. The grid are the lines inside the chart.
+ * HEX colour, e.g. '#ff0000'
+ */
+ function set_grid_colour( $colour )
+ {
+ $tmp = 'grid-colour';
+ $this->$tmp = $colour;
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_y_axis_base.php b/libs/open-flash-chart/php-ofc-library/ofc_y_axis_base.php
new file mode 100644
index 0000000000..33a2ce1d44
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_y_axis_base.php
@@ -0,0 +1,131 @@
+<?php
+
+class y_axis_labels
+{
+ function y_axis_labels()
+ {
+ }
+
+ function set_text($text)
+ {
+ $this->text = $text;
+ }
+}
+
+class y_axis_base
+{
+ function y_axis_base(){}
+
+ /**
+ * @param $s as integer, thickness of the Y axis line
+ */
+ function set_stroke( $s )
+ {
+ $this->stroke = $s;
+ }
+
+ /**
+ * @param $val as integer. The length of the ticks in pixels
+ */
+ function set_tick_length( $val )
+ {
+ $tmp = 'tick-length';
+ $this->$tmp = $val;
+ }
+
+ function set_colours( $colour, $grid_colour )
+ {
+ $this->set_colour( $colour );
+ $this->set_grid_colour( $grid_colour );
+ }
+
+ function set_colour( $colour )
+ {
+ $this->colour = $colour;
+ }
+
+ function set_grid_colour( $colour )
+ {
+ $tmp = 'grid-colour';
+ $this->$tmp = $colour;
+ }
+
+ /**
+ * Set min and max values, also (optionally) set the steps value.
+ * You can reverse the chart by setting min larger than max, e.g. min = 10
+ * and max = 0.
+ *
+ * @param $min as integer
+ * @param $max as integer
+ * @param $steps as integer.
+ */
+ function set_range( $min, $max, $steps=1 )
+ {
+ $this->min = $min;
+ $this->max = $max;
+ $this->set_steps( $steps );
+ }
+
+ /**
+ * Sugar for set_range
+ */
+ function range( $min, $max, $steps=1 )
+ {
+ $this->set_range( $min, $max, $steps );
+ return $this;
+ }
+
+ /**
+ * @param $off as Boolean. If true the Y axis is nudged up half a step.
+ */
+ function set_offset( $off )
+ {
+ $this->offset = $off?1:0;
+ }
+
+ /**
+ * @param $labels as an array of string values.
+ *
+ * By default the Y axis will show from min to max, but you can override this
+ * by passing in your own labels. Remember the Y axis min is at the bottom, so
+ * the labels will go from bottom to top.
+ */
+ function set_labels( $labels )
+ {
+ $this->labels = $labels;
+ }
+
+ /**
+ * Pass in some text for each label. This can contain magic variables "#val#" which
+ * will get replaced with the value for that Y axis label. Useful for:
+ * - "£#val#"
+ * - "#val#%"
+ * - "#val# million"
+ *
+ * @param $text as string.
+ */
+ function set_label_text( $text )
+ {
+ $tmp = new y_axis_labels();
+ $tmp->set_text( $text );
+ $this->labels = $tmp;
+ }
+
+ /**
+ * @param $steps as integer.
+ *
+ * Only show every $steps label, e.g. every 10th
+ */
+ function set_steps( $steps )
+ {
+ $this->steps = $steps;
+ }
+
+ /**
+ * Make the labels show vertical
+ */
+ function set_vertical()
+ {
+ $this->rotate = "vertical";
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_y_axis_right.php b/libs/open-flash-chart/php-ofc-library/ofc_y_axis_right.php
new file mode 100644
index 0000000000..71f7c29845
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_y_axis_right.php
@@ -0,0 +1,6 @@
+<?php
+
+class y_axis_right extends y_axis_base
+{
+ function y_axis_right(){}
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/ofc_y_legend.php b/libs/open-flash-chart/php-ofc-library/ofc_y_legend.php
new file mode 100644
index 0000000000..048d8b51e6
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/ofc_y_legend.php
@@ -0,0 +1,15 @@
+<?php
+
+class y_legend
+{
+ function y_legend( $text='' )
+ {
+ $this->text = $text;
+ }
+
+ function set_style( $css )
+ {
+ $this->style = $css;
+ //"{font-size: 20px; color:#0000ff; font-family: Verdana; text-align: center;}";
+ }
+} \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/open-flash-chart-object.php b/libs/open-flash-chart/php-ofc-library/open-flash-chart-object.php
new file mode 100644
index 0000000000..6e1129f46b
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/open-flash-chart-object.php
@@ -0,0 +1,109 @@
+<?php
+
+function open_flash_chart_object_str( $width, $height, $url, $use_swfobject=true, $base='' )
+{
+ //
+ // return the HTML as a string
+ //
+ return _ofc( $width, $height, $url, $use_swfobject, $base );
+}
+
+function open_flash_chart_object( $width, $height, $url, $use_swfobject=true, $base='' )
+{
+ //
+ // stream the HTML into the page
+ //
+ echo _ofc( $width, $height, $url, $use_swfobject, $base );
+}
+
+function _ofc( $width, $height, $url, $use_swfobject, $base )
+{
+ //
+ // I think we may use swfobject for all browsers,
+ // not JUST for IE...
+ //
+ //$ie = strstr(getenv('HTTP_USER_AGENT'), 'MSIE');
+
+ //
+ // escape the & and stuff:
+ //
+ $url = urlencode($url);
+
+ //
+ // output buffer
+ //
+ $out = array();
+
+ //
+ // check for http or https:
+ //
+ if (isset ($_SERVER['HTTPS']))
+ {
+ if (strtoupper ($_SERVER['HTTPS']) == 'ON')
+ {
+ $protocol = 'https';
+ }
+ else
+ {
+ $protocol = 'http';
+ }
+ }
+ else
+ {
+ $protocol = 'http';
+ }
+
+ //
+ // if there are more than one charts on the
+ // page, give each a different ID
+ //
+ global $open_flash_chart_seqno;
+ $obj_id = 'chart';
+ $div_name = 'flashcontent';
+
+ //$out[] = '<script type="text/javascript" src="'. $base .'js/ofc.js"></script>';
+
+ if( !isset( $open_flash_chart_seqno ) )
+ {
+ $open_flash_chart_seqno = 1;
+ $out[] = '<script type="text/javascript" src="'. $base .'js/swfobject.js"></script>';
+ }
+ else
+ {
+ $open_flash_chart_seqno++;
+ $obj_id .= '_'. $open_flash_chart_seqno;
+ $div_name .= '_'. $open_flash_chart_seqno;
+ }
+
+ if( $use_swfobject )
+ {
+ // Using library for auto-enabling Flash object on IE, disabled-Javascript proof
+ $out[] = '<div id="'. $div_name .'"></div>';
+ $out[] = '<script type="text/javascript">';
+ $out[] = 'var so = new SWFObject("'. $base .'open-flash-chart.swf", "'. $obj_id .'", "'. $width . '", "' . $height . '", "9", "#FFFFFF");';
+
+ $out[] = 'so.addVariable("data-file", "'. $url . '");';
+
+ $out[] = 'so.addParam("allowScriptAccess", "always" );//"sameDomain");';
+ $out[] = 'so.write("'. $div_name .'");';
+ $out[] = '</script>';
+ $out[] = '<noscript>';
+ }
+
+ $out[] = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="' . $protocol . '://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
+ $out[] = 'width="' . $width . '" height="' . $height . '" id="ie_'. $obj_id .'" align="middle">';
+ $out[] = '<param name="allowScriptAccess" value="sameDomain" />';
+ $out[] = '<param name="movie" value="'. $base .'open-flash-chart.swf?data='. $url .'" />';
+ $out[] = '<param name="quality" value="high" />';
+ $out[] = '<param name="bgcolor" value="#FFFFFF" />';
+ $out[] = '<embed src="'. $base .'open-flash-chart.swf?data=' . $url .'" quality="high" bgcolor="#FFFFFF" width="'. $width .'" height="'. $height .'" name="'. $obj_id .'" align="middle" allowScriptAccess="sameDomain" ';
+ $out[] = 'type="application/x-shockwave-flash" pluginspage="' . $protocol . '://www.macromedia.com/go/getflashplayer" id="'. $obj_id .'"/>';
+ $out[] = '</object>';
+
+ if ( $use_swfobject ) {
+ $out[] = '</noscript>';
+ }
+
+ return implode("\n",$out);
+}
+?> \ No newline at end of file
diff --git a/libs/open-flash-chart/php-ofc-library/open-flash-chart.php b/libs/open-flash-chart/php-ofc-library/open-flash-chart.php
new file mode 100644
index 0000000000..c3cab1a0b2
--- /dev/null
+++ b/libs/open-flash-chart/php-ofc-library/open-flash-chart.php
@@ -0,0 +1,174 @@
+<?php
+
+// var_dump(debug_backtrace());
+
+//
+// Omar Kilani's php C extension for encoding JSON has been incorporated in stock PHP since 5.2.0
+// http://www.aurore.net/projects/php-json/
+//
+// -- Marcus Engene
+//
+if (! function_exists('json_encode'))
+{
+ include_once 'JSON.php';
+}
+
+include_once 'json_format.php';
+
+// ofc classes
+include_once 'ofc_title.php';
+include_once 'ofc_y_axis_base.php';
+include_once 'ofc_y_axis.php';
+include_once 'ofc_y_axis_right.php';
+include_once 'ofc_x_axis.php';
+
+
+include_once 'ofc_pie.php';
+//include_once 'ofc_bar.php';
+include_once 'ofc_bar_glass.php';
+include_once 'ofc_bar_filled.php';
+include_once 'ofc_bar_stack.php';
+//include_once 'ofc_bar_3d.php';
+include_once 'ofc_hbar.php';
+include_once 'ofc_line_base.php';
+include_once 'ofc_line.php';
+//include_once 'ofc_line_dot.php';
+//include_once 'ofc_line_hollow.php';
+
+include_once 'ofc_area_base.php';
+//include_once 'ofc_area_hollow.php';
+//include_once 'ofc_area_line.php';
+
+include_once 'ofc_x_legend.php';
+include_once 'ofc_y_legend.php';
+include_once 'ofc_bar_sketch.php';
+include_once 'ofc_scatter.php';
+include_once 'ofc_scatter_line.php';
+include_once 'ofc_x_axis_labels.php';
+include_once 'ofc_x_axis_label.php';
+include_once 'ofc_tooltip.php';
+include_once 'ofc_shape.php';
+include_once 'ofc_radar_axis.php';
+include_once 'ofc_radar_axis_labels.php';
+include_once 'ofc_radar_spoke_labels.php';
+include_once 'ofc_line_style.php';
+
+include_once 'dot_base.php';
+include_once 'ofc_menu.php';
+
+class open_flash_chart
+{
+ function open_flash_chart()
+ {
+ //$this->title = new title( "Many data lines" );
+ $this->elements = array();
+ }
+
+ function set_title( $t )
+ {
+ $this->title = $t;
+ }
+
+ function set_x_axis( $x )
+ {
+ $this->x_axis = $x;
+ }
+
+ function set_y_axis( $y )
+ {
+ $this->y_axis = $y;
+ }
+
+ function add_y_axis( $y )
+ {
+ $this->y_axis = $y;
+ }
+
+ function set_y_axis_right( $y )
+ {
+ $this->y_axis_right = $y;
+ }
+
+ function add_element( $e )
+ {
+ $this->elements[] = $e;
+ }
+
+ function set_x_legend( $x )
+ {
+ $this->x_legend = $x;
+ }
+
+ function set_y_legend( $y )
+ {
+ $this->y_legend = $y;
+ }
+
+ function set_bg_colour( $colour )
+ {
+ $this->bg_colour = $colour;
+ }
+
+ function set_radar_axis( $radar )
+ {
+ $this->radar_axis = $radar;
+ }
+
+ function set_tooltip( $tooltip )
+ {
+ $this->tooltip = $tooltip;
+ }
+
+ /**
+ * This is a bit funky :(
+ *
+ * @param $num_decimals as integer. Truncate the decimals to $num_decimals, e.g. set it
+ * to 5 and 3.333333333 will display as 3.33333. 2.0 will display as 2 (or 2.00000 - see below)
+ * @param $is_fixed_num_decimals_forced as boolean. If true it will pad the decimals.
+ * @param $is_decimal_separator_comma as boolean
+ * @param $is_thousand_separator_disabled as boolean
+ *
+ * This needs a bit of love and attention
+ */
+ function set_number_format($num_decimals, $is_fixed_num_decimals_forced, $is_decimal_separator_comma, $is_thousand_separator_disabled )
+ {
+ $this->num_decimals = $num_decimals;
+ $this->is_fixed_num_decimals_forced = $is_fixed_num_decimals_forced;
+ $this->is_decimal_separator_comma = $is_decimal_separator_comma;
+ $this->is_thousand_separator_disabled = $is_thousand_separator_disabled;
+ }
+
+ /**
+ * This is experimental and will change as we make it work
+ *
+ * @param $m as ofc_menu
+ */
+ function set_menu($m)
+ {
+ $this->menu = $m;
+ }
+
+ function toString()
+ {
+ if (function_exists('json_encode'))
+ {
+ return json_encode($this);
+ }
+ else
+ {
+ $json = new Services_JSON();
+ return $json->encode( $this );
+ }
+ }
+
+ function toPrettyString()
+ {
+ return json_format( $this->toString() );
+ }
+}
+
+
+
+//
+// there is no PHP end tag so we don't mess the headers up!
+// \ No newline at end of file
diff --git a/misc/widget_example_lastvisits.html b/misc/widget_example_lastvisits.html
index 5adf21fdb2..403a3d4f88 100644
--- a/misc/widget_example_lastvisits.html
+++ b/misc/widget_example_lastvisits.html
@@ -1,5 +1,5 @@
<html><body>
<p>Number of visits per week for the last 52 weeks</p>
-<div id="widgetIframe"><iframe width="800" height="450" src="http://piwik.org/demo/index.php?module=Widgetize&action=iframe&moduleToWidgetize=VisitsSummary&actionToWidgetize=getLastVisitsGraph&idSite=1&period=week&date=last52&disableLink=1" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe></div>
+<div id="widgetIframe"><iframe width="800" height="450" src="http://piwik.org/demo/index.php?module=Widgetize&action=iframe&moduleToWidgetize=VisitsSummary&actionToWidgetize=getEvolutionGraph&idSite=1&period=week&date=last52&columns[]=nb_visits&disableLink=1" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe></div>
</body>
</html>
diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php
index 530e30eef9..e8963fe272 100644
--- a/plugins/Actions/Actions.php
+++ b/plugins/Actions/Actions.php
@@ -52,9 +52,9 @@ class Piwik_Actions extends Piwik_Plugin
function addWidgets()
{
- Piwik_AddWidget( 'Actions', 'getActions', Piwik_Translate('Actions_SubmenuPages'));
- Piwik_AddWidget( 'Actions', 'getDownloads', Piwik_Translate('Actions_SubmenuDownloads'));
- Piwik_AddWidget( 'Actions', 'getOutlinks', Piwik_Translate('Actions_SubmenuOutlinks'));
+ Piwik_AddWidget( 'Actions_Actions', 'Actions_SubmenuPages', 'Actions', 'getActions');
+ Piwik_AddWidget( 'Actions_Actions', 'Actions_SubmenuOutlinks', 'Actions', 'getOutlinks');
+ Piwik_AddWidget( 'Actions_Actions', 'Actions_SubmenuDownloads', 'Actions', 'getDownloads');
}
function addMenus()
diff --git a/plugins/CoreHome/templates/calendar.js b/plugins/CoreHome/templates/calendar.js
index db71c42fe8..774ba55ed2 100644
--- a/plugins/CoreHome/templates/calendar.js
+++ b/plugins/CoreHome/templates/calendar.js
@@ -147,26 +147,26 @@ $(document).ready(function(){
currentText: "",
customDate: isDateSelected,
dayNames: [
- _pk_translate('CoreHome_DaySu'),
- _pk_translate('CoreHome_DayMo'),
- _pk_translate('CoreHome_DayTu'),
- _pk_translate('CoreHome_DayWe'),
- _pk_translate('CoreHome_DayTh'),
- _pk_translate('CoreHome_DayFr'),
- _pk_translate('CoreHome_DaySa')],
+ _pk_translate('CoreHome_DaySu_js'),
+ _pk_translate('CoreHome_DayMo_js'),
+ _pk_translate('CoreHome_DayTu_js'),
+ _pk_translate('CoreHome_DayWe_js'),
+ _pk_translate('CoreHome_DayTh_js'),
+ _pk_translate('CoreHome_DayFr_js'),
+ _pk_translate('CoreHome_DaySa_js')],
monthNames: [
- _pk_translate('CoreHome_MonthJanuary'),
- _pk_translate('CoreHome_MonthFebruary'),
- _pk_translate('CoreHome_MonthMarch'),
- _pk_translate('CoreHome_MonthApril'),
- _pk_translate('CoreHome_MonthMay'),
- _pk_translate('CoreHome_MonthJune'),
- _pk_translate('CoreHome_MonthJuly'),
- _pk_translate('CoreHome_MonthAugust'),
- _pk_translate('CoreHome_MonthSeptember'),
- _pk_translate('CoreHome_MonthOctober'),
- _pk_translate('CoreHome_MonthNovember'),
- _pk_translate('CoreHome_MonthDecember')]
+ _pk_translate('CoreHome_MonthJanuary_js'),
+ _pk_translate('CoreHome_MonthFebruary_js'),
+ _pk_translate('CoreHome_MonthMarch_js'),
+ _pk_translate('CoreHome_MonthApril_js'),
+ _pk_translate('CoreHome_MonthMay_js'),
+ _pk_translate('CoreHome_MonthJune_js'),
+ _pk_translate('CoreHome_MonthJuly_js'),
+ _pk_translate('CoreHome_MonthAugust_js'),
+ _pk_translate('CoreHome_MonthSeptember_js'),
+ _pk_translate('CoreHome_MonthOctober_js'),
+ _pk_translate('CoreHome_MonthNovember_js'),
+ _pk_translate('CoreHome_MonthDecember_js')]
},
currentDate);
diff --git a/plugins/CoreHome/templates/datatable.css b/plugins/CoreHome/templates/datatable.css
index cb13c6553e..48fcf6824f 100644
--- a/plugins/CoreHome/templates/datatable.css
+++ b/plugins/CoreHome/templates/datatable.css
@@ -1,13 +1,13 @@
/*Overriding some dataTable css for better dashboard display*/
-.widgetDiv .dataTableWrapper,
-.widgetDiv .dataTableAllColumnsWrapper,
-.widgetDiv .dataTableGraphWrapper,
-.widgetDiv .dataTableActionsWrapper,
-.widgetDiv .dataTableGraphEvolutionWrapper {
+.widget .dataTableWrapper,
+.widget .dataTableAllColumnsWrapper,
+.widget .dataTableGraphWrapper,
+.widget .dataTableActionsWrapper,
+.widget .dataTableGraphEvolutionWrapper {
width: 100%;
}
-.widgetDiv {
+.widget {
z-index:1;
}
diff --git a/plugins/CoreHome/templates/datatable.js b/plugins/CoreHome/templates/datatable.js
index 7c83458dff..a14b49eb83 100644
--- a/plugins/CoreHome/templates/datatable.js
+++ b/plugins/CoreHome/templates/datatable.js
@@ -258,12 +258,12 @@ dataTable.prototype =
}
if(Number(self.param.enable_filter_excludelowpop) != 0)
{
- string = _pk_translate('CoreHome_IncludeAllPopulation');
+ string = _pk_translate('CoreHome_IncludeAllPopulation_js');
self.param.enable_filter_excludelowpop = 1;
}
else
{
- string = _pk_translate('CoreHome_ExcludeLowPopulation');
+ string = _pk_translate('CoreHome_ExcludeLowPopulation_js');
self.param.enable_filter_excludelowpop = 0;
}
$(this).html(string);
@@ -377,7 +377,7 @@ dataTable.prototype =
// only show this string if there is some rows in the datatable
if(totalRows != 0)
{
- var str = sprintf(_pk_translate('CoreHome_PageOf'),offset + '-' + offsetEndDisp,totalRows);
+ var str = sprintf(_pk_translate('CoreHome_PageOf_js'),offset + '-' + offsetEndDisp,totalRows);
$(this).text(str);
}
}
@@ -653,15 +653,15 @@ dataTable.prototype =
// at the end of the query it will replace the ID matching the new HTML table #ID
// we need to create this ID first
- $(this).after( '\
- <tr>\
- <td colspan="'+numberOfColumns+'" class="cellSubDataTable">\
- <div id="'+divIdToReplaceWithSubTable+'">\
- <span id="loadingDataTable" style="display:inline"><img src="'+piwik.piwik_url+'themes/default/images/loading-blue.gif" />'+ _pk_translate('CoreHome_Loading') +'</span>\
- </div>\
- </td>\
- </tr>\
- ');
+ $(this).after(
+ '<tr>'+
+ '<td colspan="'+numberOfColumns+'" class="cellSubDataTable">'+
+ '<div id="'+divIdToReplaceWithSubTable+'">'+
+ '<span id="loadingDataTable" style="display:inline"><img src="'+piwik.piwik_url+'themes/default/images/loading-blue.gif" />'+ _pk_translate('CoreHome_Loading_js') +'</span>'+
+ '</div>'+
+ '</td>'+
+ '</tr>'
+ );
var savedActionVariable = self.param.action;
diff --git a/plugins/CoreHome/templates/datatable_footer.tpl b/plugins/CoreHome/templates/datatable_footer.tpl
index 2e44ebbcf7..6c3f3a0d06 100644
--- a/plugins/CoreHome/templates/datatable_footer.tpl
+++ b/plugins/CoreHome/templates/datatable_footer.tpl
@@ -1,5 +1,4 @@
<div id="dataTableFeatures">
-
{if $properties.show_exclude_low_population}
<span id="dataTableExcludeLowPopulation"></span>
{/if}
diff --git a/plugins/CoreHome/templates/datatable_js.tpl b/plugins/CoreHome/templates/datatable_js.tpl
index acae875cf4..04aa61d391 100644
--- a/plugins/CoreHome/templates/datatable_js.tpl
+++ b/plugins/CoreHome/templates/datatable_js.tpl
@@ -5,7 +5,6 @@ $(document).ready(function(){literal}{{/literal}
dataTables['{$properties.uniqueId}'].param = {literal}{{/literal}
{foreach from=$javascriptVariablesToSet key=name item=value name=loop}
{$name}: '{$value}'{if !$smarty.foreach.loop.last},{/if}
-
{/foreach}
{literal}};{/literal}
dataTables['{$properties.uniqueId}'].init('{$properties.uniqueId}');
diff --git a/plugins/CoreHome/templates/header_message.tpl b/plugins/CoreHome/templates/header_message.tpl
index 577f2986d6..2a5f3a5ee6 100644
--- a/plugins/CoreHome/templates/header_message.tpl
+++ b/plugins/CoreHome/templates/header_message.tpl
@@ -1,10 +1,10 @@
<span id="header_message">
{if $piwikUrl == 'http://piwik.org/demo/'}
- {'General_YouAreCurrentlyViewingDemoOfPiwik'|translate:"<a target='_blank' href='http://piwik.org'>Piwik</a>":"<a href='http://piwik.org/'><u>":"</u></a>":"<a href='http://piwik.org'><u>piwik.org</u></a>"}
+ {'General_YouAreCurrentlyViewingDemoOfPiwik'|translate:"<a target='_blank' href='http://piwik.org'>Piwik</a>":"<a href='http://piwik.org/'>":"</a>":"<a href='http://piwik.org'>piwik.org</a>"}
{elseif $latest_version_available}
<img src='themes/default/images/warning_small.png' alt='' style="vertical-align: middle;">
{'General_PiwikXIsAvailablePleaseUpdateNow'|translate:$latest_version_available:"<br /><a href='index.php?module=CoreUpdater&action=newVersionAvailable'>":"</a>":"<a href='misc/redirectToUrl.php?url=http://piwik.org/changelog/' target='_blank'>":"</a>"}
{else}
- {'General_PiwikIsACollaborativeProjectYouCanContribute'|translate:"<a href='misc/redirectToUrl.php?url=http://piwik.org'>":"$piwik_version</a>":"<br />":"<a target='_blank' href='misc/redirectToUrl.php?url=http://piwik.org/contribute/'>":"</a></u>"}
+ {'General_PiwikIsACollaborativeProjectYouCanContribute'|translate:"<a href='misc/redirectToUrl.php?url=http://piwik.org'>":"$piwik_version</a>":"<br />":"<a target='_blank' href='misc/redirectToUrl.php?url=http://piwik.org/contribute/'>":"</a>"}
{/if}
</span>
diff --git a/plugins/CoreHome/templates/js_css_includes.tpl b/plugins/CoreHome/templates/js_css_includes.tpl
index 606ded1728..6755d2fe7a 100644
--- a/plugins/CoreHome/templates/js_css_includes.tpl
+++ b/plugins/CoreHome/templates/js_css_includes.tpl
@@ -1,5 +1,3 @@
-{* when adding a script here you may want to also add it for Iframe embedded widgets
- in plugins/Widgetize/templates/iframe.tpl *}
<script type="text/javascript" src="libs/jquery/jquery.js"></script>
<script type="text/javascript" src="themes/default/common.js"></script>
<script type="text/javascript" src="libs/jquery/jquery.dimensions.js"></script>
diff --git a/plugins/CoreHome/templates/piwik_tag.tpl b/plugins/CoreHome/templates/piwik_tag.tpl
index 7807ceb5bd..ef25de38d4 100644
--- a/plugins/CoreHome/templates/piwik_tag.tpl
+++ b/plugins/CoreHome/templates/piwik_tag.tpl
@@ -1,4 +1,5 @@
{if ereg('http://127.0.0.1|http://localhost|http://piwik.org', $url)}
+<div style="clear:both"></div>
{literal}
<!-- Piwik -->
<a href="http://piwik.org" title="Web analytics" onclick="window.open(this.href);return(false);">
diff --git a/plugins/CoreHome/templates/sparkline.js b/plugins/CoreHome/templates/sparkline.js
index 382f5bb2db..5753235977 100644
--- a/plugins/CoreHome/templates/sparkline.js
+++ b/plugins/CoreHome/templates/sparkline.js
@@ -1,58 +1,36 @@
-
$(document).ready( function(){
-
- //for every section
- $("a[name='evolutionGraph']").each(
- function()
- {
- //try to find the graph
- var graph = $(this);
-
- if(graph && graph.size() > 0)
- {
- //try to find sparklines and add them clickable behaviour
- $(this).parent().find('p').each(
- function()
- {
- var url = "";
- //find the sparkline and get it's src attribute
- $(".sparkline", this).each(
- function()
- {
- //search viewDataTable parameter and replace it with value for chart
- var reg = new RegExp("(viewDataTable=sparkline)", "g");
- url = this.src.replace(reg,'viewDataTable=generateDataChartEvolution');
- }
- );
-
- if(url != "")
- {
- $("*", this).each(
- function()
- {
- //on click, reload the graph with the new url
- $(this).click(
- function()
- {
- //get the main page graph and reload with new data
- findSWFGraph(graph.attr('graphId')+"Chart_swf").reload(url);
- lazyScrollTo(graph[0], 400);
- }
- );
-
- //on hover, change cursor to indicate clickable item
- $(this).hover(
- function()
- {
- $(this).css({ cursor: "pointer"});
- }, function (){}
- );
- }
- );
+ $("a[name='evolutionGraph']").each( function() {
+ var graph = $(this);
+ if(graph && graph.size() > 0) {
+ //try to find sparklines and add them clickable behaviour
+ $(this).parent().find('div.sparkline').each( function() {
+ var url = "";
+ //find the sparkline and get it's src attribute
+ $("img.sparkline", this).each(function() {
+ //search viewDataTable parameter and replace it with value for chart
+ var reg = new RegExp("(viewDataTable=sparkline)", "g");
+ url = this.src.replace(reg,'viewDataTable=generateDataChartEvolution');
+ });
+ if(url != ""){
+ //on click, reload the graph with the new url
+ $(this).click( function() {
+ //get the main page graph and reload with new data
+ findSWFGraph(graph.attr('graphId')+"Chart_swf").reload(url);
+ lazyScrollTo(graph[0], 400);
+ });
+ $(this).hover(
+ function() {
+ $(this).css({
+ "cursor": "pointer",
+ "border-bottom": "1px dashed #C3C3C3",
+ });
+ },
+ function(){
+ $(this).css({"border-bottom":"1px solid white"});
}
- }
- );
- }
+ );
+ }
+ });
}
- );
-});
+ });
+}); \ No newline at end of file
diff --git a/plugins/CoreHome/templates/styles.css b/plugins/CoreHome/templates/styles.css
index 1c86ed5d2a..d05e47494f 100644
--- a/plugins/CoreHome/templates/styles.css
+++ b/plugins/CoreHome/templates/styles.css
@@ -8,6 +8,7 @@ h2 {
font-size: 1.6em;
color: #1D3256;
padding-bottom: 0.5em;
+ clear:both;
}
h3 {
@@ -26,17 +27,23 @@ p {
margin-left: 10px;
}
+
/* 2 columns reports */
#leftcolumn {
float: left;
width: 50%;
padding-left: 10px;
}
-
#rightcolumn {
float: right;
width: 45%;
}
+/* not in widget */
+.widget #leftcolumn, .widget #rightcolumn {
+ float:left;
+ width:100%;
+ padding-left:10px;
+}
#calendar {
display: block;
@@ -78,8 +85,15 @@ p {
border-bottom: 1px solid #520202;
}
-.sparkline {
+div .sparkline {
+ float:left;
+ clear:both;
+ padding-bottom: 1px;
+ margin-top:10px;
+ border-bottom:1px solid white;
+}
+.sparkline img {
vertical-align: middle;
padding-right: 10px;
+ margin-top: 0;
}
-
diff --git a/plugins/Dashboard/Controller.php b/plugins/Dashboard/Controller.php
index cf6aa2c902..331f84437b 100644
--- a/plugins/Dashboard/Controller.php
+++ b/plugins/Dashboard/Controller.php
@@ -17,27 +17,23 @@ require_once "ViewDataTable.php";
*/
class Piwik_Dashboard_Controller extends Piwik_Controller
{
- function getListWidgets()
- {
- $widgets = Piwik_GetWidgetsList();
- $json = json_encode($widgets);
- return $json;
- }
-
public function embeddedIndex()
- {
+ {
$view = new Piwik_View('Dashboard/templates/index.tpl');
$this->setGeneralVariablesView($view);
- $view->layout = $this->getLayout();
- $view->availableWidgets = $this->getListWidgets();
+ $view->layout = html_entity_decode($this->getLayout());
+
+ $view->availableWidgets = json_encode(Piwik_GetWidgetsList());
echo $view->render();
}
+
public function index()
{
- //add the header for stand-alone mode
- $view = new Piwik_View('Dashboard/templates/header.tpl');
+ $view = new Piwik_View('Dashboard/templates/standalone.tpl');
+ $this->setGeneralVariablesView($view);
+ $view->layout = html_entity_decode($this->getLayout());
+ $view->availableWidgets = json_encode(Piwik_GetWidgetsList());
echo $view->render();
- $this->embeddedIndex();
}
/**
diff --git a/plugins/Dashboard/Dashboard.php b/plugins/Dashboard/Dashboard.php
index 95162bb30d..dea80e07de 100644
--- a/plugins/Dashboard/Dashboard.php
+++ b/plugins/Dashboard/Dashboard.php
@@ -34,6 +34,7 @@ class Piwik_Dashboard extends Piwik_Plugin
{
echo '
<script type="text/javascript" src="plugins/Dashboard/templates/widgetMenu.js"></script>
+<script type="text/javascript" src="libs/javascript/json2.js"></script>
<script type="text/javascript" src="plugins/Dashboard/templates/Dashboard.js"></script>
';
}
diff --git a/plugins/Dashboard/templates/Dashboard.js b/plugins/Dashboard/templates/Dashboard.js
index 7ca8f323da..de12a8fcc6 100644
--- a/plugins/Dashboard/templates/Dashboard.js
+++ b/plugins/Dashboard/templates/Dashboard.js
@@ -1,37 +1,10 @@
-function contains(array, searchElem) {
- for(var i=0; i<array.length; i++) {
- if (array[i]==searchElem) {
- return true;
- }
- }
- return false;
-}
-
-//Default configuration of the blockUI jquery plugin
-function blockUIConfig()
-{
- //set default style value for blockUI
- $.extend($.blockUI.defaults.overlayCSS, { backgroundColor: '#000000', opacity: '0.4'});
- //disable animation effect
- $.extend($.blockUI.defaults,{ fadeIn: 0, fadeOut: 0 });
- //unblock UI on 'escape' key pressed...
- $(window).keydown(
- function(e)
- {
- var key = e.keyCode || e.which;
- if(key == 27) //escape key ascii code
- $.unblockUI();
- }
- );
-}
-
function dashboard()
{
- this.dashArea = new Object;
- this.dashColumns = new Object;
+ this.dashboardElement = new Object;
+ this.dashboardColumnsElement = new Object;
this.layout = '';
}
-
+
dashboard.prototype =
{
//function called on dashboard initialisation
@@ -40,314 +13,221 @@ dashboard.prototype =
var self = this;
//save some often used DOM objects
- self.dashArea = $('#dashboardWidgetsArea');
- self.dashColumns = $('.col', self.dashDom);
+ self.dashboardElement = $('#dashboardWidgetsArea');
+ self.dashboardColumnsElement = $('.col', self.dashDom);
//dashboard layout
self.layout = layout;
//generate dashboard layout and load every displayed widgets
self.generateLayout();
-
- //setup widget dynamic behaviour
- self.setupWidgetSortable();
+
+ self.makeSortable();
},
- //return the DOM corresponding to the dashboard columns
- getColumns: function()
+ getWidgetsElementsInsideElement: function(elementToSearch)
{
- return this.dashColumns;
+ return $('.sortable:not(.dummyItem) .widget', elementToSearch);
},
- //'widgetize' every created widgets:
- //add an handle bar and apply 'sortable' drag&drop effect
- setupWidgetSortable: function()
- {
- var self = this;
-
- //add a dummy item on each columns
- self.dashColumns.each(
- function()
- {
- $(this).append('<div class="items dummyItem"><div class="handle dummyHandle"></div></div>');
- });
-
- self.hideUnnecessaryDummies();
-
- self.makeSortable();
- },
-
- //generate dashboard DOM corresponding to the initial layout
generateLayout: function()
{
var self = this;
- //dashboardLayout looks like :
- //'Actions.getActions~Actions.getDownloads|UserCountry.getCountry|Referers.getSearchEngines';
- //'|' separate columns
- //'~' separate widgets
- //'.' separate plugin name from action name
- var col = self.layout.split('|');
- for(var i=0; i<col.length; i++)
- {
- if(col[i] != '')
- {
- var widgets = col[i].split('~');
- for(var j=0; j<widgets.length; j++)
- {
- var wid = widgets[j].split('.');
- self.addWidgetAndLoad(i+1, wid[0], wid[1]);
+ if(typeof self.layout == 'string') {
+ var layout = new Object;
+ //Old dashboard layout format: a string that looks like 'Actions.getActions~Actions.getDownloads|UserCountry.getCountry|Referers.getSearchEngines';
+ // '|' separate columns
+ // '~' separate widgets
+ // '.' separate plugin name from action name
+ var columns = self.layout.split('|');
+ for(var columnNumber=0; columnNumber<columns.length; columnNumber++) {
+ if(columns[columnNumber].length == 0) {
+ continue;
+ }
+ var widgets = columns[columnNumber].split('~');
+ layout[columnNumber] = new Object;
+ for(var j=0; j<widgets.length; j++) {
+ wid = widgets[j].split('.');
+ uniqueId = 'widget'+wid[0]+wid[1];
+ layout[columnNumber][j] = {
+ "uniqueId": uniqueId,
+ "parameters": {
+ "module": wid[0],
+ "action": wid[1]
+ }
+ };
}
}
+ self.layout = layout;
}
- },
-
- //add a new widget to the dashboard
- //colnumber is the column in wich you want to add the widget
- //plugin/action is the widget to load
- //onTop: boolean specifying if the widget should be added on top of the column
- addEmptyWidget: function(colNumber, plugin, action, onTop)
- {
- var self = this;
-
- if((plugin === "") || (action === "")) return;
-
- if(typeof onTop == "undefined")
- onTop = false;
-
- var item = '<div class="items"><div class="widget"><div class="widgetLoading">'+ _pk_translate('Dashboard_LoadingWidget') +'</div><div plugin="'+plugin+'"'+' id="'+action+'" class="widgetDiv"></div></div></div>';
-
- if(onTop)
- {
- $(self.dashColumns[colNumber-1]).prepend(item);
- }
- else
- {
- $(self.dashColumns[colNumber-1]).append(item);
+ layout = self.layout;
+ for(var columnNumber in layout) {
+ var widgetsInColumn = layout[columnNumber];
+ for(var widgetId in widgetsInColumn) {
+ widgetParameters = widgetsInColumn[widgetId]["parameters"];
+ uniqueId = widgetsInColumn[widgetId]["uniqueId"];
+ if(uniqueId.length>0) {
+ self.addEmptyWidget(columnNumber, uniqueId, false);
+ }
+ }
+ self.addDummyWidgetAtBottomOfColumn(columnNumber);
}
-
- //find the title of the widget
- var title = self.getWidgetTitle(plugin, action);
-
- //add an handle to each items
- var widget = $('.widgetDiv#'+action+'[plugin='+plugin+']', self.dashColumns[colNumber-1]).parents('.widget');
- self.addHandleToWidget(widget, title);
-
- var button = $('.button#close', widget);
+
+ self.makeSortable();
- //Only show handle buttons on mouse hover
- $(widget).hover(
- function()
- {
- $(this).addClass('widgetHover');
- $('.handle',this).addClass('handleHover');
- button.show();
- },
- function()
+ // load all widgets
+ $('.widget', self.dashboardElement).each( function() {
+ var uniqueId = $(this).attr('id');
+ function onWidgetLoadedReplaceElementWithContent(loadedContent)
{
- $(this).removeClass('widgetHover');
- $('.handle',this).removeClass('handleHover');
- button.hide();
+ $('#'+uniqueId+'>.widgetContent', self.dashboardElement).html(loadedContent);
}
- );
-
- //Bind click event on close button
- button.click(function(ev){self.onDeleteItem(this, ev);});
-
- self.makeSortable();
- },
-
- //return widget title designated by its plugin/action couple
- getWidgetTitle: function(plugin, action)
- {
- var self = this;
-
- var title = _pk_translate('Dashboard_WidgetNotFound');
- var widgets = piwik.availableWidgets[plugin];
- for(var i in widgets)
- {
- if(action == widgets[i][1])
- title = widgets[i][0];
- }
- return title;
+ widget = widgetsHelper.getWidgetObjectFromUniqueId(uniqueId);
+ widgetParameters = widget["parameters"];
+ $.ajax(widgetsHelper.getLoadWidgetAjaxRequest(uniqueId, widgetParameters, onWidgetLoadedReplaceElementWithContent));
+ });
},
- //add the widget and load it
- addWidgetAndLoad: function(colNumber, plugin, action, onTop)
+ addDummyWidgetAtBottomOfColumn: function(columnNumber)
{
var self = this;
-
- self.addEmptyWidget(colNumber, plugin, action, onTop);
- self.loadItem($('.items [plugin='+plugin+']#'+action, self.dashArea).parents('.items'));
+ var columnElement = $(self.dashboardColumnsElement[columnNumber]);
+ $(columnElement).append(
+ '<div class="sortable dummyItem">'+
+ '<div class="widgetTop dummyWidgetTop"></div>'+
+ '</div>');
},
- //add an handle bar to a given widget with a particular title
- addHandleToWidget: function(widget, title)
+ addEmptyWidget: function(columnNumber, uniqueId, addWidgetOnTop)
{
- widget.prepend('<div class="handle">\
- <div class="button" id="close">\
- <img src="themes/default/images/close.png" />\
- </div>\
- <div class="widgetTitle">'+title+'</div>\
- </div>');
- },
-
- //auxiliary function calling ajax loading procedure for a given DOM element
- loadItem: function(domElem)
- {
var self = this;
- //load every widgetDiv with asynchronous ajax
- $('.widgetDiv', domElem).each(
- function()
- {
- // get the ID of the div and load with ajax
- loadWidgetInDiv($(this).attr('plugin'), $(this).attr('id'));
+ widgetName = widgetsHelper.getWidgetNameFromUniqueId(uniqueId);
+ if(widgetName == false) {
+ widgetName = _pk_translate('Dashboard_WidgetNotFound_js');
+ }
+ columnElement = $(self.dashboardColumnsElement[columnNumber]);
+ emptyWidgetContent = '<div class="sortable">'+
+ widgetsHelper.getEmptyWidgetHtml(uniqueId, widgetName, _pk_translate('Dashboard_LoadingWidget_js'))+
+ '</div>';
+ if(addWidgetOnTop) {
+ columnElement.prepend(emptyWidgetContent);
+ } else {
+ columnElement.append(emptyWidgetContent);
+ }
+ widgetElement = $('#'+ uniqueId);
+ widgetElement
+ .hover( function() {
+ $(this).addClass('widgetHover');
+ $('.widgetTop', this).addClass('widgetTopHover');
+ $('.button#close', this).show();
+ }, function() {
+ $(this).removeClass('widgetHover');
+ $('.widgetTop', this).removeClass('widgetTopHover');
+ $('.button#close', this).hide();
+ });
+ $('.button#close', widgetElement)
+ .click( function(ev){
+ self.onDeleteItem(this, ev);
});
+
+ widgetElement.show();
+ return widgetElement;
},
//apply jquery sortable plugin to the dashboard layout
makeSortable: function()
{
var self = this;
-
- function getHelper()
- {
+ function getHelper() {
return $(this).clone().addClass('helper');
}
-
- function onStart()
- {
- self.showDummies();
+ function onStart() {
}
-
- function onStop()
- {
- self.hideUnnecessaryDummies();
- self.saveLayout();
-
+ function onStop() {
$('.widgetHover', this).removeClass('widgetHover');
- $('.handleHover', this).removeClass('handleHover');
+ $('.widgetTopHover', this).removeClass('widgetTopHover');
$('.button#close', this).hide();
+ self.saveLayout();
}
-
//launch 'sortable' property on every dashboard widgets
- self.dashArea.sortableDestroy()
- .sortable({
- items:'.items',
- hoverClass: 'hover',
- handle: '.handle',
- helper: getHelper,
- start: onStart,
- stop: onStop
- });
+ self.dashboardElement
+ .sortableDestroy()
+ .sortable({
+ items:'.sortable',
+ hoverClass: 'hover',
+ handle: '.widgetTop',
+ helper: getHelper,
+ start: onStart,
+ stop: onStop
+ });
},
- //on mouse click on close widget button
- //we ask for confirmation and we delete the widget from the dashboard
+ // on mouse click on close widget button
+ // we ask for confirmation and if 'yes' is clicked, we delete the widget from the dashboard
onDeleteItem: function(target, ev)
{
var self = this;
- //ask confirmation and delete item
var question = $('.dialog#confirm');
- $('#yes', question).click(function()
- {
- var item = $(target).parents('.items');
- var plugin = $('.widgetDiv', item).attr('plugin');
- var action = $('.widgetDiv', item).attr('id');
-
- //hide confirmation dialog
+ $('#no', question).click($.unblockUI);
+ $('#yes', question).click(function() {
+ var item = $(target).parents('.sortable');
$.unblockUI();
-
- //the item disapear slowly and is removed from the DOM
- item.fadeOut(200, function()
- {
- $(this).remove();
- self.showDummies();
- self.saveLayout();
- self.makeSortable();
- });
-
- //show menu item
- $('.menu#widgetChooser .menuItem[pluginToLoad='+plugin+'][actionToLoad='+action+']').show();
+ item.fadeOut(200, function() {
+ $(this).remove();
+ self.saveLayout();
+ self.makeSortable();
+ });
});
- $('#no', question).click($.unblockUI);
- $.blockUI({message: question, css: { width: '300px', border:'1px solid black' }});
- },
-
- //dummies are invisible item that help for widget positionning
- //and keep the column visible even when there aren't widget anymore in it
- showDummies: function()
- {
- var self = this;
- $('.dummyItem').css('display', 'block');
- },
-
- //see showDummies
- //hide dummies that are not needed for column consistency
- hideUnnecessaryDummies: function()
- {
- var self = this;
- $('.dummyItem').each(function(){
- $(this).appendTo($(this).parent());
- if($(this).siblings().size() > 0)
- $(this).css('display', 'none');
+ $.blockUI({
+ message: question,
+ css: { width: '300px', border:'1px solid black' }
});
},
- //save the layout in the database/cookie so the user can
- //retrieve it the next time he load the dashboard
saveLayout: function()
{
var self = this;
- var column = new Array;
- //parse the dom to see how our div are organized
- //build a list of widget sorted by columns
- self.dashColumns.each(function() {
- column.push(getWidgetInDom(this));
+ // build the layout object to save
+ var layout = new Array;
+ var columnNumber = 0;
+ self.dashboardColumnsElement.each(function() {
+ layout[columnNumber] = new Array;
+ var items = self.getWidgetsElementsInsideElement(this);
+ for(var j=0; j<items.size(); j++) {
+ widgetElement = items[j];
+ uniqueId = $(widgetElement).attr('id');
+ widget = widgetsHelper.getWidgetObjectFromUniqueId(uniqueId);
+ widgetParameters = widget["parameters"];
+ layout[columnNumber][j] =
+ {
+ "uniqueId": uniqueId,
+ "parameters": widgetParameters
+ };
+ }
+ columnNumber++;
});
- var ajaxRequest =
- {
- type: 'GET',
- url: 'index.php',
- dataType: 'html',
- async: true,
- error: ajaxHandleError, // Callback when the request fails
- data: { module: 'Dashboard',
- action: 'saveLayout' }
- };
-
- //write layout in a string
- //using '|' as column separator
- // and '~' as widget separator
- var layout = '';
- for(var i=0; i<column.length; i++)
- {
- layout += column[i].join('~');
- layout += '|';
- }
-
//only save layout if it has changed
- if(layout != self.layout)
- {
+ layoutString = JSON.stringify(layout);
+ if(layoutString != JSON.stringify(self.layout)) {
self.layout = layout;
- ajaxRequest.data['layout'] = layout;
+ var ajaxRequest =
+ {
+ type: 'GET',
+ url: 'index.php',
+ dataType: 'html',
+ async: true,
+ error: ajaxHandleError,
+ data: { "module": "Dashboard",
+ "action": "saveLayout",
+ "layout": layoutString
+ }
+ };
$.ajax(ajaxRequest);
}
}
};
-
-//auxiliary function: list widgets available in a DOM tree
-function getWidgetInDom(domElem)
-{
- var items = $('.items:not(.dummyItem) .widgetDiv', domElem);
- var widgets = new Array;
- for(var i=0; i<items.size(); i++)
- {
- widgets.push($(items[i]).attr('plugin')+'.'+$(items[i]).attr('id'));
- }
- return widgets;
-}
diff --git a/plugins/Dashboard/templates/dashboard.css b/plugins/Dashboard/templates/dashboard.css
index a13cd6867f..6717152409 100644
--- a/plugins/Dashboard/templates/dashboard.css
+++ b/plugins/Dashboard/templates/dashboard.css
@@ -1,14 +1,9 @@
-.widgetDiv {
- display: none;
-}
-
-/*--- end of dataTable.css modif*/
.col {
float: left;
width: 33%;
}
-.items {
+.sortable {
background: white;
}
@@ -29,7 +24,7 @@
border: 1px solid #CBD3E7;
}
-.handle {
+.widgetTop {
background: #F0F0FA;
border-bottom: 1px solid #D2D9EB;
width: 100%;
@@ -39,19 +34,20 @@
padding-bottom: 4px;
}
-.handleHover {
+.widgetTopHover {
background: #E6E6F5;
}
-.widgetTitle {
+.widgetName {
font-size: 14pt;
margin-left: 25px;
}
.dummyItem {
width: 100%;
- height: 200px;
+ height: 150px;
display: block;
+ visibility:hidden;
}
.button {
@@ -170,10 +166,6 @@ ul#widgetList {
font-weight: bold;
}
-.previewDiv {
- height: auto;
-}
-
.widget input {
background: #F7F7FF none repeat scroll 0% 50%;
border: 1px solid #B3B3B3;
@@ -185,3 +177,6 @@ ul#widgetList {
#widgetChooser {
z-index:100;
}
+#widgetChooser .widgetTop {
+ cursor:pointer;
+} \ No newline at end of file
diff --git a/plugins/Dashboard/templates/header.tpl b/plugins/Dashboard/templates/header.tpl
index 342f53a807..724608a17c 100644
--- a/plugins/Dashboard/templates/header.tpl
+++ b/plugins/Dashboard/templates/header.tpl
@@ -1,23 +1,11 @@
{* This header is for loading the dashboard in stand alone mode*}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html>
-<body>
+<head>
{loadJavascriptTranslations plugins='CoreHome Dashboard'}
-
-<script type="text/javascript" src="libs/jquery/jquery.js"></script>
-
-<script type="text/javascript" src="themes/default/common.js"></script>
-<script type="text/javascript" src="libs/jquery/jquery.dimensions.js"></script>
-<script type="text/javascript" src="libs/jquery/tooltip/jquery.tooltip.js"></script>
-<script type="text/javascript" src="libs/jquery/truncate/jquery.truncate.js"></script>
-<script type="text/javascript" src="libs/jquery/jquery.scrollTo.js"></script>
-<script type="text/javascript" src="libs/swfobject/swfobject.js"></script>
-
-<script type="text/javascript" src="plugins/CoreHome/templates/datatable.js"></script>
-
-<script type="text/javascript" src="libs/jquery/jquery.blockUI.js"></script>
-<script type="text/javascript" src="libs/jquery/ui.mouse.js"></script>
-<script type="text/javascript" src="libs/jquery/ui.sortable_modif.js"></script>
-
+{include file="CoreHome/templates/js_css_includes.tpl"}
+{include file="CoreHome/templates/js_global_variables.tpl"}
<link rel="stylesheet" href="plugins/CoreHome/templates/datatable.css">
<link rel="stylesheet" href="plugins/Dashboard/templates/dashboard.css">
+</head>
+<body> \ No newline at end of file
diff --git a/plugins/Dashboard/templates/index.tpl b/plugins/Dashboard/templates/index.tpl
index a093795270..0b2f8d044a 100644
--- a/plugins/Dashboard/templates/index.tpl
+++ b/plugins/Dashboard/templates/index.tpl
@@ -1,25 +1,47 @@
{loadJavascriptTranslations plugins='CoreHome Dashboard'}
<script type="text/javascript">
- {if !empty($layout) }
- piwik.dashboardLayout = '{$layout}';
- {else}
- // Load default layout...
- piwik.dashboardLayout = 'VisitsSummary.getLastVisitsGraph~VisitorInterest.getNumberOfVisitsPerVisitDuration~UserSettings.getBrowser~ExampleFeedburner.feedburner|Referers.getKeywords~Referers.getWebsites|Referers.getSearchEngines~VisitTime.getVisitInformationPerServerTime~ExampleRssWidget.rssPiwik|';
- {/if}
-
- piwik.availableWidgets = {$availableWidgets};
+{if !empty($layout) }
+ piwik.dashboardLayout = {$layout};
+{else}
+{literal}
+ piwik.dashboardLayout =
+ [
+ [
+ {"uniqueId":"widgetVisitsSummarygetEvolutionGraph","parameters":{"module":"VisitsSummary","action":"getEvolutionGraph","columns":["nb_visits"]}},
+ {"uniqueId":"widgetVisitorInterestgetNumberOfVisitsPerVisitDuration","parameters":{"module":"VisitorInterest","action":"getNumberOfVisitsPerVisitDuration"}},
+ {"uniqueId":"widgetUserSettingsgetBrowser","parameters":{"module":"UserSettings","action":"getBrowser"}},
+ {"uniqueId":"widgetUserCountrygetCountry","parameters":{"module":"UserCountry","action":"getCountry"}},
+ {"uniqueId":"widgetExampleFeedburnerfeedburner","parameters":{"module":"ExampleFeedburner","action":"feedburner"}}
+ ],
+ [
+ {"uniqueId":"widgetReferersgetKeywords","parameters":{"module":"Referers","action":"getKeywords"}},
+ {"uniqueId":"widgetReferersgetWebsites","parameters":{"module":"Referers","action":"getWebsites"}}
+ ],
+ [
+ {"uniqueId":"widgetReferersgetSearchEngines","parameters":{"module":"Referers","action":"getSearchEngines"}},
+ {"uniqueId":"widgetVisitTimegetVisitInformationPerServerTime","parameters":{"module":"VisitTime","action":"getVisitInformationPerServerTime"}},
+ {"uniqueId":"widgetExampleRssWidgetrssPiwik","parameters":{"module":"ExampleRssWidget","action":"rssPiwik"}}
+ ]
+ ];
+{/literal}
+
+ {*
+ the old dashboard layout style is:
+ piwik.dashboardLayout = 'VisitsSummary.getEvolutionGraph~VisitorInterest.getNumberOfVisitsPerVisitDuration~UserSettings.getBrowser~ExampleFeedburner.feedburner|Referers.getKeywords~Referers.getWebsites|Referers.getSearchEngines~VisitTime.getVisitInformationPerServerTime~ExampleRssWidget.rssPiwik|';
+ *}
+{/if}
+piwik.availableWidgets = {$availableWidgets};
</script>
{literal}
<script type="text/javascript">
$(document).ready( function() {
- var dash = new dashboard();
- var menu = new widgetMenu(dash);
- blockUIConfig();
- dash.init(piwik.dashboardLayout);
- menu.init();
- $('.button#addWidget').click(function(){menu.show();});
+ var dashboardObject = new dashboard();
+ var widgetMenuObject = new widgetMenu(dashboardObject);
+ dashboardObject.init(piwik.dashboardLayout);
+ widgetMenuObject.init();
+ $('.button#addWidget').click(function(){widgetMenuObject.show();});
});
</script>
{/literal}
@@ -39,35 +61,16 @@ $(document).ready( function() {
<div class="menu" id="widgetChooser">
<div id="closeMenuIcon"><img src="themes/default/images/close_medium.png" title="{'General_Close'|translate}"/></div>
<div id="menuTitleBar">{'Dashboard_SelectWidget'|translate}</div>
- <div class="subMenu" id="sub1">
- </div>
-
- <div class="subMenu" id="sub2">
- </div>
-
- <div class="subMenu" id="sub3">
- <div class="widget">
- <div class="handle" title="{'Dashboard_AddPreviewedWidget'|translate}">
- <div class="button" id="close">
- <img src="themes/default/images/close.png" title="{'General_Close'|translate}"/>
- </div>
- <div class="widgetTitle">{'Dashboard_WidgetPreview'|translate}</div>
- </div>
- <div class="widgetDiv previewDiv" ></div>
- </div>
- </div>
-
+
+ <div class="subMenu" id="sub1"></div>
+ <div class="subMenu" id="sub2"></div>
+ <div class="subMenu" id="sub3"></div>
<div class="menuClear"> </div>
</div>
<div id="dashboardWidgetsArea">
- <div class="col" id="1">
- </div>
-
- <div class="col" id="2">
- </div>
-
- <div class="col" id="3">
- </div>
+ <div class="col" id="1"></div>
+ <div class="col" id="2"></div>
+ <div class="col" id="3"></div>
</div>
</div>
diff --git a/plugins/Dashboard/templates/standalone.tpl b/plugins/Dashboard/templates/standalone.tpl
new file mode 100644
index 0000000000..784ca3c7d5
--- /dev/null
+++ b/plugins/Dashboard/templates/standalone.tpl
@@ -0,0 +1,5 @@
+
+{include file="Dashboard/templates/header.tpl"}
+{include file="Dashboard/templates/index.tpl"}
+</body>
+</html> \ No newline at end of file
diff --git a/plugins/Dashboard/templates/widgetMenu.js b/plugins/Dashboard/templates/widgetMenu.js
index 620a27673a..701056be78 100644
--- a/plugins/Dashboard/templates/widgetMenu.js
+++ b/plugins/Dashboard/templates/widgetMenu.js
@@ -1,17 +1,91 @@
-//widgetMenu constructor
-function widgetMenu(dash)
+function widgetsHelper()
+{
+}
+
+widgetsHelper.getWidgetCategoryNameFromUniqueId = function (uniqueId)
+{
+ var widgets = piwik.availableWidgets;
+ for(var widgetCategory in widgets) {
+ var widgetInCategory = widgets[widgetCategory];
+ for(var i in widgetInCategory) {
+ if(widgetInCategory[i]["uniqueId"] == uniqueId) {
+ return widgetCategory;
+ }
+ }
+ }
+ return false;
+};
+
+widgetsHelper.getWidgetObjectFromUniqueId = function (uniqueId)
+{
+ var widgets = piwik.availableWidgets;
+ for(var widgetCategory in widgets) {
+ var widgetInCategory = widgets[widgetCategory];
+ for(var i in widgetInCategory) {
+ if(widgetInCategory[i]["uniqueId"] == uniqueId) {
+ return widgetInCategory[i];
+ }
+ }
+ }
+ return false;
+};
+
+widgetsHelper.getWidgetNameFromUniqueId = function (uniqueId)
+{
+ widget = this.getWidgetObjectFromUniqueId(uniqueId);
+ if(widget == false) {
+ return false;
+ }
+ return widget["name"];
+};
+
+widgetsHelper.getLoadWidgetAjaxRequest = function (widgetUniqueId, widgetParameters, onWidgetLoadedCallback)
+{
+ var ajaxRequest =
+ {
+ widgetUniqueId:widgetUniqueId,
+ type: 'GET',
+ url: 'index.php',
+ dataType: 'html',
+ async: true,
+ error: ajaxHandleError,
+ success: onWidgetLoadedCallback,
+ data: piwikHelper.getQueryStringFromParameters(widgetParameters) + "&idSite="+piwik.idSite+"&period="+piwik.period+"&date="+piwik.currentDateString
+ };
+ return ajaxRequest;
+};
+
+widgetsHelper.getEmptyWidgetHtml = function (uniqueId, widgetName, widgetLoadingString)
+{
+ return '<div id="'+uniqueId+'" class="widget">'+
+ '<div class="widgetTop">'+
+ '<div class="button" id="close">'+
+ '<img src="themes/default/images/close.png" title="'+_pk_translate('Dashboard_Close_js')+'" />'+
+ '</div>'+
+ '<div class="widgetName">'+widgetName+'</div>'+
+ '</div>'+
+ '<div class="widgetContent">'+
+ '<div class="widgetLoading">'+
+ widgetLoadingString +
+ '</div>'+
+ '</div>'+
+ '</div>';
+};
+
+// widgetMenu constructor
+function widgetMenu(dashboard)
{
this.menu = new Object;
- this.dashboard = dash;
+ this.dashboard = dashboard;
}
-//Prototype of the widgetMenu object
+// widgetMenu object
widgetMenu.prototype =
{
- //function called when the menu is built for the first time
init: function()
{
var self = this;
+ self.menuElement = $('#widgetChooser');
self.buildMenu();
},
@@ -20,189 +94,181 @@ widgetMenu.prototype =
this.onWidgetLoad = callbackOnWidgetLoad;
},
- registerCallbackOnMainMenuHover: function( callbackOnMainMenuHover )
- {
- this.onMainMenuHover = callbackOnMainMenuHover;
- },
-
- registerCallbackOnSubMenuHover: function( callbackOnSubMenuHover )
+ registerCallbackOnMenuHover: function( callbackOnMenuHover )
{
- this.onSubMenuHover = callbackOnSubMenuHover;
- },
-
- //function called when a clone of an existing menu is built
- initBuilt: function(menuDom)
- {
- var self = this;
- self.menu = menuDom;
- self.bindEvents();
+ this.onMenuHover = callbackOnMenuHover;
},
//create DOM elements of the menu
buildMenu: function()
{
var self = this;
+ var menuWidgetCategories = $('.subMenu#sub1', self.menuElement);
+ var menuWidgetNames = $('.subMenu#sub2', self.menuElement);
- //load menu widgets list
- self.menu = $('#widgetChooser');
- var subMenu1 = $('.subMenu#sub1', self.menu);
- var subMenu2 = $('.subMenu#sub2', self.menu);
-
- subMenu1.append('<ol id="menuList"></ol>');
- subMenu2.append('<ul id="widgetList"></ul>');
- var lineHeight = $('ol', subMenu1).css('line-height');
+ menuWidgetCategories.append('<ol id="menuList"></ol>');
+ menuWidgetNames.append('<ul id="widgetList"></ul>');
+ var lineHeight = $('ol', menuWidgetCategories).css('line-height');
lineHeight = Number(lineHeight.substring(0, lineHeight.length-2));
- var count=0;
- for(var plugin in piwik.availableWidgets)
- {
- var widgets = piwik.availableWidgets[plugin];
-
- for(var i in widgets)
- {
- var exist = $('.subMenuItem#'+plugin, subMenu1);
- if(exist.size()==0)
- {
- $('ol', subMenu1).append('<li class="subMenuItem" id="'+plugin+'"><span>'+plugin+'</span></li>');
- $('ul', subMenu2).append('<li class="subMenuItem" id="'+plugin+'"></li>');
+ var i=0;
+ for(var widgetCategory in piwik.availableWidgets) {
+ var widgets = piwik.availableWidgets[widgetCategory];
+ for(var j in widgets) {
+ widgetName = widgets[j]["name"];
+ widgetUniqueId = widgets[j]["uniqueId"];
+ widgetParameters = widgets[j]["parameters"];
+ widgetCategoryId = 'category'+i;
+ exist = $('.subMenuItem#'+widgetCategoryId, menuWidgetCategories);
+ if(exist.size() == 0) {
+ $('ol', menuWidgetCategories)
+ .append('<li class="subMenuItem" id="'+widgetCategoryId+'">'+
+ '<span>'+widgetCategory+'</span>'+
+ '</li>');
+ $('ul', menuWidgetNames)
+ .append('<li class="subMenuItem" id="'+widgetCategoryId+'"></li>');
}
-
- var sm2Div = $('.subMenuItem#'+plugin, subMenu2);
- sm2Div.append('<div class="button menuItem" pluginToLoad="'+plugin+'" actionToLoad="'+widgets[i][1]+'">'+widgets[i][0] + '</div>');
- sm2Div.css('padding-top', count*lineHeight+'px');
+ // we prepend the ID with "ID" to not conflict with the <div>
+ // that contains the widget preview and that has the widgetUniqueId already
+ $('.subMenuItem#'+widgetCategoryId, menuWidgetNames)
+ .append('<div class="button menuWidgetName" id="'+ 'ID' + widgetUniqueId +'">'+
+ widgetName +
+ '</div>')
+ .css('padding-top', i*lineHeight+'px');
}
- count++;
+ i++;
}
-
- $('.subMenuItem', subMenu2).hide();
+ $('.subMenuItem', menuWidgetNames).hide();
+ },
+
+ resetMenuState: function ()
+ {
+ $('.menuSelected', self.menuElement).removeClass('menuSelected');
+ $('#sub2 .subMenuItem', self.menuElement).hide();
+ $('#sub3').empty().html('<div class="widget"></div>');
},
- //bind events (click/hover/...) of the menu to appropriate callback
bindEvents: function()
{
var self = this;
+ if(typeof self.menuInitialized != 'undefined') {
+ return;
+ }
+ self.menuInitialized = true;
- //menu buttons
- $('.button#hideMenu', self.menu).click(function(){self.hide();});
- $('#closeMenuIcon', self.menu).click(function(){self.hide();});
- $('.subMenu#sub3 .widget .handle', self.menu)
- .css('cursor', 'pointer')
- .click(function(){self.movePreviewToDashboard();});
-
- //update widget list on submenu#1 mouse over
- $('.subMenu#sub1 .subMenuItem', self.menu).each(function(){
- var plugin = $(this).attr('id');
- var item = $('.subMenu#sub2 .subMenuItem#' + plugin, self.menu);
-
- $(this).hover(
- function()
- {
- if(typeof self.onMainMenuHover != 'undefined')
- {
- self.onMainMenuHover();
- }
- $('#embedThisWidget').empty();
- $('.widgetDiv.previewDiv', self.menu).empty()
- .attr('plugin', '')
- .attr('id', '');
- $('.menuItem', self.menu).removeClass('menuSelected');
- $('.subMenu#sub1 .subMenuItem', self.menu).removeClass('menuSelected');
- $('.subMenu#sub2 .subMenuItem', self.menu).hide();
- $(this).addClass('menuSelected');
- item.show();
- },function(){});
- });
+ // Main menu (widget categories)
+ $('.subMenu#sub1 .subMenuItem', self.menuElement)
+ .hover(function() {
+ self.resetMenuState();
+ categoryIdHovered = $(this).attr('id');
+ $('#sub2 #'+categoryIdHovered, self.menuElement).show();
+ $(this).addClass('menuSelected');
+ }, function() {}
+ );
- //update widget preview on submenu#2 mouse over
- $('.menuItem', self.menu)
- .click( function() { if(!$(this).hasClass('menuDisabled')) self.movePreviewToDashboard(); })
- .hover( function()
- {
- if($(this).hasClass('menuDisabled'))
- {
- return;
- }
- var plugin = $(this).attr('pluginToLoad');
- var action = $(this).attr('actionToLoad');
- var widgetName = $(this).text();
-
- if(typeof self.onSubMenuHover != 'undefined')
- {
- self.onSubMenuHover(plugin, action, widgetName);
- }
-
- $('.subMenu#sub2 .menuSelected').removeClass('menuSelected');
- $(this).addClass('menuSelected');
-
- $('.widgetDiv.previewDiv', self.menu).each(function(){
- //only reload preview if necessary
- if($(this).attr('plugin')!=plugin || $(this).attr('id')!=action)
- {
- //format the div for upcomming ajax loading and set a temporary content
- $(this) .attr('plugin', plugin)
- .attr('id', action)
- .html('<div id="loadingPiwik"><img src="themes/default/images/loading-blue.gif" /> '+ _pk_translate('Dashboard_LoadingPreview') +'</div>').show();
- $('#embedThisWidget').empty();
- loadWidgetInDiv(plugin, action, self.onWidgetLoad);
+ // Sub menu (each widget in the middle column)
+ $('.menuWidgetName', self.menuElement)
+ .hover( function() {
+ if($(this).hasClass('menuDisabled')) {
+ return;
}
- });
- },function(){});
- },
-
- hide: function()
- {
- //simply disable modal dialog box
- $.unblockUI();
+ // the ID is prefixed with "ID"
+ widgetUniqueId = $(this).attr('id').substr(2);
+
+ // only reload preview if necessary
+ if($('#sub3 .widget').attr('id') == widgetUniqueId) {
+ return;
+ }
+ self.expectedWidgetUniqueId = widgetUniqueId;
+
+ widget = widgetsHelper.getWidgetObjectFromUniqueId(widgetUniqueId);
+ widgetParameters = widget['parameters'];
+
+ $('.subMenu#sub2 .menuSelected').removeClass('menuSelected');
+ $(this).addClass('menuSelected');
+
+ if(typeof self.onMenuHover != 'undefined') {
+ self.onMenuHover(widgetUniqueId);
+ }
+ emptyWidgetHtml = widgetsHelper.getEmptyWidgetHtml(
+ widgetUniqueId,
+ '<div title="'+_pk_translate("Dashboard_AddPreviewedWidget_js")+'">'+
+ _pk_translate('Dashboard_WidgetPreview_js')+
+ '</div>',
+ '<span id="loadingPiwik">'+
+ '<img src="themes/default/images/loading-blue.gif"> ' +_pk_translate('Dashboard_LoadingWidget_js') +
+ '</span>'
+ );
+ $('#sub3').html(emptyWidgetHtml);
+
+ $('#sub3 .widgetTop').click(function() {
+ self.movePreviewToDashboard();
+ });
+
+ var onWidgetLoadedCallback = function (response) {
+ if(this.widgetUniqueId != self.expectedWidgetUniqueId) {
+ return;
+ }
+ widgetElement = $('#'+this.widgetUniqueId);
+ $('.widgetContent', widgetElement).html($(response));
+ if(typeof self.onWidgetLoad != 'undefined') {
+ self.onWidgetLoad( widgetUniqueId,
+ widgetElement
+ );
+ }
+ };
+ ajaxRequest = widgetsHelper.getLoadWidgetAjaxRequest(widgetUniqueId, widgetParameters, onWidgetLoadedCallback);
+ $.ajax(ajaxRequest);
+ }, function() {}
+ );
},
show: function()
{
var self = this;
- if(self.dashboard != undefined)
- {
+ if(typeof self.dashboard != 'undefined') {
+ self.initWidgetMenuForDashboard();
self.filterOutAlreadyLoadedWidget();
- var dispMenu = $('#widgetChooser');
- $.blockUI({message: dispMenu, css: {width:'', top: '5%',left:'10%', right:'10%', margin:"0px", textAlign:'', cursor:'', border:'0px'}});
- menuDom = $('.blockMsg #widgetChooser');
+ $.blockUI({
+ message: self.menuElement,
+ css: {width:'', top: '5%',left:'10%', right:'10%', margin:"0px", textAlign:'', cursor:'', border:'0px'}
+ });
}
- else
- {
- menuDom = $('#widgetChooser');
- }
- var dispMenuObject = new widgetMenu(self.dashboard);
- dispMenuObject.initBuilt(menuDom);
- dispMenuObject.registerCallbackOnWidgetLoad(self.onWidgetLoad);
- dispMenuObject.registerCallbackOnMainMenuHover(self.onMainMenuHover);
- dispMenuObject.registerCallbackOnSubMenuHover(self.onSubMenuHover);
+ self.resetMenuState();
+ self.bindEvents();
},
+ hideMenu: function()
+ {
+ $.unblockUI();
+ },
+
filterOutAlreadyLoadedWidget: function()
{
var self = this;
-
- //build a list of loaded widget, parse the dashboard column
- var widgets = new Array;
- self.dashboard.getColumns().each(
- function()
- {
- widgets = widgets.concat(getWidgetInDom(this));
+
+ function contains(array, searchElem) {
+ for(var i=0; i<array.length; i++) {
+ if (array[i] == searchElem) {
+ return true;
+ }
}
- );
-
- //find widget from the loaded list in the menu, and apply
- //appropriate style and behaviour
- $('.menuItem', self.menu).each(function(){
- var plugin = $(this).attr('pluginToLoad');
- var action = $(this).attr('actionToLoad');
- if(contains(widgets, plugin+'.'+action))
- {
+ return false;
+ }
+ var widgets = self.dashboard.getWidgetsElementsInsideElement( self.dashboard.dashboardElement );
+ var widgetInDashboardUniqueIds = new Array;
+ for(var i=0; i<widgets.size(); i++) {
+ widgetInDashboardUniqueIds.push($(widgets[i]).attr('id'));
+ }
+ $('.menuWidgetName', self.menuElement).each( function() {
+ // the ID is prefixed with "ID"
+ var uniqueId = $(this).attr('id').substr(2);
+ if(contains(widgetInDashboardUniqueIds, uniqueId)) {
$(this).addClass('menuDisabled');
- $(this).attr('title', _pk_translate('Dashboard_TitleWidgetInDashboard'));
- }
- else
- {
+ $(this).attr('title', _pk_translate('Dashboard_TitleWidgetInDashboard_js'));
+ } else {
$(this).removeClass('menuDisabled');
- $(this).attr('title', _pk_translate('Dashboard_TitleClickToAdd'));
+ $(this).attr('title', _pk_translate('Dashboard_TitleClickToAdd_js'));
}
});
},
@@ -210,59 +276,46 @@ widgetMenu.prototype =
movePreviewToDashboard: function()
{
var self = this;
-
- $('.widgetDiv.previewDiv', self.menu).each(function(){
- var plugin = $(this).attr('plugin');
- var action = $(this).attr('id');
-
- self.dashboard.addEmptyWidget(1, plugin, action, true);
-
- var parDiv = $('.widgetDiv[plugin='+plugin+']'+'#'+action, self.dashboard.getColumns()[0]);
- parDiv.show();
- parDiv.siblings('.widgetLoading').hide();
-
- $(this).children().clone(true).appendTo(parDiv);
+ if(typeof self.dashboard == 'undefined') {
+ return;
+ }
+ $('#sub3 .widget', self.menuElement).each(function() {
+ uniqueId = $(this).attr('id');
+ widgetAddedToDashboard = self.dashboard.addEmptyWidget(0, uniqueId, true);
+ widgetContentToReplace = $('.widgetContent', widgetAddedToDashboard );
+ widgetContentLoadedInPreview = $('.widgetContent', this).clone(true);
+ widgetContentToReplace.replaceWith( widgetContentLoadedInPreview );
});
-
- self.hide();
- self.clearPreviewDiv();
+ self.hideMenu();
+ self.dashboard.makeSortable();
self.dashboard.saveLayout();
},
-
- //clear the widget preview box
- clearPreviewDiv: function()
+
+ initWidgetMenuForDashboard: function()
{
var self = this;
- $('.subMenu .widgetDiv.previewDiv', self.menu).empty()
- .attr('id', '')
- .attr('plugin', '');
- $('#embedThisWidget').empty();
+ if(typeof self.menuInitialized == 'undefined') {
+ $('.menuWidgetName', self.menuElement)
+ .click( function() {
+ if(!$(this).hasClass('menuDisabled')) {
+ self.movePreviewToDashboard();
+ }
+ });
+ $('.button#hideMenu', self.menuElement)
+ .click(function() { self.hideMenu(); }
+ );
+ $('#closeMenuIcon', self.menuElement)
+ .click(function() { self.hideMenu(); }
+ );
+ $.extend($.blockUI.defaults.overlayCSS, { backgroundColor: '#000000', opacity: '0.4'});
+ $.extend($.blockUI.defaults,{ fadeIn: 0, fadeOut: 0 });
+ $(window).keydown( function(e) {
+ var key = e.keyCode || e.which;
+ if(key == 27) {
+ self.hideMenu();
+ }
+ });
+ }
}
};
-function loadWidgetInDiv(pluginId, actionId, callbackOnWidgetLoad)
-{
- function onLoaded(response)
- {
- var parDiv = $('.widgetDiv#'+actionId+'[plugin='+pluginId+']');
- parDiv.siblings('.widgetLoading').hide();
- parDiv.html($(response));
- parDiv.show();
-
- if(typeof callbackOnWidgetLoad != 'undefined')
- {
- callbackOnWidgetLoad(parDiv, pluginId, actionId);
- }
- }
- var ajaxRequest =
- {
- type: 'GET',
- url: 'index.php',
- dataType: 'html',
- async: true,
- error: ajaxHandleError,
- success: onLoaded,
- data: "module="+pluginId+"&action="+actionId+"&idSite="+piwik.idSite+"&period="+piwik.period+"&date="+piwik.currentDateString
- };
- $.ajax(ajaxRequest);
-}
diff --git a/plugins/ExampleFeedburner/ExampleFeedburner.php b/plugins/ExampleFeedburner/ExampleFeedburner.php
index 7a50ec59c6..089be108d3 100644
--- a/plugins/ExampleFeedburner/ExampleFeedburner.php
+++ b/plugins/ExampleFeedburner/ExampleFeedburner.php
@@ -33,7 +33,7 @@ class Piwik_ExampleFeedburner extends Piwik_Plugin
}
}
-Piwik_AddWidget('ExampleFeedburner', 'feedburner', 'Feedburner statistics');
+Piwik_AddWidget('Example Widgets', 'Feedburner statistics', 'ExampleFeedburner', 'feedburner');
class Piwik_ExampleFeedburner_Controller extends Piwik_Controller
{
@@ -44,7 +44,7 @@ class Piwik_ExampleFeedburner_Controller extends Piwik_Controller
*/
function feedburner()
{
- $view = new Piwik_View('ExampleFeedburner/feedburner.tpl');
+ $view = new Piwik_View('ExampleFeedburner/templates/feedburner.tpl');
$idSite = Piwik_Common::getRequestVar('idSite',1,'int');
$feedburnerFeedName = Piwik_FetchOne('SELECT feedburnerName FROM '.Piwik::prefixTable('site').
' WHERE idsite = ?', $idSite );
diff --git a/plugins/ExampleFeedburner/feedburner.tpl b/plugins/ExampleFeedburner/templates/feedburner.tpl
index 95ea984c98..95ea984c98 100644
--- a/plugins/ExampleFeedburner/feedburner.tpl
+++ b/plugins/ExampleFeedburner/templates/feedburner.tpl
diff --git a/plugins/ExamplePlugin/ExamplePlugin.php b/plugins/ExamplePlugin/ExamplePlugin.php
index 36a6e84f4d..b9788b58f4 100644
--- a/plugins/ExamplePlugin/ExamplePlugin.php
+++ b/plugins/ExamplePlugin/ExamplePlugin.php
@@ -44,9 +44,10 @@ class Piwik_ExamplePlugin extends Piwik_Plugin
function postLoad()
{
// we register the widgets so they appear in the "Add a new widget" window in the dashboard
- Piwik_AddWidget('ExamplePlugin', 'exampleWidget', Piwik_Translate('ExamplePlugin_exampleWidget'));
- Piwik_AddWidget('ExamplePlugin', 'blogPiwik', Piwik_Translate('ExamplePlugin_blogPiwikRss'));
- Piwik_AddWidget('ExamplePlugin', 'photostreamMatt', Piwik_Translate('ExamplePlugin_photostreamMatt'));
+ // Note that the first two parameters can be either a normal string, or an index to a translation string
+ Piwik_AddWidget('Example Widgets', 'ExamplePlugin_exampleWidget', 'ExamplePlugin', 'exampleWidget');
+ Piwik_AddWidget('Example Widgets', 'ExamplePlugin_blogPiwikRss', 'ExamplePlugin', 'blogPiwik');
+ Piwik_AddWidget('Example Widgets', 'ExamplePlugin_photostreamMatt', 'ExamplePlugin', 'photostreamMatt');
}
}
@@ -72,7 +73,9 @@ class Piwik_ExamplePlugin_Controller extends Piwik_Controller
echo "Hello world! <br> You can output whatever you want in widgets, and put them on dashboard or everywhere on the web (in your blog, website, etc.).
<br>Widgets can include graphs, tables, flash, text, images, etc.
<br>It's very easy to create a new plugin and widgets in Piwik. Have a look at this example file (/plugins/ExamplePlugin/ExamplePlugin.php).
- <br><i>Happy coding!</i>";
+ <div id='happycoding'><i>Happy coding!</i></div>
+ <div id='jsenabled'>You can easily use Jquery in widgets</div>
+ <script type=\"text/javascript\">$('#happycoding').hide().fadeIn(5000);$('#jsenabled').hide().css({'color':'red'}).fadeIn(10000);</script>";
}
/**
@@ -102,15 +105,15 @@ class Piwik_ExamplePlugin_Controller extends Piwik_Controller
$out .= '<h2>General</h2>';
$out .= '<h3>Accessible from your plugin controller</h3>';
- $out .= '<code>$this->date</code> = current selected <b>Piwik_Date</b> object (<a href="http://piwik.org/documentation/Piwik_Helper/Piwik_Date.html">documentation</a>)<br/>';
+ $out .= '<code>$this->date</code> = current selected <b>Piwik_Date</b> object (<a href="http://dev.piwik.org/trac/browser/trunk/core/Date.php">class</a>)<br/>';
$out .= '<code>$period = Piwik_Common::getRequestVar("period");</code> - Get the current selected period<br/>';
$out .= '<code>$idSite = Piwik_Common::getRequestVar("idSite");</code> - Get the selected idSite<br/>';
- $out .= '<code>$site = new Piwik_Site($idSite);</code> - Build the Piwik_Site object (<a href="http://piwik.org/documentation/Piwik_Site/Piwik_Site.html">documentation</a>)<br/>';
+ $out .= '<code>$site = new Piwik_Site($idSite);</code> - Build the Piwik_Site object (<a href="http://dev.piwik.org/trac/browser/trunk/core/Site.php">class</a>)<br/>';
$out .= '<code>$this->str_date</code> = current selected date in YYYY-MM-DD format<br/>';
$out .= '<h3>Misc</h3>';
$out .= '<code>Piwik_AddMenu( $mainMenuName, $subMenuName, $url );</code> - Adds an entry to the menu in the Piwik interface (See the example in the <a href="http://dev.piwik.org/trac/browser/trunk/plugins/UserCountry/UserCountry.php#L146">UserCountry Plugin file</a>)<br/>';
- $out .= '<code>Piwik_AddWidget( $pluginName, $controllerMethodToCall, $widgetTitle );</code> - Adds an entry to the menu in the Piwik interface (See the example in the <a href="http://dev.piwik.org/trac/browser/trunk/plugins/UserCountry/UserCountry.php#L143">UserCountry Plugin file</a>)<br/>';
+ $out .= '<code>Piwik_AddWidget( $widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array());</code> - Adds a widget that users can add in the dashboard, or export using the Widgets link at the top of the screen. See the example in the <a href="http://dev.piwik.org/trac/browser/trunk/plugins/UserCountry/UserCountry.php#L143">UserCountry Plugin file</a> or any other plugin)<br/>';
$out .= '<code>Piwik::prefixTable("site")</code> = <b>' . Piwik::prefixTable("site") . '</b><br/>';
diff --git a/plugins/ExampleRssWidget/ExampleRssWidget.php b/plugins/ExampleRssWidget/ExampleRssWidget.php
index 7130c6cd70..57bbb64b9e 100644
--- a/plugins/ExampleRssWidget/ExampleRssWidget.php
+++ b/plugins/ExampleRssWidget/ExampleRssWidget.php
@@ -20,12 +20,12 @@ class Piwik_ExampleRssWidget extends Piwik_Plugin
function css()
{
- echo '<link rel="stylesheet" type="text/css" href="plugins/ExampleRssWidget/styles.css" />';
+ echo '<link rel="stylesheet" type="text/css" href="plugins/ExampleRssWidget/templates/styles.css" />';
}
}
-Piwik_AddWidget('ExampleRssWidget', 'rssPiwik', 'Piwik.org Blog');
-Piwik_AddWidget('ExampleRssWidget', 'rssChangelog', 'Piwik Changelog');
+Piwik_AddWidget('Example Widgets', 'Piwik.org Blog', 'ExampleRssWidget', 'rssPiwik');
+Piwik_AddWidget('Example Widgets', 'Piwik Changelog', 'ExampleRssWidget', 'rssChangelog');
class Piwik_ExampleRssWidget_Controller extends Piwik_Controller
{
diff --git a/plugins/ExampleRssWidget/styles.css b/plugins/ExampleRssWidget/templates/styles.css
index 43722016e1..43722016e1 100644
--- a/plugins/ExampleRssWidget/styles.css
+++ b/plugins/ExampleRssWidget/templates/styles.css
diff --git a/plugins/Feedback/Controller.php b/plugins/Feedback/Controller.php
index 733ee36225..a1833e3fa0 100644
--- a/plugins/Feedback/Controller.php
+++ b/plugins/Feedback/Controller.php
@@ -17,7 +17,7 @@ class Piwik_Feedback_Controller extends Piwik_Controller
{
function index()
{
- $view = new Piwik_View('Feedback/index.tpl');
+ $view = new Piwik_View('Feedback/templates/index.tpl');
echo $view->render();
}
@@ -29,7 +29,7 @@ class Piwik_Feedback_Controller extends Piwik_Controller
$body = Piwik_Common::getRequestVar('body', '', 'string');
$email = Piwik_Common::getRequestVar('email', '', 'string');
- $view = new Piwik_View('Feedback/sent.tpl');
+ $view = new Piwik_View('Feedback/templates/sent.tpl');
try
{
$minimumBodyLength = 10;
diff --git a/plugins/Feedback/index.tpl b/plugins/Feedback/templates/index.tpl
index 62f1d16c2f..62f1d16c2f 100644
--- a/plugins/Feedback/index.tpl
+++ b/plugins/Feedback/templates/index.tpl
diff --git a/plugins/Feedback/sent.tpl b/plugins/Feedback/templates/sent.tpl
index 65495497bf..65495497bf 100644
--- a/plugins/Feedback/sent.tpl
+++ b/plugins/Feedback/templates/sent.tpl
diff --git a/plugins/Goals/API.php b/plugins/Goals/API.php
index b3935612a5..ef1ee36216 100644
--- a/plugins/Goals/API.php
+++ b/plugins/Goals/API.php
@@ -151,7 +151,8 @@ class Piwik_Goals_API
$nbVisitsReturning = $request->process();
// echo $nbVisitsConvertedReturningVisitors;
// echo "<br>". $nbVisitsReturning;exit;
- return $this->getPercentage($nbVisitsConvertedReturningVisitors, $nbVisitsReturning);
+
+ return Piwik::getPercentageSafe($nbVisitsConvertedReturningVisitors, $nbVisitsReturning, Piwik_Goals::ROUNDING_PRECISION);
}
public function getConversionRateNewVisitors( $idSite, $period, $date, $idGoal = false )
@@ -176,26 +177,29 @@ class Piwik_Goals_API
$request = new Piwik_API_Request("method=VisitsSummary.getVisits&idSite=$idSite&period=$period&date=$date&format=original");
$nbVisits = $request->process();
$newVisits = $nbVisits - $nbVisitsReturning;
- return $this->getPercentage($convertedNewVisits, $newVisits);
- }
-
- protected function getPercentage($a, $b)
- {
- if($b == 0)
- {
- return 0;
- }
- return round(100 * $a / $b, Piwik_Goals::ROUNDING_PRECISION);
+ return Piwik::getPercentageSafe($convertedNewVisits, $newVisits, Piwik_Goals::ROUNDING_PRECISION);
}
- public function get( $idSite, $period, $date, $idGoal = false )
+ public function get( $idSite, $period, $date, $idGoal = false, $columns = array() )
{
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
- $toFetch = array( Piwik_Goals::getRecordName('nb_conversions', $idGoal),
- Piwik_Goals::getRecordName('conversion_rate', $idGoal),
- Piwik_Goals::getRecordName('revenue', $idGoal),
- );
+ if(!empty($columns))
+ {
+ $toFetch = $columns;
+ }
+ else
+ {
+ $toFetch = array(
+ 'nb_conversions',
+ 'conversion_rate',
+ 'revenue',
+ );
+ foreach($toFetch as &$columnName)
+ {
+ $columnName = Piwik_Goals::getRecordName($columnName, $idGoal);
+ }
+ }
$dataTable = $archive->getDataTableFromNumeric($toFetch);
return $dataTable;
}
diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php
index 869b66b540..2476dbd81f 100644
--- a/plugins/Goals/Controller.php
+++ b/plugins/Goals/Controller.php
@@ -4,16 +4,22 @@ require_once "Goals/API.php";
class Piwik_Goals_Controller extends Piwik_Controller
{
const CONVERSION_RATE_PRECISION = 1;
+
+ function __construct()
+ {
+ parent::__construct();
+ $this->idSite = Piwik_Common::getRequestVar('idSite');
+ $this->goals = Piwik_Goals_API::getGoals($this->idSite);
+ }
+
function goalReport()
{
$idGoal = Piwik_Common::getRequestVar('idGoal', null, 'int');
- $idSite = Piwik_Common::getRequestVar('idSite');
- $goals = Piwik_Goals_API::getGoals($idSite);
- if(!isset($goals[$idGoal]))
+ if(!isset($this->goals[$idGoal]))
{
throw new Exception("idgoal $idGoal not valid.");
}
- $goalDefinition = $goals[$idGoal];
+ $goalDefinition = $this->goals[$idGoal];
$view = new Piwik_View('Goals/templates/single_goal.tpl');
$view->currency = Piwik::getCurrency();
@@ -24,8 +30,8 @@ class Piwik_Goals_Controller extends Piwik_Controller
}
$view->name = $goalDefinition['name'];
$view->title = $goalDefinition['name'] . ' - Conversions';
- $view->graphEvolution = $this->getLastNbConversionsGraph(true);
- $view->nameGraphEvolution = 'GoalsgetLastNbConversionsGraph'; // must be the function name used above
+ $view->graphEvolution = $this->getEvolutionGraph(true, array(Piwik_Goals::getRecordName('nb_conversions', $idGoal)), $idGoal);
+ $view->nameGraphEvolution = 'GoalsgetEvolutionGraph';
$view->topSegments = $this->getTopSegments($idGoal);
// conversion rate for new and returning visitors
@@ -80,18 +86,19 @@ class Piwik_Goals_Controller extends Piwik_Controller
return $topSegments;
}
- protected function getMetricsForGoal($goalId)
+ protected function getMetricsForGoal($idGoal)
{
- $request = new Piwik_API_Request("method=Goals.get&format=original&idGoal=$goalId");
+ $request = new Piwik_API_Request("method=Goals.get&format=original&idGoal=$idGoal");
$datatable = $request->process();
+ $dataRow = $datatable->getFirstRow();
return array (
- 'id' => $goalId,
- 'nb_conversions' => $datatable->getRowFromLabel(Piwik_Goals::getRecordName('nb_conversions', $goalId))->getColumn('value'),
- 'conversion_rate' => round($datatable->getRowFromLabel(Piwik_Goals::getRecordName('conversion_rate', $goalId))->getColumn('value'), 1),
- 'revenue' => $datatable->getRowFromLabel(Piwik_Goals::getRecordName('revenue', $goalId))->getColumn('value'),
- 'urlSparklineConversions' => $this->getUrlSparkline('getLastNbConversionsGraph', $goalId) . "&idGoal=".$goalId,
- 'urlSparklineConversionRate' => $this->getUrlSparkline('getLastConversionRateGraph', $goalId) . "&idGoal=".$goalId,
- 'urlSparklineRevenue' => $this->getUrlSparkline('getLastRevenueGraph', $goalId) . "&idGoal=".$goalId,
+ 'id' => $idGoal,
+ 'nb_conversions' => $dataRow->getColumn(Piwik_Goals::getRecordName('nb_conversions', $idGoal)),
+ 'conversion_rate' => round($dataRow->getColumn(Piwik_Goals::getRecordName('conversion_rate', $idGoal)), 1),
+ 'revenue' => $dataRow->getColumn(Piwik_Goals::getRecordName('revenue', $idGoal)),
+ 'urlSparklineConversions' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('nb_conversions', $idGoal)), 'idGoal' => $idGoal)),
+ 'urlSparklineConversionRate' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('conversion_rate', $idGoal)), 'idGoal' => $idGoal)),
+ 'urlSparklineRevenue' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('revenue', $idGoal)), 'idGoal' => $idGoal)),
);
}
@@ -101,57 +108,98 @@ class Piwik_Goals_Controller extends Piwik_Controller
$view->currency = Piwik::getCurrency();
$view->title = 'All goals - evolution';
- $view->graphEvolution = $this->getLastNbConversionsGraph(true);
- $view->nameGraphEvolution = 'GoalsgetLastNbConversionsGraph'; // must be the function name used above
+ $view->graphEvolution = $this->getEvolutionGraph(true, array(Piwik_Goals::getRecordName('nb_conversions')));
+ $view->nameGraphEvolution = 'GoalsgetEvolutionGraph';
// sparkline for the historical data of the above values
- $view->urlSparklineConversions = $this->getUrlSparkline('getLastNbConversionsGraph');
- $view->urlSparklineConversionRate = $this->getUrlSparkline('getLastConversionRateGraph');
- $view->urlSparklineRevenue = $this->getUrlSparkline('getLastRevenueGraph');
+ $view->urlSparklineConversions = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('nb_conversions'))));
+ $view->urlSparklineConversionRate = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('conversion_rate'))));
+ $view->urlSparklineRevenue = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('revenue'))));
$request = new Piwik_API_Request("method=Goals.get&format=original");
$datatable = $request->process();
- $view->nb_conversions = $datatable->getRowFromLabel('Goal_nb_conversions')->getColumn('value');
- $view->conversion_rate = $datatable->getRowFromLabel('Goal_conversion_rate')->getColumn('value');
- $view->revenue = $datatable->getRowFromLabel('Goal_revenue')->getColumn('value');
+ $dataRow = $datatable->getFirstRow();
+ $view->nb_conversions = $dataRow->getColumn('Goal_nb_conversions');
+ $view->conversion_rate = $dataRow->getColumn('Goal_conversion_rate');
+ $view->revenue = $dataRow->getColumn('Goal_revenue');
$goalMetrics = array();
-
- $idSite = Piwik_Common::getRequestVar('idSite');
- $goals = Piwik_Goals_API::getGoals($idSite);
- foreach($goals as $idGoal => $goal)
+ foreach($this->goals as $idGoal => $goal)
{
$goalMetrics[$idGoal] = $this->getMetricsForGoal($idGoal);
$goalMetrics[$idGoal]['name'] = $goal['name'];
}
$view->goalMetrics = $goalMetrics;
- $view->goals = $goals;
- $view->goalsJSON = json_encode($goals);
- $view->userCanEditGoals = Piwik::isUserHasAdminAccess($idSite);
+ $view->goals = $this->goals;
+ $view->goalsJSON = json_encode($this->goals);
+ $view->userCanEditGoals = Piwik::isUserHasAdminAccess($this->idSite);
echo $view->render();
}
function addNewGoal()
{
$view = new Piwik_View('Goals/templates/add_new_goal.tpl');
- $idSite = Piwik_Common::getRequestVar('idSite');
- $view->userCanEditGoals = Piwik::isUserHasAdminAccess($idSite);
+ $view->userCanEditGoals = Piwik::isUserHasAdminAccess($this->idSite);
$view->currency = Piwik::getCurrency();
$view->onlyShowAddNewGoal = true;
echo $view->render();
}
+ protected $goalColumnNameToLabel = array(
+ 'nb_conversions' => 'Goals_ColumnConversions',
+ 'conversion_rate'=> 'Goals_ColumnConversionRate',
+ 'revenue' => 'Goals_ColumnRevenue',
+ );
+
+ public function getEvolutionGraph( $fetch = false, $columns = false, $idGoal = false)
+ {
+ if(empty($columns))
+ {
+ $columns = Piwik_Common::getRequestVar('columns');
+ }
+ if(empty($idGoal))
+ {
+ $idGoal = Piwik_Common::getRequestVar('idGoal', false);
+ }
+ $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Goals.get');
+ $view->setParametersToModify(array('idGoal' => $idGoal));
+
+ foreach($columns as $columnName)
+ {
+ // find the right translation for this column, eg. find 'revenue' if column is Goal_1_revenue
+ foreach($this->goalColumnNameToLabel as $metric => $metricTranslation)
+ {
+ if(strpos($columnName, $metric) !== false)
+ {
+ $columnTranslation = Piwik_Translate($metricTranslation);
+ break;
+ }
+ }
+
+ if(!empty($idGoal))
+ {
+ $goalName = $this->goals[$idGoal]['name'];
+ $columnTranslation = "$columnTranslation (goal \"$goalName\")";
+ }
+ $view->setColumnTranslation($columnName, $columnTranslation);
+ }
+ $view->setColumnsToDisplay($columns);
+ return $this->renderView($view, $fetch);
+ }
+
function getLastNbConversionsGraph( $fetch = false )
{
$view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Goals.getConversions');
return $this->renderView($view, $fetch);
}
+
function getLastConversionRateGraph( $fetch = false )
{
$view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Goals.getConversionRate');
return $this->renderView($view, $fetch);
}
+
function getLastRevenueGraph( $fetch = false )
{
$view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Goals.getRevenue');
diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php
index 2fdd6206f7..d75c29dbc7 100644
--- a/plugins/Goals/Goals.php
+++ b/plugins/Goals/Goals.php
@@ -59,7 +59,6 @@ class Piwik_Goals extends Piwik_Plugin
function addWidgets()
{
-// Piwik_AddWidget( 'Referers', 'getKeywords', Piwik_Translate('Referers_WidgetKeywords'));
}
function addMenus()
diff --git a/plugins/Goals/templates/overview.tpl b/plugins/Goals/templates/overview.tpl
index 7bf8f4c25f..f87b72b1bf 100644
--- a/plugins/Goals/templates/overview.tpl
+++ b/plugins/Goals/templates/overview.tpl
@@ -5,18 +5,15 @@
{assign var=nb_conversions value=$goal.nb_conversions}
{assign var=conversion_rate value=$goal.conversion_rate}
<h2 style="padding-top: 30px;">{$goal.name} (goal)</h2>
-<table width=700px>
- <tr><td>
- <p>{sparkline src=$goal.urlSparklineConversions}<span>
- {'%s conversions'|translate:"<strong>$nb_conversions</strong>"}</span></p>
- </td><td>
- <p>{sparkline src=$goal.urlSparklineConversionRate}<span>
- {'%s conversion rate'|translate:"<strong>$conversion_rate%</strong>"}</span></p>
- </td><td>
+<div id='leftcolumn'>
+ <div class="sparkline">{sparkline src=$goal.urlSparklineConversions}
+ {'%s conversions'|translate:"<strong>$nb_conversions</strong>"}</div>
+</div>
+<div id='rightcolumn'>
+ <div class="sparkline">{sparkline src=$goal.urlSparklineConversionRate}
+ {'%s conversion rate'|translate:"<strong>$conversion_rate%</strong>"}</div>
{* (<a href=''>more</a>) *}
- </td></tr>
-</table>
-
+</div>
{/foreach}
{if $userCanEditGoals}
diff --git a/plugins/Goals/templates/release_notes.tpl b/plugins/Goals/templates/release_notes.tpl
index 2a55ccfee6..6b5a089789 100644
--- a/plugins/Goals/templates/release_notes.tpl
+++ b/plugins/Goals/templates/release_notes.tpl
@@ -1,4 +1,5 @@
-<hr>
+<div style="clear:both" />
+<br><br><hr>
<b>About the Goal Tracking Plugin</b><br>
<pre>
The Goal Tracking Plugin is in alpha release. There is more coming soon!
@@ -13,6 +14,7 @@ The Goal Tracking Plugin is in alpha release. There is more coming soon!
- documentation, eg. http://feedproxy.google.com/~r/WebAnalyticsWorld/~3/1g5Z7k7jDKQ/10-must-track-google-analytics-goals.html
- internationalization of all strings i18n
- provide documentation, screenshots, blog post + add screenshot and inline help in "Add a New Goal"
+- way to test a URL against the regex
Known bugs
- need to clarify that goals are triggered once per visit max, but can be triggered multiple times by one unique visitor > need option to force only once per uniq visitor? (ie. e-commerce transaction)
diff --git a/plugins/Goals/templates/title_and_evolution_graph.tpl b/plugins/Goals/templates/title_and_evolution_graph.tpl
index 0b1b8d2c7b..8a344df003 100644
--- a/plugins/Goals/templates/title_and_evolution_graph.tpl
+++ b/plugins/Goals/templates/title_and_evolution_graph.tpl
@@ -4,17 +4,15 @@
<h2>{$title}</h2>
{$graphEvolution}
-<table>
- <tr><td>
- <p>{sparkline src=$urlSparklineConversions}<span>
- {'%s conversions'|translate:"<strong>$nb_conversions</strong>"}</span></p>
- {if $revenue != 0 }
- <p>{sparkline src=$urlSparklineRevenue}<span>
- {'%s overall revenue'|translate:"<strong>$currency$revenue</strong>"}</span></p>
- {/if}
- </td><td valign="top">
- <p>{sparkline src=$urlSparklineConversionRate}<span>
- {'%s overall conversion rate (visits with a completed goal)'|translate:"<strong>$conversion_rate%</strong>"}</span></p>
- </td></tr>
-</table>
-
+<div id='leftcolumn'>
+ <div class="sparkline">{sparkline src=$urlSparklineConversions}
+ {'%s conversions'|translate:"<strong>$nb_conversions</strong>"}</div>
+ {if $revenue != 0 }
+ <div class="sparkline">{sparkline src=$urlSparklineRevenue}
+ {'%s overall revenue'|translate:"<strong>$currency$revenue</strong>"}</div>
+ {/if}
+</div>
+<div id='rightcolumn'>
+ <div class="sparkline">{sparkline src=$urlSparklineConversionRate}
+ {'%s overall conversion rate (visits with a completed goal)'|translate:"<strong>$conversion_rate%</strong>"}</div>
+</div>
diff --git a/plugins/Live/API.php b/plugins/Live/API.php
index 9757cf3db2..a2638c59d7 100644
--- a/plugins/Live/API.php
+++ b/plugins/Live/API.php
@@ -74,7 +74,8 @@ class Piwik_Live_API
$visitor = new Piwik_Live_Visitor($visitorDetail);
$visitorDetailsArray = $visitor->getAllVisitorDetails();
$dateTimeVisit = Piwik_Date::factory($visitorDetailsArray['firstActionTimestamp']);
- $visitorDetailsArray['serverDatePretty'] = $dateTimeVisit->getLocalized('%a %d %b');
+ //TODO TO FIX
+ $visitorDetailsArray['serverDatePretty'] = $dateTimeVisit->getLocalized('%longDay% %d %b');
$visitorDetailsArray['serverTimePretty'] = $dateTimeVisit->getLocalized('%X');
$table->addRowFromArray( array(Piwik_DataTable_Row::COLUMNS => $visitorDetailsArray));
}
diff --git a/plugins/Live/Live.php b/plugins/Live/Live.php
index a8078b4c45..ce280aed64 100644
--- a/plugins/Live/Live.php
+++ b/plugins/Live/Live.php
@@ -28,4 +28,4 @@ class Piwik_Live extends Piwik_Plugin
}
}
-Piwik_AddWidget('Live', 'widget', 'Live Visitors!'); \ No newline at end of file
+Piwik_AddWidget('Live!', 'Live Visitors!', 'Live', 'widget'); \ No newline at end of file
diff --git a/plugins/Provider/Provider.php b/plugins/Provider/Provider.php
index 0dcdf42426..963f01685d 100644
--- a/plugins/Provider/Provider.php
+++ b/plugins/Provider/Provider.php
@@ -62,7 +62,7 @@ class Piwik_Provider extends Piwik_Plugin
function addWidget()
{
- Piwik_AddWidget( 'Provider', 'getProvider', Piwik_Translate('Provider_WidgetProviders'));
+ Piwik_AddWidget('General_Visitors', 'Provider_WidgetProviders', 'Provider', 'getProvider');
}
function addMenu()
diff --git a/plugins/Referers/API.php b/plugins/Referers/API.php
index 47a214d190..9d8534cd69 100644
--- a/plugins/Referers/API.php
+++ b/plugins/Referers/API.php
@@ -140,7 +140,7 @@ class Piwik_Referers_API
{
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
- return $archive->getDataTableFromNumeric($name);
+ return $archive->getNumeric($name);
}
}
diff --git a/plugins/Referers/Controller.php b/plugins/Referers/Controller.php
index 32f7657ac4..1ae05933c9 100644
--- a/plugins/Referers/Controller.php
+++ b/plugins/Referers/Controller.php
@@ -5,8 +5,8 @@ class Piwik_Referers_Controller extends Piwik_Controller
{
$view = new Piwik_View('Referers/templates/index.tpl');
- $view->graphEvolutionReferers = $this->getLastDirectEntryGraph(true);
- $view->nameGraphEvolutionReferers = 'ReferersgetLastDirectEntryGraph'; // must be the function name used above
+ $view->graphEvolutionReferers = $this->getEvolutionGraph(true, Piwik_Common::REFERER_TYPE_DIRECT_ENTRY, array('nb_visits'));
+ $view->nameGraphEvolutionReferers = 'ReferersgetEvolutionGraph'; // must be the function name used above TODO why?
$view->numberDistinctSearchEngines = $this->getNumberOfDistinctSearchEngines(true);
$view->numberDistinctKeywords = $this->getNumberOfDistinctKeywords(true);
@@ -23,10 +23,10 @@ class Piwik_Referers_Controller extends Piwik_Controller
$view->$name = $value;
}
// sparkline for the historical data of the above values
- $view->urlSparklineSearchEngines = $this->getUrlSparkline('getLastSearchEnginesGraph');
- $view->urlSparklineDirectEntry = $this->getUrlSparkline('getLastDirectEntryGraph');
- $view->urlSparklineWebsites = $this->getUrlSparkline('getLastWebsitesGraph');
- $view->urlSparklineCampaigns = $this->getUrlSparkline('getLastCampaignsGraph');
+ $view->urlSparklineSearchEngines = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_visits'), 'typeReferer' => Piwik_Common::REFERER_TYPE_SEARCH_ENGINE));
+ $view->urlSparklineDirectEntry = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_visits'), 'typeReferer' => Piwik_Common::REFERER_TYPE_DIRECT_ENTRY));
+ $view->urlSparklineWebsites = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_visits'), 'typeReferer' => Piwik_Common::REFERER_TYPE_WEBSITE));
+ $view->urlSparklineCampaigns = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_visits'), 'typeReferer' => Piwik_Common::REFERER_TYPE_CAMPAIGN));
// sparklines for the evolution of the distinct keywords count/websites count/ etc
$view->urlSparklineDistinctSearchEngines = $this->getUrlSparkline('getLastDistinctSearchEnginesGraph');
@@ -179,9 +179,10 @@ class Piwik_Referers_Controller extends Piwik_Controller
}
+ // TODO FIXME WITH NEW API
+ // example of how to show evolution of a given column over multiple days
public function getSearchEnginesEvolution($fetch = false)
{
- // TODO example of how to show evolution of a given column over multiple days
$view = Piwik_ViewDataTable::factory('graphEvolution');
$view->init( $this->pluginName, __FUNCTION__, 'Referers.getSearchEngines' );
@@ -221,50 +222,73 @@ class Piwik_Referers_Controller extends Piwik_Controller
}
return $return;
}
- function getLastSearchEnginesGraph( $fetch = false )
- {
- $view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, 'Referers.getRefererType');
- $view->setSearchPattern(Piwik_Common::REFERER_TYPE_SEARCH_ENGINE, 'label');
- return $this->renderView($view, $fetch);
- }
- function getLastDirectEntryGraph( $fetch = false )
- {
- $view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, 'Referers.getRefererType');
- $view->setSearchPattern(Piwik_Common::REFERER_TYPE_DIRECT_ENTRY, 'label');
- return $this->renderView($view, $fetch);
- }
- function getLastWebsitesGraph( $fetch = false )
- {
- $view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, 'Referers.getRefererType');
- $view->setSearchPattern(Piwik_Common::REFERER_TYPE_WEBSITE, 'label');
- return $this->renderView($view, $fetch);
- }
- function getLastCampaignsGraph( $fetch = false )
+
+ protected $refererTypeToLabel = array(
+ Piwik_Common::REFERER_TYPE_DIRECT_ENTRY => 'Referers_DirectEntry',
+ Piwik_Common::REFERER_TYPE_SEARCH_ENGINE => 'Referers_SearchEngines',
+ Piwik_Common::REFERER_TYPE_WEBSITE => 'Referers_Websites',
+ Piwik_Common::REFERER_TYPE_CAMPAIGN => 'Referers_Campaigns',
+ );
+
+ public function getEvolutionGraph( $fetch = false, $typeReferer = false, $columns = false)
{
- $view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, 'Referers.getRefererType');
- $view->setSearchPattern(Piwik_Common::REFERER_TYPE_CAMPAIGN, 'label');
+ $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Referers.getRefererType');
+ if(empty($columns))
+ {
+ $columns = Piwik_Common::getRequestVar('columns');
+ }
+ if(empty($typeReferer))
+ {
+ $typeReferer = Piwik_Common::getRequestVar('typeReferer');
+ }
+ $view->setColumnsToDisplay($columns);
+ $view->setSearchPattern($typeReferer, 'label');
+ $view->setParametersToModify(array('typeReferer' => $typeReferer));
+ foreach($columns as $columnName)
+ {
+ $columnTranslation = $this->standardColumnNameToTranslation[$columnName];
+ $refererTypeTranslation = $this->refererTypeToLabel[$typeReferer];
+ $view->setColumnTranslation(
+ $columnName,
+ Piwik_Translate('Referers_MetricsFromRefererTypeGraphLegend',
+ array( Piwik_Translate($columnTranslation),
+ Piwik_Translate($refererTypeTranslation)
+ )
+ )
+ );
+ }
return $this->renderView($view, $fetch);
}
+
function getLastDistinctSearchEnginesGraph( $fetch = false )
{
$view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, "Referers.getNumberOfDistinctSearchEngines");
+ $view->setColumnTranslation('Referers_distinctSearchEngines', ucfirst(Piwik_Translate('Referers_DistinctSearchEngines')));
+ $view->setColumnsToDisplay(array('Referers_distinctSearchEngines'));
return $this->renderView($view, $fetch);
}
function getLastDistinctKeywordsGraph( $fetch = false )
{
$view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, "Referers.getNumberOfDistinctKeywords");
+ $view->setColumnTranslation('Referers_distinctKeywords', ucfirst(Piwik_Translate('Referers_DistinctKeywords')));
+ $view->setColumnsToDisplay(array('Referers_distinctKeywords'));
return $this->renderView($view, $fetch);
}
function getLastDistinctWebsitesGraph( $fetch = false )
{
$view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, "Referers.getNumberOfDistinctWebsites");
+ $view->setColumnTranslation('Referers_distinctWebsites', ucfirst(Piwik_Translate('Referers_DistinctWebsites')));
+ $view->setColumnsToDisplay(array('Referers_distinctWebsites'));
return $this->renderView($view, $fetch);
}
function getLastDistinctCampaignsGraph( $fetch = false )
{
$view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, "Referers.getNumberOfDistinctCampaigns");
+ $view->setColumnTranslation('Referers_distinctCampaigns', ucfirst(Piwik_Translate('Referers_DistinctCampaigns')));
+ $view->setColumnsToDisplay(array('Referers_distinctCampaigns'));
return $this->renderView($view, $fetch);
}
+
function getNumberOfDistinctSearchEngines( $fetch = false)
{
return $this->getNumericValue('Referers.' . __FUNCTION__);
diff --git a/plugins/Referers/Referers.php b/plugins/Referers/Referers.php
index 4041955db2..8bf6446d0f 100644
--- a/plugins/Referers/Referers.php
+++ b/plugins/Referers/Referers.php
@@ -51,11 +51,11 @@ class Piwik_Referers extends Piwik_Plugin
function addWidgets()
{
- Piwik_AddWidget( 'Referers', 'getKeywords', Piwik_Translate('Referers_WidgetKeywords'));
- Piwik_AddWidget( 'Referers', 'getCampaigns', Piwik_Translate('Referers_WidgetCampaigns'));
- Piwik_AddWidget( 'Referers', 'getWebsites', Piwik_Translate('Referers_WidgetExternalWebsites'));
- Piwik_AddWidget( 'Referers', 'getSearchEngines', Piwik_Translate('Referers_WidgetSearchEngines'));
- Piwik_AddWidget( 'Referers', 'getRefererType', Piwik_Translate('Referers_WidgetOverview'));
+ Piwik_AddWidget( 'Referers', 'Referers_WidgetKeywords', 'Referers', 'getKeywords');
+ Piwik_AddWidget( 'Referers', 'Referers_WidgetCampaigns', 'Referers', 'getCampaigns');
+ Piwik_AddWidget( 'Referers', 'Referers_WidgetExternalWebsites', 'Referers', 'getWebsites');
+ Piwik_AddWidget( 'Referers', 'Referers_WidgetSearchEngines', 'Referers', 'getSearchEngines');
+ Piwik_AddWidget( 'Referers', 'Referers_WidgetOverview', 'Referers', 'getRefererType');
}
function addMenus()
diff --git a/plugins/Referers/templates/index.tpl b/plugins/Referers/templates/index.tpl
index 6715b2a774..bb00ae94e6 100644
--- a/plugins/Referers/templates/index.tpl
+++ b/plugins/Referers/templates/index.tpl
@@ -8,16 +8,16 @@
<div id='leftcolumn'>
<h2>{'Referers_Type'|translate}</h2>
<div id='leftcolumn'>
- <p>{sparkline src=$urlSparklineDirectEntry}<span>
- {'Referers_TypeDirectEntries'|translate:"<strong>$visitorsFromDirectEntry</strong>"}</span></p>
- <p>{sparkline src=$urlSparklineSearchEngines}<span>
- {'Referers_TypeSearchEngines'|translate:"<strong>$visitorsFromSearchEngines</strong>"}</span></p>
+ <div class="sparkline">{sparkline src=$urlSparklineDirectEntry}
+ {'Referers_TypeDirectEntries'|translate:"<strong>$visitorsFromDirectEntry</strong>"}</div>
+ <div class="sparkline">{sparkline src=$urlSparklineSearchEngines}
+ {'Referers_TypeSearchEngines'|translate:"<strong>$visitorsFromSearchEngines</strong>"}</div>
</div>
<div id='rightcolumn'>
- <p>{sparkline src=$urlSparklineWebsites}<span>
- {'Referers_TypeWebsites'|translate:"<strong>$visitorsFromWebsites</strong>"}</span></p>
- <p>{sparkline src=$urlSparklineCampaigns}<span>
- {'Referers_TypeCampaigns'|translate:"<strong>$visitorsFromCampaigns</strong>"}</span></p>
+ <div class="sparkline">{sparkline src=$urlSparklineWebsites}
+ {'Referers_TypeWebsites'|translate:"<strong>$visitorsFromWebsites</strong>"}</div>
+ <div class="sparkline">{sparkline src=$urlSparklineCampaigns}
+ {'Referers_TypeCampaigns'|translate:"<strong>$visitorsFromCampaigns</strong>"}</div>
</div>
</div>
@@ -27,17 +27,17 @@
</div>
<div style="clear:both" />
-<h2>{'Referers_Other'|translate}</h2>
-<table>
- <tr><td>
- <p>{sparkline src=$urlSparklineDistinctSearchEngines}<span>
- {'Referers_OtherDistinctSearchEngines'|translate:"<strong>$numberDistinctSearchEngines</strong>"}</span></p>
- <p>{sparkline src=$urlSparklineDistinctKeywords}<span>
- {'Referers_OtherDistinctKeywords'|translate:"<strong>$numberDistinctKeywords</strong>"}</span></p>
- </td><td>
- <p>{sparkline src=$urlSparklineDistinctWebsites}<span>
- {'Referers_OtherDistinctWebsites'|translate:"<strong>$numberDistinctWebsites</strong>":"<strong>$numberDistinctWebsitesUrls</strong>"}</span></p>
- <p>{sparkline src=$urlSparklineDistinctCampaigns}<span>
- {'Referers_OtherDistinctCampaigns'|translate:"<strong>$numberDistinctCampaigns</strong>"}</span></p>
- </td></tr>
+<h2>{'Referers_Distinct'|translate}</h2>
+<table cellpadding="15">
+<tr><td style="padding-right:50px">
+ <div class="sparkline">{sparkline src=$urlSparklineDistinctSearchEngines}
+ <strong>{$numberDistinctSearchEngines}</strong> {'Referers_DistinctSearchEngines'|translate}</div>
+ <div class="sparkline">{sparkline src=$urlSparklineDistinctKeywords}
+ <strong>{$numberDistinctKeywords}</strong> {'Referers_DistinctKeywords'|translate}</div>
+</td>
+ <div class="sparkline">{sparkline src=$urlSparklineDistinctWebsites}
+ <strong>{$numberDistinctWebsites}</strong> {'Referers_DistinctWebsites'|translate} {'Referers_UsingNDistinctUrls'|translate:"<strong>$numberDistinctWebsitesUrls</strong>"}</div>
+ <div class="sparkline">{sparkline src=$urlSparklineDistinctCampaigns}
+ <strong>{$numberDistinctCampaigns}</strong> {'Referers_DistinctCampaigns'|translate}</div>
+</td></tr>
</table>
diff --git a/plugins/SitesManager/templates/SitesManager.js b/plugins/SitesManager/templates/SitesManager.js
index 8ebfedd3b3..48bcab165d 100644
--- a/plugins/SitesManager/templates/SitesManager.js
+++ b/plugins/SitesManager/templates/SitesManager.js
@@ -92,7 +92,7 @@ $(document).ready( function() {
var idRow = $(this).attr('id');
var nameToDelete = $(this).parent().parent().find('#siteName').html();
var idsiteToDelete = $(this).parent().parent().find('#idSite').html();
- if(confirm(sprintf(_pk_translate('SitesManager_DeleteConfirm'),'"'+nameToDelete+'" (idSite = '+idsiteToDelete+')')) )
+ if(confirm(sprintf(_pk_translate('SitesManager_DeleteConfirm_js'),'"'+nameToDelete+'" (idSite = '+idsiteToDelete+')')) )
{
$.ajax( getDeleteSiteAJAX( idsiteToDelete ) );
}
diff --git a/plugins/UserCountry/API.php b/plugins/UserCountry/API.php
index 976f649344..ac9f758fb0 100644
--- a/plugins/UserCountry/API.php
+++ b/plugins/UserCountry/API.php
@@ -62,7 +62,7 @@ class Piwik_UserCountry_API
{
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
- return $archive->getDataTableFromNumeric('UserCountry_distinctCountries');
+ return $archive->getNumeric('UserCountry_distinctCountries');
}
diff --git a/plugins/UserCountry/Controller.php b/plugins/UserCountry/Controller.php
index ecf5c0548f..a7fadc8b17 100644
--- a/plugins/UserCountry/Controller.php
+++ b/plugins/UserCountry/Controller.php
@@ -5,7 +5,7 @@ class Piwik_UserCountry_Controller extends Piwik_Controller
{
function index()
{
- $view = new Piwik_View('UserCountry/index.tpl');
+ $view = new Piwik_View('UserCountry/templates/index.tpl');
$view->urlSparklineCountries = $this->getUrlSparkline('getLastDistinctCountriesGraph');
$view->numberDistinctCountries = $this->getNumberOfDistinctCountries(true);
diff --git a/plugins/UserCountry/UserCountry.php b/plugins/UserCountry/UserCountry.php
index 7f39f2a147..04b41463bd 100644
--- a/plugins/UserCountry/UserCountry.php
+++ b/plugins/UserCountry/UserCountry.php
@@ -40,8 +40,8 @@ class Piwik_UserCountry extends Piwik_Plugin
function addWidgets()
{
- Piwik_AddWidget( 'UserCountry', 'getContinent', Piwik_Translate('UserCountry_WidgetContinents'));
- Piwik_AddWidget( 'UserCountry', 'getCountry', Piwik_Translate('UserCountry_WidgetCountries'));
+ Piwik_AddWidget( 'General_Visitors', 'UserCountry_WidgetContinents', 'UserCountry', 'getContinent');
+ Piwik_AddWidget( 'General_Visitors', 'UserCountry_WidgetCountries', 'UserCountry', 'getCountry');
}
function addMenu()
diff --git a/plugins/UserCountry/index.tpl b/plugins/UserCountry/templates/index.tpl
index efea18c986..efea18c986 100644
--- a/plugins/UserCountry/index.tpl
+++ b/plugins/UserCountry/templates/index.tpl
diff --git a/plugins/UserSettings/Controller.php b/plugins/UserSettings/Controller.php
index 055a4c2f5b..f8306b39d0 100644
--- a/plugins/UserSettings/Controller.php
+++ b/plugins/UserSettings/Controller.php
@@ -4,7 +4,7 @@ class Piwik_UserSettings_Controller extends Piwik_Controller
{
function index()
{
- $view = new Piwik_View('UserSettings/index.tpl');
+ $view = new Piwik_View('UserSettings/templates/index.tpl');
$view->dataTablePlugin = $this->getPlugin( true );
$view->dataTableResolution = $this->getResolution( true );
diff --git a/plugins/UserSettings/UserSettings.php b/plugins/UserSettings/UserSettings.php
index 0ead724fcf..5ab97e0bb8 100644
--- a/plugins/UserSettings/UserSettings.php
+++ b/plugins/UserSettings/UserSettings.php
@@ -38,7 +38,7 @@ class Piwik_UserSettings extends Piwik_Plugin
static public $browserType_display = array(
'ie' => 'Internet Explorer',
'gecko' => 'Gecko (Mozilla, Netscape)',
- 'khtml' => 'Khtml (Konqueror, Safari)',
+ 'khtml' => 'KHTML (Safari, Chrome)',
'opera' => 'Opera',
);
@@ -55,13 +55,13 @@ class Piwik_UserSettings extends Piwik_Plugin
function addWidgets()
{
- Piwik_AddWidget( 'UserSettings', 'getResolution', Piwik_Translate('UserSettings_WidgetResolutions'));
- Piwik_AddWidget( 'UserSettings', 'getBrowser', Piwik_Translate('UserSettings_WidgetBrowsers'));
- Piwik_AddWidget( 'UserSettings', 'getPlugin', Piwik_Translate('UserSettings_WidgetPlugins'));
- Piwik_AddWidget( 'UserSettings', 'getWideScreen', Piwik_Translate('UserSettings_WidgetWidescreen'));
- Piwik_AddWidget( 'UserSettings', 'getBrowserType', Piwik_Translate('UserSettings_WidgetBrowserFamilies'));
- Piwik_AddWidget( 'UserSettings', 'getOS', Piwik_Translate('UserSettings_WidgetOperatingSystems'));
- Piwik_AddWidget( 'UserSettings', 'getConfiguration', Piwik_Translate('UserSettings_WidgetGlobalVisitors'));
+ Piwik_AddWidget( 'UserSettings_VisitorSettings', 'UserSettings_WidgetResolutions', 'UserSettings', 'getResolution');
+ Piwik_AddWidget( 'UserSettings_VisitorSettings', 'UserSettings_WidgetBrowsers', 'UserSettings', 'getBrowser');
+ Piwik_AddWidget( 'UserSettings_VisitorSettings', 'UserSettings_WidgetPlugins', 'UserSettings', 'getPlugin');
+ Piwik_AddWidget( 'UserSettings_VisitorSettings', 'UserSettings_WidgetWidescreen', 'UserSettings', 'getWideScreen');
+ Piwik_AddWidget( 'UserSettings_VisitorSettings', 'UserSettings_WidgetBrowserFamilies', 'UserSettings', 'getBrowserType');
+ Piwik_AddWidget( 'UserSettings_VisitorSettings', 'UserSettings_WidgetOperatingSystems', 'UserSettings', 'getOS');
+ Piwik_AddWidget( 'UserSettings_VisitorSettings', 'UserSettings_WidgetGlobalVisitors', 'UserSettings', 'getConfiguration');
}
function addMenu()
diff --git a/plugins/UserSettings/index.tpl b/plugins/UserSettings/templates/index.tpl
index 91400a6e7c..91400a6e7c 100644
--- a/plugins/UserSettings/index.tpl
+++ b/plugins/UserSettings/templates/index.tpl
diff --git a/plugins/UsersManager/templates/UsersManager.js b/plugins/UsersManager/templates/UsersManager.js
index 2b1e446270..5dc9fa9ca2 100644
--- a/plugins/UsersManager/templates/UsersManager.js
+++ b/plugins/UsersManager/templates/UsersManager.js
@@ -200,7 +200,7 @@ $(document).ready( function() {
ajaxHideError();
var idRow = $(this).attr('id');
var loginToDelete = $(this).parent().parent().find('#userLogin').html();
- if( confirm(sprintf(_pk_translate('UsersManager_DeleteConfirm'),'"'+loginToDelete+'"')) )
+ if( confirm(sprintf(_pk_translate('UsersManager_DeleteConfirm_js'),'"'+loginToDelete+'"')) )
{
$.ajax( getDeleteUserAJAX( loginToDelete ) );
}
diff --git a/plugins/VisitFrequency/API.php b/plugins/VisitFrequency/API.php
index 70e6010a02..ab9ed031b2 100644
--- a/plugins/VisitFrequency/API.php
+++ b/plugins/VisitFrequency/API.php
@@ -26,19 +26,36 @@ class Piwik_VisitFrequency_API
return self::$instance;
}
- public function getSummary( $idSite, $period, $date )
+ public function get( $idSite, $period, $date, $columns = array() )
{
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
- $toFetch = array( 'nb_uniq_visitors_returning',
- 'nb_visits_returning',
- 'nb_actions_returning',
- 'max_actions_returning',
- 'sum_visit_length_returning',
- 'bounce_count_returning',
- 'nb_visits_converted_returning',
- );
+ $bounceRateReturningRequested = false;
+ if(!empty($columns))
+ {
+ $toFetch = $columns;
+ if(($bounceRateReturningRequested = array_search('bounce_rate_returning', $toFetch)) !== false)
+ {
+ $toFetch = array('nb_visits_returning', 'bounce_count_returning');
+ }
+ }
+ else
+ {
+ $toFetch = array( 'nb_uniq_visitors_returning',
+ 'nb_visits_returning',
+ 'nb_actions_returning',
+ 'max_actions_returning',
+ 'sum_visit_length_returning',
+ 'bounce_count_returning',
+ 'nb_visits_converted_returning',
+ );
+ }
$dataTable = $archive->getDataTableFromNumeric($toFetch);
+ if($bounceRateReturningRequested !== false)
+ {
+ $dataTable->filter('ColumnCallbackAddColumnPercentage', array('bounce_count_returning', 'bounce_rate_returning', 'nb_visits_returning', 0));
+ $dataTable->deleteColumns($toFetch);
+ }
return $dataTable;
}
diff --git a/plugins/VisitFrequency/Controller.php b/plugins/VisitFrequency/Controller.php
index 366ed17ab4..e792b0a104 100644
--- a/plugins/VisitFrequency/Controller.php
+++ b/plugins/VisitFrequency/Controller.php
@@ -5,70 +5,61 @@ class Piwik_VisitFrequency_Controller extends Piwik_Controller
{
function index()
{
- $view = new Piwik_View('VisitFrequency/index.tpl');
- $view->graphEvolutionVisitFrequency = $this->getLastVisitsReturningGraph( true );
+ $view = new Piwik_View('VisitFrequency/templates/index.tpl');
+ $view->graphEvolutionVisitFrequency = $this->getEvolutionGraph(true, array('nb_visits_returning') );
$this->setSparklinesAndNumbers($view);
echo $view->render();
}
- protected function setSparklinesAndNumbers($view)
+ public function getSparklines()
{
-
- $view->urlSparklineNbVisitsReturning = $this->getUrlSparkline( 'getLastVisitsReturningGraph');
- $view->urlSparklineNbActionsReturning = $this->getUrlSparkline( 'getLastActionsReturningGraph');
- $view->urlSparklineSumVisitLengthReturning = $this->getUrlSparkline( 'getLastSumVisitsLengthReturningGraph');
- $view->urlSparklineMaxActionsReturning = $this->getUrlSparkline( 'getLastMaxActionsReturningGraph');
- $view->urlSparklineBounceCountReturning = $this->getUrlSparkline( 'getLastBounceCountReturningGraph');
-
- $dataTableFrequency = $this->getSummary();
- $view->nbVisitsReturning = $dataTableFrequency->getColumn('nb_visits_returning');
- $view->nbActionsReturning = $dataTableFrequency->getColumn('nb_actions_returning');
- $view->maxActionsReturning = $dataTableFrequency->getColumn('max_actions_returning');
- $view->sumVisitLengthReturning = $dataTableFrequency->getColumn('sum_visit_length_returning');
- $view->bounceCountReturning = $dataTableFrequency->getColumn('bounce_count_returning');
- }
-
- function getSparklines()
- {
- $view = new Piwik_View('VisitFrequency/sparklines.tpl');
+ $view = new Piwik_View('VisitFrequency/templates/sparklines.tpl');
$this->setSparklinesAndNumbers($view);
echo $view->render();
}
-
- protected function getSummary()
- {
- $requestString = "method=VisitFrequency.getSummary&format=original";
- $request = new Piwik_API_Request($requestString);
- return $request->process();
- }
-
- function getLastVisitsReturningGraph( $fetch = false )
- {
- $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "VisitFrequency.getVisitsReturning");
- return $this->renderView($view, $fetch);
- }
-
- function getLastActionsReturningGraph( $fetch = false )
- {
- $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "VisitFrequency.getActionsReturning");
- return $this->renderView($view, $fetch);
- }
- function getLastSumVisitsLengthReturningGraph( $fetch = false )
+ public function getEvolutionGraph( $fetch = false, $columns = false)
{
- $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "VisitFrequency.getSumVisitsLengthReturning");
+ $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "VisitFrequency.get");
+ if(empty($columns))
+ {
+ $columns = Piwik_Common::getRequestVar('columns');
+ }
+ $view->setColumnsToDisplay($columns);
+ $view->setColumnsTranslations(array(
+ 'nb_visits_returning' => Piwik_Translate('VisitFrequency_ColumnReturningVisits'),
+ 'nb_actions_returning' => Piwik_Translate('VisitFrequency_ColumnActionsByReturningVisits'),
+ 'max_actions_returning' => Piwik_Translate('VisitFrequency_ColumnMaximumActionsByAReturningVisit'),
+ 'sum_visit_length_returning' => Piwik_Translate('VisitFrequency_ColumnTotalTimeSpentByReturningVisits'),
+ 'bounce_rate_returning' => Piwik_Translate('VisitFrequency_ColumnBounceRateForReturningVisits'),
+ ));
return $this->renderView($view, $fetch);
}
- function getLastMaxActionsReturningGraph( $fetch = false )
+ protected function setSparklinesAndNumbers($view)
{
- $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "VisitFrequency.getMaxActionsReturning");
- return $this->renderView($view, $fetch);
+ $view->urlSparklineNbVisitsReturning = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('nb_visits_returning')));
+ $view->urlSparklineNbActionsReturning = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('nb_actions_returning')));
+ $view->urlSparklineMaxActionsReturning = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('max_actions_returning')));
+ $view->urlSparklineSumVisitLengthReturning = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('sum_visit_length_returning')));
+ $view->urlSparklineBounceRateReturning = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('bounce_rate_returning')));
+
+ $dataTableFrequency = $this->getSummary();
+ $dataRow = $dataTableFrequency->getFirstRow();
+ $nbVisitsReturning = $dataRow->getColumn('nb_visits_returning');
+ $view->nbVisitsReturning = $nbVisitsReturning;
+ $view->nbActionsReturning = $dataRow->getColumn('nb_actions_returning');
+ $view->maxActionsReturning = $dataRow->getColumn('max_actions_returning');
+ $view->sumVisitLengthReturning = $dataRow->getColumn('sum_visit_length_returning');
+ $nbBouncedReturningVisits = $dataRow->getColumn('bounce_count_returning');
+ $view->bounceRateReturning = Piwik::getPercentageSafe($nbBouncedReturningVisits, $nbVisitsReturning);
+
}
-
- function getLastBounceCountReturningGraph( $fetch = false )
- {
- $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "VisitFrequency.getBounceCountReturning");
- return $this->renderView($view, $fetch);
+
+ protected function getSummary()
+ {
+ $requestString = "method=VisitFrequency.get&format=original";
+ $request = new Piwik_API_Request($requestString);
+ return $request->process();
}
}
diff --git a/plugins/VisitFrequency/VisitFrequency.php b/plugins/VisitFrequency/VisitFrequency.php
index 226960bc4a..fbab275603 100644
--- a/plugins/VisitFrequency/VisitFrequency.php
+++ b/plugins/VisitFrequency/VisitFrequency.php
@@ -40,8 +40,8 @@ class Piwik_VisitFrequency extends Piwik_Plugin
function addWidgets()
{
- Piwik_AddWidget( 'VisitFrequency', 'getSparklines', Piwik_Translate('VisitFrequency_WidgetOverview'));
- Piwik_AddWidget( 'VisitFrequency', 'getLastVisitsReturningGraph', Piwik_Translate('VisitFrequency_WidgetGraphReturning'));
+ Piwik_AddWidget( 'General_Visitors', 'VisitFrequency_WidgetOverview', 'VisitFrequency', 'getSparklines');
+ Piwik_AddWidget( 'General_Visitors', 'VisitFrequency_WidgetGraphReturning', 'VisitFrequency', 'getEvolutionGraph', array('columns' => array('nb_visits_returning')));
}
function addMenu()
diff --git a/plugins/VisitFrequency/sparklines.tpl b/plugins/VisitFrequency/sparklines.tpl
deleted file mode 100644
index bccbd06ea4..0000000000
--- a/plugins/VisitFrequency/sparklines.tpl
+++ /dev/null
@@ -1,13 +0,0 @@
-
- <p>{sparkline src=$urlSparklineNbVisitsReturning}<span>
- {'VisitFrequency_ReturnVisits'|translate:"<strong>$nbVisitsReturning</strong>"}</span></p>
- <p>{sparkline src=$urlSparklineNbActionsReturning}<span>
- {'VisitFrequency_ReturnActions'|translate:"<strong>$nbActionsReturning</strong>"}</span></p>
- <p>{sparkline src=$urlSparklineMaxActionsReturning}<span>
- {'VisitFrequency_ReturnMaxActions'|translate:"<strong>$maxActionsReturning</strong>"}</span></p>
- <p>{sparkline src=$urlSparklineSumVisitLengthReturning}<span>
- {assign var=sumtimeVisitLengthReturning value=$sumVisitLengthReturning|sumtime}
- {'VisitFrequency_ReturnTotalTime'|translate:"<strong>$sumtimeVisitLengthReturning</strong>"}</span></p>
- <p>{sparkline src=$urlSparklineBounceCountReturning}<span>
- {'VisitFrequency_ReturnBounces'|translate:"<strong>$bounceCountReturning</strong>"} </span></p>
-
diff --git a/plugins/VisitFrequency/index.tpl b/plugins/VisitFrequency/templates/index.tpl
index 069a56d4df..ec4664d310 100644
--- a/plugins/VisitFrequency/index.tpl
+++ b/plugins/VisitFrequency/templates/index.tpl
@@ -1,11 +1,11 @@
{postEvent name="template_headerVisitsFrequency"}
<script type="text/javascript" src="plugins/CoreHome/templates/sparkline.js"></script>
-<a name="evolutionGraph" graphId="VisitFrequencygetLastVisitsReturningGraph"></a>
+<a name="evolutionGraph" graphId="VisitFrequencygetEvolutionGraph"></a>
<h2>{'VisitFrequency_Evolution'|translate}</h2>
{$graphEvolutionVisitFrequency}
<br />
-{include file=VisitFrequency/sparklines.tpl}
+{include file=VisitFrequency/templates/sparklines.tpl}
{postEvent name="template_footerVisitsFrequency"}
diff --git a/plugins/VisitFrequency/templates/sparklines.tpl b/plugins/VisitFrequency/templates/sparklines.tpl
new file mode 100644
index 0000000000..a72ae2eb6c
--- /dev/null
+++ b/plugins/VisitFrequency/templates/sparklines.tpl
@@ -0,0 +1,11 @@
+<div class="sparkline">{sparkline src=$urlSparklineNbVisitsReturning}
+{'VisitFrequency_ReturnVisits'|translate:"<strong>$nbVisitsReturning</strong>"}</div>
+<div class="sparkline">{sparkline src=$urlSparklineNbActionsReturning}
+{'VisitFrequency_ReturnActions'|translate:"<strong>$nbActionsReturning</strong>"}</div>
+<div class="sparkline">{sparkline src=$urlSparklineMaxActionsReturning}
+ {'VisitFrequency_ReturnMaxActions'|translate:"<strong>$maxActionsReturning</strong>"}</div>
+<div class="sparkline">{sparkline src=$urlSparklineSumVisitLengthReturning}
+ {assign var=sumtimeVisitLengthReturning value=$sumVisitLengthReturning|sumtime}
+ {'VisitFrequency_ReturnTotalTime'|translate:"<strong>$sumtimeVisitLengthReturning</strong>"}</div>
+<div class="sparkline">{sparkline src=$urlSparklineBounceRateReturning}
+ {'VisitFrequency_ReturnBounceRate'|translate:"<strong>$bounceRateReturning%</strong>"} </div> \ No newline at end of file
diff --git a/plugins/VisitTime/Controller.php b/plugins/VisitTime/Controller.php
index 923c406a1e..0a21a346ac 100644
--- a/plugins/VisitTime/Controller.php
+++ b/plugins/VisitTime/Controller.php
@@ -5,7 +5,7 @@ class Piwik_VisitTime_Controller extends Piwik_Controller
{
function index()
{
- $view = new Piwik_View('VisitTime/index.tpl');
+ $view = new Piwik_View('VisitTime/templates/index.tpl');
$view->dataTableVisitInformationPerLocalTime = $this->getVisitInformationPerLocalTime(true);
$view->dataTableVisitInformationPerServerTime = $this->getVisitInformationPerServerTime(true);
echo $view->render();
diff --git a/plugins/VisitTime/VisitTime.php b/plugins/VisitTime/VisitTime.php
index 531c303014..8d32d3012f 100644
--- a/plugins/VisitTime/VisitTime.php
+++ b/plugins/VisitTime/VisitTime.php
@@ -40,8 +40,8 @@ class Piwik_VisitTime extends Piwik_Plugin
function addWidgets()
{
- Piwik_AddWidget( 'VisitTime', 'getVisitInformationPerLocalTime', Piwik_Translate('VisitTime_WidgetLocalTime'));
- Piwik_AddWidget( 'VisitTime', 'getVisitInformationPerServerTime', Piwik_Translate('VisitTime_WidgetServerTime'));
+ Piwik_AddWidget( 'VisitTime_SubmenuTimes', 'VisitTime_WidgetLocalTime', 'VisitTime', 'getVisitInformationPerLocalTime');
+ Piwik_AddWidget( 'VisitTime_SubmenuTimes', 'VisitTime_WidgetServerTime', 'VisitTime', 'getVisitInformationPerServerTime');
}
function addMenu()
@@ -101,7 +101,7 @@ class Piwik_VisitTime extends Piwik_Plugin
private function makeSureAllHoursAreSet($table, $archiveProcessing)
{
- for($i=0;$i<=23;$i++)
+ for($i=0; $i<=23; $i++)
{
if($table->getRowFromLabel($i) === false)
{
diff --git a/plugins/VisitTime/index.tpl b/plugins/VisitTime/templates/index.tpl
index 82af946c7a..82af946c7a 100644
--- a/plugins/VisitTime/index.tpl
+++ b/plugins/VisitTime/templates/index.tpl
diff --git a/plugins/VisitorInterest/Controller.php b/plugins/VisitorInterest/Controller.php
index dcca856b3a..cd4817ef3d 100644
--- a/plugins/VisitorInterest/Controller.php
+++ b/plugins/VisitorInterest/Controller.php
@@ -5,7 +5,7 @@ class Piwik_VisitorInterest_Controller extends Piwik_Controller
{
function index()
{
- $view = new Piwik_View('VisitorInterest/index.tpl');
+ $view = new Piwik_View('VisitorInterest/templates/index.tpl');
$view->dataTableNumberOfVisitsPerVisitDuration = $this->getNumberOfVisitsPerVisitDuration(true);
$view->dataTableNumberOfVisitsPerPage = $this->getNumberOfVisitsPerPage(true);
echo $view->render();
diff --git a/plugins/VisitorInterest/VisitorInterest.php b/plugins/VisitorInterest/VisitorInterest.php
index 3f36d8b474..d5bb5091b1 100644
--- a/plugins/VisitorInterest/VisitorInterest.php
+++ b/plugins/VisitorInterest/VisitorInterest.php
@@ -66,9 +66,10 @@ class Piwik_VisitorInterest extends Piwik_Plugin
function addWidgets()
{
- Piwik_AddWidget( 'VisitorInterest', 'getNumberOfVisitsPerVisitDuration', Piwik_Translate('VisitorInterest_WidgetLengths'));
- Piwik_AddWidget( 'VisitorInterest', 'getNumberOfVisitsPerPage', Piwik_Translate('VisitorInterest_WidgetPages'));
+ Piwik_AddWidget( 'General_Visitors', 'VisitorInterest_WidgetLengths', 'VisitorInterest', 'getNumberOfVisitsPerVisitDuration');
+ Piwik_AddWidget( 'General_Visitors', 'VisitorInterest_WidgetPages', 'VisitorInterest', 'getNumberOfVisitsPerPage');
}
+
function addMenu()
{
Piwik_RenameMenuEntry('General_Visitors', 'VisitFrequency_SubmenuFrequency',
diff --git a/plugins/VisitorInterest/index.tpl b/plugins/VisitorInterest/templates/index.tpl
index f3855a44dc..f3855a44dc 100644
--- a/plugins/VisitorInterest/index.tpl
+++ b/plugins/VisitorInterest/templates/index.tpl
diff --git a/plugins/VisitsSummary/API.php b/plugins/VisitsSummary/API.php
index ed9a75df7c..e042e518df 100644
--- a/plugins/VisitsSummary/API.php
+++ b/plugins/VisitsSummary/API.php
@@ -25,20 +25,37 @@ class Piwik_VisitsSummary_API
return self::$instance;
}
- public function get( $idSite, $period, $date )
+ public function get( $idSite, $period, $date, $columns = array() )
{
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
- $toFetch = array( 'max_actions',
- 'nb_uniq_visitors',
- 'nb_visits',
- 'nb_actions',
- 'sum_visit_length',
- 'bounce_count',
- 'nb_visits_converted',
- );
+ $bounceRateRequested = false;
+ if(!empty($columns))
+ {
+ $toFetch = $columns;
+ if(($bounceRateRequested = array_search('bounce_rate', $toFetch)) !== false)
+ {
+ $toFetch = array('nb_visits', 'bounce_count');
+ }
+ }
+ else
+ {
+ $toFetch = array( 'max_actions',
+ 'nb_uniq_visitors',
+ 'nb_visits',
+ 'nb_actions',
+ 'sum_visit_length',
+ 'bounce_count',
+ 'nb_visits_converted',
+ );
+ }
$dataTable = $archive->getDataTableFromNumeric($toFetch);
+ if($bounceRateRequested !== false)
+ {
+ $dataTable->filter('ColumnCallbackAddColumnPercentage', array('bounce_count', 'bounce_rate', 'nb_visits', 0));
+ $dataTable->deleteColumns($toFetch);
+ }
return $dataTable;
}
@@ -70,23 +87,23 @@ class Piwik_VisitsSummary_API
return self::getNumeric( $idSite, $period, $date, 'max_actions');
}
- public function getSumVisitsLength( $idSite, $period, $date )
+ public function getBounceCount( $idSite, $period, $date )
{
- return self::getNumeric( $idSite, $period, $date, 'sum_visit_length');
+ return self::getNumeric( $idSite, $period, $date, 'bounce_count');
}
- public function getSumVisitsLengthPretty( $idSite, $period, $date )
+ public function getVisitsConverted( $idSite, $period, $date )
{
- return Piwik::getPrettyTimeFromSeconds(self::getSumVisitsLength( $idSite, $period, $date ));
+ return self::getNumeric( $idSite, $period, $date, 'nb_visits_converted');
}
- public function getBounceCount( $idSite, $period, $date )
+ public function getSumVisitsLength( $idSite, $period, $date )
{
- return self::getNumeric( $idSite, $period, $date, 'bounce_count');
+ return self::getNumeric( $idSite, $period, $date, 'sum_visit_length');
}
- public function getVisitsConverted( $idSite, $period, $date )
+ public function getSumVisitsLengthPretty( $idSite, $period, $date )
{
- return self::getNumeric( $idSite, $period, $date, 'nb_visits_converted');
+ return Piwik::getPrettyTimeFromSeconds(self::getSumVisitsLength( $idSite, $period, $date ));
}
}
diff --git a/plugins/VisitsSummary/Controller.php b/plugins/VisitsSummary/Controller.php
index 9f7b5ad296..d622dfb19b 100644
--- a/plugins/VisitsSummary/Controller.php
+++ b/plugins/VisitsSummary/Controller.php
@@ -3,51 +3,31 @@ require_once "ViewDataTable.php";
class Piwik_VisitsSummary_Controller extends Piwik_Controller
{
- function index()
+ public function index()
{
- $view = new Piwik_View('VisitsSummary/index.tpl');
+ $view = new Piwik_View('VisitsSummary/templates/index.tpl');
$this->setPeriodVariablesView($view);
- $view->graphEvolutionVisitsSummary = $this->getLastVisitsGraph( true );
+ $view->graphEvolutionVisitsSummary = $this->getEvolutionGraph( true, array('nb_visits') );
$this->setSparklinesAndNumbers($view);
echo $view->render();
}
- protected function setSparklinesAndNumbers($view)
+ public function getSparklines()
{
- $view->urlSparklineNbVisits = $this->getUrlSparkline( 'getLastVisitsGraph');
- $view->urlSparklineNbActions = $this->getUrlSparkline( 'getLastActionsGraph');
- $view->urlSparklineSumVisitLength = $this->getUrlSparkline( 'getLastSumVisitsLengthGraph');
- $view->urlSparklineMaxActions = $this->getUrlSparkline( 'getLastMaxActionsGraph');
- $view->urlSparklineBounceCount = $this->getUrlSparkline( 'getLastBounceCountGraph');
-
- $dataTableVisit = self::getVisitsSummary();
-
- if($view->period == 'day')
- {
- $view->urlSparklineNbUniqVisitors = $this->getUrlSparkline( 'getLastUniqueVisitorsGraph');
- $view->nbUniqVisitors = $dataTableVisit->getColumn('nb_uniq_visitors');
- }
- $view->nbVisits = $dataTableVisit->getColumn('nb_visits');
- $view->nbActions = $dataTableVisit->getColumn('nb_actions');
- $view->sumVisitLength = $dataTableVisit->getColumn('sum_visit_length');
- $view->bounceCount = $dataTableVisit->getColumn('bounce_count');
- $view->maxActions = $dataTableVisit->getColumn('max_actions');
- }
-
- function getSparklines()
- {
- $view = new Piwik_View('VisitsSummary/sparklines.tpl');
+ $view = new Piwik_View('VisitsSummary/templates/sparklines.tpl');
$this->setSparklinesAndNumbers($view);
echo $view->render();
}
- static public function getVisits()
+ public function getEvolutionGraph( $fetch = false, $columns = false)
{
- $requestString = "method=VisitsSummary.getVisits".
- "&format=original".
- "&disable_generic_filters=true";
- $request = new Piwik_API_Request($requestString);
- return $request->process();
+ $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "VisitsSummary.get");
+ if(empty($columns))
+ {
+ $columns = Piwik_Common::getRequestVar('columns');
+ }
+ $view->setColumnsToDisplay($columns);
+ return $this->renderView($view, $fetch);
}
static public function getVisitsSummary()
@@ -61,39 +41,36 @@ class Piwik_VisitsSummary_Controller extends Piwik_Controller
return $request->process();
}
- function getLastVisitsGraph( $fetch = false )
- {
- $view = $this->getLastUnitGraph('VisitsSummary', __FUNCTION__, "VisitsSummary.getVisits");
- return $this->renderView($view, $fetch);
- }
-
- function getLastUniqueVisitorsGraph( $fetch = false )
- {
- $view = $this->getLastUnitGraph('VisitsSummary', __FUNCTION__, "VisitsSummary.getUniqueVisitors");
- return $this->renderView($view, $fetch);
- }
-
- function getLastActionsGraph( $fetch = false )
- {
- $view = $this->getLastUnitGraph('VisitsSummary', __FUNCTION__, "VisitsSummary.getActions");
- return $this->renderView($view, $fetch);
- }
-
- function getLastSumVisitsLengthGraph( $fetch = false )
- {
- $view = $this->getLastUnitGraph('VisitsSummary', __FUNCTION__, "VisitsSummary.getSumVisitsLength");
- return $this->renderView($view, $fetch);
- }
-
- function getLastMaxActionsGraph( $fetch = false )
+ static public function getVisits()
{
- $view = $this->getLastUnitGraph('VisitsSummary', __FUNCTION__, "VisitsSummary.getMaxActions");
- return $this->renderView($view, $fetch);
+ $requestString = "method=VisitsSummary.getVisits".
+ "&format=original".
+ "&disable_generic_filters=true";
+ $request = new Piwik_API_Request($requestString);
+ return $request->process();
}
- function getLastBounceCountGraph( $fetch = false )
+ protected function setSparklinesAndNumbers($view)
{
- $view = $this->getLastUnitGraph('VisitsSummary', __FUNCTION__, "VisitsSummary.getBounceCount");
- return $this->renderView($view, $fetch);
+ $view->urlSparklineNbVisits = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('nb_visits')));
+ $view->urlSparklineNbActions = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('nb_actions')));
+ $view->urlSparklineSumVisitLength = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('sum_visit_length')));
+ $view->urlSparklineMaxActions = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('max_actions')));
+ $view->urlSparklineBounceRate = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('bounce_rate')));
+
+ $dataTableVisit = self::getVisitsSummary();
+ $dataRow = $dataTableVisit->getFirstRow();
+ if($view->period == 'day')
+ {
+ $view->urlSparklineNbUniqVisitors = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('nb_uniq_visitors')));
+ $view->nbUniqVisitors = $dataRow->getColumn('nb_uniq_visitors');
+ }
+ $nbVisits = $dataRow->getColumn('nb_visits');
+ $view->nbVisits = $nbVisits;
+ $view->nbActions = $dataRow->getColumn('nb_actions');
+ $view->sumVisitLength = $dataRow->getColumn('sum_visit_length');
+ $nbBouncedVisits = $dataRow->getColumn('bounce_count');
+ $view->bounceRate = Piwik::getPercentageSafe($nbBouncedVisits, $nbVisits);
+ $view->maxActions = $dataRow->getColumn('max_actions');
}
}
diff --git a/plugins/VisitsSummary/VisitsSummary.php b/plugins/VisitsSummary/VisitsSummary.php
index 29e4398a90..846a3dcb5e 100644
--- a/plugins/VisitsSummary/VisitsSummary.php
+++ b/plugins/VisitsSummary/VisitsSummary.php
@@ -36,10 +36,9 @@ class Piwik_VisitsSummary extends Piwik_Plugin
function addWidgets()
{
- Piwik_AddWidget( 'VisitsSummary', 'getLastVisitsGraph', Piwik_Translate('VisitsSummary_WidgetLastVisits'));
- Piwik_AddWidget( 'VisitsSummary', 'getSparklines', Piwik_Translate('VisitsSummary_WidgetVisits'));
- Piwik_AddWidget( 'VisitsSummary', 'getLastUniqueVisitorsGraph', Piwik_Translate('VisitsSummary_WidgetLastVisitors'));
- Piwik_AddWidget( 'VisitsSummary', 'index', Piwik_Translate('VisitsSummary_WidgetOverviewGraph'));
+ Piwik_AddWidget( 'Visits Summary', 'VisitsSummary_WidgetLastVisits', 'VisitsSummary', 'getEvolutionGraph', array('columns' => array('nb_visits')));
+ Piwik_AddWidget( 'Visits Summary', 'VisitsSummary_WidgetVisits', 'VisitsSummary', 'getSparklines');
+ Piwik_AddWidget( 'Visits Summary', 'VisitsSummary_WidgetOverviewGraph', 'VisitsSummary', 'index');
}
function addMenu()
diff --git a/plugins/VisitsSummary/sparklines.tpl b/plugins/VisitsSummary/sparklines.tpl
deleted file mode 100644
index 7d0f2e28d7..0000000000
--- a/plugins/VisitsSummary/sparklines.tpl
+++ /dev/null
@@ -1,13 +0,0 @@
-<div id='leftcolumn'>
- <p>{sparkline src=$urlSparklineNbVisits} <span>{'VisitsSummary_NbVisits'|translate:"<strong>$nbVisits</strong>"}</span></p>
- {if isset($urlSparklineNbUniqVisitors)}
- <p>{sparkline src=$urlSparklineNbUniqVisitors} <span>{'VisitsSummary_NbUniqueVisitors'|translate:"<strong>$nbUniqVisitors</strong>"}</span></p>
- {/if}
- <p>{sparkline src=$urlSparklineNbActions} <span>{'VisitsSummary_NbActions'|translate:"<strong>$nbActions</strong>"}</span></p>
-</div>
-<div id='rightcolumn'>
- <p>{sparkline src=$urlSparklineSumVisitLength} <span>{assign var=sumtimeVisitLength value=$sumVisitLength|sumtime} {'VisitsSummary_TotalTime'|translate:"<strong>$sumtimeVisitLength</strong>"}</span></p>
- <p>{sparkline src=$urlSparklineMaxActions} <span>{'VisitsSummary_MaxNbActions'|translate:"<strong>$maxActions</strong>"}</span></p>
- <p>{sparkline src=$urlSparklineBounceCount} <span>{'VisitsSummary_NbBounced'|translate:"<strong>$bounceCount</strong>"}</span></p>
-</div>
-<div style="clear:both" /> \ No newline at end of file
diff --git a/plugins/VisitsSummary/index.tpl b/plugins/VisitsSummary/templates/index.tpl
index 8e8e51398d..7255107589 100644
--- a/plugins/VisitsSummary/index.tpl
+++ b/plugins/VisitsSummary/templates/index.tpl
@@ -1,11 +1,12 @@
+
<script type="text/javascript" src="plugins/CoreHome/templates/sparkline.js"></script>
-<a name="evolutionGraph" graphId="VisitsSummarygetLastVisitsGraph"></a>
-<h2>{'VisitsSummary_EvolutionPeriods'|translate:$periodsNames.$period.plural}</h2>
+<a name="evolutionGraph" graphId="VisitsSummarygetEvolutionGraph"></a>
+<h2>{'VisitsSummary_EvolutionOverLastPeriods'|translate:$periodsNames.$period.plural}</h2>
{$graphEvolutionVisitsSummary}
<h2>{'VisitsSummary_Report'|translate}</h2>
-{include file=VisitsSummary/sparklines.tpl}
+{include file=VisitsSummary/templates/sparklines.tpl}
<br /><br /><br />
<p style='color:lightgrey; size:0.8em;'>
diff --git a/plugins/VisitsSummary/templates/sparklines.tpl b/plugins/VisitsSummary/templates/sparklines.tpl
new file mode 100644
index 0000000000..f8ce97cc29
--- /dev/null
+++ b/plugins/VisitsSummary/templates/sparklines.tpl
@@ -0,0 +1,13 @@
+<div id='leftcolumn'>
+ <div class="sparkline">{sparkline src=$urlSparklineNbVisits} {'VisitsSummary_NbVisits'|translate:"<strong>$nbVisits</strong>"}</div>
+ {if isset($urlSparklineNbUniqVisitors)}
+ <div class="sparkline">{sparkline src=$urlSparklineNbUniqVisitors} {'VisitsSummary_NbUniqueVisitors'|translate:"<strong>$nbUniqVisitors</strong>"}</div>
+ {/if}
+ <div class="sparkline">{sparkline src=$urlSparklineNbActions} {'VisitsSummary_NbActions'|translate:"<strong>$nbActions</strong>"}</div>
+</div>
+<div id='rightcolumn'>
+ <div class="sparkline">{sparkline src=$urlSparklineSumVisitLength} {assign var=sumtimeVisitLength value=$sumVisitLength|sumtime} {'VisitsSummary_TotalTime'|translate:"<strong>$sumtimeVisitLength</strong>"}</div>
+ <div class="sparkline">{sparkline src=$urlSparklineMaxActions} {'VisitsSummary_MaxNbActions'|translate:"<strong>$maxActions</strong>"}</div>
+ <div class="sparkline">{sparkline src=$urlSparklineBounceRate} {'VisitsSummary_NbVisitsBounced'|translate:"<strong>$bounceRate%</strong>"}</div>
+</div>
+<div style="clear:both" /> \ No newline at end of file
diff --git a/plugins/Widgetize/templates/iframe.tpl b/plugins/Widgetize/templates/iframe.tpl
index 0cb5f23cf9..6d61d51ada 100644
--- a/plugins/Widgetize/templates/iframe.tpl
+++ b/plugins/Widgetize/templates/iframe.tpl
@@ -4,20 +4,9 @@
{loadJavascriptTranslations plugins='CoreHome'}
{include file="CoreHome/templates/js_global_variables.tpl"}
-<script type="text/javascript" src="libs/jquery/jquery.js"></script>
-<script type="text/javascript" src="libs/javascript/sprintf.js"></script>
-<script type="text/javascript" src="themes/default/common.js"></script>
-<script type="text/javascript" src="libs/jquery/jquery.dimensions.js"></script>
-<script type="text/javascript" src="libs/jquery/tooltip/jquery.tooltip.js"></script>
-<script type="text/javascript" src="libs/jquery/truncate/jquery.truncate.js"></script>
-<script type="text/javascript" src="libs/jquery/jquery.scrollTo.js"></script>
+{include file="CoreHome/templates/js_css_includes.tpl"}
-<script type="text/javascript" src="libs/swfobject/swfobject.js"></script>
-
-<script type="text/javascript" src="plugins/CoreHome/templates/datatable.js"></script>
-<link rel="stylesheet" href="plugins/CoreHome/templates/datatable.css">
-
-<div class="widgetDiv">
+<div class="widget">
{$content}
</div>
diff --git a/plugins/Widgetize/templates/index.tpl b/plugins/Widgetize/templates/index.tpl
index 8254bf9fef..cf78a1f1dd 100644
--- a/plugins/Widgetize/templates/index.tpl
+++ b/plugins/Widgetize/templates/index.tpl
@@ -4,7 +4,6 @@
{loadJavascriptTranslations plugins='Dashboard'}
<script type="text/javascript" src="plugins/Dashboard/templates/widgetMenu.js"></script>
-
<script type="text/javascript" src="themes/default/common.js"></script>
<script type="text/javascript" src="libs/jquery/jquery.dimensions.js"></script>
<script type="text/javascript" src="libs/jquery/tooltip/jquery.tooltip.js"></script>
@@ -65,53 +64,31 @@ label {
$(document).ready( function() {
var menu = new widgetMenu();
var widgetized = new widgetize();
- widgetized.callbackHideButtons();
menu.init();
menu.registerCallbackOnWidgetLoad( widgetized.callbackAddExportButtonsUnderWidget );
- menu.registerCallbackOnMainMenuHover( widgetized.callbackHideButtons );
- menu.registerCallbackOnSubMenuHover( widgetized.callbackSavePluginName );
+ menu.registerCallbackOnMenuHover( widgetized.deleteEmbedElements );
menu.show();
+ $('#exportFullDashboard').html(
+ widgetized.getInputFormWithHtml( 'dashboardEmbed', '<iframe src="'+document.location.protocol + '//' + document.location.hostname + document.location.pathname + '?'+'module=Widgetize&action=iframe&moduleToWidgetize=Dashboard&actionToWidgetize=index&idSite=1&period=week&date=yesterday" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%"></iframe>')
+ );
});
{/literal}
</script>
<div style="max-width:980px;">
-<p>With Piwik, you can export your Web Analytics reports on your blog, website, or intranet dashboard... in one click.
-If you want your widgets to be viewable by everybody, you first have to set the 'view' permissions to the anonymous user in the <a href='?module=UsersManager'>Users Management section</a>.</p>
-<div id="widgetChooser">
- <div class="subMenu" id="sub1">
- </div>
- <div class="subMenu" id="sub2">
- </div>
- <div class="subMenu" id="sub3">
- <div class="widget">
- <div class="widgetDiv previewDiv"></div>
- </div>
-
- <div id="embedThisWidgetIframe">
- <label for="embedThisWidgetIframeInput">&rsaquo; Embed Iframe</label>
- <span id="embedThisWidgetIframeInput"></span>
- </div>
-
- <div id="embedThisWidgetFlash">
- <label for="embedThisWidgetFlashInput">&rsaquo; Embed Flash</label>
- <span id="embedThisWidgetFlashInput"></span>
- </div>
-
- <div id="embedThisWidgetEverywhere">
- <div id="exportThisWidget">
- <label for="flashEmbed">&rsaquo; Export anywhere!</label>
- <img src='http://cdn.clearspring.com/launchpad/static/cs_button_share1.gif'>
- </div>
- <div id="exportThisWidgettest"></div>
- <div id="exportThisWidgetMenu">
- <span style="display:none"><img src="{$piwikUrl}themes/default/images/loading-blue.gif" /></span>
- </div>
- </div>
- </div>
+ <p>With Piwik, you can export your Web Analytics reports on your blog, website, or intranet dashboard... in one click.
+ If you want your widgets to be viewable by everybody, you first have to set the 'view' permissions
+ to the anonymous user in the <a href='?module=UsersManager'>Users Management section</a>.
+ <br>Note: You can also display the full Piwik dashboard in your application or website in an Iframe.
+ For example, for idSite=1 and date=yesterday, you can write: <span id='exportFullDashboard'></span>
+ </p>
- <div class="menuClear"> </div>
-</div>
-<div id='iframeDivToExport' style='display:none;'></div>
+ <div id="widgetChooser">
+ <div class="subMenu" id="sub1"></div>
+ <div class="subMenu" id="sub2"></div>
+ <div class="subMenu" id="sub3"></div>
+ <div class="menuClear"></div>
+ </div>
+ <div id='iframeDivToExport' style='display:none;'></div>
</div>
diff --git a/plugins/Widgetize/templates/js.tpl b/plugins/Widgetize/templates/js.tpl
index 50284a9591..0cce58d362 100644
--- a/plugins/Widgetize/templates/js.tpl
+++ b/plugins/Widgetize/templates/js.tpl
@@ -1,4 +1,4 @@
-{loadJavascriptTranslations noHtml=1 plugins='CoreHome'}
+{loadJavascriptTranslations disableOutputScriptTag=1 plugins='CoreHome'}
document.write('<scr'+'ipt language="javascript" src="{$piwikUrl}libs/swfobject/swfobject.js"></scr'+'ipt>');
document.write('<scr'+'ipt language="javascript" src="{$piwikUrl}libs/javascript/sprintf.js"></scr'+'ipt>');
diff --git a/plugins/Widgetize/templates/widgetize.js b/plugins/Widgetize/templates/widgetize.js
index ad3a05a979..3f30806ff1 100644
--- a/plugins/Widgetize/templates/widgetize.js
+++ b/plugins/Widgetize/templates/widgetize.js
@@ -7,24 +7,31 @@ function widgetize()
return '<input class="formEmbedCode" id="'+inputId+'" value=\''+ htmlEmbed +'\' onclick="javascript:document.getElementById(\''+inputId+'\').focus();document.getElementById(\''+inputId+'\').select();" readonly="true" type="text">';
}
- this.getEmbedUrl = function( pluginId, actionId, exportFormat )
+ this.getEmbedUrl = function( parameters, exportFormat )
{
+ copyParameters = new Object;
+ for(var variableName in parameters) {
+ copyParameters[variableName] = parameters[variableName];
+ }
+ copyParameters['moduleToWidgetize'] = parameters['module'];
+ copyParameters['actionToWidgetize'] = parameters['action'];
+ delete copyParameters['action'];
+ delete copyParameters['module'];
var sourceUrl;
sourceUrl = document.location.protocol + '//' + document.location.hostname + document.location.pathname + '?';
- sourceUrl += "module=Widgetize&action="+exportFormat+"&moduleToWidgetize="+pluginId+"&actionToWidgetize="+actionId+"&idSite="+piwik.idSite+"&period="+piwik.period+"&date="+piwik.currentDateString;
- sourceUrl += "&disableLink=1";
+ sourceUrl += "module=Widgetize" +
+ "&action="+exportFormat+
+ "&"+piwikHelper.getQueryStringFromParameters(copyParameters)+
+ "&idSite="+piwik.idSite+
+ "&period="+piwik.period+
+ "&date="+piwik.currentDateString+
+ "&disableLink=1";
return sourceUrl;
}
- this.callbackSavePluginName = function(pluginName, actionName, widgetName)
+ this.deleteEmbedElements = function()
{
- self.currentWidgetName = widgetName;
- self.callbackHideButtons();
- }
-
- this.callbackHideButtons = function()
- {
- $('#embedThisWidgetIframe, #embedThisWidgetFlash, #embedThisWidgetEverywhere').hide();
+ $('#exportButtons').remove();
}
this.htmlentities = function(s)
@@ -32,47 +39,79 @@ function widgetize()
return s.replace( /[<>&]/g, function(m) { return "&" + m.charCodeAt(0) + ";"; });
}
- this.callbackAddExportButtonsUnderWidget = function (widget, pluginId, actionId)
+ this.callbackAddExportButtonsUnderWidget = function ( widgetUniqueId,
+ loadedWidgetElement)
{
- var html = widget.html();
-
- // Div containing IFRAME code to load the widget
- var widgetIframe = '<div id="widgetIframe"><iframe width="100%" height="350" src="'
- + self.getEmbedUrl(pluginId, actionId, "iframe")
- + '" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe></div>';
+ widget = widgetsHelper.getWidgetObjectFromUniqueId(widgetUniqueId);
+ widgetName = widget["name"];
+ widgetParameters = widget['parameters'];
- // Iframe Export
- $('#embedThisWidgetIframe')
- .show()
- .find('#embedThisWidgetIframeInput')
- .empty()
- .append(self.getInputFormWithHtml('iframeEmbed', widgetIframe));
-
-
- // Flash Export
- widget.find('embed').each(function() {
- var htmlEmbed = $(this).parent().html();
- $('#embedThisWidgetFlash')
- .show()
- .find('#embedThisWidgetFlashInput')
- .empty()
- .append(self.getInputFormWithHtml('flashEmbed', htmlEmbed));
- });
+ self.deleteEmbedElements();
+ var exportButtonsElement = $('<span id="exportButtons">');
+
+ // We first build the HTML code that will load the widget in an IFRAME
+ var widgetIframeHtml = '<div id="widgetIframe">'+
+ '<iframe width="100%" height="350" src="'+
+ self.getEmbedUrl(widgetParameters, "iframe")+
+ '" scrolling="no" frameborder="0" marginheight="0" marginwidth="0">'+
+ '</iframe>'+
+ '</div>';
+
+ // Add the input field containing the widget in an Iframe
+ $(exportButtonsElement).append(
+ '<div id="embedThisWidgetIframe">'+
+ '<label for="embedThisWidgetIframeInput">&rsaquo; Embed Iframe</label>'+
+ '<span id="embedThisWidgetIframeInput">'+
+ self.getInputFormWithHtml('iframeEmbed', widgetIframeHtml)+
+ '</span>'+
+ '</div>'
+ );
+ // Add the Flash Export if a flash <embed> is found in the widget
+ $(loadedWidgetElement)
+ .find('embed,object')
+ .each(function() {
+ var htmlEmbed = $(this).parent().html();
+
+ $(exportButtonsElement).append(
+ '<div id="embedThisWidgetFlash">'+
+ '<label for="embedThisWidgetFlashInput">&rsaquo; Embed Flash</label>'+
+ '<span id="embedThisWidgetFlashInput">'+
+ self.getInputFormWithHtml('flashEmbed', htmlEmbed) +
+ '</span>'+
+ '</div>'
+ );
+ });
- // Clearspring Export
+ // Add the Clearspring Export
+ $(exportButtonsElement).append(
+ '<div id="embedThisWidgetEverywhere">'+
+ '<div id="exportThisWidget">'+
+ '<label for="flashEmbed">&rsaquo; Export anywhere!</label>'+
+ '<img src="http://cdn.clearspring.com/launchpad/static/cs_button_share1.gif">'+
+ '</div>'+
+ '<div id="exportThisWidgetMenu"></div>'+
+ '</div>'
+ );
+
+ // We then replace the div iframeDivToExport with the actual Iframe html
+ // Clearspring will then build a widget that has the same html as this div
$('#iframeDivToExport')
- .html(widgetIframe);
+ .html(widgetIframeHtml);
- $('#exportThisWidgetMenu').empty();
- $('#embedThisWidgetEverywhere').show();
+ // Finally we append the content to the parent widget DIV
+ $(loadedWidgetElement)
+ .parent()
+ .append(exportButtonsElement);
+
+ // Call clearspring
$Launchpad.ShowButton({
actionElement : "exportThisWidget",
targetElement : "exportThisWidgetMenu",
- userId : "49ac5bea72e5cd05",
- widgetName : self.currentWidgetName + " - Piwik",
+ userId : "4797da88692e4fe9",
+ widgetName : widgetName + " - Piwik",
source : "iframeDivToExport"
- });
+ });
// JS is buggy at least on IE
//var widgetJS = '<script type="text/javascript" src="'+ getEmbedUrl(pluginId, actionId, "js") +'"></scr'+'ipt>';
diff --git a/tests/core/DataTable/Renderer.test.php b/tests/core/DataTable/Renderer.test.php
index dbfb455054..a170ca784b 100644
--- a/tests/core/DataTable/Renderer.test.php
+++ b/tests/core/DataTable/Renderer.test.php
@@ -231,13 +231,8 @@ Yahoo!,1,,,15,151,147,50,517,90,http://www.yahoo.com,./plugins/Referers/images/s
$render = new Piwik_DataTable_Renderer_Csv();
$render->setTable($dataTable);
$render->convertToUnicode = false;
- $expected = 'label,value
-max_actions,14
-nb_uniq_visitors,57
-nb_visits,66
-nb_actions,151
-sum_visit_length,5118
-bounce_count,44';
+ $expected = 'max_actions,nb_uniq_visitors,nb_visits,nb_actions,sum_visit_length,bounce_count
+14,57,66,151,5118,44';
$this->assertEqual( $expected,$render->render());
}
@@ -1018,11 +1013,9 @@ date2,Yahoo!1,150,1510,http://www.yahoo.com1,./plugins/Referers/images/searchEng
$render = new Piwik_DataTable_Renderer_Csv();
$render->setTable($dataTable);
$render->convertToUnicode = false;
- $expected = 'testKey,label,value
-row1,max_actions,14
-row1,nb_uniq_visitors,57
-row2,max_actions,140
-row2,nb_uniq_visitors,570';
+ $expected = 'testKey,max_actions,nb_uniq_visitors
+row1,14,57
+row2,140,570';
$rendered = $render->render();
$this->assertEqual( $expected,$rendered);
@@ -1063,11 +1056,9 @@ idSite,date2,Yahoo!1,150,1510,http://www.yahoo.com1,./plugins/Referers/images/se
$render = new Piwik_DataTable_Renderer_Csv();
$render->setTable($dataTable);
$render->convertToUnicode = false;
- $expected = 'parentArrayKey,testKey,label,value
-idSite,row1,max_actions,14
-idSite,row1,nb_uniq_visitors,57
-idSite,row2,max_actions,140
-idSite,row2,nb_uniq_visitors,570';
+ $expected = 'parentArrayKey,testKey,max_actions,nb_uniq_visitors
+idSite,row1,14,57
+idSite,row2,140,570';
$rendered = $render->render();
$this->assertEqual( $expected,$rendered);
diff --git a/tests/core/Url.test.php b/tests/core/Url.test.php
index 04ea0fadd3..1b130472f2 100644
--- a/tests/core/Url.test.php
+++ b/tests/core/Url.test.php
@@ -19,6 +19,7 @@ class Test_Piwik_Url extends UnitTestCase
$this->assertEqual(Piwik_Url::getCurrentQueryStringWithParametersModified(array()),Piwik_Url::getCurrentQueryString() );
$this->assertEqual(Piwik_Url::getCurrentUrl(), Piwik_Url::getCurrentUrlWithoutQueryString());
$this->assertEqual(Piwik_Url::getCurrentUrl(), Piwik_Url::getCurrentHost() . Piwik_Url::getCurrentScriptName() );
+
print("<br>\nPiwik_Url::getCurrentQueryStringWithParametersModified() "
. Piwik_Url::getCurrentQueryStringWithParametersModified(array()));
print("<br>\nPiwik_Url::getCurrentUrl() "
@@ -35,6 +36,17 @@ class Test_Piwik_Url extends UnitTestCase
. Piwik_Url::getCurrentQueryString());
print("<br>\nPiwik_Url::getArrayFromCurrentQueryString() ");
var_dump(Piwik_Url::getArrayFromCurrentQueryString());
+
+ // setting parameter to null should remove it from url
+ // test on Url.test.php?test=value
+ $parameters = array_keys(Piwik_Url::getArrayFromCurrentQueryString());
+ $parametersNameToValue = array();
+ foreach($parameters as $name)
+ {
+ $parametersNameToValue[$name] = null;
+ }
+ $this->assertEqual(Piwik_Url::getCurrentQueryStringWithParametersModified($parametersNameToValue), '');
+
}
}
diff --git a/themes/default/common.js b/themes/default/common.js
index d0d2611c7c..29a16923dd 100644
--- a/themes/default/common.js
+++ b/themes/default/common.js
@@ -1,3 +1,34 @@
+function piwikHelper()
+{
+}
+/*
+ * Returns query string for an object of key,values
+ * Note: we don't use $.param from jquery as it doesn't return array values the PHP way (returns a=v1&a=v2 instead of a[]=v1&a[]=v2)
+ * Example:
+ * piwikHelper.getQueryStringFromParameters({"a":"va","b":["vb","vc"],"c":1})
+ * Returns:
+ * a=va&b[]=vb&b[]=vc&c=1
+ */
+piwikHelper.getQueryStringFromParameters = function(parameters)
+{
+ var queryString = '';
+ if(parameters.length==0) {
+ return queryString;
+ }
+ for(var name in parameters) {
+ value = parameters[name];
+ if(typeof value == 'object') {
+ for(var i in value) {
+ queryString += name + '[]=' + value[i] + '&';
+ }
+ } else {
+ queryString += name + '=' + value + '&';
+ }
+ }
+ return queryString.substring(0, queryString.length-1);
+}
+
+//TODO all piwik global functions should be static of piwikHelper
function findSWFGraph(name) {
if (navigator.appName.indexOf("Microsoft")!= -1) {
return window[name];
@@ -6,6 +37,9 @@ function findSWFGraph(name) {
}
}
+function redirectToUrl(url) {
+ window.location = url;
+}
function ajaxHandleError()
{
$('#loadingError').show();