update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
296343bf3b
commit
d885a4baa9
5833 changed files with 418860 additions and 226988 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -11,7 +11,6 @@ namespace Piwik\DataTable\Renderer;
|
|||
use Piwik\Common;
|
||||
use Piwik\DataTable\Renderer;
|
||||
use Piwik\DataTable;
|
||||
use Piwik\ProxyHttp;
|
||||
|
||||
/**
|
||||
* JSON export.
|
||||
|
|
@ -27,27 +26,9 @@ class Json extends Renderer
|
|||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->renderHeader();
|
||||
return $this->renderTable($this->table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the exception output and returns the string/binary
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function renderException()
|
||||
{
|
||||
$this->renderHeader();
|
||||
|
||||
$exceptionMessage = $this->getExceptionMessage();
|
||||
$exceptionMessage = str_replace(array("\r\n", "\n"), "", $exceptionMessage);
|
||||
|
||||
$result = json_encode(array('result' => 'error', 'message' => $exceptionMessage));
|
||||
|
||||
return $this->jsonpWrap($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the output for the given data table
|
||||
*
|
||||
|
|
@ -73,7 +54,6 @@ class Json extends Renderer
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$array = $this->convertDataTableToArray($table);
|
||||
}
|
||||
|
|
@ -90,40 +70,15 @@ class Json extends Renderer
|
|||
};
|
||||
array_walk_recursive($array, $callback);
|
||||
|
||||
$str = json_encode($array);
|
||||
|
||||
return $this->jsonpWrap($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @return string
|
||||
*/
|
||||
protected function jsonpWrap($str)
|
||||
{
|
||||
if (($jsonCallback = Common::getRequestVar('callback', false)) === false)
|
||||
$jsonCallback = Common::getRequestVar('jsoncallback', false);
|
||||
if ($jsonCallback !== false) {
|
||||
if (preg_match('/^[0-9a-zA-Z_.]*$/D', $jsonCallback) > 0) {
|
||||
$str = $jsonCallback . "(" . $str . ")";
|
||||
}
|
||||
}
|
||||
// silence "Warning: json_encode(): Invalid UTF-8 sequence in argument"
|
||||
$str = @json_encode($array);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the http header for json file
|
||||
*/
|
||||
protected function renderHeader()
|
||||
{
|
||||
self::sendHeaderJSON();
|
||||
ProxyHttp::overrideCacheControlHeaders();
|
||||
}
|
||||
|
||||
public static function sendHeaderJSON()
|
||||
{
|
||||
@header('Content-Type: application/json; charset=utf-8');
|
||||
Common::sendHeader('Content-Type: application/json; charset=utf-8');
|
||||
}
|
||||
|
||||
private function convertDataTableToArray($table)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue