mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 01:58:47 +02:00
N°3567 - Migrate backoffice pages to new UIBlock system : App. upgrade (remove UIHtml from twig)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
{# @copyright Copyright (C) 2010-2019 Combodo SARL #}
|
||||
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
||||
|
||||
{% apply spaceless %}
|
||||
|
||||
{% UIContentBlock Standard {'sContainerClass':'ibo-update-core display_block display-files'} %}
|
||||
|
||||
@@ -6,31 +6,23 @@
|
||||
|
||||
{% UITitle ForPage {'sTitle':'iTopUpdate:UI:PageTitle'|dict_s} %}
|
||||
|
||||
{% UIHtml %}
|
||||
<div class="ibo-v-spacer"> </div>
|
||||
{% EndUIHtml %}
|
||||
<div class="ibo-v-spacer"> </div>
|
||||
|
||||
{% UIContentBlock Standard {'sContainerClass':'display_block display-files'} %}
|
||||
{% UIFieldSet Standard {'sLegend':'iTopUpdate:UI:Status'|dict_s} %}
|
||||
{% UIAlert ForInformation {'sId':'header-requirements', 'IsCollapsible':false, 'IsClosable':false} %}
|
||||
{% UIContentBlock Standard {'sContainerClass':'ibo-update-core-header-requirements', 'sId':'can-core-update'} %}
|
||||
{% UIHtml %}
|
||||
{{ 'iTopUpdate:UI:CanCoreUpdate:Loading'|dict_s }}
|
||||
{% EndUIHtml %}
|
||||
{{ 'iTopUpdate:UI:CanCoreUpdate:Loading'|dict_s }}
|
||||
{% UISpinner Standard {} %}
|
||||
{% EndUIContentBlock %}
|
||||
{% EndUIAlert %}
|
||||
|
||||
{% UIField Standard {'sLabel':'iTopUpdate:UI:CurrentVersion'|dict_s} %}
|
||||
{% UIHtml %}
|
||||
{{ 'UI:iTopVersion:Long'|dict_format(constant('ITOP_APPLICATION'), constant('ITOP_VERSION'), constant('ITOP_REVISION'), constant('ITOP_BUILD_DATE')) }}
|
||||
{% EndUIHtml %}
|
||||
{{ 'UI:iTopVersion:Long'|dict_format(constant('ITOP_APPLICATION'), constant('ITOP_VERSION'), constant('ITOP_REVISION'), constant('ITOP_BUILD_DATE')) }}
|
||||
{% EndUIField %}
|
||||
|
||||
{% UIField Standard {'sLabel':'iTopUpdate:UI:DiskFreeSpace'|dict_s} %}
|
||||
{% UIHtml %}
|
||||
{{ sDiskFreeSpace }}
|
||||
{% EndUIHtml %}
|
||||
{{ sDiskFreeSpace }}
|
||||
{% EndUIField %}
|
||||
|
||||
{% UIField Standard {'sLabel':'iTopUpdate:UI:ItopDiskSpace'|dict_s, 'ValueId':'itop-disk-space'} %}
|
||||
@@ -42,9 +34,7 @@
|
||||
{% EndUIField %}
|
||||
|
||||
{% UIField Standard {'sLabel':'iTopUpdate:UI:FileUploadMaxSize'|dict_s} %}
|
||||
{% UIHtml %}
|
||||
{{ sFileUploadMaxSize }}
|
||||
{% EndUIHtml %}
|
||||
{{ sFileUploadMaxSize }}
|
||||
{% EndUIField %}
|
||||
|
||||
{% EndUIFieldSet %}
|
||||
@@ -56,19 +46,13 @@
|
||||
|
||||
{% UIAlert ForFailure {'sId':'header-file-size', 'IsHidden':true} %}
|
||||
{% UIContentBlock Standard {'sContainerClass':'ibo-file-size-error'} %}
|
||||
{% UIHtml %}
|
||||
{{ 'iTopUpdate:Error:FileUploadMaxSizeTooStandard'|dict_s }}
|
||||
{% EndUIHtml %}
|
||||
{{ 'iTopUpdate:Error:FileUploadMaxSizeTooStandard'|dict_s }}
|
||||
{% EndUIContentBlock %}
|
||||
{% UIContentBlock Standard {'sContainerClass':'ibo-file-size-error'} %}
|
||||
{% UIHtml %}
|
||||
{{ 'iTopUpdate:UI:PostMaxSize'|dict_format(sPostMaxSize) }}
|
||||
{% EndUIHtml %}
|
||||
{{ 'iTopUpdate:UI:PostMaxSize'|dict_format(sPostMaxSize) }}
|
||||
{% EndUIContentBlock %}
|
||||
{% UIContentBlock Standard {'sContainerClass':'ibo-file-size-error'} %}
|
||||
{% UIHtml %}
|
||||
{{ 'iTopUpdate:UI:UploadMaxFileSize'|dict_format(sUploadMaxSize) }}
|
||||
{% EndUIHtml %}
|
||||
{{ 'iTopUpdate:UI:UploadMaxFileSize'|dict_format(sUploadMaxSize) }}
|
||||
{% EndUIContentBlock %}
|
||||
{% EndUIAlert %}
|
||||
|
||||
@@ -77,9 +61,7 @@
|
||||
{% EndUIContentBlock %}
|
||||
|
||||
{% UIAlert ForWarning {'sId':'dobackup-warning', 'IsHidden':true} %}
|
||||
{% UIHtml %}
|
||||
{{ 'iTopUpdate:UI:DoBackup:Warning'|dict_s }}
|
||||
{% EndUIHtml %}
|
||||
{{ 'iTopUpdate:UI:DoBackup:Warning'|dict_s }}
|
||||
{% EndUIAlert %}
|
||||
|
||||
{% UIField Standard {'sLabel':'iTopUpdate:UI:DoBackup:Label'|dict_s, 'sLayout':'large'} %}
|
||||
|
||||
@@ -6,24 +6,20 @@
|
||||
{% UIContentBlock Standard {'sContainerClass':'ibo-update-core display_block display-files'} %}
|
||||
|
||||
{% UIFieldSet Standard {'sLegend':'iTopUpdate:UI:Progress'|dict_s, 'sId':'installation_progress'} %}
|
||||
{% UIHtml %}
|
||||
{# Todo 3.0 Add Progress bar UIBlock #}
|
||||
<div id="progress_content">
|
||||
<p class="center">
|
||||
<span id="setup_msg">{{ 'iTopUpdate:UI:SetupMessage:Ready'|dict_s }}</span>
|
||||
</p>
|
||||
<div id="progress">0%</div>
|
||||
</div>
|
||||
{% EndUIHtml %}
|
||||
{# Todo 3.0 Add Progress bar UIBlock #}
|
||||
<div id="progress_content">
|
||||
<p class="center">
|
||||
<span id="setup_msg">{{ 'iTopUpdate:UI:SetupMessage:Ready'|dict_s }}</span>
|
||||
</p>
|
||||
<div id="progress">0%</div>
|
||||
</div>
|
||||
{% EndUIFieldSet %}
|
||||
|
||||
{% UIFieldSet Standard {'sLegend':'iTopUpdate:UI:Status'|dict_s} %}
|
||||
{% UIField Large {'sId':'new_version', 'sLabel':'iTopUpdate:UI:NewVersion'|dict_s, 'ValueId':'db-disk-space', 'IsHidden':true} %}{% EndUIField %}
|
||||
{% UIAlert ForInformation {'sId':'current_version', 'IsCollapsible':false, 'IsClosable':false} %}
|
||||
{% UIContentBlock Standard {'sId':'current-version','sContainerClass':'ibo-update-core--current-version'} %}
|
||||
{% UIHtml %}
|
||||
{{ sCurrentVersion }}
|
||||
{% EndUIHtml %}
|
||||
{{ sCurrentVersion }}
|
||||
{% EndUIContentBlock %}
|
||||
{% EndUIAlert %}
|
||||
|
||||
@@ -48,18 +44,12 @@
|
||||
{% UIAlert ForFailure {'sId':'setup_error_outer', 'sContent':'', 'IsCollapsible':false, 'IsClosable':false, 'IsHidden':true} %}
|
||||
{% UIContentBlock Standard {'sId':'setup_error','sContainerClass':'ibo-update-core--error'} %}{% EndUIContentBlock %}
|
||||
{% if bDoFilesArchive %}
|
||||
{% UIHtml %}
|
||||
{{ 'iTopUpdate:UI:RestoreArchive'|dict_format(sItopArchive) }}
|
||||
{% EndUIHtml %}
|
||||
{{ 'iTopUpdate:UI:RestoreArchive'|dict_format(sItopArchive) }}
|
||||
{% endif %}
|
||||
{% if bDoBackup %}
|
||||
{% UIHtml %}
|
||||
{{ 'iTopUpdate:UI:RestoreBackup'|dict_format(sBackupFile) }}
|
||||
{% EndUIHtml %}
|
||||
{{ 'iTopUpdate:UI:RestoreBackup'|dict_format(sBackupFile) }}
|
||||
{% endif %}
|
||||
{% UIHtml %}
|
||||
{{ 'iTopUpdate:UI:MaintenanceModeActive'|dict_s }}
|
||||
{% EndUIHtml %}
|
||||
{% EndUIAlert %}
|
||||
|
||||
{% UIContentBlock Standard {'sId':'run_setup','sContainerClass':'ibo-update-core--run-setup', 'IsHidden':true} %}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2021 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Application\TwigBase\UI\Component;
|
||||
|
||||
use Twig\Compiler;
|
||||
use Twig\Node\Node;
|
||||
|
||||
class UIHtmlNode extends Node
|
||||
{
|
||||
public function __construct($oBody, $lineno = 0, $tag = null)
|
||||
{
|
||||
parent::__construct(['body' => $oBody], [], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Compiler $compiler)
|
||||
{
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
->write("ob_start();\n")
|
||||
->subcompile($this->getNode('body'))
|
||||
->write("\$sHtml = ob_get_contents();\n")
|
||||
->write("ob_end_clean();\n")
|
||||
->write("end(\$context['UIBlockParent'])->AddSubBlock(new Combodo\\iTop\\Application\\UI\\Base\\Component\\Html\\Html(\$sHtml));\n");
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2021 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Application\TwigBase\UI\Component;
|
||||
|
||||
|
||||
use Twig\Token;
|
||||
use Twig\TokenParser\AbstractTokenParser;
|
||||
|
||||
class UIHtmlParser extends AbstractTokenParser
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function parse(Token $token)
|
||||
{
|
||||
$iLineno = $token->getLine();
|
||||
$oStream = $this->parser->getStream();
|
||||
$oStream->expect(Token::BLOCK_END_TYPE);
|
||||
|
||||
$oBody = $this->parser->subparse([$this, 'decideForEnd'], true);
|
||||
$oStream->expect(Token::BLOCK_END_TYPE);
|
||||
|
||||
return new UIHtmlNode($oBody, $iLineno, $this->getTag());
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTag()
|
||||
{
|
||||
return 'UIHtml';
|
||||
}
|
||||
|
||||
public function decideForEnd(Token $token)
|
||||
{
|
||||
return $token->test('EndUIHtml');
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ class UIBlockExtension extends AbstractExtension
|
||||
{
|
||||
public function getTokenParsers()
|
||||
{
|
||||
$aParsers = [new UIHtmlParser()];
|
||||
$aParsers = [];
|
||||
|
||||
$sInterface = "Combodo\\iTop\\Application\\UI\\Base\\iUIBlockFactory";
|
||||
$aFactoryClasses = self::GetClassForInterface($sInterface);
|
||||
|
||||
@@ -38,7 +38,11 @@ class UIBlockNode extends Node
|
||||
$oParams = $this->getAttribute('params');
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
->write("\$aParams = ")
|
||||
->write("\$sHtml = trim(ob_get_contents());\n")
|
||||
->write("ob_end_clean();\n")
|
||||
->write("if (strlen(\$sHtml) > 0) {\n")
|
||||
->indent()->write("end(\$context['UIBlockParent'])->AddSubBlock(new \Combodo\iTop\Application\UI\Base\Component\Html\Html(\$sHtml));\n")->outdent()
|
||||
->write("}\n") ->write("\$aParams = ")
|
||||
->subcompile($oParams)
|
||||
->raw(";\n");
|
||||
|
||||
@@ -107,8 +111,15 @@ class UIBlockNode extends Node
|
||||
if ($oSubNode) {
|
||||
$compiler
|
||||
->write("array_push(\$context['UIBlockParent'], \${$sBlockVar});\n")
|
||||
->write("ob_start();\n")
|
||||
->subcompile($oSubNode)
|
||||
->write("\$sHtml = trim(ob_get_contents());\n")
|
||||
->write("ob_end_clean();\n")
|
||||
->write("if (strlen(\$sHtml) > 0) {\n")
|
||||
->indent()->write("end(\$context['UIBlockParent'])->AddSubBlock(new \Combodo\iTop\Application\UI\Base\Component\Html\Html(\$sHtml));\n")->outdent()
|
||||
->write("}\n")
|
||||
->write("array_pop(\$context['UIBlockParent']);\n");
|
||||
}
|
||||
$compiler->write("ob_start();\n");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user