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
|
||||
|
|
@ -12,29 +12,30 @@ namespace Piwik\DataTable;
|
|||
use Exception;
|
||||
use Piwik\Common;
|
||||
use Piwik\DataTable;
|
||||
use Piwik\Singleton;
|
||||
|
||||
/**
|
||||
* The DataTable_Manager registers all the instanciated DataTable and provides an
|
||||
* easy way to access them. This is used to store all the DataTable during the archiving process.
|
||||
* At the end of archiving, the ArchiveProcessor will read the stored datatable and record them in the DB.
|
||||
*
|
||||
* @method static \Piwik\DataTable\Manager getInstance()
|
||||
*/
|
||||
class Manager extends Singleton
|
||||
class Manager extends \ArrayObject
|
||||
{
|
||||
/**
|
||||
* Array used to store the DataTable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $tables = array();
|
||||
|
||||
/**
|
||||
* Id of the next inserted table id in the Manager
|
||||
* @var int
|
||||
*/
|
||||
protected $nextTableId = 1;
|
||||
protected $nextTableId = 0;
|
||||
|
||||
private static $instance;
|
||||
|
||||
public static function getInstance()
|
||||
{
|
||||
if (!isset(self::$instance)) {
|
||||
self::$instance = new Manager();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a DataTable to the registry
|
||||
|
|
@ -44,9 +45,9 @@ class Manager extends Singleton
|
|||
*/
|
||||
public function addTable($table)
|
||||
{
|
||||
$this->tables[$this->nextTableId] = $table;
|
||||
$this->nextTableId++;
|
||||
return $this->nextTableId - 1;
|
||||
$this[$this->nextTableId] = $table;
|
||||
return $this->nextTableId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -60,10 +61,11 @@ class Manager extends Singleton
|
|||
*/
|
||||
public function getTable($idTable)
|
||||
{
|
||||
if (!isset($this->tables[$idTable])) {
|
||||
throw new TableNotFoundException(sprintf("This report has been reprocessed since your last click. To see this error less often, please increase the timeout value in seconds in Settings > General Settings. (error: id %s not found).", $idTable));
|
||||
if (!isset($this[$idTable])) {
|
||||
throw new TableNotFoundException(sprintf("Error: table id %s not found in memory. (If this error is causing you problems in production, please report it in Piwik issue tracker.)", $idTable));
|
||||
}
|
||||
return $this->tables[$idTable];
|
||||
|
||||
return $this[$idTable];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -73,7 +75,7 @@ class Manager extends Singleton
|
|||
*/
|
||||
public function getMostRecentTableId()
|
||||
{
|
||||
return $this->nextTableId - 1;
|
||||
return $this->nextTableId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -81,14 +83,15 @@ class Manager extends Singleton
|
|||
*/
|
||||
public function deleteAll($deleteWhenIdTableGreaterThan = 0)
|
||||
{
|
||||
foreach ($this->tables as $id => $table) {
|
||||
foreach ($this as $id => $table) {
|
||||
if ($id > $deleteWhenIdTableGreaterThan) {
|
||||
$this->deleteTable($id);
|
||||
}
|
||||
}
|
||||
|
||||
if ($deleteWhenIdTableGreaterThan == 0) {
|
||||
$this->tables = array();
|
||||
$this->nextTableId = 1;
|
||||
$this->exchangeArray(array());
|
||||
$this->nextTableId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,8 +103,8 @@ class Manager extends Singleton
|
|||
*/
|
||||
public function deleteTable($id)
|
||||
{
|
||||
if (isset($this->tables[$id])) {
|
||||
Common::destroy($this->tables[$id]);
|
||||
if (isset($this[$id])) {
|
||||
Common::destroy($this[$id]);
|
||||
$this->setTableDeleted($id);
|
||||
}
|
||||
}
|
||||
|
|
@ -131,7 +134,7 @@ class Manager extends Singleton
|
|||
*/
|
||||
public function setTableDeleted($id)
|
||||
{
|
||||
$this->tables[$id] = null;
|
||||
$this[$id] = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -140,7 +143,7 @@ class Manager extends Singleton
|
|||
public function dumpAllTables()
|
||||
{
|
||||
echo "<hr />Manager->dumpAllTables()<br />";
|
||||
foreach ($this->tables as $id => $table) {
|
||||
foreach ($this as $id => $table) {
|
||||
if (!($table instanceof DataTable)) {
|
||||
echo "Error table $id is not instance of datatable<br />";
|
||||
var_export($table);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue