Browse Source

Evolution #566: Gestion de l'avatar

Sevajol Bastien 11 years ago
parent
commit
6af30aa959
35 changed files with 1732 additions and 7 deletions
  1. 2 0
      .gitignore
  2. 1 0
      app/AppKernel.php
  3. 6 0
      app/Resources/translations/userui.fr.yml
  4. 1 1
      app/autoload.php
  5. 69 0
      src/Muzich/CoreBundle/Entity/User.php
  6. 7 0
      src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig
  7. 33 1
      src/Muzich/UserBundle/Controller/UserController.php
  8. 6 0
      src/Muzich/UserBundle/Resources/config/routing.yml
  9. 5 1
      src/Muzich/UserBundle/Resources/views/Info/bar.html.twig
  10. 19 0
      src/Muzich/UserBundle/Resources/views/User/account.html.twig
  11. 9 0
      src/Muzich/UserBundle/Resources/views/User/avatar_form.html.twig
  12. 36 0
      vendor/bundles/Gregwar/ImageBundle/DependencyInjection/GregwarImageExtension.php
  13. 54 0
      vendor/bundles/Gregwar/ImageBundle/Extensions/ImageTwig.php
  14. 9 0
      vendor/bundles/Gregwar/ImageBundle/GregwarImageBundle.php
  15. 1092 0
      vendor/bundles/Gregwar/ImageBundle/Image.php
  16. 72 0
      vendor/bundles/Gregwar/ImageBundle/ImageColor.php
  17. 37 0
      vendor/bundles/Gregwar/ImageBundle/ImageHandler.php
  18. 146 0
      vendor/bundles/Gregwar/ImageBundle/README.md
  19. 18 0
      vendor/bundles/Gregwar/ImageBundle/Resources/config/services.yml
  20. 69 0
      vendor/bundles/Gregwar/ImageBundle/Services/ImageHandling.php
  21. 25 0
      vendor/bundles/Gregwar/ImageBundle/composer.json
  22. 0 1
      web/bundles/muzichcore/css/old.css
  23. 16 3
      web/css/main.css
  24. BIN
      web/img/1360770994_user.png
  25. BIN
      web/img/1360770994_user_44_46.png
  26. BIN
      web/img/1360770994_user_48_50.png
  27. 0 0
      web/img/avatar_test.png
  28. 0 0
      web/img/icon_dart_left_white.png
  29. 0 0
      web/img/icon_dart_right_white.png
  30. 0 0
      web/img/icon_heart.png
  31. 0 0
      web/img/icon_star_2_red.png
  32. 0 0
      web/img/icon_thumb_red.png
  33. 0 0
      web/img/list_chip_red.png
  34. 0 0
      web/js/soundcloud/api.js
  35. 0 0
      web/js/soundcloud/sdk.js

+ 2 - 0
.gitignore View File

@@ -10,3 +10,5 @@ nbproject
10 10
 .debug
11 11
 .scripts
12 12
 muzich.komodoproject
13
+web/files/avatars/*
14
+web/cache/*

+ 1 - 0
app/AppKernel.php View File

@@ -24,6 +24,7 @@ class AppKernel extends Kernel
24 24
             new Sonata\BluePrintBundle\SonataBluePrintBundle(),
25 25
             new Sonata\AdminBundle\SonataAdminBundle(),
26 26
             new Knp\Bundle\MenuBundle\KnpMenuBundle(),
27
+            new Gregwar\ImageBundle\GregwarImageBundle(),
27 28
             new Muzich\CoreBundle\MuzichCoreBundle(),
28 29
             new Muzich\UserBundle\MuzichUserBundle(),
29 30
             new Muzich\IndexBundle\MuzichIndexBundle(),

+ 6 - 0
app/Resources/translations/userui.fr.yml View File

@@ -53,6 +53,12 @@ my_account:
53 53
         nocountry:  Veuillez saisir le pays
54 54
   help_clicks:      |
55 55
                     Cliquez sur les titres ci-dessous pour accèder aux autres paramètres
56
+  avatar:
57
+    title:          Mon avatar
58
+    submit:         Mettre à jour
59
+    help:           'Choisissez une image puis préssez le bouton "Mettre à jour"'
60
+    success:        Votre avatar a bien été mis à jour
61
+    error:          Une erreur est survenue lors de la mise à jour de votre avatar
56 62
   
57 63
 connexion:
58 64
   password_lost:    Mot de passe perdu ?

+ 1 - 1
app/autoload.php View File

@@ -15,7 +15,7 @@ $loader->registerNamespaces(array(
15 15
     'Assetic'          => __DIR__.'/../vendor/assetic/src',
16 16
     'Metadata'         => __DIR__.'/../vendor/metadata/src',
17 17
     'FOS'              => __DIR__.'/../vendor/bundles',
18
-    //'Muzich'           => __DIR__.'/../vendor/src',
18
+    'Gregwar'          => __DIR__.'/../vendor/bundles',
19 19
     'Doctrine\\Common\\DataFixtures' => __DIR__.'/../vendor/doctrine-fixtures/lib',
20 20
     'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
21 21
     'Stof'  => __DIR__.'/../vendor/bundles',

+ 69 - 0
src/Muzich/CoreBundle/Entity/User.php View File

@@ -216,6 +216,16 @@ class User extends BaseUser
216 216
   private $tags_favorites_quick;
217 217
   
218 218
   /**
219
+   * @Assert\Image(maxSize="6000000")
220
+   */
221
+  public $avatar;
222
+    
223
+  /**
224
+   * @ORM\Column(type="text", length=255, nullable=true)
225
+   */
226
+  public $avatar_path;
227
+  
228
+  /**
219 229
    * 
220 230
    */
221 231
   public function __construct()
@@ -917,4 +927,63 @@ class User extends BaseUser
917 927
     $this->setDatas($datas);
918 928
   }
919 929
   
930
+  public function getAvatarAbsolutePath()
931
+  {
932
+    return null === $this->avatar_path
933
+      ? null
934
+      : $this->getAvatarUploadRootDir().'/'.$this->avatar_path;
935
+  }
936
+
937
+  public function getAvatarWebPath()
938
+  {
939
+    return null === $this->avatar_path
940
+      ? null
941
+      : $this->getAvatarUploadDir().'/'.$this->avatar_path;
942
+  }
943
+
944
+  protected function getAvatarUploadRootDir()
945
+  {
946
+    return __DIR__.'/../../../../web/'.$this->getAvatarUploadDir();
947
+  }
948
+
949
+  protected function getAvatarUploadDir()
950
+  {
951
+    return 'files/avatars';
952
+  }
953
+    
954
+   /**
955
+    * @ORM\PrePersist()
956
+    * @ORM\PreUpdate()
957
+    */
958
+   public function preUploadAvatar()
959
+   {
960
+      if (null !== $this->avatar) {
961
+         $this->avatar_path = $this->getPersonalHash($this->avatar->getClientOriginalName()).'.'.$this->avatar->guessExtension();
962
+      }
963
+   }
964
+   
965
+  /**
966
+   * @ORM\PostPersist()
967
+   * @ORM\PostUpdate()
968
+   */
969
+  public function uploadAvatar()
970
+  {
971
+    if (null === $this->avatar) {
972
+      return;
973
+    }
974
+    
975
+    $this->avatar->move($this->getAvatarUploadRootDir(), $this->avatar_path);
976
+    $this->avatar = null;
977
+  }
978
+  
979
+  /**
980
+   * @ORM\PostRemove()
981
+   */
982
+  public function removeUpload()
983
+  {
984
+    if ($file = $this->getAvatarAbsolutePath()) {
985
+      unlink($file);
986
+    }
987
+  }
988
+  
920 989
 }

+ 7 - 0
src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig View File

@@ -37,6 +37,13 @@
37 37
     {% endif %}
38 38
     
39 39
     <div class="reputation">
40
+      
41
+      {% if viewed_user.avatar_path %}
42
+        <img alt="avatar" src="{{ image(viewed_user.avatarWebPath).resize(48,50,'#000000') }}" />
43
+      {% else %}
44
+        <img alt="default_avatar" src="{{ asset('/img/1360770994_user_48_50.png') }}" />
45
+      {% endif %}
46
+      
40 47
       {{ 'user.reputation.name'|trans({}, 'users') }}: 
41 48
       <span class="score">{{ viewed_user.reputation }}</span>
42 49
       {{ 'user.reputation.txt'|trans({}, 'users') }}

+ 33 - 1
src/Muzich/UserBundle/Controller/UserController.php View File

@@ -10,6 +10,7 @@ use FOS\UserBundle\Model\UserInterface;
10 10
 use Muzich\CoreBundle\Form\Tag\TagFavoritesForm;
11 11
 use Symfony\Component\Validator\Constraints\Email;
12 12
 use Symfony\Component\Validator\Constraints\Collection;
13
+use Symfony\Component\HttpFoundation\Request;
13 14
 
14 15
 class UserController extends Controller
15 16
 {
@@ -88,10 +89,19 @@ class UserController extends Controller
88 89
       'form_tags_favorites'      => $form_tags_favorites->createView(),
89 90
       'form_tags_favorites_name' => $form_tags_favorites->getName(),
90 91
       'favorite_tags_id'         => $this->getTagsFavorites(),
91
-      'change_email_form'        => $change_email_form->createView()
92
+      'change_email_form'        => $change_email_form->createView(),
93
+      'avatar_form'              => $this->getAvatarForm()->createView()
92 94
     );
93 95
   }
94 96
   
97
+  protected function getAvatarForm()
98
+  {
99
+    return $this->createFormBuilder($this->getUser())
100
+      ->add('avatar')
101
+      ->getForm()
102
+    ;
103
+  }
104
+  
95 105
   /**
96 106
    * Un bug étrange empêche la mise ne place de contraintes sur le formulaire
97 107
    * d'inscription. On effectue alors les vérifications ici.
@@ -572,5 +582,27 @@ class UserController extends Controller
572 582
       'status' => 'success'
573 583
     ));
574 584
   }
585
+  
586
+  public function updateAvatarAction(Request $request)
587
+  {
588
+    $form = $this->getAvatarForm();
589
+    $form->bindRequest($request);
590
+    
591
+    if ($form->isValid()) {
592
+      $em = $this->getEntityManager();
593
+      $form->getData()->preUploadAvatar();
594
+      $form->getData()->uploadAvatar();
595
+      $em->persist($form->getData());
596
+      $em->flush();
597
+
598
+      $this->setFlash('success',
599
+        $this->trans('my_account.avatar.success', array(), 'userui'));
600
+      return $this->redirect($this->generateUrl('my_account'));
601
+    }
575 602
     
603
+    $this->setFlash('error',
604
+      $this->trans('my_account.avatar.error', array(), 'userui'));
605
+    return $this->redirect($this->generateUrl('my_account'));
606
+  }
607
+  
576 608
 }

+ 6 - 0
src/Muzich/UserBundle/Resources/config/routing.yml View File

@@ -44,3 +44,9 @@ event_delete:
44 44
   requirements:
45 45
     _method:  GET
46 46
     message_id: \d+
47
+  
48
+user_update_avatar:
49
+  pattern:  /account/update-avatar
50
+  defaults: { _controller: MuzichUserBundle:User:updateAvatar }
51
+  requirements:
52
+    _method:  POST

+ 5 - 1
src/Muzich/UserBundle/Resources/views/Info/bar.html.twig View File

@@ -1,7 +1,11 @@
1 1
 
2 2
 <div class="user_score">
3 3
   <div class="user_avatar">
4
-    <img src="{{ asset('/img/avatar_test.png') }}" />
4
+    {% if app.user.avatar_path %}
5
+      <img alt="avatar" src="{{ image(app.user.avatarWebPath).resize(130,137,'#000000') }}" />
6
+    {% else %}
7
+      <img alt="default_avatar" src="{{ asset('/img/1360770994_user.png') }}" />
8
+    {% endif %}
5 9
   </div>
6 10
   <div class="score blackgradiant">
7 11
     {{ app.user.reputation }}

+ 19 - 0
src/Muzich/UserBundle/Resources/views/User/account.html.twig View File

@@ -83,5 +83,24 @@
83 83
     </div>
84 84
     <div style="clear:both;"></div>
85 85
   
86
+    <h2 data-open="myaccount_avatar">{{ 'my_account.avatar.title'|trans({}, 'userui') }}</h2>
87
+  
88
+    <div id="myaccount_avatar" class="myaccount_part"
89
+       style="display: none;"
90
+    >
91
+      <form
92
+          action="{{ path('user_update_avatar') }}"
93
+          method="post" {{ form_enctype(avatar_form) }}
94
+        >
95
+        
96
+          <p class="help">{{ 'my_account.avatar.help'|trans({}, 'userui') }}</p>
97
+          {% include "MuzichUserBundle:User:avatar_form.html.twig" with { 
98
+            'form': avatar_form
99
+          } %}
100
+      
101
+          <input type="submit" class="button" value="{{ 'my_account.avatar.submit'|trans({}, 'userui') }}" />
102
+      </form>
103
+    </div>
104
+    
86 105
   </div>
87 106
 {% endblock %}

+ 9 - 0
src/Muzich/UserBundle/Resources/views/User/avatar_form.html.twig View File

@@ -0,0 +1,9 @@
1
+{% form_theme form 'MuzichCoreBundle:Form:errors.html.twig' %}
2
+
3
+{{ form_errors(form) }}
4
+    
5
+  {{ form_errors(form.avatar) }}
6
+  {{ form_label(form.avatar, '') }}
7
+  {{ form_widget(form.avatar, {'attr':{'class':'niceinput'}}) }}
8
+
9
+{{ form_rest(form) }}

+ 36 - 0
vendor/bundles/Gregwar/ImageBundle/DependencyInjection/GregwarImageExtension.php View File

@@ -0,0 +1,36 @@
1
+<?php
2
+
3
+namespace Gregwar\ImageBundle\DependencyInjection;
4
+
5
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
6
+use Symfony\Component\DependencyInjection\ContainerBuilder;
7
+use Symfony\Component\DependencyInjection\Definition;
8
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
9
+use Symfony\Component\Config\FileLocator;
10
+
11
+/**
12
+ * Loading configuration
13
+ *
14
+ * @author Gregwar <g.passault@gmail.com>
15
+ */
16
+class GregwarImageExtension extends Extension
17
+{
18
+    public function load(array $configs, ContainerBuilder $container)
19
+    {
20
+        $cacheDir = 'cache';
21
+
22
+        $config = array();
23
+        foreach ($configs as $subConfig) {
24
+            $config = array_merge($config, $subConfig);
25
+        }
26
+
27
+        if (isset($config['cache_dir']))
28
+            $cacheDir = $config['cache_dir'];
29
+
30
+        $container->setParameter('gregwar_image.cache_dir', $cacheDir);
31
+
32
+        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
33
+        $loader->load('services.yml');
34
+    }
35
+}
36
+

+ 54 - 0
vendor/bundles/Gregwar/ImageBundle/Extensions/ImageTwig.php View File

@@ -0,0 +1,54 @@
1
+<?php
2
+
3
+namespace Gregwar\ImageBundle\Extensions;
4
+
5
+use Symfony\Component\Templating\EngineInterface;
6
+use Symfony\Component\DependencyInjection\ContainerInterface;
7
+
8
+use Symfony\Component\Form\FormView;
9
+
10
+/**
11
+ * ImageTwig extension
12
+ *
13
+ * @author Gregwar <g.passault@gmail.com>
14
+ * @author bzikarsky <benjamin.zikarsky@perbility.de>
15
+ */
16
+class ImageTwig extends \Twig_Extension
17
+{
18
+    private $container;
19
+    private $environment;
20
+
21
+    public function __construct(ContainerInterface $container)
22
+    {
23
+        $this->container = $container;
24
+    }
25
+    
26
+    public function initRuntime(\Twig_Environment $environment)
27
+    {
28
+        $this->environment = $environment;
29
+    }
30
+
31
+    public function getFunctions()
32
+    {
33
+        return array(
34
+            'image' => new \Twig_Function_Method($this, 'image', array('is_safe' => array('html'))),
35
+            'new_image' => new \Twig_Function_Method($this, 'newImage', array('is_safe' => array('html')))
36
+        );
37
+    }
38
+
39
+    public function image($path)
40
+    {
41
+        return $this->container->get('image.handling')->open($path);
42
+    }
43
+    
44
+    public function newImage($width, $height)
45
+    {
46
+        return $this->container->get('image.handling')->create($width, $height);
47
+    }
48
+
49
+    public function getName()
50
+    {
51
+        return 'image';
52
+    }
53
+}
54
+

+ 9 - 0
vendor/bundles/Gregwar/ImageBundle/GregwarImageBundle.php View File

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

File diff suppressed because it is too large
+ 1092 - 0
vendor/bundles/Gregwar/ImageBundle/Image.php


+ 72 - 0
vendor/bundles/Gregwar/ImageBundle/ImageColor.php View File

@@ -0,0 +1,72 @@
1
+<?php
2
+
3
+namespace Gregwar\ImageBundle;
4
+
5
+/**
6
+ * Color manipulation class
7
+ */
8
+class ImageColor
9
+{
10
+    private static $colors = array(
11
+        'black'     =>  0x000000,
12
+        'silver'    =>  0xc0c0c0,
13
+        'gray'      =>  0x808080,
14
+        'teal'      =>  0x008080,
15
+        'aqua'      =>  0x00ffff,
16
+        'blue'      =>  0x0000ff,
17
+        'navy'      =>  0x000080,
18
+        'green'     =>  0x008000,
19
+        'lime'      =>  0x00ff00,
20
+        'white'     =>  0xffffff,
21
+        'fuschia'   =>  0xff00ff,
22
+        'purple'    =>  0x800080,
23
+        'olive'     =>  0x808000,
24
+        'yellow'    =>  0xffff00,
25
+        'orange'    =>  0xffA500,
26
+        'red'       =>  0xff0000,
27
+        'maroon'    =>  0x800000,
28
+        'transparent' => 0x7fffffff
29
+    );
30
+
31
+    public static function parse($color)
32
+    {
33
+        // Direct color representation (ex: 0xff0000)
34
+        if (!is_string($color) && is_numeric($color))
35
+            return $color;
36
+
37
+        // Color name (ex: "red")
38
+        if (isset(self::$colors[$color]))
39
+            return self::$colors[$color];
40
+
41
+        if (is_string($color)) {
42
+            $color_string = str_replace(' ', '', $color);
43
+
44
+            // Color string (ex: "ff0000", "#ff0000" or "0xfff")
45
+            if (preg_match('/^(#|0x|)([0-9a-f]{3,6})/i', $color_string, $matches)) {
46
+                $col = $matches[2];
47
+
48
+                if (strlen($col) == 6)
49
+                    return hexdec($col);
50
+
51
+                if (strlen($col) == 3) {
52
+                    $r = '';
53
+                    for ($i=0; $i<3; $i++)
54
+                        $r.= $col[$i].$col[$i];
55
+                    return hexdec($r);
56
+                }
57
+            }
58
+            
59
+            // Colors like "rgb(255, 0, 0)"
60
+            if (preg_match('/^rgb\(([0-9]+),([0-9]+),([0-9]+)\)/i', $color_string, $matches)) {
61
+                $r = $matches[1];
62
+                $g = $matches[2];
63
+                $b = $matches[3];
64
+                if ($r>=0 && $r<=0xff && $g>=0 && $g<=0xff && $b>=0 && $b<=0xff) {
65
+                    return ($r << 16) | ($g << 8) | ($b);
66
+                }
67
+            }
68
+        }
69
+
70
+        throw new \InvalidArgumentException('Invalid color: '.$color);
71
+    }
72
+}

+ 37 - 0
vendor/bundles/Gregwar/ImageBundle/ImageHandler.php View File

@@ -0,0 +1,37 @@
1
+<?php
2
+
3
+namespace Gregwar\ImageBundle;
4
+
5
+use Gregwar\ImageBundle\Image;
6
+
7
+/**
8
+ * Image manipulation class
9
+ *
10
+ * @author Gregwar <g.passault@gmail.com>
11
+ */
12
+class ImageHandler extends Image 
13
+{
14
+    protected $fileCallback = null;
15
+
16
+    /**
17
+     * Defines the callback to call to compute the new filename
18
+     */
19
+    public function setFileCallback($file)
20
+    {
21
+        $this->fileCallback = $file;
22
+    }
23
+
24
+    /**
25
+     * When processing the filename, call the callback
26
+     */
27
+    protected function getFilename($filename)
28
+    {
29
+        $callback = $this->fileCallback;
30
+
31
+        if (null === $callback)
32
+            return $filename;
33
+
34
+        return $callback($filename);
35
+    }
36
+}
37
+

+ 146 - 0
vendor/bundles/Gregwar/ImageBundle/README.md View File

@@ -0,0 +1,146 @@
1
+Gregwar's ImageBundle
2
+=====================
3
+
4
+`GregwarImageBundle` provides easy Image manipulation and API for Symfony2 and Twig
5
+
6
+Installation
7
+============
8
+
9
+### Step 1: Download the GregwarImageBundle
10
+
11
+***Using the vendors script***
12
+
13
+Add the following lines to your `deps` file:
14
+
15
+```
16
+    [GregwarImageBundle]
17
+        git=http://github.com/Gregwar/ImageBundle.git
18
+        target=/bundles/Gregwar/ImageBundle
19
+```
20
+
21
+Now, run the vendors script to download the bundle:
22
+
23
+``` bash
24
+$ php bin/vendors install
25
+```
26
+
27
+***Using submodules***
28
+
29
+If you prefer instead to use git submodules, then run the following:
30
+
31
+``` bash
32
+$ git submodule add git://github.com/Gregwar/ImageBundle.git vendor/bundles/Gregwar/ImageBundle
33
+$ git submodule update --init
34
+```
35
+
36
+***Using Composer***
37
+
38
+Add the following to the "require" section of your `composer.json` file:
39
+
40
+```
41
+    "gregwar/image-bundle": "dev-master"
42
+```
43
+
44
+You can also choose a version number, (tag, commit ...)
45
+
46
+And update your dependencies
47
+
48
+```
49
+    php composer.phar update
50
+```
51
+
52
+### Step 2: Configure the Autoloader
53
+
54
+If you use composer, you can skip this step.
55
+
56
+Add it to your `autoload.pp` :
57
+
58
+```php
59
+<?php
60
+...
61
+'Gregwar' => __DIR__.'/../vendor/bundles',
62
+```
63
+
64
+### Step 3: Enable the bundle
65
+
66
+Registers the bundle in your `app/AppKernel.php`:
67
+
68
+```php
69
+<?php
70
+...
71
+public function registerBundles()
72
+{
73
+    $bundles = array(
74
+        ...
75
+        new Gregwar\ImageBundle\GregwarImageBundle(),
76
+        ...
77
+    );
78
+...
79
+```
80
+
81
+### Step 4: Configure the bundle and set up the directories
82
+
83
+Adds the following configuration to your `app/config/config.yml`:
84
+
85
+    gregwar_image: ~
86
+
87
+If you want to customize the cache directory name, you can specify it:
88
+
89
+    gregwar_image:
90
+        cache_dir:  my_cache_dir
91
+
92
+Creates the cache directory and change the permissions so the web server can write 
93
+in it:
94
+
95
+    mkdir web/cache
96
+    chmod 777 web/cache
97
+
98
+Usage
99
+=====
100
+
101
+Basics
102
+------
103
+
104
+This bundle is based on the [Gregwar's Image](http://github.com/Gregwar/Image) class and
105
+provides simple but powerful Twig extension. You can for instance use it this way:
106
+
107
+    <img src="{{ image('linux.jpg').resize(100,100).negate }}" />
108
+
109
+And that's all ! The helper will automatically create the cached file on-the-fly if it 
110
+doesn't exists yet.
111
+
112
+The available methods are the same as the [Gregwar's Image](http://github.com/Gregwar/Image).
113
+
114
+Using Image API
115
+---------------
116
+
117
+The image instance provides also a simple API, you can call some methods to get informations
118
+about the handled image:
119
+
120
+    Image width: {{ image('linux.jpg').width }}px
121
+
122
+Manipulating Image in Controllers
123
+---------------------------------
124
+
125
+The Image Handler is accessible via a service called image.handling. So you can do in your
126
+controllers:
127
+
128
+```php
129
+<?php
130
+...
131
+$this->get('image.handling')->open('linux.jpg')
132
+    ->grayscale()
133
+    ->rotate(12)
134
+    ->save('out.jpg')
135
+```
136
+
137
+Requirements
138
+============
139
+
140
+`GregwarImageBundle` needs [GD](http://php.net/gd)
141
+and [exif](http://php.net/exif) extension for PHP to be installed on the web server
142
+
143
+License
144
+=======
145
+
146
+This bundle is under MIT license

+ 18 - 0
vendor/bundles/Gregwar/ImageBundle/Resources/config/services.yml View File

@@ -0,0 +1,18 @@
1
+
2
+parameters:
3
+    image.handling.class: Gregwar\ImageBundle\Services\ImageHandling
4
+    image.handler.class: Gregwar\ImageBundle\ImageHandler
5
+
6
+services:
7
+    # Image handling factory
8
+    image.handling:
9
+        class: %image.handling.class%
10
+        arguments: [%gregwar_image.cache_dir%, %image.handler.class%, @service_container]
11
+
12
+    # Helper Twig
13
+    twig.extension.image:
14
+        class: Gregwar\ImageBundle\Extensions\ImageTwig
15
+        arguments: [@service_container]
16
+        tags:
17
+            - { name: twig.extension }
18
+

+ 69 - 0
vendor/bundles/Gregwar/ImageBundle/Services/ImageHandling.php View File

@@ -0,0 +1,69 @@
1
+<?php
2
+
3
+namespace Gregwar\ImageBundle\Services;
4
+
5
+use Gregwar\ImageBundle\ImageHandler;
6
+use Symfony\Component\DependencyInjection\ContainerInterface;
7
+
8
+/**
9
+ * Image manipulation service
10
+ *
11
+ * @author Gregwar <g.passault@gmail.com>
12
+ */
13
+class ImageHandling
14
+{
15
+    private $cache_dir;
16
+    private $container;
17
+    private $handler_class;
18
+
19
+    public function __construct($cache_dir, $handler_class, ContainerInterface $container)
20
+    {
21
+        $this->cache_dir = $cache_dir;
22
+        $this->handler_class = $handler_class;
23
+        $this->container = $container;
24
+    }
25
+
26
+    /**
27
+     * Get a manipulable image instance
28
+     *
29
+     * @param string $file the image path
30
+     *
31
+     * @return object a manipulable image instance
32
+     */
33
+    public function open($file)
34
+    {
35
+        return $this->createInstance($file);
36
+    }
37
+
38
+    /**
39
+     * Get a new image
40
+     *
41
+     * @param $w the width
42
+     * @param $h the height
43
+     *
44
+     * @return object a manipulable image instance
45
+     */
46
+    public function create($w, $h)
47
+    {
48
+        return $this->createInstance(null, $w, $h);
49
+    }
50
+
51
+    /**
52
+     * Creates an instance defining the cache directory
53
+     */
54
+    private function createInstance($file, $w = null, $h = null)
55
+    {
56
+        $asset = $this->container->get('templating.helper.assets');
57
+
58
+        $handler_class = $this->handler_class;
59
+        $image = new $handler_class($file, $w, $h);
60
+
61
+        $image->setCacheDir($this->cache_dir);
62
+
63
+        $image->setFileCallback(function($file) use ($asset) {
64
+            return $asset->getUrl($file);
65
+        });
66
+
67
+        return $image;
68
+    }
69
+}

+ 25 - 0
vendor/bundles/Gregwar/ImageBundle/composer.json View File

@@ -0,0 +1,25 @@
1
+{
2
+    "name": "gregwar/image-bundle",
3
+    "type": "symfony-bundle",
4
+    "description": "Image handling bundle",
5
+    "keywords": ["symfony2", "image"],
6
+    "homepage": "https://github.com/Gregwar/ImageBundle",
7
+    "license": "MIT",
8
+    "authors": [
9
+        {
10
+            "name": "Grégoire Passault",
11
+            "email": "g.passault@gmail.com",
12
+            "homepage": "http://www.gregwar.com/"
13
+        }
14
+    ],
15
+    "require": {
16
+        "php": ">=5.3.0",
17
+        "ext-gd": "*"
18
+    },
19
+    "autoload": {
20
+        "psr-0": {
21
+            "Gregwar\\ImageBundle": ""
22
+        }
23
+    },
24
+    "target-dir": "Gregwar/ImageBundle"
25
+}

+ 0 - 1
web/bundles/muzichcore/css/old.css View File

@@ -1161,7 +1161,6 @@ li.element td.right span.score
1161 1161
 
1162 1162
 div.reputation
1163 1163
 {
1164
-  padding-left: 15px;
1165 1164
   font-size: 110%;
1166 1165
 }
1167 1166
 

+ 16 - 3
web/css/main.css View File

@@ -609,8 +609,8 @@ div.user_score div.score
609 609
   font-size: 18px;
610 610
   padding-top: 5px;
611 611
   margin-bottom: 4px;
612
-  margin-left: 4px;
613
-  margin-right: 4px;
612
+  margin-left: 3px;
613
+  margin-right: 5px;
614 614
 }
615 615
 
616 616
 ul.user_events_infos
@@ -1642,4 +1642,17 @@ div.element_embed div.jp-playlist ul
1642 1642
   text-align: left;
1643 1643
 }
1644 1644
 
1645
-.placeholder { color:#999; }
1645
+.placeholder { color:#999; }
1646
+
1647
+div.reputation img
1648
+{
1649
+  float: left;
1650
+  margin: 4px;
1651
+  margin-right: 8px;
1652
+  margin-top: 8px;
1653
+}
1654
+
1655
+p.show_info
1656
+{
1657
+  margin-top: 0px;
1658
+}

BIN
web/img/1360770994_user.png View File


BIN
web/img/1360770994_user_44_46.png View File


BIN
web/img/1360770994_user_48_50.png View File


+ 0 - 0
web/img/avatar_test.png View File


+ 0 - 0
web/img/icon_dart_left_white.png View File


+ 0 - 0
web/img/icon_dart_right_white.png View File


+ 0 - 0
web/img/icon_heart.png View File


+ 0 - 0
web/img/icon_star_2_red.png View File


+ 0 - 0
web/img/icon_thumb_red.png View File


+ 0 - 0
web/img/list_chip_red.png View File


+ 0 - 0
web/js/soundcloud/api.js View File


+ 0 - 0
web/js/soundcloud/sdk.js View File