blob: ad105a7c9c684133b48977bcc1b7a9833d4992a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
<?php
exit;
$date = date('Y-m-d');
$period = 'month';
$idSite = 1;
$url = "http://localhost/trunk/index.php?token_auth=0b809661490d605bfd77f57ed11f0b14&module=Widgetize&action=iframe&moduleToWidgetize=UserCountry&actionToWidgetize=getCountry&idSite=$idSite&period=$period&date=$date&disableLink=1";
?>
<html>
<body>
<h3 style="color:#143974">Embedding the Piwik Country widget in an Iframe</h3>
<p>Loads a widget from localhost/trunk/ with login=root, pwd=test. <a href='<?=$url?>'>Widget URL</a></p>
<div id="widgetIframe"><iframe width="500" height="350"
src="<?php echo $url; ?>" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe></div>
<br/>
<?php
$_GET['idSite'] = $idSite;
define('PIWIK_INCLUDE_PATH', '../..');
define('PIWIK_ENABLE_DISPATCH', false);
define('PIWIK_ENABLE_ERROR_HANDLER', false);
define('PIWIK_ENABLE_SESSION_START', false);
require_once PIWIK_INCLUDE_PATH . "/index.php";
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
Piwik_FrontController::getInstance()->init();
$widgets = Piwik_GetWidgetsList();
foreach($widgets as $category => $widgetsInCategory)
{
echo '<h2>'.$category . '</h2>';
foreach($widgetsInCategory as $widget)
{
echo '<h3>'.$widget['name'].'</h3>';
$widgetUrl = Piwik_Common::getArrayFromQueryString($url);
$widgetUrl['moduleToWidgetize'] = $widget['parameters']['module'];
$widgetUrl['actionToWidgetize'] = $widget['parameters']['action'];
$parameters = $widget['parameters'];
unset($parameters['module']);
unset($parameters['action']);
foreach($parameters as $name => $value)
{
if(is_array($value))
{
$value = current($value);
}
$widgetUrl[$name] = $value;
}
$widgetUrl = Piwik_Url::getQueryStringFromParameters($widgetUrl);
echo '<div id="widgetIframe"><iframe width="500" height="350"
src="'.$widgetUrl.'" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe></div>';
}
}
?>
</body></html>
|