-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
211 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,121 +1,101 @@ | ||
/*! | ||
* owncloud_piwik v0.4.1 - 2018-05-11 | ||
* cloud_piwik v0.5.0 - 2018-10-29 | ||
* | ||
* Copyright (c) 2018 Klaus Herberth <[email protected]> <br> | ||
* Released under the MIT license | ||
* | ||
* Please see https://github.com/sualko/owncloud_piwik | ||
* Please see https://github.com/sualko/cloud_piwik | ||
* | ||
* @author Klaus Herberth <[email protected]> | ||
* @version 0.4.1 | ||
* @version 0.5.0 | ||
* @license MIT | ||
*/ | ||
|
||
/* global OC, oc_debug */ | ||
/* global OC */ | ||
|
||
var _paq = _paq || []; | ||
|
||
(function() { | ||
"use strict"; | ||
|
||
var piwik; | ||
var options; | ||
|
||
if (typeof localStorage !== 'undefined') { | ||
var piwikString = localStorage.getItem('piwik'); | ||
try { | ||
options = JSON.parse('%OPTIONS%'); | ||
} catch (err) {} | ||
|
||
try { | ||
piwik = JSON.parse(piwikString); | ||
} catch (err) {} | ||
if (!options || !options.url || !options.siteId) { | ||
return; | ||
} | ||
|
||
if (piwik && (piwik.validUntil || 0) > (new Date()).getTime() && !oc_debug) { | ||
// use cached options | ||
track(piwik); | ||
} else { | ||
// load options | ||
$.ajax({ | ||
method: 'GET', | ||
url: OC.generateUrl('apps/piwik/settings'), | ||
}) | ||
.done(function(response) { | ||
var data = response ? response.data : {}; | ||
|
||
if (data.siteId && data.url) { | ||
data.validUntil = (new Date()).getTime() + (data.validity * 1000); | ||
|
||
localStorage.setItem('piwik', JSON.stringify(data)); | ||
|
||
track(data); | ||
} | ||
}); | ||
if (options.url[options.url.length - 1] !== '/') { | ||
options.url += '/'; | ||
} | ||
|
||
function track(options) { | ||
var app = null; | ||
var path = window.location.pathname; | ||
var pathparts = path.match(/(?:index\.php\/)?apps\/([a-z0-9]+)\/?/i) || path.match(/(?:index\.php\/)?([a-z0-9]+)(\/([a-z0-9]+))?/i) || []; | ||
var app = null; | ||
var path = window.location.pathname; | ||
var pathParts = path.match(/(?:index\.php\/)?apps\/([a-z0-9]+)\/?/i) || path.match(/(?:index\.php\/)?([a-z0-9]+)(\/([a-z0-9]+))?/i) || []; | ||
|
||
if (pathparts.length >= 2) { | ||
app = pathparts[1]; | ||
if (pathParts.length >= 2) { | ||
app = pathParts[1]; | ||
|
||
if (app === 's') { | ||
// rewrite app name | ||
app = 'share'; | ||
if (app === 's') { | ||
// rewrite app name | ||
app = 'share'; | ||
|
||
var sharevalue = $('input[name="filename"]').val(); | ||
var shareValue = $('input[name="filename"]').val(); | ||
|
||
if (sharevalue) { | ||
sharevalue = pathparts[3] + ' (' + sharevalue + ')'; | ||
if (shareValue) { | ||
shareValue = pathParts[3] + ' (' + shareValue + ')'; | ||
|
||
// save share id + share name in slot 3 | ||
_paq.push(['setCustomVariable', '3', 'ShareNodes', sharevalue, 'page']); | ||
} else { | ||
sharevalue = pathparts[3]; | ||
} | ||
|
||
// save share id in slot 2 | ||
_paq.push(['setCustomVariable', '2', 'Shares', pathparts[3], 'page']); | ||
// save share id + share name in slot 3 | ||
_paq.push(['setCustomVariable', '3', 'ShareNodes', shareValue, 'page']); | ||
} else { | ||
shareValue = pathParts[3]; | ||
} | ||
|
||
// save app name in slot 1 | ||
_paq.push(['setCustomVariable', '1', 'App', app, 'page']); | ||
} | ||
|
||
if (OC && OC.currentUser) { | ||
// set user id | ||
_paq.push(['setUserId', OC.currentUser]); | ||
// save share id in slot 2 | ||
_paq.push(['setCustomVariable', '2', 'Shares', pathParts[3], 'page']); | ||
} | ||
|
||
if (options.trackDir === 'on' || options.trackDir === true) { | ||
// track file browsing | ||
// save app name in slot 1 | ||
_paq.push(['setCustomVariable', '1', 'App', app, 'page']); | ||
} | ||
|
||
$('#app-content').delegate('>div', 'afterChangeDirectory', function() { | ||
// update title and url for next page view | ||
_paq.push(['setDocumentTitle', document.title]); | ||
_paq.push(['setCustomUrl', window.location.href]); | ||
_paq.push(['trackPageView']); | ||
}); | ||
} | ||
if (OC && OC.currentUser && options.trackUser) { | ||
// set user id | ||
_paq.push(['setUserId', OC.currentUser]); | ||
} | ||
|
||
// set piwik options | ||
_paq.push(['setTrackerUrl', options.url + 'piwik.php']); | ||
_paq.push(['setSiteId', options.siteId]); | ||
if (options.trackDir === 'on' || options.trackDir === true) { | ||
// track file browsing | ||
|
||
if (app !== 'files' || options.trackDir !== 'on') { | ||
// track page view | ||
$('#app-content').delegate('>div', 'afterChangeDirectory', function() { | ||
// update title and url for next page view | ||
_paq.push(['setDocumentTitle', document.title]); | ||
_paq.push(['setCustomUrl', window.location.href]); | ||
_paq.push(['trackPageView']); | ||
} | ||
}); | ||
} | ||
|
||
if (typeof Piwik === 'undefined') { | ||
// load piwik library | ||
var d = document, | ||
g = d.createElement('script'), | ||
s = d.getElementsByTagName('script')[0]; | ||
g.type = 'text/javascript'; | ||
g.async = true; | ||
g.defer = true; | ||
g.src = options.url + 'piwik.js'; | ||
s.parentNode.insertBefore(g, s); | ||
} | ||
// set piwik options | ||
_paq.push(['setTrackerUrl', options.url + 'piwik.php']); | ||
_paq.push(['setSiteId', options.siteId]); | ||
|
||
if (app !== 'files' || options.trackDir !== 'on') { | ||
// track page view | ||
_paq.push(['trackPageView']); | ||
} | ||
|
||
if (typeof Piwik === 'undefined') { | ||
// load piwik library | ||
var d = document, | ||
g = d.createElement('script'), | ||
s = d.getElementsByTagName('script')[0]; | ||
g.type = 'text/javascript'; | ||
g.async = true; | ||
g.defer = true; | ||
g.src = options.url + 'piwik.js'; | ||
s.parentNode.insertBefore(g, s); | ||
} | ||
}()); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
namespace OCA\Piwik; | ||
|
||
use OCP\IConfig; | ||
|
||
class Config | ||
{ | ||
public function __construct($appName, IConfig $config) | ||
{ | ||
$this->appName = $appName; | ||
$this->config = $config; | ||
} | ||
|
||
public function getAppValue($key, $default = null) | ||
{ | ||
$value = $this->config->getAppValue($this->appName, $key, $default); | ||
return (empty($value)) ? $default : $value; | ||
} | ||
|
||
public function setAppValue($key, $value) | ||
{ | ||
return $this->config->setAppValue($this->appName, $key, $value); | ||
} | ||
|
||
public function getBooleanAppValue($key) | ||
{ | ||
return $this->validateBoolean($this->getAppValue($key)); | ||
} | ||
|
||
private function validateBoolean($val) | ||
{ | ||
return $val === true || $val === 'true'; | ||
} | ||
} |
Oops, something went wrong.