diff --git a/application/datatable.class.inc.php b/application/datatable.class.inc.php
deleted file mode 100644
index 4a01b1be5..000000000
--- a/application/datatable.class.inc.php
+++ /dev/null
@@ -1,880 +0,0 @@
- class) inside the set
- protected $iNbObjects; // Total number of objects in the set
- protected $bUseCustomSettings; // Whether or not the current display uses custom settings
- protected $oDefaultSettings; // the default settings for displaying such a list
- protected $bShowObsoleteData;
-
- /**
- * @param string $iListId Unique ID for this div/table in the page
- * @param DBObjectSet $oSet The set of data to display
- * @param array$aClassAliases The list of classes/aliases to be displayed in this set $sAlias => $sClassName
- * @param string $sTableId A string (or null) identifying this table in order to persist its settings
- *
- * @throws \CoreException
- * @throws \MissingQueryArgument
- * @throws \MySQLException
- * @throws \MySQLHasGoneAwayException
- */
- public function __construct($iListId, $oSet, $aClassAliases, $sTableId = null)
- {
- DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use Combodo\iTop\Application\UI\Base\Component\DataTable\Datatable');
- $this->iListId = utils::GetSafeId($iListId); // Make a "safe" ID for jQuery
- $this->sDatatableContainerId = 'datatable_'.utils::GetSafeId($iListId);
- $this->oSet = $oSet;
- $this->aClassAliases = $aClassAliases;
- $this->sTableId = $sTableId;
- $this->iNbObjects = $oSet->Count();
- $this->bUseCustomSettings = false;
- $this->oDefaultSettings = null;
- $this->bShowObsoleteData = $oSet->GetShowObsoleteData();
- }
-
- /**
- * @param WebPage $oPage
- * @param DataTableSettings $oSettings
- * @param $bActionsMenu
- * @param $sSelectMode
- * @param $bViewLink
- * @param $aExtraParams
- *
- * @return string
- * @throws \CoreException
- * @throws \MySQLException
- */
- public function Display(WebPage $oPage, DataTableSettings $oSettings, $bActionsMenu, $sSelectMode, $bViewLink, $aExtraParams)
- {
- $this->oDefaultSettings = $oSettings;
-
- // Identified tables can have their own specific settings
- $oCustomSettings = DataTableSettings::GetTableSettings($this->aClassAliases, $this->sTableId);
-
- if ($oCustomSettings != null)
- {
- // Custom settings overload the default ones
- $this->bUseCustomSettings = true;
- if ($this->oDefaultSettings->iDefaultPageSize == 0)
- {
- $oCustomSettings->iDefaultPageSize = 0;
- }
- }
- else
- {
- $oCustomSettings = $oSettings;
- }
-
- if ($oCustomSettings->iDefaultPageSize > 0)
- {
- $this->oSet->SetLimit($oCustomSettings->iDefaultPageSize);
- }
- $this->oSet->SetOrderBy($oCustomSettings->GetSortOrder());
-
- // Load only the requested columns
- $aColumnsToLoad = array();
- foreach($oCustomSettings->aColumns as $sAlias => $aColumnsInfo)
- {
- foreach($aColumnsInfo as $sAttCode => $aData)
- {
- if ($sAttCode != '_key_')
- {
- if ($aData['checked'])
- {
- $aColumnsToLoad[$sAlias][] = $sAttCode;
- }
- else
- {
- // See if this column is a must to load
- $sClass = $this->aClassAliases[$sAlias];
- $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
- if ($oAttDef->AlwaysLoadInTables()) {
- $aColumnsToLoad[$sAlias][] = $sAttCode;
- }
- }
- }
- }
- }
- $this->oSet->OptimizeColumnLoad($aColumnsToLoad);
-
-
- $bToolkitMenu = true;
- if (isset($aExtraParams['toolkit_menu']))
- {
- $bToolkitMenu = (bool) $aExtraParams['toolkit_menu'];
- }
- if (UserRights::IsPortalUser())
- {
- // Portal users have a limited access to data, for now they can only see what's configured for them
- $bToolkitMenu = false;
- }
-
- return $this->GetAsHTML($oPage, $oCustomSettings->iDefaultPageSize, $oCustomSettings->iDefaultPageSize, 0, $oCustomSettings->aColumns, $bActionsMenu, $bToolkitMenu, $sSelectMode, $bViewLink, $aExtraParams);
- }
-
- /**
- * @param WebPage $oPage
- * @param $iPageSize
- * @param $iDefaultPageSize
- * @param $iPageIndex
- * @param $aColumns
- * @param $bActionsMenu
- * @param $bToolkitMenu
- * @param $sSelectMode
- * @param $bViewLink
- * @param $aExtraParams
- *
- * @return string
- * @throws \ArchivedObjectException
- * @throws \CoreException
- */
- public function GetAsHTML(WebPage $oPage, $iPageSize, $iDefaultPageSize, $iPageIndex, $aColumns, $bActionsMenu, $bToolkitMenu, $sSelectMode, $bViewLink, $aExtraParams)
- {
- $sObjectsCount = $this->GetObjectCount($oPage, $sSelectMode);
- $sPager = $this->GetPager($oPage, $iPageSize, $iDefaultPageSize, $iPageIndex);
- $sActionsMenu = '';
- $sToolkitMenu = '';
- if ($bActionsMenu) {
- $sActionsMenu = $this->GetActionsMenu($oPage, $aExtraParams);
- }
-// if ($bToolkitMenu)
-// {
-// $sToolkitMenu = $this->GetToolkitMenu($oPage, $aExtraParams);
-// }
-
- $sDataTable = $this->GetHTMLTable($oPage, $aColumns, $sSelectMode, $iPageSize, $bViewLink, $aExtraParams);
- $sConfigDlg = $this->GetTableConfigDlg($oPage, $aColumns, $bViewLink, $iDefaultPageSize);
-
- $sHtml = "
sDatatableContainerId}\" class=\"datatable\">";
- $sHtml .= "";
- $sHtml .= "";
- $sHtml .= " ";
- $sHtml .= "$sPager ";
- $sHtml .= " ";
- $sHtml .= " |
";
- $sHtml .= "| $sDataTable |
";
- $sHtml .= "
\n";
- $oPage->add_at_the_end($sConfigDlg);
-
- $aExtraParams['show_obsolete_data'] = $this->bShowObsoleteData;
-
- $aOptions = array(
- 'sPersistentId' => '',
- 'sFilter' => $this->oSet->GetFilter()->serialize(),
- 'oColumns' => $aColumns,
- 'sSelectMode' => $sSelectMode,
- 'sViewLink' => ($bViewLink ? 'true' : 'false'),
- 'iNbObjects' => $this->iNbObjects,
- 'iDefaultPageSize' => $iDefaultPageSize,
- 'iPageSize' => $iPageSize,
- 'iPageIndex' => $iPageIndex,
- 'oClassAliases' => $this->aClassAliases,
- 'sTableId' => $this->sTableId,
- 'oExtraParams' => $aExtraParams,
- 'sRenderUrl' => utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php',
- 'oRenderParameters' => array('str' => ''), // Forces JSON to encode this as a object...
- 'oDefaultSettings' => array('str' => ''), // Forces JSON to encode this as a object...
- 'oLabels' => array('moveup' => Dict::S('UI:Button:MoveUp'), 'movedown' => Dict::S('UI:Button:MoveDown')),
- );
- if($this->oDefaultSettings != null)
- {
- $aOptions['oDefaultSettings'] = $this->GetAsHash($this->oDefaultSettings);
- }
- $sJSOptions = json_encode($aOptions);
- $oPage->add_ready_script("$('#{$this->sDatatableContainerId}').datatable($sJSOptions);");
-
- return $sHtml;
- }
-
- /**
- * When refreshing the body of a paginated table, get the rows of the table (inside the TBODY)
- * return string The HTML rows to insert inside the node
- */
- public function GetAsHTMLTableRows(WebPage $oPage, $iPageSize, $aColumns, $sSelectMode, $bViewLink, $aExtraParams)
- {
- if ($iPageSize < 1)
- {
- $iPageSize = -1; // convention: no pagination
- }
- $aAttribs = $this->GetHTMLTableConfig($aColumns, $sSelectMode, $bViewLink);
- $aValues = $this->GetHTMLTableValues($aColumns, $sSelectMode, $iPageSize, $bViewLink, $aExtraParams);
-
- $sHtml = '';
- foreach($aValues as $aRow)
- {
- $sHtml .= $oPage->GetTableRow($aRow, $aAttribs);
- }
- return $sHtml;
- }
-
- /**
- * @param WebPage $oPage
- * @param $sSelectMode
- *
- * @return string
- */
- protected function GetObjectCount(WebPage $oPage, $sSelectMode)
- {
- if (($sSelectMode == 'single') || ($sSelectMode == 'multiple'))
- {
- $sHtml = '';
- }
- else
- {
- $sHtml = '';
- }
- return $sHtml;
- }
-
- /**
- * @param WebPage $oPage
- * @param $iPageSize
- * @param $iDefaultPageSize
- * @param $iPageIndex
- *
- * @return string
- */
- protected function GetPager(WebPage $oPage, $iPageSize, $iDefaultPageSize, $iPageIndex)
- {
- $sHtml = '';
- if ($iPageSize < 1) // Display all
- {
- $sPagerStyle = 'style="display:none"'; // no limit: display the full table, so hide the "pager" UI
- // WARNING: mPDF does not take the "display" style into account
- // when applied to a or a tag, so make sure you apply this to a div
- }
- else
- {
- $sPagerStyle = '';
- }
-
- $sCombo = '';
-
- $sPages = Dict::S('UI:Pagination:PagesLabel');
- $sPageSizeCombo = Dict::Format('UI:Pagination:PageSize', $sCombo);
-
- $iNbPages = ($iPageSize < 1) ? 1 : ceil($this->iNbObjects / $iPageSize);
- if ($iNbPages == 1)
- {
- // No need to display the pager
- $sPagerStyle = 'style="display:none"';
- }
- $aPagesToDisplay = array();
- for($idx = 0; $idx <= min(4, $iNbPages-1); $idx++)
- {
- if ($idx == 0)
- {
- $aPagesToDisplay[$idx] = '1';
- }
- else
- {
- $aPagesToDisplay[$idx] = "".(1+$idx)."";
- }
- }
- $iLastPageIdx = $iNbPages - 1;
- if (!isset($aPagesToDisplay[$iLastPageIdx]))
- {
- unset($aPagesToDisplay[$idx - 1]); // remove the last page added to make room for the very last page
- $aPagesToDisplay[$iLastPageIdx] = "... $iNbPages";
- }
- $sPagesLinks = implode('', $aPagesToDisplay);
- $sPagesList = '['.implode(',', array_keys($aPagesToDisplay)).']';
-
- $sAppRootUrl = utils::GetAbsoluteUrlAppRoot();
- $sSelectionMode = ($iNbPages == 1) ? '' : 'positive';
- $sHtml =
-<<
-
-
-
-
-EOF;
- return $sHtml;
- }
-
- /**
- * @param WebPage $oPage
- * @param $aExtraParams
- *
- * @return string
- * @throws \ApplicationException
- * @throws \ArchivedObjectException
- * @throws \CoreException
- * @throws \CoreUnexpectedValue
- * @throws \DictExceptionMissingString
- * @throws \MissingQueryArgument
- * @throws \MySQLException
- * @throws \MySQLHasGoneAwayException
- * @throws \OQLException
- * @throws \ReflectionException
- * @throws \Twig\Error\LoaderError
- * @throws \Twig\Error\RuntimeError
- * @throws \Twig\Error\SyntaxError
- */
- protected function GetActionsMenu(WebPage $oPage, $aExtraParams)
- {
- $oMenuBlock = new MenuBlock($this->oSet->GetFilter(), 'list');
- $oBlock = $oMenuBlock->GetRenderContent($oPage, $aExtraParams, $this->iListId);
-
- return ConsoleBlockRenderer::RenderBlockTemplateInPage($oPage, $oBlock);
- }
-
- /**
- * @param WebPage $oPage
- * @param $aExtraParams
- *
- * @return string
- * @throws \Exception
- */
- protected function GetToolkitMenu(WebPage $oPage, $aExtraParams)
- {
- if (!$oPage->IsPrintableVersion())
- {
- $sMenuTitle = Dict::S('UI:ConfigureThisList');
- $sHtml = ' |