Files
Phraseanet/lib/classes/module/report/dashboard/group.class.php
Romain Neutron 4c5b7eb658 V 3.5 RC 1
2011-12-05 00:23:28 +01:00

110 lines
2.1 KiB
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package module_report
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class module_report_dashboard_group implements module_report_dashboard_componentInterface
{
public $group_dash;
public $dashboard = array();
private $valid = false;
/**
* @desc group the dashboard
*/
public function __construct(module_report_dashboard $report)
{
if ($report->isValid())
{
$this->valid = true;
$this->dashboard = $report->getDash();
}
$this->process();
}
/**
* @desc GROUP the dashboard
* @return <void>
*/
public function process()
{
if ($this->valid)
{
if (is_null($this->group_dash))
$this->group_dash = array();
foreach ($this->dashboard as $key => $dash)
{
if (is_object($dash) &&
$dash instanceof module_report_dashboard_feed &&
$dash->isValid())
{
$onedash = $dash->getDash();
foreach ($onedash as $typeofreport => $value)
{
if (is_array($value) && sizeof($value) == 0)
continue;
else
{
$this->group_dash[$typeofreport][] = $value;
}
}
}
else
{
throw new Exception("cannot group on a none dashboard object");
}
}
}
return;
}
/**
* @desc check if the grouped dash is valid
* @return <bool>
*/
public function isValid()
{
if (isset($this->group_dash) && sizeof($this->group_dash) > 0)
return true;
else
return false;
}
/**
* @desc return the results
* @return <array>
*/
public function getDash()
{
return $this->group_dash;
}
/**
* @desc Tri de grouped dash
* @return dashboard_merge
*/
public function tri()
{
return new module_report_dashboard_merge($this);
}
}
?>