title = $this->get_config('title', $this->title); $propbag->add('name', PLUGIN_SIDEBAR_PIWIK_NAME); $propbag->add('description', PLUGIN_SIDEBAR_PIWIK_DESC); $propbag->add('stackable', true); $propbag->add('author', 'Bernd Distler'); $propbag->add('version', '0.4.1'); $propbag->add('requirements', array( 'serendipity' => '1.6', 'smarty' => '2.6.7', 'php' => '5.1.0' )); $propbag->add('configuration', array('title','token','site_id','url','live_show','live_title','live_minutes','entries_show','entries_title','entries_days','entries_max','entries_remove','debug')); $propbag->add('groups', array('FRONTEND_EXTERNAL_SERVICES')); $this->dependencies = array('serendipity_event_piwik' => 'remove'); } /** * @param string $name * @param serendipity_property_bag $propbag * @return bool */ public function introspect_config_item($name, &$propbag) { switch($name) { case 'title': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_PIWIK_TITLE_NAME); $propbag->add('description', PLUGIN_SIDEBAR_PIWIK_TITLE_DESC); $propbag->add('default', ''); break; case 'token': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_PIWIK_TOKEN_NAME); $propbag->add('description', PLUGIN_SIDEBAR_PIWIK_TOKEN_DESC); $propbag->add('default', ''); break; case 'site_id': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_PIWIK_SITEID_NAME); $propbag->add('description', PLUGIN_SIDEBAR_PIWIK_SITEID_DESC); $propbag->add('default', ''); break; case 'url': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_PIWIK_URL_NAME); $propbag->add('description', PLUGIN_SIDEBAR_PIWIK_URL_DESC); $propbag->add('default', 'http://example.org/piwik/'); break; case 'live_show': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_SIDEBAR_PIWIK_LIVE_SHOW_NAME); $propbag->add('description', PLUGIN_SIDEBAR_PIWIK_LIVE_SHOW_DESC); $propbag->add('default', 'true'); break; case 'live_title': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_PIWIK_LIVE_TITLE_NAME); $propbag->add('description', PLUGIN_SIDEBAR_PIWIK_LIVE_TITLE_DESC); $propbag->add('default', ''); break; case 'live_minutes': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_PIWIK_LIVE_MINUTES_NAME); $propbag->add('description', PLUGIN_SIDEBAR_PIWIK_LIVE_MINUTES_DESC); $propbag->add('default', '30'); break; case 'entries_show': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_SIDEBAR_PIWIK_ENTRIES_SHOW_NAME); $propbag->add('description', PLUGIN_SIDEBAR_PIWIK_ENTRIES_SHOW_DESC); $propbag->add('default', 'true'); break; case 'entries_title': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_PIWIK_ENTRIES_TITLE_NAME); $propbag->add('description', PLUGIN_SIDEBAR_PIWIK_ENTRIES_TITLE_DESC); $propbag->add('default', ''); break; case 'entries_days': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_PIWIK_ENTRIES_DAYS_NAME); $propbag->add('description', PLUGIN_SIDEBAR_PIWIK_ENTRIES_DAYS_DESC); $propbag->add('default', '7'); break; case 'entries_max': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_PIWIK_ENTRIES_MAX_NAME); $propbag->add('description', PLUGIN_SIDEBAR_PIWIK_ENTRIES_MAX_DESC); $propbag->add('default', '5'); break; case 'entries_remove': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_PIWIK_ENTRIES_REMOVE_NAME); $propbag->add('description', PLUGIN_SIDEBAR_PIWIK_ENTRIES_REMOVE_DESC); $propbag->add('default', ''); break; case 'debug': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_SIDEBAR_PIWIK_DEBUG_NAME); $propbag->add('description', PLUGIN_SIDEBAR_PIWIK_DEBUG_DESC); $propbag->add('default', 'false'); break; } return true; } /** * @param string $title * @return void */ public function generate_content(&$title) { $title = $this->get_config('title', $title ? $title : $this->title); $token = $this->get_config('token', $this->token); $site_id = $this->get_config('site_id', $this->site_id); $url = $this->get_config('url', $this->url); $live_show = $this->get_config('live_show', $this->live_show); $live_title = $this->get_config('live_title', $this->live_title); $live_minutes = $this->get_config('live_minutes', $this->live_minutes); $entries_show = $this->get_config('entries_show', $this->entries_show); $entries_title = $this->get_config('entries_title', $this->entries_title); $entries_days = $this->get_config('entries_days', $this->entries_days); $entries_max = $this->get_config('entries_max', $this->entries_max); $entries_remove = $this->get_config('entries_remove', $this->entries_remove); $debug = $this->get_config('debug', $this->debug); $error = false; $piwik_array_pagesurls = array(); $piwik_array_pagestitles = array(); $piwik_array_live = array(); /* live statistics from last xx minutes */ if ($live_show) { $api_url = $url; $api_url .= "?module=API&method=Live.getCounters"; $api_url .= "&idSite=" . $site_id . "&lastMinutes=" . $live_minutes; $api_url .= "&format=PHP"; $api_url .= "&token_auth=$token"; if ($debug) {$this->debug_append('Live.getCounters - API-URL: '.$api_url);} try { $piwik_array_live = unserialize($this->requestPiwikData($api_url)); } catch (Exception $e) { $error = true; } if ($error) { return; } if ($live_title <> '') {echo "\n