Browse Source

Création du bundle GroupBundle. Liste des groupes créé.

bastien 13 years ago
parent
commit
027072779c

+ 1 - 0
app/AppKernel.php View File

@@ -30,6 +30,7 @@ class AppKernel extends Kernel
30 30
             new Muzich\HomeBundle\MuzichHomeBundle(),
31 31
             new Muzich\MynetworkBundle\MuzichMynetworkBundle(),
32 32
             new Muzich\AdminBundle\MuzichAdminBundle(),
33
+            new Muzich\GroupBundle\MuzichGroupBundle(),
33 34
         );
34 35
 
35 36
         if (in_array($this->getEnvironment(), array('dev', 'test'))) {

+ 3 - 0
app/Resources/translations/groups.fr.yml View File

@@ -0,0 +1,3 @@
1
+
2
+nogroups:
3
+  sentence:                     Vous n'avez créé aucun groupe.

+ 4 - 1
app/Resources/translations/navigationui.fr.yml View File

@@ -5,4 +5,7 @@ container_menu:
5 5
   
6 6
 top_bar:
7 7
   my_account:           Mon compte
8
-  logout:               Déconnexion
8
+  logout:               Déconnexion
9
+  
10
+network:
11
+  mygroups:             Mes groupes

+ 5 - 2
app/config/routing.yml View File

@@ -1,5 +1,3 @@
1
-
2
-
3 1
 # Internal routing configuration to handle ESI
4 2
 #_internal:
5 3
 #   resource: "@FrameworkBundle/Resources/config/routing/internal.xml"
@@ -39,4 +37,9 @@ MuzichUserBundle:
39 37
 MuzichMynetworkBundle:
40 38
   resource: "@MuzichMynetworkBundle/Resources/config/routing.yml"
41 39
   prefix:   /{_locale}/
40
+  defaults: { _locale: fr }
41
+  
42
+MuzichGroupBundle:
43
+  resource: "@MuzichGroupBundle/Resources/config/routing.yml"
44
+  prefix:   /{_locale}/
42 45
   defaults: { _locale: fr }

+ 1 - 1
src/Muzich/CoreBundle/Entity/Group.php View File

@@ -69,7 +69,7 @@ class Group
69 69
   /**
70 70
    * Propriétaire
71 71
    * 
72
-   * @ORM\ManyToOne(targetEntity="User")
72
+   * @ORM\ManyToOne(targetEntity="User", inversedBy="groups_owned")
73 73
    * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
74 74
    */
75 75
   protected $owner;

+ 3 - 2
src/Muzich/CoreBundle/Entity/User.php View File

@@ -97,6 +97,7 @@ class User extends BaseUser
97 97
     $this->followers_users = new ArrayCollection();
98 98
     $this->followed_groups = new ArrayCollection();
99 99
     $this->groups = new ArrayCollection();
100
+    $this->groups_owned = new ArrayCollection();
100 101
     parent::__construct();
101 102
   }
102 103
   
@@ -255,9 +256,9 @@ class User extends BaseUser
255 256
    *
256 257
    * @return Doctrine\Common\Collections\Collection 
257 258
    */
258
-  public function getGroupsOnwed()
259
+  public function getGroupsOwned()
259 260
   {
260
-    return $this->groups;
261
+    return $this->groups_owned;
261 262
   }
262 263
   
263 264
   public function getSlug()

+ 6 - 0
src/Muzich/CoreBundle/Repository/UserRepository.php View File

@@ -46,6 +46,12 @@ class UserRepository extends EntityRepository
46 46
       $join   .= ' LEFT JOIN u.tags_favorites tf LEFT JOIN tf.tag tf_t';
47 47
     }
48 48
     
49
+    if (in_array('groups_owned', $join_list))
50
+    {
51
+      $select .= ', og';
52
+      $join   .= ' LEFT JOIN u.groups_owned og';
53
+    }
54
+    
49 55
 //    if (array_key_exists('followed_user_id', $join_list))
50 56
 //    {
51 57
 //      $select .= ', fu, fu_u';

+ 13 - 1
src/Muzich/CoreBundle/Resources/views/Menu/containerMenu.html.twig View File

@@ -10,4 +10,16 @@
10 10
       {{ 'container_menu.my_network'|trans({}, 'navigationui') }}
11 11
     </a>
12 12
   </li>
13
-</ul>
13
+</ul>
14
+
15
+{% if mygroups %}
16
+
17
+  <ul id="top-tabs-my-groups" {% if active == 'mygroups' %} class="active" {% endif %}>
18
+    <li {% if active == 'mygroups' %} class="active" {% endif %}>
19
+      <a href="{{ path('groups_own_list') }}" >
20
+        {{ 'network.mygroups'|trans({}, 'navigationui') }}
21
+      </a>
22
+    </li>
23
+  </ul>
24
+
25
+{% endif %}

+ 26 - 0
src/Muzich/GroupBundle/Controller/DefaultController.php View File

@@ -0,0 +1,26 @@
1
+<?php
2
+
3
+namespace Muzich\GroupBundle\Controller;
4
+
5
+use Muzich\CoreBundle\lib\Controller;
6
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
7
+
8
+class DefaultController extends Controller
9
+{
10
+  
11
+  /**
12
+   * 
13
+   * @Template()
14
+   */
15
+  public function myListAction()
16
+  {
17
+    $user = $this->getUser(true, array('join' => array(
18
+      //'groups_owned'
19
+    )));
20
+    
21
+    return array(
22
+      'groups' => $user->getGroupsOwned()
23
+    );
24
+  }
25
+  
26
+}

+ 29 - 0
src/Muzich/GroupBundle/DependencyInjection/Configuration.php View File

@@ -0,0 +1,29 @@
1
+<?php
2
+
3
+namespace Muzich\GroupBundle\DependencyInjection;
4
+
5
+use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
+use Symfony\Component\Config\Definition\ConfigurationInterface;
7
+
8
+/**
9
+ * This is the class that validates and merges configuration from your app/config files
10
+ *
11
+ * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
12
+ */
13
+class Configuration implements ConfigurationInterface
14
+{
15
+    /**
16
+     * {@inheritDoc}
17
+     */
18
+    public function getConfigTreeBuilder()
19
+    {
20
+        $treeBuilder = new TreeBuilder();
21
+        $rootNode = $treeBuilder->root('muzich_group');
22
+
23
+        // Here you should define the parameters that are allowed to
24
+        // configure your bundle. See the documentation linked above for
25
+        // more information on that topic.
26
+
27
+        return $treeBuilder;
28
+    }
29
+}

+ 28 - 0
src/Muzich/GroupBundle/DependencyInjection/MuzichGroupExtension.php View File

@@ -0,0 +1,28 @@
1
+<?php
2
+
3
+namespace Muzich\GroupBundle\DependencyInjection;
4
+
5
+use Symfony\Component\DependencyInjection\ContainerBuilder;
6
+use Symfony\Component\Config\FileLocator;
7
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
8
+use Symfony\Component\DependencyInjection\Loader;
9
+
10
+/**
11
+ * This is the class that loads and manages your bundle configuration
12
+ *
13
+ * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
14
+ */
15
+class MuzichGroupExtension extends Extension
16
+{
17
+    /**
18
+     * {@inheritDoc}
19
+     */
20
+    public function load(array $configs, ContainerBuilder $container)
21
+    {
22
+        $configuration = new Configuration();
23
+        $config = $this->processConfiguration($configuration, $configs);
24
+
25
+        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
26
+        $loader->load('services.yml');
27
+    }
28
+}

+ 9 - 0
src/Muzich/GroupBundle/MuzichGroupBundle.php View File

@@ -0,0 +1,9 @@
1
+<?php
2
+
3
+namespace Muzich\GroupBundle;
4
+
5
+use Symfony\Component\HttpKernel\Bundle\Bundle;
6
+
7
+class MuzichGroupBundle extends Bundle
8
+{
9
+}

+ 4 - 0
src/Muzich/GroupBundle/Resources/config/routing.yml View File

@@ -0,0 +1,4 @@
1
+
2
+groups_own_list:
3
+    pattern:  /my-groups
4
+    defaults: { _controller: MuzichGroupBundle:Default:myList }

+ 7 - 0
src/Muzich/GroupBundle/Resources/config/services.yml View File

@@ -0,0 +1,7 @@
1
+parameters:
2
+#    muzich_group.example.class: Muzich\GroupBundle\Example
3
+
4
+services:
5
+#    muzich_group.example:
6
+#        class: %muzich_group.example.class%
7
+#        arguments: [@service_id, "plain_value", %parameter%]

+ 0 - 0
src/Muzich/GroupBundle/Resources/doc/index.rst View File


+ 11 - 0
src/Muzich/GroupBundle/Resources/translations/messages.fr.xliff View File

@@ -0,0 +1,11 @@
1
+<?xml version="1.0"?>
2
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3
+    <file source-language="en" datatype="plaintext" original="file.ext">
4
+        <body>
5
+            <trans-unit id="1">
6
+                <source>Symfony2 is great</source>
7
+                <target>J'aime Symfony2</target>
8
+            </trans-unit>
9
+        </body>
10
+    </file>
11
+</xliff>

+ 23 - 0
src/Muzich/GroupBundle/Resources/views/Default/myList.html.twig View File

@@ -0,0 +1,23 @@
1
+{% extends "MuzichGroupBundle::layout.html.twig" %}
2
+
3
+{% block title %}Mes groupes{% endblock %}
4
+
5
+{% block content %}
6
+
7
+  {% if groups|length %}
8
+
9
+    <ul class="inline">
10
+    {% for group in groups %} 
11
+      <li>
12
+        <a href="{{ path('show_group', { 'slug': group.slug }) }}">{{ group.name }}</a>
13
+      </li>
14
+    {% endfor %}
15
+    </ul>
16
+
17
+  {% else %}
18
+
19
+    {{ 'nogroups.sentence'|trans({}, 'groups') }}
20
+
21
+  {% endif %}
22
+
23
+{% endblock %}

+ 13 - 0
src/Muzich/GroupBundle/Resources/views/layout.html.twig View File

@@ -0,0 +1,13 @@
1
+{% extends 'MuzichCoreBundle::layout.html.twig' %}
2
+
3
+{% block css %}
4
+	<link href="{{ asset('bundles/muzichgroups/css/groups.css') }}" rel="stylesheet" media="screen" type="text/css" />
5
+{% endblock %}
6
+
7
+{% block main_content %}
8
+  
9
+  {% include "MuzichCoreBundle:Menu:containerMenu.html.twig" with { 'active': 'mygroups', 'mygroups': true } %}
10
+  
11
+  {% block content %}{% endblock %}
12
+  
13
+{% endblock %}

+ 17 - 0
src/Muzich/GroupBundle/Tests/Controller/DefaultControllerTest.php View File

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+namespace Muzich\GroupBundle\Tests\Controller;
4
+
5
+use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6
+
7
+class DefaultControllerTest extends WebTestCase
8
+{
9
+    public function testIndex()
10
+    {
11
+        $client = static::createClient();
12
+
13
+        $crawler = $client->request('GET', '/hello/Fabien');
14
+
15
+        $this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0);
16
+    }
17
+}

+ 1 - 1
src/Muzich/HomeBundle/Resources/views/layout.html.twig View File

@@ -6,7 +6,7 @@
6 6
 
7 7
 {% block main_content %}
8 8
   
9
-    {% include "MuzichCoreBundle:Menu:containerMenu.html.twig" with { 'active': 'public' } %}
9
+    {% include "MuzichCoreBundle:Menu:containerMenu.html.twig" with { 'active': 'public', 'mygroups': false } %}
10 10
   
11 11
     {% block content %}{% endblock %}
12 12
   

+ 1 - 1
src/Muzich/MynetworkBundle/Resources/views/layout.html.twig View File

@@ -6,7 +6,7 @@
6 6
 
7 7
 {% block main_content %}
8 8
   
9
-  {% include "MuzichCoreBundle:Menu:containerMenu.html.twig" with { 'active': 'private' } %}
9
+  {% include "MuzichCoreBundle:Menu:containerMenu.html.twig" with { 'active': 'private', 'mygroups': true } %}
10 10
   
11 11
   {% block content %}{% endblock %}
12 12
   

+ 1 - 1
src/Muzich/UserBundle/Resources/views/layout.html.twig View File

@@ -6,7 +6,7 @@
6 6
 
7 7
 {% block main_content %}
8 8
   
9
-    {% include "MuzichCoreBundle:Menu:containerMenu.html.twig" with { 'active': null } %}
9
+    {% include "MuzichCoreBundle:Menu:containerMenu.html.twig" with { 'active': null, 'mygroups': false } %}
10 10
   
11 11
     {% block content %}{% endblock %}
12 12
   

+ 15 - 5
web/bundles/muzichcore/css/main.css View File

@@ -45,7 +45,7 @@
45 45
   color: #00d0de;
46 46
 }
47 47
 
48
-#container #top-tabs
48
+#container #top-tabs, #container #top-tabs-my-groups
49 49
 {
50 50
   float: left;
51 51
   list-style: none outside none;
@@ -53,7 +53,7 @@
53 53
   padding: 0;
54 54
 }
55 55
 
56
-#container #top-tabs li
56
+#container #top-tabs li, #container #top-tabs-my-groups
57 57
 {
58 58
   float: left;
59 59
   margin-left: 0px;
@@ -71,20 +71,30 @@
71 71
   border-radius: 5px 5px 0px 0px;
72 72
   -moz-border-radius: 5px 5px 0px 0px;
73 73
   -webkit-border-radius: 5px 5px 0px 0px;
74
-  
75 74
 }
76 75
 
77
-#container #top-tabs li.active
76
+#container #top-tabs li.active, #container #top-tabs-my-groups li.active
78 77
 {
79 78
   background-color: white;
80 79
 }
81 80
 
82
-#container #top-tabs li a
81
+#container #top-tabs li a, #container #top-tabs-my-groups li a
83 82
 {
84 83
   text-decoration: none;
85 84
   color: black;
86 85
 }
87 86
 
87
+#container #top-tabs-my-groups
88
+{
89
+  float: right;
90
+  margin-right: -5px;
91
+}
92
+
93
+#container #top-tabs-my-groups.active
94
+{
95
+  background-color: white;
96
+}
97
+
88 98
 #top_bar
89 99
 {
90 100
   width: 220px;

+ 0 - 0
web/bundles/muzichgroups/css/groups.css View File