diff --git a/Resources/templates/CommonAdmin/ShowTemplate/ShowBuilderTemplate.php.twig b/Resources/templates/CommonAdmin/ShowTemplate/ShowBuilderTemplate.php.twig index 495d3196..677ddeab 100644 --- a/Resources/templates/CommonAdmin/ShowTemplate/ShowBuilderTemplate.php.twig +++ b/Resources/templates/CommonAdmin/ShowTemplate/ShowBuilderTemplate.php.twig @@ -4,6 +4,7 @@ {% use '../CommonAdmin/ShowTemplate/tabs.php.twig' %} {% use '../CommonAdmin/ShowTemplate/show.php.twig' %} {% use '../CommonAdmin/ShowTemplate/actions.php.twig' %} +{% use '../CommonAdmin/ShowTemplate/sidebar.php.twig' %} {{ echo_extends( builder.getBaseAdminTemplate ) }} {{ echo_block("stylesheets") }} @@ -25,7 +26,16 @@ {{- block('title') -}}
- {{- block('show_tabs') }} - {{- block('show') -}} + {% if sidebar %} +
+ {% endif %} + {{- block('show_tabs') }} + {{- block('show') -}} + {% if sidebar %} +
+
+ {{- block('show_sidebar') -}} +
+ {% endif %}
{{ echo_endblock() }} diff --git a/Resources/templates/CommonAdmin/ShowTemplate/sidebar.php.twig b/Resources/templates/CommonAdmin/ShowTemplate/sidebar.php.twig new file mode 100644 index 00000000..1564b3f6 --- /dev/null +++ b/Resources/templates/CommonAdmin/ShowTemplate/sidebar.php.twig @@ -0,0 +1,20 @@ +{% block show_sidebar %} +{{ echo_block("show_sidebar") }} + {% for name, widget in sidebar %} + {% if widget.credentials is defined %} + {{ echo_if_granted(widget.credentials, builder.ModelClass) }} + {% endif %} +
+

{{ echo_trans(name,{}, i18n_catalog is defined ? i18n_catalog : "Admin" ) }}

+ {% if widget.partial %} + {{ echo_include(widget.partial) }} + {% elseif widget.render %} + {{ echo_render(widget.render is iterable ? widget.render.controller : widget.render, widget.render is iterable ? widget.render.params : {}) }} + {% endif %} +
+ {% if widget.credentials is defined %} + {{ echo_endif () }} + {% endif %} + {% endfor %} +{{ echo_endblock() }} +{% endblock %} \ No newline at end of file diff --git a/Tests/Twig/Extension/EchoExtensionTest.php b/Tests/Twig/Extension/EchoExtensionTest.php old mode 100755 new mode 100644 index 67116e1c..d372c650 --- a/Tests/Twig/Extension/EchoExtensionTest.php +++ b/Tests/Twig/Extension/EchoExtensionTest.php @@ -413,6 +413,34 @@ public function testGetEchoTwigFilter() $this->runTwigTests($tpls, $returns); } + public function testGetEchoInclude() + { + $tpls = array( + 'string' => '{{ echo_include( "::base.htmlm.twig" ) }}', + ); + + $returns = array( + 'string' => array('{% include "::base.htmlm.twig" %}', 'include return a good include tag with string elements'), + ); + + $this->runTwigTests($tpls, $returns); + } + + public function testGetEchoRender() + { + $tpls = array( + 'controller' => '{{ echo_render( "MyController" ) }}', + 'with_params' => '{{ echo_render( "MyController", {"hello": name } ) }}', + ); + + $returns = array( + 'controller' => array('{% render(controller("MyController", { })) %}', 'controller return a good controller tag'), + 'with_params' => array('{% render(controller("MyController", { hello: \'cedric\' })) %}', 'controller return a good controller tag'), + ); + + $this->runTwigTests($tpls, $returns); + } + protected function runTwigTests($tpls, $returns) { $twig = $this->getEnvironment(false, array(), $tpls); diff --git a/Twig/Extension/EchoExtension.php b/Twig/Extension/EchoExtension.php old mode 100755 new mode 100644 index bf9b63b5..d9177c83 --- a/Twig/Extension/EchoExtension.php +++ b/Twig/Extension/EchoExtension.php @@ -42,6 +42,8 @@ public function getFunctions() 'echo_trans' => new \Twig_Function_Method($this, 'getEchoTrans'), 'echo_twig_assoc' => new \Twig_Function_Method($this, 'getEchoTwigAssoc'), 'echo_twig_filter' => new \Twig_Function_Method($this, 'getEchoTwigFilter'), + 'echo_include' => new \Twig_Function_Method($this, 'getEchoInclude'), + 'echo_render' => new \Twig_Function_Method($this, 'getEchoRender'), ); } @@ -452,6 +454,18 @@ public function getEchoTwigAssoc(array $arr) return '{ ' . implode(', ', $contents) . ' }'; } + public function getEchoInclude($twig) + { + return '{% include "'.$twig.'" %}'; + } + + public function getEchoRender($controller, array $params = array()) + { + $params = $this->getEchoTwigAssoc($params); + + return '{% render(controller("'.$controller.'", '.$params.')) %}'; + } + /** * Returns the name of the extension. *