/** * Dashboard presentation * * @copyright Copyright (C) 2010-2012 Combodo SARL * @license http://opensource.org/licenses/AGPL-3.0 */ abstract class DashboardLayout { public function __construct() { } abstract public function Render($oPage, $aDashlets, $bEditMode = false); static public function GetInfo() { return array( 'label' => '', 'icon' => '', 'description' => '', ); } } abstract class DashboardLayoutMultiCol extends DashboardLayout { protected $iNbCols; public function __construct() { $this->iNbCols = 1; } protected function TrimCell($aDashlets) { $aKeys = array_reverse(array_keys($aDashlets)); $idx = 0; $bNoVisibleFound = true; while($idx < count($aKeys) && $bNoVisibleFound) { $oDashlet = $aDashlets[$aKeys[$idx]]; if ($oDashlet->IsVisible()) { $bNoVisibleFound = false; } else { unset($aDashlets[$aKeys[$idx]]); } $idx++; } return $aDashlets; } protected function TrimCellsArray($aCells) { foreach($aCells as $key => $aDashlets) { $aCells[$key] = $this->TrimCell($aDashlets); } $aKeys = array_reverse(array_keys($aCells)); $idx = 0; $bNoVisibleFound = true; while($idx < count($aKeys) && $bNoVisibleFound) { $aDashlets = $aCells[$aKeys[$idx]]; if (count($aDashlets) > 0) { $bNoVisibleFound = false; } else { unset($aCells[$aKeys[$idx]]); } $idx++; } return $aCells; } public function Render($oPage, $aCells, $bEditMode = false, $aExtraParams = array()) { // Trim the list of cells to remove the invisible/empty ones at the end of the array $aCells = $this->TrimCellsArray($aCells); $oPage->add('
"); if (array_key_exists($iCellIdx, $aCells)) { $aDashlets = $aCells[$iCellIdx]; if (count($aDashlets) > 0) { foreach($aDashlets as $oDashlet) { if ($oDashlet->IsVisible()) { $oDashlet->DoRender($oPage, $bEditMode, true /* bEnclosingDiv */, $aExtraParams); } } } else { $oPage->add(' '); } } else { $oPage->add(' '); } $oPage->add(' | '); $iCellIdx++; } $oPage->add('
"); $oPage->add(' '); $oPage->add(' | '); } $oPage->add('