Skip to content

Commit

Permalink
im Dashboard gibt es jetzt noch einen direkten Link (Lupe) zu den wei…
Browse files Browse the repository at this point in the history
…teren Statistiken
  • Loading branch information
math authored and math committed Aug 16, 2014
1 parent 73be8e5 commit bd2e78d
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 169 deletions.
Binary file added assets/zoom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
333 changes: 170 additions & 163 deletions bepiwikcharts.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,81 +300,84 @@ function printChart($graphType, $apiModule, $period, $date, $width, $height, $sc
*/
function dashboardWelcomePage() {

// pruefen, ob die Seite im Backend aufgerufen wird
if (TL_MODE == 'BE') {
$this->import('BackendUser', 'User');

if ($GLOBALS["TL_CONFIG"]['piwikchartsWelcomePage'] || ($this->User->isAdmin && $GLOBALS["TL_CONFIG"]['piwikchartsWelcomePageAdmin'])) {

$strBuffer = '<div id="welcomepagePiwikcharts" style="margin:18px;">';
// wenn nicht Backend, dann abbrechen
if (TL_MODE != 'BE') {
return "";
}

if ( !( $GLOBALS["TL_CONFIG"]['piwikchartsWelcomePage'] || ($this->User->isAdmin && $GLOBALS["TL_CONFIG"]['piwikchartsWelcomePageAdmin'] ) ) ) {
// Statistiken nicht anzeigen, weil die Einstellungen so sind.
return "";
}

$objTemplate_head = new BackendTemplate('ce_headline');
$objTemplate_head->hl = 'h2';
$objTemplate_head->class = 'ce_headline';
$objTemplate_head->style = 'background:none repeat scroll 0 0 #F6F6F6;border: solid #E9E9E9; border-width: 1px 0px 1px 0px; margin:18px 0px 6px; padding: 2px 6px 3px;';
$objTemplate_head->headline = $GLOBALS['TL_LANG']['be_piwikcharts']['template']['dashboard']['headline'];
$strBuffer = '<div id="welcomepagePiwikcharts" style="margin:18px;">';

$strBuffer .= $objTemplate_head->parse();
$objTemplate_head = new BackendTemplate('ce_headline');
$objTemplate_head->hl = 'h2';
$objTemplate_head->class = 'ce_headline';
$objTemplate_head->style = 'background:none repeat scroll 0 0 #F6F6F6;border: solid #E9E9E9; border-width: 1px 0px 1px 0px; margin:18px 0px 6px; padding: 2px 6px 3px;';
$objTemplate_head->headline = $GLOBALS['TL_LANG']['be_piwikcharts']['template']['dashboard']['headline'];

$objTemplate_text = new BackendTemplate('ce_text');
$objTemplate_text->class = 'ce_text';
$objTemplate_text->style = 'position:relative;';
$strBuffer .= $objTemplate_head->parse();

$objTemplate_text = new BackendTemplate('ce_text');
$objTemplate_text->class = 'ce_text';
$objTemplate_text->style = 'position:relative;';

$objTemplate_content = new BackendTemplate('be_piwikcharts_welcome');
$objTemplate_content->update = $this->checkUpdate();
if ($this->error) {
$objTemplate_content->errorMessage = $GLOBALS['TL_LANG']['be_piwikcharts']['errormsg'][1];
$objTemplate_text->text = $objTemplate_content->parse();
$strBuffer .= $objTemplate_text->parse();

$strBuffer .= '</div>';
$objTemplate_content = new BackendTemplate('be_piwikcharts_welcome');
$objTemplate_content->update = $this->checkUpdate();
if ($this->error) {
$objTemplate_content->errorMessage = $GLOBALS['TL_LANG']['be_piwikcharts']['errormsg'][1];
$objTemplate_text->text = $objTemplate_content->parse();
$strBuffer .= $objTemplate_text->parse();

return $strBuffer;
}
$strBuffer .= '</div>';

// Text-Labels im Template bequem zur Verfügung stellen
$objTemplate_content->lang = (object) $GLOBALS['TL_LANG']['be_piwikcharts']['template']['dashboard'];
return $strBuffer;
}

// Diagramme
$objTemplate_content->chart_evolutionVisitsSummaryDay .= $this->printChart("evolution", "VisitsSummary", "day", "previous30", 400, 180, 80, "get", "", "margin-right:20px;");
$objTemplate_content->chart_evolutionVisitsSummaryMonth .= $this->printChart("evolution", "VisitsSummary", "month", "previous24", 400, 100, 80, "get", "&colors=,,ff0000", "margin-bottom: 10px;");
// Text-Labels im Template bequem zur Verfügung stellen
$objTemplate_content->lang = (object) $GLOBALS['TL_LANG']['be_piwikcharts']['template']['dashboard'];

//im Demo-Modus (0) ist die Anzeige letzte 30Min/24h deaktivert
if ($this->modus > 0) {
$temp = $this->PHPload($this->buildURL("Live.getCounters", "", "", "&format=php&lastMinutes=" . (60 * 24)), array("visits"));
$objTemplate_content->visitsLast30Minutes = $temp[0];
$temp = $this->PHPload($this->buildURL("Live.getCounters", "", "", "&format=php&lastMinutes=" . (60 * 24)), array("visits"));
$objTemplate_content->visitsLast24Hours = $temp[0];
} else {
$objTemplate_content->visitsLast30Minutes = "(disabled)";
$objTemplate_content->visitsLast24Hours = "(disabled)";
}
// Diagramme
$objTemplate_content->chart_evolutionVisitsSummaryDay .= $this->printChart("evolution", "VisitsSummary", "day", "previous30", 400, 180, 80, "get", "", "margin-right:20px;");
$objTemplate_content->chart_evolutionVisitsSummaryMonth .= $this->printChart("evolution", "VisitsSummary", "month", "previous24", 400, 100, 80, "get", "&colors=,,ff0000", "margin-bottom: 10px;");

$objTemplate_content->link_optOut = $this->url . "index.php?module=CoreAdminHome&action=optOut";
$objTemplate_content->showOptOut = $GLOBALS["TL_CONFIG"]['piwikchartsWelcomePageOptout'] || $this->User->isAdmin;
$objTemplate_content->optOutIcon = "system/modules/be_piwikcharts/assets/optout.png";
//im Demo-Modus (0) ist die Anzeige letzte 30Min/24h deaktivert
if ($this->modus > 0) {
$temp = $this->PHPload($this->buildURL("Live.getCounters", "", "", "&format=php&lastMinutes=" . (60 * 24)), array("visits"));
$objTemplate_content->visitsLast30Minutes = $temp[0];
$temp = $this->PHPload($this->buildURL("Live.getCounters", "", "", "&format=php&lastMinutes=" . (60 * 24)), array("visits"));
$objTemplate_content->visitsLast24Hours = $temp[0];
} else {
$objTemplate_content->visitsLast30Minutes = "(disabled)";
$objTemplate_content->visitsLast24Hours = "(disabled)";
}

$objTemplate_content->link_optOut = $this->url . "index.php?module=CoreAdminHome&action=optOut";
$objTemplate_content->showOptOut = $GLOBALS["TL_CONFIG"]['piwikchartsWelcomePageOptout'] || $this->User->isAdmin;
$objTemplate_content->optOutIcon = "system/modules/be_piwikcharts/assets/optout.png";

$objTemplate_content->showUpdate = $this->User->isAdmin || $GLOBALS["TL_CONFIG"]['piwikchartsWelcomePageUpdate'];
$objTemplate_content->updateIcon = "system/modules/be_piwikcharts/assets/update.png";
$objTemplate_content->link_server = $this->url;

$objTemplate_content->showUpdate = $this->User->isAdmin || $GLOBALS["TL_CONFIG"]['piwikchartsWelcomePageUpdate'];
$objTemplate_content->updateIcon = "system/modules/be_piwikcharts/assets/update.png";
$objTemplate_content->link_server = $this->url;

$this->import('BackendUser', 'User');
if ($this->User->hasAccess('be_piwikcharts', 'modules')) {
$objTemplate_content->moreLinkAccess = true;
$objTemplate_content->zoomIcon = "system/modules/be_piwikcharts/assets/zoom.png";
} else {
$objTemplate_content->moreLinkAccess = false;
}

$objTemplate_text->text = $objTemplate_content->parse();
$strBuffer .= $objTemplate_text->parse();
$objTemplate_text->text = $objTemplate_content->parse();
$strBuffer .= $objTemplate_text->parse();

$strBuffer .= '</div>';
$strBuffer .= '</div>';

return $strBuffer;
} else {
// Statistiken nicht anzeigen, weil die Einstellungen so sind.
return "";
}
} else {
return "";
}
return $strBuffer;
}

/**
Expand All @@ -383,122 +386,126 @@ function dashboardWelcomePage() {
* Templatevariablen belegen
*/
public function generate() {
// pruefen, ob die Seite im Backend aufgerufen wird
if (TL_MODE == 'BE') {
// Objekt vom Template "be_piwikcharts" erzeugen
$objTemplate = new BackendTemplate('be_piwikcharts');

$objTemplate->lang = (object) $GLOBALS['TL_LANG']['be_piwikcharts']['template']['sheet'];
// wenn nicht Backend, dann abbrechen
if (TL_MODE != 'BE') {
// generate() von der Oberklasse (BackendModule) aufrufen
return parent::generate();
}

// Objekt vom Template "be_piwikcharts" erzeugen
$objTemplate = new BackendTemplate('be_piwikcharts');

$objTemplate->update = $this->checkUpdate();
if ($this->error) {
$objTemplate->errorMessage = $GLOBALS['TL_LANG']['be_piwikcharts']['errormsg'][1];
return $objTemplate->parse();
}
$objTemplate->lang = (object) $GLOBALS['TL_LANG']['be_piwikcharts']['template']['sheet'];

// Userklasse laden. Wird zum Prüfen benötigt, ob der User ein Admin ist
$this->import('BackendUser', 'User');
$objTemplate->isAdmin = $this->User->isAdmin;
$objTemplate->update = $this->checkUpdate();
if ($this->error) {
$objTemplate->errorMessage = $GLOBALS['TL_LANG']['be_piwikcharts']['errormsg'][1];
return $objTemplate->parse();
}

// Steuerelemente
$objTemplate->link_settings = $this->Environment->path . "/contao/main.php?do=settings#pal_piwikcharts_legend";
// Userklasse laden. Wird zum Prüfen benötigt, ob der User ein Admin ist
$this->import('BackendUser', 'User');
$objTemplate->isAdmin = $this->User->isAdmin;

if (!empty($this->username) && !empty($this->password)) {
$hashed = hash('md5', @Encryption::decrypt($this->password));
$objTemplate->link_server_login = $this->url . 'index.php?module=Login&action=logme&login=' . $this->username . '&password=' . $hashed;
}
// Steuerelemente
$objTemplate->link_settings = $this->Environment->path . "/contao/main.php?do=settings#pal_piwikcharts_legend";

$objTemplate->link_server = $this->url;


$objTemplate->piwik_IDsite = $this->piwik_IDsite;
$objTemplate->link_optOut = $this->url . "index.php?module=CoreAdminHome&action=optOut";

$objTemplate->showUpdate = $this->User->isAdmin || $GLOBALS["TL_CONFIG"]['piwikchartsWelcomePageUpdate'];

// 30 Tage Besuchergraf
$objTemplate->chart_evolutionVisitsSummaryDay = $this->printChart("evolution", "VisitsSummary", "day", "previous30", 400, 200, 80, "get");

// 24 Monate Besuchergraf
$objTemplate->chart_evolutionVisitsSummaryMonth = $this->printChart("evolution", "VisitsSummary", "month", "previous24", 400, 200, 80, "get", "&colors=,,ff0000");

// Diagramm Besuchszeiten
$objTemplate->chart_verticalBarVisitsPerServerTime = $this->printChart("verticalBar", "VisitTime", "range", "previous30", 400, 200, 80, "getVisitInformationPerServerTime");

// Diagramm Besuchertage
$objTemplate->chart_verticalBarVisitTimeByDayOfWeek = $this->printChart("verticalBar", "VisitTime", "range", "previous30", 400, 200, 80, "getByDayOfWeek");

// Diagramm Browser
$objTemplate->chart_horizontalBarUserBrowser = $this->printChart("horizontalBar", "UserSettings", "range", "previous30", 400, 200, 80, "getBrowser");

// Diagramm Länder
$objTemplate->chart_horizontalBarUserCountry = $this->printChart("horizontalBar", "UserCountry", "range", "previous30", 400, 200, 80, "getCountry");

//Tabelle: Suchworte von Suchmaschinen
$objTemplate->table_keywords = $this->printTable(
$this->PHPload(
$this->buildURL(
"Referers.getKeywords", "range", "previous30", "&format=php&filter_limit=20"
), array("label", "nb_visits")
), array(
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['sheet']['table']['keywords_header_keyword'],
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['sheet']['table']['keywords_header_count']
), "data"
);

//Tabelle: Besucher von Webseite
$objTemplate->table_fromWebsite = $this->printTable(
$this->PHPload(
$this->buildURL(
"Referers.getWebsites", "range", "previous30", "&format=php&filter_limit=20"
), array("label", "nb_visits")
), array(
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['sheet']['table']['fromWebsite_header_website'],
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['sheet']['table']['fromWebsite_header_count']
), "data"
);

// Tabelle: angeschaute Seiten
$objTemplate->table_visitedPages = $this->printTable(
$this->PHPload(
$this->buildURL(
"Actions.getPageUrls", "range", "previous30", "&format=php&filter_limit=20"
), array("label", "nb_visits")
), array(
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['sheet']['table']['visitedPages_header_page'],
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['sheet']['table']['visitedPages_header_count']
), "data"
);

// Tabelle: Downloads
$objTemplate->table_downloads = $this->printTable_downloads(
$this->PHPload(
$this->buildURL(
"Actions.getDownloads", "range", "previous30", "&format=php&filter_limit=20&expanded=1&filter_limit=10"
), array("label", "subtable")
), "downloads"
);

// Zusammenfassung (letzte 30 Minuten/letzte 24 Stunden)
//im Demo-Modus ist die Anzeige letzte 30Min/24h deaktivert
if ($this->modus > 0) {
$temp = $this->PHPload($this->buildURL("Live.getCounters", "", "", "&format=php&lastMinutes=" . (60 * 24)), array("visits"));
$objTemplate->visitsLast30Minutes = $temp[0];
$temp = $this->PHPload($this->buildURL("Live.getCounters", "", "", "&format=php&lastMinutes=" . (60 * 24)), array("visits"));
$objTemplate->visitsLast24Hours = $temp[0];
} else {
$objTemplate->visitsLast30Minutes = "(disabled)";
$objTemplate->visitsLast24Hours = "(disabled)";
}
if (!empty($this->username) && !empty($this->password)) {
$hashed = hash('md5', @Encryption::decrypt($this->password));
$objTemplate->link_server_login = $this->url . 'index.php?module=Login&action=logme&login=' . $this->username . '&password=' . $hashed;
}

return $objTemplate->parse();
$objTemplate->link_server = $this->url;


$objTemplate->piwik_IDsite = $this->piwik_IDsite;
$objTemplate->link_optOut = $this->url . "index.php?module=CoreAdminHome&action=optOut";

$objTemplate->showUpdate = $this->User->isAdmin || $GLOBALS["TL_CONFIG"]['piwikchartsWelcomePageUpdate'];

// 30 Tage Besuchergraf
$objTemplate->chart_evolutionVisitsSummaryDay = $this->printChart("evolution", "VisitsSummary", "day", "previous30", 400, 200, 80, "get");

// 24 Monate Besuchergraf
$objTemplate->chart_evolutionVisitsSummaryMonth = $this->printChart("evolution", "VisitsSummary", "month", "previous24", 400, 200, 80, "get", "&colors=,,ff0000");

// Diagramm Besuchszeiten
$objTemplate->chart_verticalBarVisitsPerServerTime = $this->printChart("verticalBar", "VisitTime", "range", "previous30", 400, 200, 80, "getVisitInformationPerServerTime");

// Diagramm Besuchertage
$objTemplate->chart_verticalBarVisitTimeByDayOfWeek = $this->printChart("verticalBar", "VisitTime", "range", "previous30", 400, 200, 80, "getByDayOfWeek");

// Diagramm Browser
$objTemplate->chart_horizontalBarUserBrowser = $this->printChart("horizontalBar", "UserSettings", "range", "previous30", 400, 200, 80, "getBrowser");

// Diagramm Länder
$objTemplate->chart_horizontalBarUserCountry = $this->printChart("horizontalBar", "UserCountry", "range", "previous30", 400, 200, 80, "getCountry");

//Tabelle: Suchworte von Suchmaschinen
$objTemplate->table_keywords = $this->printTable(
$this->PHPload(
$this->buildURL(
"Referers.getKeywords", "range", "previous30", "&format=php&filter_limit=20"
), array("label", "nb_visits")
), array(
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['sheet']['table']['keywords_header_keyword'],
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['sheet']['table']['keywords_header_count']
), "data"
);

//Tabelle: Besucher von Webseite
$objTemplate->table_fromWebsite = $this->printTable(
$this->PHPload(
$this->buildURL(
"Referers.getWebsites", "range", "previous30", "&format=php&filter_limit=20"
), array("label", "nb_visits")
), array(
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['sheet']['table']['fromWebsite_header_website'],
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['sheet']['table']['fromWebsite_header_count']
), "data"
);

// Tabelle: angeschaute Seiten
$objTemplate->table_visitedPages = $this->printTable(
$this->PHPload(
$this->buildURL(
"Actions.getPageUrls", "range", "previous30", "&format=php&filter_limit=20"
), array("label", "nb_visits")
), array(
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['sheet']['table']['visitedPages_header_page'],
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['sheet']['table']['visitedPages_header_count']
), "data"
);

// Tabelle: Downloads
$objTemplate->table_downloads = $this->printTable_downloads(
$this->PHPload(
$this->buildURL(
"Actions.getDownloads", "range", "previous30", "&format=php&filter_limit=20&expanded=1&filter_limit=10"
), array("label", "subtable")
), "downloads"
);

// Zusammenfassung (letzte 30 Minuten/letzte 24 Stunden)
//im Demo-Modus ist die Anzeige letzte 30Min/24h deaktivert
if ($this->modus > 0) {
$temp = $this->PHPload($this->buildURL("Live.getCounters", "", "", "&format=php&lastMinutes=" . (60 * 24)), array("visits"));
$objTemplate->visitsLast30Minutes = $temp[0];
$temp = $this->PHPload($this->buildURL("Live.getCounters", "", "", "&format=php&lastMinutes=" . (60 * 24)), array("visits"));
$objTemplate->visitsLast24Hours = $temp[0];
} else {
$objTemplate->visitsLast30Minutes = "(disabled)";
$objTemplate->visitsLast24Hours = "(disabled)";
}

// generate() von der Oberklasse (BackendModule) aufrufen
return parent::generate();
return $objTemplate->parse();
}

/* * **************************************************************************




/****************************************************************************
* individuelle rgxp:
* siehe Contao-Doku: https://contao.org/de/manual/3.3/customizing-contao.html#addcustomregexp
* ************************************************************************** */
Expand Down
4 changes: 3 additions & 1 deletion languages/de/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['dashboard']['live']['last24hours'] = "letzte 24 Stunden";
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['dashboard']['optOut'] = "Optout: Eigene Besuche auf der Webseite nicht mehr erfassen";
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['dashboard']['newVersionHint'] = "Ein neues Update der Piwik-Software ist verfügbar";
$GLOBALS['TL_LANG']['be_piwikcharts']['template']['dashboard']['zoomIt'] = "Mehr Statistiken...";

$GLOBALS['TL_LANG']['be_piwikcharts']['template']['sheet']['headline'] = "Statistiken Besucher mit Piwik";

Expand Down Expand Up @@ -94,7 +95,8 @@
* Load on be_welcome
*/
if (TL_MODE == 'BE') {
if (!strlen($_GET['do'])) {
$this->import('BackendUser', 'User');
if (!strlen($_GET['do']) && ($this->User->language == "de") ) {
$bepiwikcharts = new bepiwikcharts();
$GLOBALS['TL_LANG']['MSC']['welcomeTo'] .= '</h1>' . $bepiwikcharts->dashboardWelcomePage() . '<h1 style="display:none">&nbsp;';
}
Expand Down
Loading

0 comments on commit bd2e78d

Please sign in to comment.