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
|
||||
|
|
@ -9,10 +9,11 @@
|
|||
namespace Piwik\DataTable;
|
||||
|
||||
use Exception;
|
||||
use Piwik\Common;
|
||||
use Piwik\DataTable;
|
||||
use Piwik\Loader;
|
||||
use Piwik\Metrics;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\BaseFactory;
|
||||
|
||||
/**
|
||||
* A DataTable Renderer can produce an output given a DataTable object.
|
||||
|
|
@ -22,7 +23,7 @@ use Piwik\Piwik;
|
|||
* $render->setTable($dataTable);
|
||||
* echo $render;
|
||||
*/
|
||||
abstract class Renderer
|
||||
abstract class Renderer extends BaseFactory
|
||||
{
|
||||
protected $table;
|
||||
|
||||
|
|
@ -100,7 +101,7 @@ abstract class Renderer
|
|||
*/
|
||||
protected function renderHeader()
|
||||
{
|
||||
@header('Content-Type: text/plain; charset=utf-8');
|
||||
Common::sendHeader('Content-Type: text/plain; charset=utf-8');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -110,22 +111,6 @@ abstract class Renderer
|
|||
*/
|
||||
abstract public function render();
|
||||
|
||||
/**
|
||||
* Computes the exception output and returns the string/binary
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function renderException();
|
||||
|
||||
protected function getExceptionMessage()
|
||||
{
|
||||
$message = $this->exception->getMessage();
|
||||
if (\Piwik_ShouldPrintBackTraceWithMessage()) {
|
||||
$message .= "\n" . $this->exception->getTraceAsString();
|
||||
}
|
||||
return self::renderHtmlEntities($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see render()
|
||||
* @return string
|
||||
|
|
@ -144,32 +129,17 @@ abstract class Renderer
|
|||
public function setTable($table)
|
||||
{
|
||||
if (!is_array($table)
|
||||
&& !($table instanceof DataTable)
|
||||
&& !($table instanceof DataTable\Map)
|
||||
&& !($table instanceof DataTableInterface)
|
||||
) {
|
||||
throw new Exception("DataTable renderers renderer accepts only DataTable and Map instances, and arrays.");
|
||||
throw new Exception("DataTable renderers renderer accepts only DataTable, Simple and Map instances, and arrays.");
|
||||
}
|
||||
$this->table = $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Exception to be rendered
|
||||
*
|
||||
* @param Exception $exception to be rendered
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setException($exception)
|
||||
{
|
||||
if (!($exception instanceof Exception)) {
|
||||
throw new Exception("The exception renderer accepts only an Exception object.");
|
||||
}
|
||||
$this->exception = $exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
static protected $availableRenderers = array('xml',
|
||||
protected static $availableRenderers = array('xml',
|
||||
'json',
|
||||
'csv',
|
||||
'tsv',
|
||||
|
|
@ -182,41 +152,25 @@ abstract class Renderer
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
static public function getRenderers()
|
||||
public static function getRenderers()
|
||||
{
|
||||
return self::$availableRenderers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the DataTable associated to the output format $name
|
||||
*
|
||||
* @param string $name
|
||||
* @throws Exception If the renderer is unknown
|
||||
* @return \Piwik\DataTable\Renderer
|
||||
*/
|
||||
static public function factory($name)
|
||||
protected static function getClassNameFromClassId($id)
|
||||
{
|
||||
$className = ucfirst(strtolower($name));
|
||||
$className = ucfirst(strtolower($id));
|
||||
$className = 'Piwik\DataTable\Renderer\\' . $className;
|
||||
try {
|
||||
Loader::loadClass($className);
|
||||
return new $className;
|
||||
} catch (Exception $e) {
|
||||
$availableRenderers = implode(', ', self::getRenderers());
|
||||
@header('Content-Type: text/plain; charset=utf-8');
|
||||
throw new Exception(Piwik::translate('General_ExceptionInvalidRendererFormat', array($className, $availableRenderers)));
|
||||
}
|
||||
|
||||
return $className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns $rawData after all applicable characters have been converted to HTML entities.
|
||||
*
|
||||
* @param String $rawData data to be converted
|
||||
* @return String
|
||||
*/
|
||||
static protected function renderHtmlEntities($rawData)
|
||||
protected static function getInvalidClassIdExceptionMessage($id)
|
||||
{
|
||||
return self::formatValueXml($rawData);
|
||||
$availableRenderers = implode(', ', self::getRenderers());
|
||||
$klassName = self::getClassNameFromClassId($id);
|
||||
|
||||
return Piwik::translate('General_ExceptionInvalidRendererFormat', array($klassName, $availableRenderers));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -236,12 +190,14 @@ abstract class Renderer
|
|||
$value = @mb_convert_encoding($value, 'UTF-8', 'UTF-8');
|
||||
}
|
||||
$value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
|
||||
|
||||
$htmlentities = array(" ", "¡", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "­", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ", "€");
|
||||
$xmlentities = array("¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "­", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ", "€");
|
||||
$value = str_replace($htmlentities, $xmlentities, $value);
|
||||
$xmlentities = array("¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "­", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ", "€");
|
||||
$value = str_replace($htmlentities, $xmlentities, $value);
|
||||
} elseif ($value === false) {
|
||||
$value = 0;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue