Author: jp_morvan
Date: 2010-04-14 14:33:42 +0200 (Wed, 14 Apr 2010)
New Revision: 29136

Modified:
   plugins/vjCommentPlugin/TRUNK/README
   plugins/vjCommentPlugin/TRUNK/lib/model/doctrine/PluginComment.class.php
   plugins/vjCommentPlugin/TRUNK/lib/tools/GravatarApi.class.php
   plugins/vjCommentPlugin/TRUNK/package.xml.tmpl
Log:
add option to define gravatar's directories (by default : 
sf_web_dir/sf_upload_dir/g_cache)


Modified: plugins/vjCommentPlugin/TRUNK/README
===================================================================
--- plugins/vjCommentPlugin/TRUNK/README        2010-04-14 07:00:47 UTC (rev 
29135)
+++ plugins/vjCommentPlugin/TRUNK/README        2010-04-14 12:33:42 UTC (rev 
29136)
@@ -113,7 +113,7 @@
           gravatar:
             enabled:        false
 
-You can change default size or default image of gravatar
+You can change default size, image or directories of gravatar
 
   * edit apps/your_frontend_app/config/app.yml
 
@@ -121,6 +121,8 @@
           gravatar:
             default_size:   40
             default_image:  ../web/images/gravatar_default.png
+            upload_dir:     .. # by default, this uses sf_upload_dir 
configuration
+            cache_dir_name: g_cache
 
 How to moderate comments and/or reports ?
 -------------

Modified: 
plugins/vjCommentPlugin/TRUNK/lib/model/doctrine/PluginComment.class.php
===================================================================
--- plugins/vjCommentPlugin/TRUNK/lib/model/doctrine/PluginComment.class.php    
2010-04-14 07:00:47 UTC (rev 29135)
+++ plugins/vjCommentPlugin/TRUNK/lib/model/doctrine/PluginComment.class.php    
2010-04-14 12:33:42 UTC (rev 29136)
@@ -12,7 +12,6 @@
 {
     public function getAuthor()
     {
-        //var_dump( is_null( $this->getUserId() ) );
         if( null !== $this->getUserId() )
         {
             return $this->getUser()->getUsername();

Modified: plugins/vjCommentPlugin/TRUNK/lib/tools/GravatarApi.class.php
===================================================================
--- plugins/vjCommentPlugin/TRUNK/lib/tools/GravatarApi.class.php       
2010-04-14 07:00:47 UTC (rev 29135)
+++ plugins/vjCommentPlugin/TRUNK/lib/tools/GravatarApi.class.php       
2010-04-14 12:33:42 UTC (rev 29136)
@@ -32,9 +32,7 @@
 
   public function __construct($image_size = null, $rating = null)
   {
-    $this->cache_dir = sfConfig::get('sf_upload_dir').DIRECTORY_SEPARATOR
-                       .sfConfig::get('app_gravatar_cache_dir_name', 
'g_cache').DIRECTORY_SEPARATOR;
-    $this->cache_dir_name = str_replace(sfConfig::get('sf_web_dir'), '', 
$this->cache_dir);
+    $this->setDirectories();
     if (!is_dir($this->cache_dir))
     {
       if (false === @mkdir($this->cache_dir, 0777, true))
@@ -168,4 +166,32 @@
 
     return str_replace(DIRECTORY_SEPARATOR, '/', 
$this->cache_dir_name).$to_return;
   }
+
+  protected function setDirectories()
+  {
+    $gravatar_cache_dir_name = sfConfig::get('app_gravatar_cache_dir_name', 
'g_cache');
+    
+    $this->cache_dir = $this->clearPath(sfConfig::get('sf_web_dir')
+                        .DIRECTORY_SEPARATOR
+                        .$this->getGravatarUploadDir()
+                        .DIRECTORY_SEPARATOR
+                        .$gravatar_cache_dir_name
+                        .DIRECTORY_SEPARATOR);
+    $this->cache_dir_name = str_replace(sfConfig::get('sf_web_dir'), '', 
$this->cache_dir);
+  }
+
+  protected function hasGravatarUploadDir()
+  {
+    return !is_null(sfConfig::get('app_gravatar_upload_dir'));
+  }
+
+  protected function getGravatarUploadDir()
+  {
+    return $this->clearPath(sfConfig::get('app_gravatar_upload_dir', 
str_replace(sfConfig::get('sf_web_dir'), '', sfConfig::get('sf_upload_dir'))));
+  }
+
+  protected function clearPath($path)
+  {
+    return str_replace("//", "/", $path);
+  }
 }
\ No newline at end of file

Modified: plugins/vjCommentPlugin/TRUNK/package.xml.tmpl
===================================================================
--- plugins/vjCommentPlugin/TRUNK/package.xml.tmpl      2010-04-14 07:00:47 UTC 
(rev 29135)
+++ plugins/vjCommentPlugin/TRUNK/package.xml.tmpl      2010-04-14 12:33:42 UTC 
(rev 29136)
@@ -70,6 +70,7 @@
         * fizyk: added setting that allows adding relation bewteen comment and 
sfGuardUser, so it will no longer be mandatory to use sfGuardUser.
         * fizyk: integrated functionality to make use of sfGuardUser
         * fizyk: added relation to sfGuardUser
+        * jp_morvan: add option to define gravatar's directories (by default : 
sf_web_dir/sf_upload_dir/g_cache)
       </notes>
     </release>
     <release>

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to