From 68fa05a7f227d3ac6f1d9d34be23a2753dd5f032 Mon Sep 17 00:00:00 2001
From: mattpiwik <matthieu.aubry@gmail.com>
Date: Sun, 20 Jan 2008 00:17:36 +0000
Subject: [PATCH] - all piwik datatable now work in IFRAME :-) it rocks!!! try
 to load /piwik/?module=Widgetize&action=testIframe

git-svn-id: http://dev.piwik.org/svn/trunk@202 59fd770c-687e-43c8-a1e3-f5a4ff64c105
---
 config/global.ini.php                         |  2 +-
 index.php                                     |  9 +--
 modules/Controller.php                        |  4 +
 modules/FrontController.php                   | 44 ++++++++---
 modules/ViewDataTable.php                     |  7 +-
 modules/ViewDataTable/Cloud.php               |  6 +-
 modules/ViewDataTable/GenerateGraphData.php   |  6 +-
 modules/ViewDataTable/Graph.php               | 12 ++-
 modules/ViewDataTable/Html.php                |  6 +-
 modules/Visualization/ChartEvolution.php      |  2 +-
 plugins/Home/Controller.php                   | 73 +++++++++++--------
 plugins/Widgetize/Controller.php              | 56 ++++++++++++++
 plugins/Widgetize/templates/iframe.tpl        | 20 +++++
 plugins/Widgetize/templates/index.tpl         |  5 ++
 plugins/Widgetize/templates/js_include.tpl    | 10 +++
 plugins/Widgetize/templates/test_iframe.tpl   | 23 ++++++
 .../Widgetize/templates/test_jsinclude.tpl    | 10 +++
 17 files changed, 236 insertions(+), 59 deletions(-)
 create mode 100644 plugins/Widgetize/Controller.php
 create mode 100644 plugins/Widgetize/templates/iframe.tpl
 create mode 100644 plugins/Widgetize/templates/index.tpl
 create mode 100644 plugins/Widgetize/templates/js_include.tpl
 create mode 100644 plugins/Widgetize/templates/test_iframe.tpl
 create mode 100644 plugins/Widgetize/templates/test_jsinclude.tpl

diff --git a/config/global.ini.php b/config/global.ini.php
index 741436cc8c..115770610a 100755
--- a/config/global.ini.php
+++ b/config/global.ini.php
@@ -53,7 +53,7 @@ always_archive_data = false
 [General]
 ; Time in seconds after which an archive will be computed again. 
 ; This setting is used only for today's statistics.
-time_before_archive_considered_outdated = 600
+time_before_archive_considered_outdated = 6000
 
 ; character used to automatically create categories in the "Action" "Downloads" reports
 ; for example a URL like "example.com/blog/development/first-post" will create 
diff --git a/index.php b/index.php
index 4403d16036..c50abbd156 100755
--- a/index.php
+++ b/index.php
@@ -57,10 +57,9 @@ set_exception_handler('Piwik_ExceptionHandler');
 require_once "FrontController.php";
 
 
-$controller = new Piwik_FrontController;
+Piwik_FrontController::$enableDispatch = ENABLE_DISPATCH;
+
+$controller = Piwik_FrontController::getInstance();
 $controller->init();
-if(ENABLE_DISPATCH)
-{
-	$controller->dispatch();
-}
+$controller->dispatch();
 $controller->end();
diff --git a/modules/Controller.php b/modules/Controller.php
index ca7f1a9d71..7a569f9ac8 100644
--- a/modules/Controller.php
+++ b/modules/Controller.php
@@ -15,6 +15,10 @@
  */
 abstract class Piwik_Controller
 {
+	function __construct()
+	{
+	}
+	
 	function getDefaultAction()
 	{
 		return 'index';
diff --git a/modules/FrontController.php b/modules/FrontController.php
index 653989fd35..b98f9541f2 100644
--- a/modules/FrontController.php
+++ b/modules/FrontController.php
@@ -44,16 +44,40 @@ class Piwik_FrontController
 {
 	static public $enableDispatch = true;
 	
-	function dispatch()
+	static private $instance = null;	
+	static public function getInstance()
+	{
+		if (self::$instance == null)
+		{			
+			$c = __CLASS__;
+			self::$instance = new $c();
+		}
+		return self::$instance;
+	}
+	
+	function dispatch( $module = null, $action = null, $parameters = null)
 	{
 		if( self::$enableDispatch === false)
 		{
 			return;
 		}
-		$defaultModule = 'Home';
 		
-		// load the module requested
-		$module = Piwik_Common::getRequestVar('module', $defaultModule, 'string');
+		if(is_null($module))
+		{
+			$defaultModule = 'Home';
+			// load the module requested
+			$module = Piwik_Common::getRequestVar('module', $defaultModule, 'string');
+		}
+		
+		if(is_null($action))
+		{
+			$action = Piwik_Common::getRequestVar('action', false);
+		}
+		
+		if(is_null($parameters))
+		{
+			$parameters = array();
+		}
 		
 		if(ctype_alnum($module))
 		{
@@ -66,16 +90,16 @@ class Piwik_FrontController
 				
 				$controller = new $controllerClassName;
 				
-				$defaultAction = $controller->getDefaultAction();
-				$action = Piwik_Common::getRequestVar('action', $defaultAction, 'string');
-				
+				
+				if($action === false)
+				{
+					$action = $controller->getDefaultAction();
+				}
 				if(method_exists($controller, $action))
 				{
 					try{
-						$controller->$action();
+						return call_user_func_array( array($controller, $action ), $parameters);
 					} catch(Piwik_Access_NoAccessException $e) {
-	//					Piwik::log("NO ACCESS EXCEPTION =>");
-						
 						Piwik_PostEvent('FrontController.NoAccessException', $e);					
 					}
 				}
diff --git a/modules/ViewDataTable.php b/modules/ViewDataTable.php
index 67c533eaed..b7bda1bdee 100644
--- a/modules/ViewDataTable.php
+++ b/modules/ViewDataTable.php
@@ -98,10 +98,12 @@ abstract class Piwik_ViewDataTable
 		}
 	}
 	
-	function init( $currentControllerAction, 
+	function init( $currentControllerName,
+						$currentControllerAction, 
 						$moduleNameAndMethod, 
 						$actionToLoadTheSubTable = null)
 	{
+		$this->currentControllerName = $currentControllerName;
 		$this->currentControllerAction = $currentControllerAction;
 		$this->moduleNameAndMethod = $moduleNameAndMethod;
 		$this->actionToLoadTheSubTable = $actionToLoadTheSubTable;
@@ -110,7 +112,7 @@ abstract class Piwik_ViewDataTable
 		
 		$this->method = $moduleNameAndMethod;
 		
-		
+		$this->showFooter = Piwik_Common::getRequestVar('showDataTableFooter', true);
 		$this->variablesDefault['filter_excludelowpop_default'] = 'false';
 		$this->variablesDefault['filter_excludelowpop_value_default'] = 'false';	
 	}
@@ -207,6 +209,7 @@ abstract class Piwik_ViewDataTable
 		}
 		
 		
+		$javascriptVariablesToSet['module'] = $this->currentControllerName;
 		$javascriptVariablesToSet['action'] = $this->currentControllerAction;
 		
 		if(!is_null($this->actionToLoadTheSubTable))
diff --git a/modules/ViewDataTable/Cloud.php b/modules/ViewDataTable/Cloud.php
index 3e87194a6e..cf6b23338e 100644
--- a/modules/ViewDataTable/Cloud.php
+++ b/modules/ViewDataTable/Cloud.php
@@ -19,10 +19,12 @@ require_once "Visualization/Cloud.php";
 class Piwik_ViewDataTable_Cloud extends Piwik_ViewDataTable
 {
 	protected $displayLogoInsteadOfLabel = false;
-	function init($currentControllerAction, 
+	function init($currentControllerName,
+						$currentControllerAction, 
 						$moduleNameAndMethod )
 	{
-		parent::init($currentControllerAction, 
+		parent::init($currentControllerName,
+						$currentControllerAction, 
 						$moduleNameAndMethod );
 		$this->dataTableTemplate = 'Home/templates/cloud.tpl';
 		
diff --git a/modules/ViewDataTable/GenerateGraphData.php b/modules/ViewDataTable/GenerateGraphData.php
index 732ac245ed..854d0e05f9 100644
--- a/modules/ViewDataTable/GenerateGraphData.php
+++ b/modules/ViewDataTable/GenerateGraphData.php
@@ -17,10 +17,12 @@
 abstract class Piwik_ViewDataTable_GenerateGraphData extends Piwik_ViewDataTable
 {
 	
-	function init($currentControllerAction, 
+	function init($currentControllerName,
+						$currentControllerAction, 
 						$moduleNameAndMethod )
 	{
-		parent::init($currentControllerAction, 
+		parent::init($currentControllerName, 
+						$currentControllerAction, 
 						$moduleNameAndMethod );
 		
 		$this->disableOffsetInformation();
diff --git a/modules/ViewDataTable/Graph.php b/modules/ViewDataTable/Graph.php
index be22f3ef38..45c483e468 100644
--- a/modules/ViewDataTable/Graph.php
+++ b/modules/ViewDataTable/Graph.php
@@ -19,10 +19,12 @@ abstract class Piwik_ViewDataTable_Graph extends Piwik_ViewDataTable
 	protected $width = 400; 
 	protected $height = 250; 
 	
-	function init($currentControllerAction, 
+	function init($currentControllerName,
+						$currentControllerAction, 
 						$moduleNameAndMethod )
 	{
-		parent::init($currentControllerAction, 
+		parent::init($currentControllerName,
+						$currentControllerAction, 
 						$moduleNameAndMethod );
 		$this->dataTableTemplate = 'Home/templates/graph.tpl';
 		
@@ -134,10 +136,12 @@ class Piwik_ViewDataTable_Graph_ChartEvolution extends Piwik_ViewDataTable_Graph
 		
 	}
 	
-	function init($currentControllerAction, 
+	function init($currentControllerName,
+						$currentControllerAction, 
 						$moduleNameAndMethod )
 	{
-		parent::init($currentControllerAction, 
+		parent::init($currentControllerName,
+						$currentControllerAction, 
 						$moduleNameAndMethod );
 		
 		$this->parametersToModify['date'] = 'last30';
diff --git a/modules/ViewDataTable/Html.php b/modules/ViewDataTable/Html.php
index 722ee3c18e..4d933a5c0f 100644
--- a/modules/ViewDataTable/Html.php
+++ b/modules/ViewDataTable/Html.php
@@ -20,11 +20,13 @@ class Piwik_ViewDataTable_Html extends Piwik_ViewDataTable
 	
 	public $arrayDataTable; // phpArray
 	
-	function init($currentControllerAction, 
+	function init($currentControllerName,
+						$currentControllerAction, 
 						$moduleNameAndMethod,						
 						$actionToLoadTheSubTable = null )
 	{
-		parent::init($currentControllerAction, 
+		parent::init($currentControllerName,
+						$currentControllerAction, 
 						$moduleNameAndMethod,						
 						$actionToLoadTheSubTable);
 		$this->dataTableTemplate = 'Home/templates/datatable.tpl';
diff --git a/modules/Visualization/ChartEvolution.php b/modules/Visualization/ChartEvolution.php
index 2b4090287b..791ed1df82 100644
--- a/modules/Visualization/ChartEvolution.php
+++ b/modules/Visualization/ChartEvolution.php
@@ -29,7 +29,7 @@ class Piwik_Visualization_ChartEvolution extends Piwik_Visualization_Chart
 		$this->bg_colour = '#ffffff';
 		$this->set_data( $this->arrayData );
 		$this->set_x_labels( $this->arrayLabel );
-		$this->area_hollow( 2, 4, 15,'0x3357A0',  ' visits', 10 );
+		$this->area_hollow( 1, 3, 10,'0x3357A0',  ' visits', 10 );
 		
 		$this->set_tool_tip( '#x_label# <br>#val# #key# ' );
 		
diff --git a/plugins/Home/Controller.php b/plugins/Home/Controller.php
index ded9b3e75f..4e03a08c25 100644
--- a/plugins/Home/Controller.php
+++ b/plugins/Home/Controller.php
@@ -20,6 +20,11 @@ require_once "ViewDataTable.php";
  */
 class Piwik_Home_Controller extends Piwik_Controller
 {
+	function __construct()
+	{
+		parent::__construct();
+		$this->currentControllerName = 'Home';
+	}
 	function getDefaultAction()
 	{
 		return 'redirectToIndex';
@@ -154,12 +159,14 @@ List of the public methods for the class Piwik_Actions_API
 - getOutlinks : [idSite, period, date, expanded = , idSubtable = ]
 
 		 */
-	function getActionsView($currentMethod,
+	function getActionsView($currentControllerName,
+						$currentMethod,
 						$methodToCall = 'Actions.getActions', 
 						$subMethod = 'getActionsSubDataTable')
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init(  	$currentMethod, 
+		$view->init(  	$currentControllerName,
+						$currentMethod, 
 						$methodToCall, 
 						$subMethod );
 		$view->setTemplate('Home/templates/datatable_actions.tpl');
@@ -240,7 +247,8 @@ List of the public methods for the class Piwik_Actions_API
 	}
 	function getDownloads($fetch = false)
 	{
-		$view = $this->getActionsView( 	__FUNCTION__,
+		$view = $this->getActionsView( 	$this->currentControllerName, 
+										__FUNCTION__,
 										'Actions.getDownloads', 
 										'getDownloadsSubDataTable' );
 		
@@ -248,7 +256,8 @@ List of the public methods for the class Piwik_Actions_API
 	}
 	function getDownloadsSubDataTable($fetch = false)
 	{
-		$view = $this->getActionsView( 	__FUNCTION__,
+		$view = $this->getActionsView( 	$this->currentControllerName, 
+										__FUNCTION__,
 										'Actions.getDownloads', 
 										'getDownloadsSubDataTable' );
 		
@@ -256,7 +265,8 @@ List of the public methods for the class Piwik_Actions_API
 	}
 	function getActions($fetch = false)
 	{
-		$view = $this->getActionsView(	__FUNCTION__,
+		$view = $this->getActionsView(	$this->currentControllerName, 
+										__FUNCTION__,
 										'Actions.getActions', 
 										'getActionsSubDataTable' );
 		
@@ -264,7 +274,8 @@ List of the public methods for the class Piwik_Actions_API
 	}
 	function getActionsSubDataTable($fetch = false)
 	{
-		$view = $this->getActionsView( 	__FUNCTION__,
+		$view = $this->getActionsView( 	$this->currentControllerName, 
+										__FUNCTION__,
 										'Actions.getActions', 
 										'getActionsSubDataTable'  );
 		
@@ -272,7 +283,8 @@ List of the public methods for the class Piwik_Actions_API
 	}
 	function getOutlinks($fetch = false)
 	{
-		$view = $this->getActionsView(	__FUNCTION__,
+		$view = $this->getActionsView(	$this->currentControllerName, 
+										__FUNCTION__,
 										'Actions.getOutlinks', 
 										'getOutlinksSubDataTable' );
 		
@@ -280,7 +292,8 @@ List of the public methods for the class Piwik_Actions_API
 	}
 	function getOutlinksSubDataTable($fetch = false)
 	{
-		$view = $this->getActionsView( 	__FUNCTION__,
+		$view = $this->getActionsView( 	$this->currentControllerName, 
+										__FUNCTION__,
 										'Actions.getOutlinks', 
 										'getOutlinksSubDataTable'  );
 		
@@ -304,14 +317,14 @@ List of the public methods for the class Piwik_Actions_API
 	{
 		require_once "ViewDataTable/Graph.php";
 		$view = Piwik_ViewDataTable::factory(null, 'graphEvolution');
-		$view->init( __FUNCTION__, "VisitsSummary.getVisits" );
+		$view->init( $this->currentControllerName, __FUNCTION__, "VisitsSummary.getVisits" );
 		return $this->renderView($view, $fetch);
 	}
 	function getLastDistinctKeywordsGraph( $fetch = false )
 	{
 		require_once "ViewDataTable/Graph.php";
 		$view = Piwik_ViewDataTable::factory(null, 'graphEvolution');
-		$view->init( __FUNCTION__, "Referers.getNumberOfDistinctKeywords" );
+		$view->init( $this->currentControllerName, __FUNCTION__, "Referers.getNumberOfDistinctKeywords" );
 		return $this->renderView($view, $fetch);
 	}
 	
@@ -331,7 +344,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getVisitInformationPerServerTime( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init(  __FUNCTION__, 
+		$view->init( $this->currentControllerName,  __FUNCTION__, 
 								"VisitTime.getVisitInformationPerServerTime" );
 		
 		$view->setColumnsToDisplay( array(0,2) );
@@ -347,7 +360,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getVisitInformationPerLocalTime( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init(  __FUNCTION__, 
+		$view->init( $this->currentControllerName,  __FUNCTION__, 
 								"VisitTime.getVisitInformationPerLocalTime" );
 		
 		$view->setColumnsToDisplay( array(0,2) );
@@ -366,7 +379,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getNumberOfVisitsPerVisitDuration( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init(  __FUNCTION__, 
+		$view->init( $this->currentControllerName,  __FUNCTION__, 
 									"VisitorInterest.getNumberOfVisitsPerVisitDuration" );
 		
 		$view->setColumnsToDisplay( array(0,1) );
@@ -381,7 +394,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getNumberOfVisitsPerPage( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init(  __FUNCTION__, 
+		$view->init( $this->currentControllerName,  __FUNCTION__, 
 									"VisitorInterest.getNumberOfVisitsPerPage" );
 		
 		$view->setColumnsToDisplay( array(0,1) );
@@ -401,7 +414,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getProvider( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init(  __FUNCTION__, "Provider.getProvider" );
+		$view->init( $this->currentControllerName,  __FUNCTION__, "Provider.getProvider" );
 		
 		$view->setColumnsToDisplay( array(0,1) );
 		$view->setSortedColumn( 1 );
@@ -416,7 +429,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getCountry( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init( __FUNCTION__, "UserCountry.getCountry" );
+		$view->init( $this->currentControllerName, __FUNCTION__, "UserCountry.getCountry" );
 		$view->disableExcludeLowPopulation();
 		
 		$view->setColumnsToDisplay( array(0,1) );
@@ -434,7 +447,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getContinent( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init( __FUNCTION__, "UserCountry.getContinent" );
+		$view->init( $this->currentControllerName, __FUNCTION__, "UserCountry.getContinent" );
 		$view->disableExcludeLowPopulation();
 		$view->disableSearchBox();
 		$view->disableOffsetInformation();
@@ -452,7 +465,7 @@ List of the public methods for the class Piwik_Actions_API
 												$APItoCall )
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init(  $currentControllerAction, $APItoCall );
+		$view->init( $this->currentControllerName,  $currentControllerAction, $APItoCall );
 		$view->disableSearchBox();
 		$view->disableExcludeLowPopulation();
 		
@@ -524,7 +537,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getPlugin( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init(  __FUNCTION__, 'UserSettings.getPlugin' );
+		$view->init( $this->currentControllerName,  __FUNCTION__, 'UserSettings.getPlugin' );
 		$view->disableSearchBox();
 		$view->disableExcludeLowPopulation();
 		$view->disableSort();
@@ -545,7 +558,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getRefererType( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init(  	'getRefererType', 
+		$view->init( $this->currentControllerName,  	'getRefererType', 
 											'Referers.getRefererType'
 								);
 		$view->disableSearchBox();
@@ -560,7 +573,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getKeywords( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init( 	'getKeywords', 
+		$view->init( $this->currentControllerName, 	'getKeywords', 
 											'Referers.getKeywords', 
 											'getSearchEnginesFromKeywordId'
 								);
@@ -573,7 +586,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getSearchEnginesFromKeywordId( $fetch = false )
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init( 	'getSearchEnginesFromKeywordId', 
+		$view->init( $this->currentControllerName, 	'getSearchEnginesFromKeywordId', 
 											'Referers.getSearchEnginesFromKeywordId'
 								);
 		$view->disableSearchBox();
@@ -587,7 +600,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getSearchEngines( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init(  	'getSearchEngines', 
+		$view->init( $this->currentControllerName,  	'getSearchEngines', 
 											'Referers.getSearchEngines', 
 											'getKeywordsFromSearchEngineId'
 								);
@@ -603,7 +616,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getKeywordsFromSearchEngineId( $fetch = false )
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init( 	'getKeywordsFromSearchEngineId', 
+		$view->init( $this->currentControllerName, 	'getKeywordsFromSearchEngineId', 
 											'Referers.getKeywordsFromSearchEngineId'
 								);
 		$view->disableSearchBox();
@@ -616,7 +629,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getWebsites( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init(  	'getWebsites', 
+		$view->init( $this->currentControllerName,  	'getWebsites', 
 											'Referers.getWebsites',
 											'getUrlsFromWebsiteId'
 								);
@@ -633,7 +646,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getCampaigns( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init(  	'getCampaigns', 
+		$view->init( $this->currentControllerName,  	'getCampaigns', 
 											'Referers.getCampaigns',
 											'getKeywordsFromCampaignId'
 								);
@@ -650,7 +663,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getKeywordsFromCampaignId( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init( 	'getKeywordsFromCampaignId', 
+		$view->init( $this->currentControllerName, 	'getKeywordsFromCampaignId', 
 											'Referers.getKeywordsFromCampaignId'
 								);
 
@@ -664,7 +677,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getUrlsFromWebsiteId( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init( 	'getUrlsFromWebsiteId', 
+		$view->init( $this->currentControllerName, 	'getUrlsFromWebsiteId', 
 											'Referers.getUrlsFromWebsiteId'
 								);
 		$view->disableSearchBox();
@@ -677,7 +690,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getPartners( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init(  	'getPartners', 
+		$view->init( $this->currentControllerName,  	'getPartners', 
 											'Referers.getPartners',
 											'getUrlsFromPartnerId'
 								);
@@ -693,7 +706,7 @@ List of the public methods for the class Piwik_Actions_API
 	function getUrlsFromPartnerId( $fetch = false)
 	{
 		$view = Piwik_ViewDataTable::factory();
-		$view->init( 	'getUrlsFromPartnerId', 
+		$view->init( $this->currentControllerName, 	'getUrlsFromPartnerId', 
 											'Referers.getUrlsFromPartnerId'
 								);
 		$view->disableSearchBox();
diff --git a/plugins/Widgetize/Controller.php b/plugins/Widgetize/Controller.php
new file mode 100644
index 0000000000..2bcaeadc3b
--- /dev/null
+++ b/plugins/Widgetize/Controller.php
@@ -0,0 +1,56 @@
+<?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: Controller.php 169 2008-01-14 05:41:15Z matt $
+ * 
+ * @package Piwik_SitesManager
+ */
+
+
+/**
+ * 
+ * @package Piwik_Widgetize
+ */
+class Piwik_Widgetize_Controller extends Piwik_Controller
+{
+	function index()
+	{
+		$view = new Piwik_View('Widgetize/templates/index.tpl');
+		echo $view->render();
+	}
+
+	// display code calling the IFRAME
+	function testIframe()
+	{
+		$view = new Piwik_View('Widgetize/templates/test_iframe.tpl');
+		$view->url1 = '?module=Widgetize&action=iframe&moduleToWidgetize=Home&actionToWidgetize=getBrowser&idSite=1&period=day&date=yesterday';
+		$view->url2 = '?module=Widgetize&action=iframe&moduleToWidgetize=Home&actionToWidgetize=getBrowser&idSite=1&period=day&date=yesterday&viewDataTable=cloud&showDataTableFooter=0';
+		
+		echo $view->render();
+	}
+	
+	
+	function testJsInclude()
+	{
+		$view = new Piwik_View('Widgetize/templates/test_jsinclude.tpl');
+		echo $view->render();
+	}
+	
+	// the code inside the IFRAME
+	function iframe()
+	{		
+		$controllerName = Piwik_Common::getRequestVar('moduleToWidgetize');
+		$actionName = Piwik_Common::getRequestVar('actionToWidgetize');
+		$parameters = array ( $fetch = true );
+		$outputDataTable='';
+		
+		$outputDataTable = Piwik_FrontController::getInstance()->dispatch( $controllerName, $actionName, $parameters);
+		
+		$view = new Piwik_View('Widgetize/templates/iframe.tpl');
+		$view->content = $outputDataTable;
+		echo $view->render();
+	}
+}
\ No newline at end of file
diff --git a/plugins/Widgetize/templates/iframe.tpl b/plugins/Widgetize/templates/iframe.tpl
new file mode 100644
index 0000000000..2052355c84
--- /dev/null
+++ b/plugins/Widgetize/templates/iframe.tpl
@@ -0,0 +1,20 @@
+<html>
+<body>
+
+<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/swfobject/swfobject.js"></script>
+
+<script type="text/javascript" src="plugins/Home/templates/datatable.js"></script>
+<link rel="stylesheet" href="libs/jquery/tooltip/jquery.tooltip.css">
+<link rel="stylesheet" href="plugins/Home/templates/datatable.css">
+
+
+{$content}
+
+</body>
+</html>
\ No newline at end of file
diff --git a/plugins/Widgetize/templates/index.tpl b/plugins/Widgetize/templates/index.tpl
new file mode 100644
index 0000000000..15dd30b82f
--- /dev/null
+++ b/plugins/Widgetize/templates/index.tpl
@@ -0,0 +1,5 @@
+<ul>
+<li><a href='?module=Widgetize&action=testIframe'>Test getCountry table in a IFRAME</li>
+
+<li><a href='?module=Widgetize&action=testJsInclude'>Test getCountry table in a JS include</a></li>
+</ul>
\ No newline at end of file
diff --git a/plugins/Widgetize/templates/js_include.tpl b/plugins/Widgetize/templates/js_include.tpl
new file mode 100644
index 0000000000..3314e6470b
--- /dev/null
+++ b/plugins/Widgetize/templates/js_include.tpl
@@ -0,0 +1,10 @@
+<html>
+<body>
+<h2>Test getCountry table in a JS include</h2>
+
+<noscript>Powered by <a href="http://piwik.org">Piwik</a></div></noscript>
+
+<p>This test is after the JS INCLUDE</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/plugins/Widgetize/templates/test_iframe.tpl b/plugins/Widgetize/templates/test_iframe.tpl
new file mode 100644
index 0000000000..e7b6f065ec
--- /dev/null
+++ b/plugins/Widgetize/templates/test_iframe.tpl
@@ -0,0 +1,23 @@
+<html>
+<body>
+<h2>Test datatable in a IFRAME</h2>
+
+<iframe 
+ width="400" height="350" 
+ src="{$url1}" 
+ scrolling="no" frameborder="0" marginheight="0" marginwidth="0">
+</iframe>
+<noscript>Powered by <a href="http://piwik.org">Piwik</a></div></noscript>
+<hr>
+<h2>Test tag cloud  in a IFRAME</h2>
+<iframe 
+ width="500" height="100" 
+ src="{$url2}" 
+ scrolling="no" frameborder="0" marginheight="0" marginwidth="0">
+</iframe>
+<noscript>Powered by <a href="http://piwik.org">Piwik</a></div></noscript>
+
+<p>Note that here there is NO footer (no icons) (it's a parameter in the URL = showDataTableFooter)</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/plugins/Widgetize/templates/test_jsinclude.tpl b/plugins/Widgetize/templates/test_jsinclude.tpl
new file mode 100644
index 0000000000..4730e66c29
--- /dev/null
+++ b/plugins/Widgetize/templates/test_jsinclude.tpl
@@ -0,0 +1,10 @@
+<html>
+<body>
+<h2>Test table in a js include</h2>
+<code>not there yet</code>
+<noscript>Powered by <a href="http://piwik.org">Piwik</a></div></noscript>
+
+<p>This text is after the Js include</p>
+
+</body>
+</html>
\ No newline at end of file
-- 
GitLab