diff --git a/application/dashboard.class.inc.php b/application/dashboard.class.inc.php
index e046fec13..4e31c401f 100644
--- a/application/dashboard.class.inc.php
+++ b/application/dashboard.class.inc.php
@@ -7,6 +7,7 @@
use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableSettings;
use Combodo\iTop\Application\UI\Base\Component\Toolbar\ToolbarUIBlockFactory;
+use Combodo\iTop\Application\UI\Base\Layout\Dashboard\UIDashboardLayoutBlock;
require_once(APPROOT.'application/dashboardlayout.class.inc.php');
require_once(APPROOT.'application/dashlet.class.inc.php');
@@ -515,6 +516,8 @@ EOF
* @param bool $bEditMode
* @param array $aExtraParams
* @param bool $bCanEdit
+ *
+ * @return \Combodo\iTop\Application\UI\Base\Layout\Dashboard\UIDashboardLayoutBlock
*/
public function Render($oPage, $bEditMode = false, $aExtraParams = array(), $bCanEdit = true)
{
@@ -522,21 +525,6 @@ EOF
$aExtraParams['dashboard_div_id'] = utils::Sanitize($this->GetId(), '', 'element_identifier');
}
- $sTitleForHTML = utils::HtmlEntities(Dict::S($this->sTitle));
-
- $sHtml = "
{$sTitleForHTML}
";
- if ($oPage instanceof iTopWebPage) {
- $oTopBar = $oPage->GetTopBarLayout();
- $oToolbar = ToolbarUIBlockFactory::MakeStandard();
- $oTopBar->SetToolbar($oToolbar);
- $oToolbar->AddHtml($sHtml);
- } else {
- $oPage->add_script(<<sLayoutClass();
@@ -547,11 +535,36 @@ JS
}
}
- $oLayout->Render($oPage, $this->aCells, $bEditMode, $aExtraParams);
+ $oDashboard = $oLayout->Render($oPage, $this->aCells, $bEditMode, $aExtraParams);
+ $oPage->AddUiBlock($oDashboard);
+
+ $bFromDasboardPage = isset($aExtraParams['from_dashboard_page']) ? isset($aExtraParams['from_dashboard_page']) : false;
+
+ if ($bFromDasboardPage) {
+ $sTitleForHTML = utils::HtmlEntities(Dict::S($this->sTitle));
+ $sHtml = "{$sTitleForHTML}
";
+ if ($oPage instanceof iTopWebPage) {
+ $oTopBar = $oPage->GetTopBarLayout();
+ $oToolbar = ToolbarUIBlockFactory::MakeStandard();
+ $oTopBar->SetToolbar($oToolbar);
+
+ $oToolbar->AddHtml($sHtml);
+ } else {
+ $oPage->add_script(<<SetTitle(Dict::S($this->sTitle));
+ }
+
if (!$bEditMode) {
$oPage->add_linked_script('../js/dashlet.js');
$oPage->add_linked_script('../js/dashboard.js');
}
+
+ return $oDashboard;
}
/**
@@ -935,42 +948,30 @@ class RuntimeDashboard extends Dashboard
if (!isset($aExtraParams['query_params']) && isset($aExtraParams['this->class'])) {
$oObj = MetaModel::GetObject($aExtraParams['this->class'], $aExtraParams['this->id']);
$aRenderParams = array('query_params' => $oObj->ToArgsForQuery());
- }
- else
- {
+ } else {
$aRenderParams = $aExtraParams;
}
- parent::Render($oPage, $bEditMode, $aRenderParams);
+ $oDashboard = parent::Render($oPage, $bEditMode, $aRenderParams);
- if (isset($aExtraParams['query_params']['this->object()']))
- {
+ if (isset($aExtraParams['query_params']['this->object()'])) {
/** @var \DBObject $oObj */
$oObj = $aExtraParams['query_params']['this->object()'];
$aAjaxParams = array('this->class' => get_class($oObj), 'this->id' => $oObj->GetKey());
- }
- else
- {
+ if (isset($aExtraParams['from_dashboard_page'])) {
+ $aAjaxParams['from_dashboard_page'] = $aExtraParams['from_dashboard_page'];
+ }
+ } else {
$aAjaxParams = $aExtraParams;
}
- if (!$bEditMode && !$oPage->IsPrintableVersion())
- {
+ if (!$bEditMode && !$oPage->IsPrintableVersion()) {
$sId = $this->GetId();
$sDivId = utils::Sanitize($sId, '', 'element_identifier');
- if ($this->GetAutoReload())
- {
- $sFile = addslashes($this->GetDefinitionFile());
- $sExtraParams = json_encode($aAjaxParams);
+ if ($this->GetAutoReload()) {
$iReloadInterval = 1000 * $this->GetAutoReloadInterval();
- $sReloadURL = $this->GetReloadURL();
- $oAppContext = new ApplicationContext();
- $sContext=$oAppContext->GetForPostParams();
- //$sContext is named "c" because it use the existing code for context parameters c[org_id] and c[menu]
-
-
$oPage->add_script(
-<<add_script(
-<<RenderSelector($oPage, $aAjaxParams);
- $this->RenderEditionTools($oPage, $aAjaxParams);
+ if ($bCanEdit) {
+ $this->RenderSelector($oPage, $oDashboard, $aAjaxParams);
+ $this->RenderEditionTools($oPage, $oDashboard, $aAjaxParams);
}
}
}
/**
* @param WebPage $oPage
+ * @param \Combodo\iTop\Application\UI\Base\Layout\Dashboard\UIDashboardLayoutBlock $oDashboard
+ * @param bool $bFromDashboardPage
* @param array $aAjaxParams
*
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
*/
- protected function RenderSelector(WebPage $oPage, $aAjaxParams = array())
+ protected function RenderSelector(WebPage $oPage, UIDashboardLayoutBlock $oDashboard, $aAjaxParams = array())
{
if (!$this->HasCustomDashboard()) {
return;
@@ -1032,19 +1034,26 @@ EOF
$sSwitchToCustom = Dict::S('UI:Toggle:SwitchToCustomDashboard');
$bStandardSelected = appUserPreferences::GetPref('display_original_dashboard_'.$sId, false);
- $sSelectorHtml = '