mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 00:28:47 +02:00
N°2847 - Refactor
This commit is contained in:
@@ -21,7 +21,6 @@ namespace Combodo\iTop\Renderer;
|
||||
|
||||
use Combodo\iTop\Application\TwigBase\Twig\TwigHelper;
|
||||
use Combodo\iTop\Application\UI\iUIBlock;
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* Class BlockRenderer
|
||||
@@ -221,8 +220,6 @@ class BlockRenderer
|
||||
HTML;
|
||||
}
|
||||
|
||||
// TODO 2.8.0
|
||||
//$sOutput .= utils::FilterXSS($this->RenderHtml());
|
||||
$sOutput .= $this->RenderHtml();
|
||||
|
||||
// JS last so all markup is build and ready
|
||||
|
||||
@@ -284,102 +284,7 @@ class TabManager
|
||||
*/
|
||||
public function RenderIntoContent(string $sContent, WebPage $oPage)
|
||||
{
|
||||
// Render the tabs in the page (if any)
|
||||
$container_index = 0;
|
||||
foreach ($this->m_aTabs as $sTabContainerName => $aTabs) {
|
||||
$sTabs = '';
|
||||
$sPrefix = $aTabs['prefix'];
|
||||
if (count($aTabs['tabs']) > 0) {
|
||||
// Clean tabs
|
||||
foreach ($aTabs['tabs'] as $sTabCode => $aTabData) {
|
||||
// Sometimes people set an empty tab to force content NOT to be rendered in the previous one. We need to remove them.
|
||||
// Note: Look for "->SetCurrentTab('');" for examples.
|
||||
if ($sTabCode === '') {
|
||||
unset($aTabs['tabs'][$sTabCode]);
|
||||
}
|
||||
}
|
||||
|
||||
// Render tabs
|
||||
if ($oPage->IsPrintableVersion()) {
|
||||
$oPage->add_ready_script(
|
||||
<<< EOF
|
||||
oHiddeableChapters = {};
|
||||
EOF
|
||||
);
|
||||
$sTabs = "<!-- tabs -->\n<div id=\"tabbedContent_{$sPrefix}{$container_index}\" class=\"light\">\n";
|
||||
$i = 0;
|
||||
foreach ($aTabs['tabs'] as $sTabCode => $aTabData) {
|
||||
$sTabCodeForJs = addslashes($sTabCode);
|
||||
$sTabTitleForHtml = utils::HtmlEntities($aTabData['title']);
|
||||
$sTabId = "tab_{$sPrefix}{$container_index}$i";
|
||||
switch ($aTabData['type']) {
|
||||
case static::ENUM_TAB_TYPE_AJAX:
|
||||
$sTabHtml = '';
|
||||
$sUrl = $aTabData['url'];
|
||||
$oPage->add_ready_script(
|
||||
<<< EOF
|
||||
$.post('$sUrl', {printable: '1'}, function(data){
|
||||
$('#$sTabId > .printable-tab-content').append(data);
|
||||
});
|
||||
EOF
|
||||
);
|
||||
break;
|
||||
|
||||
case static::ENUM_TAB_TYPE_HTML:
|
||||
default:
|
||||
$sTabHtml = $aTabData['html'];
|
||||
}
|
||||
$sTabs .= "<div class=\"printable-tab\" id=\"$sTabId\"><h2 class=\"printable-tab-title\">$sTabTitleForHtml</h2><div class=\"printable-tab-content\">".$sTabHtml."</div></div>\n";
|
||||
$oPage->add_ready_script(
|
||||
<<< EOF
|
||||
oHiddeableChapters['$sTabId'] = '$sTabTitleForHtml';
|
||||
EOF
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
$sTabs .= "</div>\n<!-- end of tabs-->\n";
|
||||
} else {
|
||||
$sTabs = "<!-- tabs -->\n<div id=\"tabbedContent_{$sPrefix}{$container_index}\" class=\"light\">\n";
|
||||
$sTabs .= "<ul>\n";
|
||||
// Display the unordered list that will be rendered as the tabs
|
||||
$i = 0;
|
||||
foreach ($aTabs['tabs'] as $sTabCode => $aTabData) {
|
||||
$sTabCodeForHtml = utils::HtmlEntities($sTabCode);
|
||||
$sTabTitleForHtml = utils::HtmlEntities($aTabData['title']);
|
||||
switch ($aTabData['type']) {
|
||||
case static::ENUM_TAB_TYPE_AJAX:
|
||||
$sTabs .= "<li data-cache=\"".($aTabData['cache'] ? 'true' : 'false')."\"><a href=\"{$aTabData['url']}\" class=\"tab\" data-tab-id=\"$sTabCodeForHtml\"><span>$sTabTitleForHtml</span></a></li>\n";
|
||||
break;
|
||||
|
||||
case static::ENUM_TAB_TYPE_HTML:
|
||||
default:
|
||||
$sTabs .= "<li><a href=\"#tab_{$sPrefix}{$container_index}$i\" class=\"tab\" data-tab-id=\"$sTabCodeForHtml\"><span>$sTabTitleForHtml</span></a></li>\n";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$sTabs .= "</ul>\n";
|
||||
// Now add the content of the tabs themselves
|
||||
$i = 0;
|
||||
foreach ($aTabs['tabs'] as $sTabCode => $aTabData) {
|
||||
switch ($aTabData['type']) {
|
||||
case static::ENUM_TAB_TYPE_AJAX:
|
||||
// Nothing to add
|
||||
break;
|
||||
|
||||
case static::ENUM_TAB_TYPE_HTML:
|
||||
default:
|
||||
$sTabs .= "<div id=\"tab_{$sPrefix}{$container_index}$i\">".$aTabData['html']."</div>\n";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$sTabs .= "</div>\n<!-- end of tabs-->\n";
|
||||
}
|
||||
}
|
||||
$sContent = str_replace("\$Tabs:$sTabContainerName\$", $sTabs, $sContent);
|
||||
$container_index++;
|
||||
}
|
||||
|
||||
return $sContent;
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -697,10 +697,8 @@ class WebPage implements Page
|
||||
public function output()
|
||||
{
|
||||
// Send headers
|
||||
if ($this->GetOutputFormat() === 'html') {
|
||||
foreach ($this->a_headers as $sHeader) {
|
||||
header($sHeader);
|
||||
}
|
||||
foreach ($this->a_headers as $sHeader) {
|
||||
header($sHeader);
|
||||
}
|
||||
|
||||
$this->s_content = $this->ob_get_clean_safe();
|
||||
@@ -730,7 +728,7 @@ class WebPage implements Page
|
||||
'aCssInline' => $this->a_styles,
|
||||
'aJsFiles' => $this->a_linked_scripts,
|
||||
'aJsInlineLive' => $this->a_scripts,
|
||||
// TODO 2.8.0: TEMP, used while developping, remove it.
|
||||
// TODO 2.8.0: TEMP, used while developing, remove it.
|
||||
'sSanitizedContent' => utils::FilterXSS($this->s_content),
|
||||
'sDeferredContent' => utils::FilterXSS($this->s_deferred_content),
|
||||
];
|
||||
@@ -1012,8 +1010,7 @@ class WebPage implements Page
|
||||
*/
|
||||
protected function outputCollapsibleSectionInit()
|
||||
{
|
||||
if (!$this->bHasCollapsibleSection)
|
||||
{
|
||||
if (!$this->bHasCollapsibleSection) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage
|
||||
const DEFAULT_BREADCRUMB_ENTRY_ICON_TYPE = self::ENUM_BREADCRUMB_ENTRY_ICON_TYPE_IMAGE;
|
||||
|
||||
/** @var string DEFAULT_PAGE_TEMPLATE_REL_PATH The relative path (from <ITOP>/templates/) to the default page template */
|
||||
const DEFAULT_PAGE_TEMPLATE_REL_PATH = 'pages/backoffice/layout';
|
||||
const DEFAULT_PAGE_TEMPLATE_REL_PATH = 'pages/backoffice/itopwebpage/layout';
|
||||
|
||||
private $m_aMessages;
|
||||
private $m_aInitScript = array();
|
||||
@@ -979,6 +979,9 @@ EOF;
|
||||
$this->output_dict_entries();
|
||||
$this->GetContentLayout()->SetExtraHtmlContent(utils::FilterXSS($this->s_content));
|
||||
|
||||
// TODO 2.8.0 : to be removed
|
||||
$this->outputCollapsibleSectionInit();
|
||||
|
||||
// Base structure of data to pass to the TWIG template
|
||||
$aData['aPage'] = [
|
||||
'sAbsoluteUrlAppRoot' => $sAbsoluteUrlAppRoot,
|
||||
@@ -1056,10 +1059,8 @@ EOF;
|
||||
$oTwigEnv = TwigHelper::GetTwigEnvironment(BlockRenderer::TWIG_BASE_PATH, BlockRenderer::TWIG_ADDITIONAL_PATHS);
|
||||
|
||||
// Send headers
|
||||
if ($this->GetOutputFormat() === 'html')
|
||||
{
|
||||
foreach ($this->a_headers as $sHeader)
|
||||
{
|
||||
if ($this->GetOutputFormat() === 'html') {
|
||||
foreach ($this->a_headers as $sHeader) {
|
||||
header($sHeader);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
{% apply spaceless %}
|
||||
{# <div id="{{ oUIBlock.GetId() }}" class="ibo-content-block"> #}
|
||||
{% block iboContentBlockContainer %}
|
||||
{% for oSubBlock in oUIBlock.GetSubBlocks() %}
|
||||
{{ render_block(oSubBlock, {aPage: aPage}) }}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{# </div> #}
|
||||
{% endapply %}
|
||||
@@ -23,4 +23,4 @@
|
||||
{% for sJsInline in aPage.aJsInlineOnInit %}
|
||||
{{ sJsInline|raw }}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
@@ -6,5 +6,4 @@
|
||||
{{ sJsInline|raw }}
|
||||
}, 50);
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% endblock %}
|
||||
@@ -74,4 +74,4 @@
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Reference in New Issue
Block a user