瀏覽代碼

Add overridable history revision timestamp template.

Romain Geissler 12 年之前
父節點
當前提交
5bb5deaeb3

+ 1 - 0
DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php

@@ -273,6 +273,7 @@ class AddDependencyCallsCompilerPass implements CompilerPassInterface
             'edit'                     => 'SonataAdminBundle:CRUD:edit.html.twig',
             'history'                  => 'SonataAdminBundle:CRUD:history.html.twig',
             'history_revision'         => 'SonataAdminBundle:CRUD:history_revision.html.twig',
+            'history_revision_timestamp' => 'SonataAdminBundle:CRUD:history_revision_timestamp.html.twig',
             'acl'                      => 'SonataAdminBundle:CRUD:acl.html.twig',
             'action'                   => 'SonataAdminBundle:CRUD:action.html.twig',
             'short_object_description' => 'SonataAdminBundle:Helper:short-object-description.html.twig',

+ 1 - 0
DependencyInjection/Configuration.php

@@ -153,6 +153,7 @@ class Configuration implements ConfigurationInterface
                         ->scalarNode('history')->defaultValue('SonataAdminBundle:CRUD:history.html.twig')->cannotBeEmpty()->end()
                         ->scalarNode('history_revision')->defaultValue('SonataAdminBundle:CRUD:history_revision.html.twig')->cannotBeEmpty()->end()
                         ->scalarNode('acl')->defaultValue('SonataAdminBundle:CRUD:acl.html.twig')->cannotBeEmpty()->end()
+                        ->scalarNode('history_revision_timestamp')->defaultValue('SonataAdminBundle:CRUD:history_revision_timestamp.html.twig')->cannotBeEmpty()->end()
                         ->scalarNode('action')->defaultValue('SonataAdminBundle:CRUD:action.html.twig')->cannotBeEmpty()->end()
                         ->scalarNode('list_block')->defaultValue('SonataAdminBundle:Block:block_admin_list.html.twig')->cannotBeEmpty()->end()
                         ->scalarNode('short_object_description')->defaultValue('SonataAdminBundle:Helper:short-object-description.html.twig')->cannotBeEmpty()->end()

+ 9 - 0
DependencyInjection/SonataAdminExtension.php

@@ -44,6 +44,15 @@ class SonataAdminExtension extends Extension
             ));
         }
 
+        if (isset($bundles['SonataIntlBundle'])) {
+            // integrate the SonataUserBundle if the bundle exists
+            array_unshift($configs, array(
+                'templates' => array(
+                    'history_revision_timestamp' => 'SonataIntlBundle:CRUD:history_revision_timestamp.html.twig'
+                )
+            ));
+        }
+
         $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
         $loader->load('templates.xml');
         $loader->load('twig.xml');

+ 1 - 1
Resources/views/CRUD/base_history.html.twig

@@ -36,7 +36,7 @@ file that was distributed with this source code.
                 {% for revision in revisions %}
                     <tr>
                         <td>{{ revision.rev}}</td>
-                        <td>{{ revision.timestamp | date}}</td>
+                        <td>{% include admin.getTemplate('history_revision_timestamp') %}</td>
                         <td>{{ revision.username}}</td>
                         <td><a href="{{ admin.generateObjectUrl('history_view_revision', object, {'revision': revision.rev }) }}" class="revision-link" rel="{{ revision.rev }}">{{ "label_view_revision"|trans({}, 'SonataAdminBundle') }}</a></td>
                     </tr>

+ 12 - 0
Resources/views/CRUD/history_revision_timestamp.html.twig

@@ -0,0 +1,12 @@
+{#
+
+This file is part of the Sonata package.
+
+(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
+
+For the full copyright and license information, please view the LICENSE
+file that was distributed with this source code.
+
+#}
+
+{{ revision.timestamp | date }}