Selaa lähdekoodia

Evolution #151: Evenements

bastien 13 vuotta sitten
vanhempi
commit
30e2b72ec4

+ 1 - 1
src/Muzich/CoreBundle/Entity/Event.php Näytä tiedosto

18
 class Event
18
 class Event
19
 {
19
 {
20
   
20
   
21
-  const TYPE_COMMENT_ADDED_OWNED_ELEMENT = "com.add.ow.e";
21
+  const TYPE_COMMENT_ADDED_ELEMENT = "com.adde.ele";
22
   
22
   
23
   /**
23
   /**
24
    * @ORM\Id
24
    * @ORM\Id

+ 13 - 1
src/Muzich/CoreBundle/Extension/MyTwigExtension.php Näytä tiedosto

24
   
24
   
25
   public function getFunctions() {
25
   public function getFunctions() {
26
     return array(
26
     return array(
27
-      'date_or_relative_date'  => new \Twig_Filter_Method($this, 'date_or_relative_date')
27
+      'date_or_relative_date'  => new \Twig_Filter_Method($this, 'date_or_relative_date'),
28
+      'event_const'  => new \Twig_Filter_Method($this, 'event_const')
28
     );
29
     );
29
   }
30
   }
30
   
31
   
115
     $date = str_replace(':', '', $date);
116
     $date = str_replace(':', '', $date);
116
     return $date;
117
     return $date;
117
   }
118
   }
119
+  
120
+  public function event_const($const_name)
121
+  {
122
+    switch ($const_name)
123
+    {
124
+      case 'TYPE_COMMENT_ADDED_ELEMENT':
125
+        return \Muzich\CoreBundle\Entity\Event::TYPE_COMMENT_ADDED_ELEMENT;
126
+      break;
127
+    }
128
+    return null;
129
+  }
118
 
130
 
119
 }
131
 }

+ 2 - 2
src/Muzich/CoreBundle/Propagator/EventElementComment.php Näytä tiedosto

27
           (e.view = \'FALSE\' OR e.view = \'0\')'
27
           (e.view = \'FALSE\' OR e.view = \'0\')'
28
       )->setParameters(array(
28
       )->setParameters(array(
29
         'uid' => $element->getOwner()->getId(),
29
         'uid' => $element->getOwner()->getId(),
30
-        'type' => Event::TYPE_COMMENT_ADDED_OWNED_ELEMENT
30
+        'type' => Event::TYPE_COMMENT_ADDED_ELEMENT
31
       ))->getSingleResult()
31
       ))->getSingleResult()
32
       ;
32
       ;
33
       $new = false;
33
       $new = false;
42
     if ($new)
42
     if ($new)
43
     {
43
     {
44
       $uea->createEvent(
44
       $uea->createEvent(
45
-        Event::TYPE_COMMENT_ADDED_OWNED_ELEMENT,
45
+        Event::TYPE_COMMENT_ADDED_ELEMENT,
46
         $element->getId()
46
         $element->getId()
47
       );
47
       );
48
     }
48
     }

+ 22 - 1
src/Muzich/CoreBundle/Repository/EventRepository.php Näytä tiedosto

4
 
4
 
5
 use Doctrine\ORM\EntityRepository;
5
 use Doctrine\ORM\EntityRepository;
6
 
6
 
7
-class ElementRepository extends EntityRepository
7
+class EventRepository extends EntityRepository
8
 {
8
 {
9
+  
10
+  public function getNotViewEvents($user_id)
11
+  {
12
+    $events = array();
13
+    $result = $this->getEntityManager()
14
+      ->createQuery('
15
+        SELECT e FROM MuzichCoreBundle:Event e
16
+        WHERE e.user = :uid AND 
17
+        (e.view = \'FALSE\' OR e.view = \'0\')'
18
+      )
19
+      ->setParameter('uid', $user_id)
20
+      ->getArrayResult()
21
+    ;
9
     
22
     
23
+    foreach ($result as $event)
24
+    {
25
+      $events[$event['type']] = $event;
26
+    }
27
+    
28
+    return $events;
29
+  }
30
+  
10
 }
31
 }

+ 7 - 3
src/Muzich/CoreBundle/Resources/views/layout.html.twig Näytä tiedosto

75
       </p>
75
       </p>
76
     </div>
76
     </div>
77
   </noscript>
77
   </noscript>
78
-  
78
+      
79
   <div id="container">
79
   <div id="container">
80
+    
81
+    {% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
82
+      {% render "MuzichUserBundle:User:infoBar" %}
83
+    {% endif %}
84
+    
80
     {% block main_content %}{% endblock %}
85
     {% block main_content %}{% endblock %}
81
     {% block fos_user_content %}{% endblock %}
86
     {% block fos_user_content %}{% endblock %}
82
   </div>
87
   </div>
83
-  
84
-  
88
+    
85
   {% for key, flash in app.session.getFlashes() %}
89
   {% for key, flash in app.session.getFlashes() %}
86
     <div class="{{ key }} message">
90
     <div class="{{ key }} message">
87
       <a class="message-close" href="#" title="fermer"><img alt="close" src="{{ asset('bundles/muzichcore/img/1317386146_cancel.png') }}" /></a>
91
       <a class="message-close" href="#" title="fermer"><img alt="close" src="{{ asset('bundles/muzichcore/img/1317386146_cancel.png') }}" /></a>

+ 11 - 0
src/Muzich/UserBundle/Controller/UserController.php Näytä tiedosto

566
       'status' => 'success'
566
       'status' => 'success'
567
     ));
567
     ));
568
   }
568
   }
569
+  
570
+  public function infoBarAction()
571
+  {
572
+    $events = $this->getDoctrine()->getRepository('MuzichCoreBundle:Event')
573
+      ->getNotViewEvents($this->getUserId())
574
+    ;
575
+    
576
+    return $this->render('MuzichUserBundle:Info:bar.html.twig', array(
577
+      'events' => $events
578
+    ));
579
+  }
569
     
580
     
570
 }
581
 }

+ 17 - 0
src/Muzich/UserBundle/Resources/views/Info/bar.html.twig Näytä tiedosto

1
+<div id="events">
2
+    
3
+    <div class="score">
4
+      <img src="{{ asset('bundles/muzichcore/img/1332286466_stock_scores.png') }}" alt="" />
5
+      <span>{{ app.user.reputation }}</span>
6
+    </div>
7
+    
8
+    <div class="comments">
9
+      <img src="{{ asset('bundles/muzichcore/img/1332286007_comments_reply.png') }}" alt="" />
10
+      {% if events[event_const('TYPE_COMMENT_ADDED_ELEMENT')] is defined %}
11
+        <span>{{ events[event_const('TYPE_COMMENT_ADDED_ELEMENT')].count }}</span>
12
+      {% else %}
13
+        <span>0</span>
14
+      {% endif %}
15
+    </div>
16
+  
17
+  </div>

+ 45 - 0
web/bundles/muzichcore/css/main.css Näytä tiedosto

1097
 {
1097
 {
1098
   font-size: 125%;
1098
   font-size: 125%;
1099
   font-weight: bold;
1099
   font-weight: bold;
1100
+}
1101
+
1102
+div#events
1103
+{
1104
+  width: 62px;
1105
+  position: absolute;
1106
+  margin-top: 50px;
1107
+  margin-left: 650px;
1108
+  background-color: white;
1109
+  padding: 4px;
1110
+  
1111
+  border-top: 0px solid #d5d5d5;
1112
+  border-right: 0px solid #d5d5d5;
1113
+  border-bottom: 0px solid #d5d5d5;
1114
+  border-left: none;
1115
+  border-radius: 0px 5px 5px 0px;
1116
+  -moz-border-radius: 0px 5px 5px 0px;
1117
+  -webkit-border-radius: 0px 5px 5px 0px;
1118
+  
1119
+  -webkit-box-shadow: 2px 2px 2px #666;
1120
+  -moz-box-shadow: 2px 2px 2px #666 ;
1121
+  box-shadow: 2px 2px 2px #666;
1122
+}
1123
+
1124
+div#events div.score img
1125
+{
1126
+  margin-bottom: -5px;
1127
+}
1128
+
1129
+div#events div.score span
1130
+{
1131
+  font-weight: bold;
1132
+  padding-bottom: 2px;
1133
+}
1134
+
1135
+div#events div.comments img
1136
+{
1137
+  margin-left: 3px;
1138
+  margin-bottom: -4px;
1139
+}
1140
+
1141
+div#events div.comments span
1142
+{
1143
+  font-weight: bold;
1144
+  margin-left: 5px;
1100
 }
1145
 }

BIN
web/bundles/muzichcore/img/1332286007_comments_reply.png Näytä tiedosto


BIN
web/bundles/muzichcore/img/1332286466_stock_scores.png Näytä tiedosto