mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 08:38:45 +02:00
Customers portal : Fixed dynamic tiles on home page APIs
SVN:trunk[4264]
This commit is contained in:
@@ -21,6 +21,7 @@ namespace Combodo\iTop\Portal\Controller;
|
||||
|
||||
use Silex\Application;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Combodo\iTop\Portal\Brick\PortalBrick;
|
||||
|
||||
class DefaultController
|
||||
{
|
||||
@@ -28,6 +29,20 @@ class DefaultController
|
||||
public function homeAction(Request $oRequest, Application $oApp)
|
||||
{
|
||||
$aData = array();
|
||||
|
||||
// Rendering tiles
|
||||
$aData['aTilesRendering'] = array();
|
||||
foreach($oApp['combodo.portal.instance.conf']['bricks'] as $oBrick)
|
||||
{
|
||||
// Doing it only for tile visible on home page to avoid unnecessary rendering
|
||||
if (($oBrick->GetVisibleHome() === true) && ($oBrick->GetTileControllerAction() !== null))
|
||||
{
|
||||
$oController = new \Combodo\iTop\Portal\Controller\ManageBrickController($oRequest, $oApp);
|
||||
$aData['aTilesRendering'][$oBrick->GetId()] = $oController->HomeAction($oRequest, $oApp);
|
||||
}
|
||||
}
|
||||
|
||||
// Home page template
|
||||
$template = $oApp['combodo.portal.instance.conf']['properties']['templates']['home'];
|
||||
|
||||
return $oApp['twig']->render($template, $aData);
|
||||
|
||||
@@ -40,6 +40,7 @@ abstract class PortalBrick extends AbstractBrick
|
||||
const DEFAULT_DECORATION_CLASS_HOME = '';
|
||||
const DEFAULT_DECORATION_CLASS_NAVIGATION_MENU = '';
|
||||
const DEFAULT_TILE_TEMPLATE_PATH = 'itop-portal-base/portal/src/views/bricks/tile.html.twig';
|
||||
const DEFAULT_TILE_CONTROLLER_ACTION = null;
|
||||
|
||||
static $sRouteName = null;
|
||||
protected $iWidth;
|
||||
@@ -50,6 +51,7 @@ abstract class PortalBrick extends AbstractBrick
|
||||
protected $sDecorationClassHome;
|
||||
protected $sDecorationClassNavigationMenu;
|
||||
protected $sTileTemplatePath;
|
||||
protected $sTileControllerAction;
|
||||
// Vars below are itemization from parent class
|
||||
protected $fRankHome;
|
||||
protected $fRankNavigationMenu;
|
||||
@@ -76,6 +78,7 @@ abstract class PortalBrick extends AbstractBrick
|
||||
$this->sDecorationClassHome = static::DEFAULT_DECORATION_CLASS_HOME;
|
||||
$this->sDecorationClassNavigationMenu = static::DEFAULT_DECORATION_CLASS_NAVIGATION_MENU;
|
||||
$this->sTileTemplatePath = static::DEFAULT_TILE_TEMPLATE_PATH;
|
||||
$this->sTileControllerAction = static::DEFAULT_TILE_CONTROLLER_ACTION;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,6 +191,16 @@ abstract class PortalBrick extends AbstractBrick
|
||||
return $this->sTitleNavigationMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the brick tile controller action
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetTileControllerAction()
|
||||
{
|
||||
return $this->sTileControllerAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the brick tile template path
|
||||
*
|
||||
@@ -330,6 +343,17 @@ abstract class PortalBrick extends AbstractBrick
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the brick tile controller action
|
||||
*
|
||||
* @param boolean $sTileControllerAction
|
||||
*/
|
||||
public function SetTileControllerAction($sTileControllerAction)
|
||||
{
|
||||
$this->sTileControllerAction = $sTileControllerAction;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the brick's data from the xml passed as a ModuleDesignElement.
|
||||
* This is used to set all the brick attributes at once.
|
||||
|
||||
@@ -27,7 +27,11 @@
|
||||
<section class="row tiles_wrapper">
|
||||
{% for brick in app['combodo.portal.instance.conf'].bricks_ordering.home %}
|
||||
{% if brick.GetVisibleHome %}
|
||||
{% include '' ~ brick.GetTileTemplatePath with {brick: brick} %}
|
||||
{% if aTilesRendering[brick.GetId] is defined %}
|
||||
{{ aTilesRendering[brick.GetId]|raw }}
|
||||
{% else %}
|
||||
{% include '' ~ brick.GetTileTemplatePath with {brick: brick} %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user