diff options
Diffstat (limited to 'plugins/Widgetize')
-rw-r--r-- | plugins/Widgetize/Controller.php | 11 | ||||
-rw-r--r-- | plugins/Widgetize/Widgetize.php | 7 | ||||
-rw-r--r-- | plugins/Widgetize/templates/index.tpl | 25 | ||||
-rw-r--r-- | plugins/Widgetize/templates/js.tpl | 26 | ||||
-rw-r--r-- | plugins/Widgetize/templates/widgetize.js | 29 |
5 files changed, 38 insertions, 60 deletions
diff --git a/plugins/Widgetize/Controller.php b/plugins/Widgetize/Controller.php index 8cd3b7c902..700c9885f7 100644 --- a/plugins/Widgetize/Controller.php +++ b/plugins/Widgetize/Controller.php @@ -41,17 +41,9 @@ class Piwik_Widgetize_Controller extends Piwik_Controller echo $view->render(); } - function testClearspring() - { - $view = Piwik_View::factory('test_widget'); - $view->url1 = Piwik_Url::getCurrentUrlWithoutQueryString().'?module=Widgetize&action=iframe&moduleToWidgetize=Referers&actionToWidgetize=getKeywords&idSite=1&period=day&date=yesterday&filter_limit=5&token_auth='.Piwik::getCurrentUserTokenAuth(); - $view->url2 = Piwik_Url::getCurrentUrlWithoutQueryString().'?module=Widgetize&action=iframe&moduleToWidgetize=VisitTime&actionToWidgetize=getVisitInformationPerServerTime&idSite=1&period=day&date=yesterday&viewDataTable=graphVerticalBar&show_footer=0&token_auth='.Piwik::getCurrentUserTokenAuth(); - $view->url3 = Piwik_Url::getCurrentUrlWithoutQueryString().'?module=Widgetize&action=iframe&moduleToWidgetize=Referers&actionToWidgetize=getKeywords&idSite=1&period=day&date=yesterday&viewDataTable=cloud&show_footer=1&filter_limit=15&show_search=false&token_auth='.Piwik::getCurrentUserTokenAuth(); - echo $view->render(); - } - function js() { + Piwik_API_Request::reloadAuthUsingTokenAuth(); $controllerName = Piwik_Common::getRequestVar('moduleToWidgetize'); $actionName = Piwik_Common::getRequestVar('actionToWidgetize'); $parameters = array ( $fetch = true ); @@ -65,6 +57,7 @@ class Piwik_Widgetize_Controller extends Piwik_Controller function iframe() { + Piwik_API_Request::reloadAuthUsingTokenAuth(); $controllerName = Piwik_Common::getRequestVar('moduleToWidgetize'); $actionName = Piwik_Common::getRequestVar('actionToWidgetize'); $parameters = array ( $fetch = true ); diff --git a/plugins/Widgetize/Widgetize.php b/plugins/Widgetize/Widgetize.php index 9e60096a01..cfe98e3aa1 100644 --- a/plugins/Widgetize/Widgetize.php +++ b/plugins/Widgetize/Widgetize.php @@ -19,11 +19,10 @@ class Piwik_Widgetize extends Piwik_Plugin public function getInformation() { return array( - 'name' => 'Widgetize your data!', - 'description' => 'The plugin makes it very easy to export any Piwik Widget in your Blog, Website or on Igoogle and Netvibes!', + 'description' => Piwik_Translate('Widgetize_PluginDescription'), 'author' => 'Piwik', - 'homepage' => 'http://piwik.org/', - 'version' => '0.1', + 'author_homepage' => 'http://piwik.org/', + 'version' => Piwik_Version::VERSION, ); } } diff --git a/plugins/Widgetize/templates/index.tpl b/plugins/Widgetize/templates/index.tpl index f2f3573019..3e705fb001 100644 --- a/plugins/Widgetize/templates/index.tpl +++ b/plugins/Widgetize/templates/index.tpl @@ -1,6 +1,6 @@ {assign var=showSitesSelection value=true} {assign var=showPeriodSelection value=true} -{include file="CoreAdminHome/templates/header.tpl"} +{include file="CoreHome/templates/header.tpl"} {loadJavascriptTranslations plugins='Dashboard'} <link rel="stylesheet" type="text/css" href="plugins/CoreHome/templates/styles.css" /> @@ -8,16 +8,16 @@ <link rel="stylesheet" type="text/css" href="plugins/CoreHome/templates/cloud.css" /> <link rel="stylesheet" type="text/css" href="plugins/Dashboard/templates/dashboard.css" /> -<script type="text/javascript" src="themes/default/common.js"></script> <script type="text/javascript" src="libs/swfobject/swfobject.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="themes/default/common.js"></script> <script type="text/javascript" src="plugins/CoreHome/templates/datatable.js"></script> <script type="text/javascript" src="plugins/Dashboard/templates/widgetMenu.js"></script> <script type="text/javascript" src="plugins/Widgetize/templates/widgetize.js"></script> -<script src="http://cdn.clearspring.com/launchpad/v2/standalone.js" type="text/javascript"></script> + {literal} <style> .menu { @@ -64,9 +64,11 @@ $(document).ready( function() { menu.registerCallbackOnWidgetLoad( widgetized.callbackAddExportButtonsUnderWidget ); menu.registerCallbackOnMenuHover( widgetized.deleteEmbedElements ); menu.show(); + var dashboardUrl = document.location.protocol + '//' + document.location.hostname + document.location.pathname + '?module=Widgetize&action=iframe&moduleToWidgetize=Dashboard&actionToWidgetize=index&idSite=1&period=week&date=yesterday'; $('#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>') + widgetized.getInputFormWithHtml( 'dashboardEmbed', '<iframe src="'+ dashboardUrl +'" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%"></iframe>') ); + $('#linkDashboardUrl').attr('href',dashboardUrl); }); {/literal} @@ -74,13 +76,18 @@ $(document).ready( function() { <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='index.php?module=UsersManager'>Users Management section</a>. - <br>Note: You can also display the full Piwik dashboard in your application or website in an Iframe. + <p><b>› Widget authentication:</b> 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='index.php?module=UsersManager'>Users Management section</a>. + <br />Alternatively, if you are publishing widgets on a password protected or private page, + you don't necessarily have to allow 'anonymous' to view your reports. In this case, you can add the secret token_auth parameter (found in the <a href='{url module=API action=listAllAPI}' target='_blank'>API page</a>) in the widget URL. + </p> + <p><b>› Widgetize the full dashboard:</b> You can also display the full Piwik dashboard in your application or website in an IFRAME (<a href='' target='_blank' id='linkDashboardUrl'>see example</a>). + The date parameter can be set to a specific calendar date, "today", or "yesterday". The period parameter can be set to "day", "week", "month", or "year". + The language parameter can be set to the language code of a translation, such as language=fr. For example, for idSite=1 and date=yesterday, you can write: <span id='exportFullDashboard'></span> </p> - - <div id="widgetChooser"> + <p> <b>› Select a report, and copy paste in your page the embed code below the widget:</b> + <div id="widgetChooser" style='height:600px'> <div class="subMenu" id="sub1"></div> <div class="subMenu" id="sub2"></div> <div class="subMenu" id="sub3"></div> diff --git a/plugins/Widgetize/templates/js.tpl b/plugins/Widgetize/templates/js.tpl index 18ea5d877b..a92c76e6fc 100644 --- a/plugins/Widgetize/templates/js.tpl +++ b/plugins/Widgetize/templates/js.tpl @@ -1,19 +1,19 @@ {loadJavascriptTranslations disableOutputScriptTag=1 plugins='CoreHome'} -document.write('<link rel="stylesheet" href="{$piwikUrl}themes/default/common.css">'); -document.write('<link rel="stylesheet" href="{$piwikUrl}plugins/CoreHome/templates/styles.css">'); -document.write('<link rel="stylesheet" href="{$piwikUrl}plugins/CoreHome/templates/datatable.css">'); -document.write('<link rel="stylesheet" href="{$piwikUrl}plugins/CoreHome/templates/cloud.css">'); +document.write('<link rel="stylesheet" type="text/css" href="{$piwikUrl}themes/default/common.css" />'); +document.write('<link rel="stylesheet" type="text/css" href="{$piwikUrl}plugins/CoreHome/templates/styles.css" />'); +document.write('<link rel="stylesheet" type="text/css" href="{$piwikUrl}plugins/CoreHome/templates/datatable.css" />'); +document.write('<link rel="stylesheet" type="text/css" href="{$piwikUrl}plugins/CoreHome/templates/cloud.css" />'); -document.write('<scr'+'ipt language="javascript" src="{$piwikUrl}themes/default/common.js"></scr'+'ipt>'); -document.write('<scr'+'ipt language="javascript" src="{$piwikUrl}libs/swfobject/swfobject.js"></scr'+'ipt>'); -document.write('<scr'+'ipt language="javascript" src="{$piwikUrl}libs/jquery/jquery.js"></scr'+'ipt>'); -document.write('<scr'+'ipt language="javascript" src="{$piwikUrl}libs/jquery/jquery-ui.js"></scr'+'ipt>'); -document.write('<scr'+'ipt language="javascript" src="{$piwikUrl}libs/jquery/tooltip/jquery.tooltip.js"></scr'+'ipt>'); -document.write('<scr'+'ipt language="javascript" src="{$piwikUrl}libs/jquery/truncate/jquery.truncate.js"></scr'+'ipt>'); -document.write('<scr'+'ipt language="javascript" src="{$piwikUrl}libs/javascript/sprintf.js"></scr'+'ipt>'); -document.write('<scr'+'ipt language="javascript" src="{$piwikUrl}plugins/CoreHome/templates/datatable.js"></scr'+'ipt>'); +document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}libs/swfobject/swfobject.js"></scr'+'ipt>'); +document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}libs/jquery/jquery.js"></scr'+'ipt>'); +document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}libs/jquery/jquery-ui.js"></scr'+'ipt>'); +document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}libs/jquery/tooltip/jquery.tooltip.js"></scr'+'ipt>'); +document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}libs/jquery/truncate/jquery.truncate.js"></scr'+'ipt>'); +document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}libs/javascript/sprintf.js"></scr'+'ipt>'); +document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}themes/default/common.js"></scr'+'ipt>'); +document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}plugins/CoreHome/templates/datatable.js"></scr'+'ipt>'); var content = '{$content|escape:'javascript'}'; -document.write('<scr'+'ipt language="javascript">document.write(content)</scr'+'ipt>'); +document.write('<scr'+'ipt type="text/javascript">document.write(content)</scr'+'ipt>'); diff --git a/plugins/Widgetize/templates/widgetize.js b/plugins/Widgetize/templates/widgetize.js index e509a63cdd..5f8a3c368d 100644 --- a/plugins/Widgetize/templates/widgetize.js +++ b/plugins/Widgetize/templates/widgetize.js @@ -4,7 +4,7 @@ function widgetize() this.getInputFormWithHtml = function(inputId, htmlEmbed) { - return '<input class="formEmbedCode" id="'+inputId+'" value="'+ htmlEmbed.replace(/"/g, '"') +'" onclick="javascript:document.getElementById(\''+inputId+'\').focus();document.getElementById(\''+inputId+'\').select();" readonly="true" type="text">'; + return '<input class="formEmbedCode" id="'+inputId+'" value="'+ htmlEmbed.replace(/"/g, '"') +'" onclick="javascript:document.getElementById(\''+inputId+'\').focus();document.getElementById(\''+inputId+'\').select();" readonly="true" type="text" />'; } this.getEmbedUrl = function( parameters, exportFormat ) @@ -84,21 +84,9 @@ function widgetize() '</span>'+ '</div>' ); - }); - - // Add the Clearspring Export - $(exportButtonsElement).append( - '<div id="embedThisWidgetEverywhere">'+ - '<div id="exportThisWidget">'+ - '<label for="flashEmbed">› 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(widgetIframeHtml); @@ -107,17 +95,8 @@ function widgetize() .parent() .append(exportButtonsElement); - // Call clearspring - $Launchpad.ShowButton({ - actionElement : "exportThisWidget", - targetElement : "exportThisWidgetMenu", - 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>'; - //divEmbedThisWidget.append('<br/>Embed JS: '+ getInputFormWithHtml('javascriptEmbed', widgetJS)); + //divEmbedThisWidget.append('<br />Embed JS: '+ getInputFormWithHtml('javascriptEmbed', widgetJS)); } } |