diff --git a/oss/piwik/trunk/plugins/ExampleFeedburner/ExampleFeedburner.php b/oss/piwik/trunk/plugins/ExampleFeedburner/ExampleFeedburner.php
new file mode 100644
index 00000000..633e3e9f
--- /dev/null
+++ b/oss/piwik/trunk/plugins/ExampleFeedburner/ExampleFeedburner.php
@@ -0,0 +1,153 @@
+ Piwik_Translate('ExampleFeedburner_PluginDescription'),
+ 'author' => 'Piwik',
+ 'author_homepage' => 'http://piwik.org/',
+ 'version' => '0.1',
+ );
+ }
+
+ function install()
+ {
+ try{
+ Piwik_Exec('ALTER TABLE '.Piwik_Common::prefixTable('site'). " ADD `feedburnerName` VARCHAR( 100 ) DEFAULT NULL");
+ } catch(Exception $e){
+ // mysql code error 1060: column already exists
+ // if there is another error we throw the exception, otherwise it is OK as we are simply reinstalling the plugin
+ if(!Zend_Registry::get('db')->isErrNo($e, '1060'))
+ {
+ throw $e;
+ }
+ }
+ }
+
+ function uninstall()
+ {
+ Piwik_Query('ALTER TABLE '.Piwik_Common::prefixTable('site'). " DROP `feedburnerName`");
+ }
+}
+
+Piwik_AddWidget('Example Widgets', 'Feedburner statistics', 'ExampleFeedburner', 'feedburner');
+
+/**
+ *
+ * @package Piwik_ExampleFeedburner
+ */
+class Piwik_ExampleFeedburner_Controller extends Piwik_Controller
+{
+
+ /**
+ * Simple feedburner statistics output
+ *
+ */
+ function feedburner()
+ {
+ $view = Piwik_View::factory('feedburner');
+ $idSite = Piwik_Common::getRequestVar('idSite',1,'int');
+ $feedburnerFeedName = Piwik_FetchOne('SELECT feedburnerName FROM '.Piwik_Common::prefixTable('site').
+ ' WHERE idsite = ?', $idSite );
+ if(empty($feedburnerFeedName))
+ {
+ $feedburnerFeedName = 'Piwik';
+ }
+ $view->feedburnerFeedName = $feedburnerFeedName;
+ $view->idSite = $idSite;
+ $view->fbStats = $this->getFeedData($feedburnerFeedName);
+ echo $view->render();
+ }
+
+
+ /**
+ * Returns array of counts and images based on Feedburner URI
+ *
+ * @param string $uri
+ * @return array()
+ */
+ protected function getFeedData($uri)
+ {
+ // Awareness API only supports yesterday and back;
+ // we get stats for previous two days;
+ // @see http://code.google.com/apis/feedburner/awareness_api.html#dates
+ $yesterday = Piwik_Date::factory('-1 day', 'America/Los_Angeles');
+ $beforeYesterday = Piwik_Date::factory('-2 day', 'America/Los_Angeles');
+
+ //create url to gather XML feed from
+ $url = 'https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri='.$uri.'&dates='.$beforeYesterday->toString().','.$yesterday->toString();
+ $data = '';
+ try {
+ $data = Piwik_Http::sendHttpRequest($url, 5);
+ $xml = new SimpleXMLElement($data);
+ } catch(Exception $e) {
+ return "Error parsing the data for feed $uri. Fetched data was: \n'". $data."'";
+ }
+
+ if(count($xml->feed->entry) != 2) {
+ return "Error fetching the Feedburner stats. Expected XML, Got: \n" . strip_tags($data);
+ }
+ $data = array();
+ $i = 0;
+ foreach($xml->feed->entry as $feedDay){
+ $data[0][$i] = (int)$feedDay['circulation'];
+ $data[1][$i] = (int)$feedDay['hits'];
+ $data[2][$i] = (int)$feedDay['reach'];
+ $i++;
+ }
+
+ foreach($data as $key => $value) {
+ if( $value[0] == $value[1]) {
+ $img = 'stop.png';
+ } else if($value[0] < $value[1]) {
+ $img = 'arrow_up.png';
+ } else {
+ $img = 'arrow_down.png';
+ }
+
+ $prefixImage = '';
+ $data[$key][2] = $prefixImage . $img . $suffixImage;
+ }
+ return $data;
+ }
+
+ /**
+ * Function called to save the Feedburner ID entered in the form
+ *
+ */
+ function saveFeedburnerName()
+ {
+ // we save the value in the DB for an authenticated user
+ if(Piwik::getCurrentUserLogin() != 'anonymous')
+ {
+ Piwik_Query('UPDATE '.Piwik_Common::prefixTable('site').'
+ SET feedburnerName = ? WHERE idsite = ?',
+ array(Piwik_Common::getRequestVar('name','','string'), Piwik_Common::getRequestVar('idSite',1,'int'))
+ );
+ }
+ }
+}
diff --git a/oss/piwik/trunk/plugins/ExampleFeedburner/templates/feedburner.tpl b/oss/piwik/trunk/plugins/ExampleFeedburner/templates/feedburner.tpl
new file mode 100644
index 00000000..812dcdc2
--- /dev/null
+++ b/oss/piwik/trunk/plugins/ExampleFeedburner/templates/feedburner.tpl
@@ -0,0 +1,57 @@
+
+
+
+{/literal}
+
+{if !is_array($fbStats)}
+ {$fbStats}
+{else}
+
| + | Previous | +Yesterday | ++ |
| Circulation | +{$fbStats[0][0]} | +{$fbStats[0][1]} | +{$fbStats[0][2]} | +
| Hits | +{$fbStats[1][0]} | +{$fbStats[1][1]} | +{$fbStats[1][2]} | +
| Reach | +{$fbStats[2][0]} | +{$fbStats[2][1]} | +{$fbStats[2][2]} | +
$this->date = current selected Piwik_Date object (class)$period = Piwik_Common::getRequestVar("period"); - Get the current selected period$idSite = Piwik_Common::getRequestVar("idSite"); - Get the selected idSite$site = new Piwik_Site($idSite); - Build the Piwik_Site object (class)$this->str_date = current selected date in YYYY-MM-DD formatPiwik_AddMenu( $mainMenuName, $subMenuName, $url ); - Adds an entry to the menu in the Piwik interface (See the example in the UserCountry Plugin file)Piwik_AddWidget( $widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array()); - 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 UserCountry Plugin file or any other plugin)Piwik_Common::prefixTable("site") = ' . Piwik_Common::prefixTable("site") . 'Piwik::getCurrentUserLogin() = ' . Piwik::getCurrentUserLogin() . 'Piwik::isUserHasSomeAdminAccess() = ' . self::boolToString(Piwik::isUserHasSomeAdminAccess()) . 'Piwik::isUserHasAdminAccess( array $idSites = array(1,2) ) = ' . self::boolToString(Piwik::isUserHasAdminAccess(array(1,2) )) . 'Piwik::isUserHasViewAccess( array $idSites = array(1) ) = ' . self::boolToString(Piwik::isUserHasViewAccess(array(1))) . 'Piwik::isUserIsSuperUser() = ' . self::boolToString(Piwik::isUserIsSuperUser()) . 'Piwik_FetchOne("'.$txtQuery.'", array("anonymous")) = ' . var_export($result,true) . '$query = Piwik_Query("'.$txtQuery.'", array("anonymous"))$fetched = $query->fetch();$fetched[\'token_auth\'] == '.var_export($token_auth,true) . 'Piwik_SitesManager_API::getInstance()->getSitesWithViewAccess() = ' .var_export(Piwik_SitesManager_API::getInstance()->getSitesWithViewAccess(),true) . '
Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess() = ' .var_export(Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess(),true) . '
Piwik_UsersManager_API::getInstance()->getUsersSitesFromAccess("view"); or Piwik_UsersManager_API::getInstance()->deleteUser("userToDelete");\'Goals_AddGoal_js\' => \'Add Goal\', in the lang/en.php file{loadJavascriptTranslations plugins=\'$YOUR_PLUGIN_NAME\'}. In our previous example, the $YOUR_PLUGIN_NAME being Goals, we would write {loadJavascriptTranslations plugins=\'Goals\'}
+ _pk_translate(\'Goals_AddGoal_js\');.
+ piwik.dashboardObject.reloadEnclosingWidget($(this));.';
+
+ $out .= '