Author: rande
Date: 2010-05-20 17:08:24 +0200 (Thu, 20 May 2010)
New Revision: 29554

Modified:
   plugins/swCombinePlugin/trunk/lib/combine/swCombineBase.class.php
   plugins/swCombinePlugin/trunk/lib/combine/swCombineStylesheet.class.php
   plugins/swCombinePlugin/trunk/lib/task/swOptimizeCreateFilesTask.class.php
Log:
[swCombinePlugin] fix absolute reference when fixing image path

Modified: plugins/swCombinePlugin/trunk/lib/combine/swCombineBase.class.php
===================================================================
--- plugins/swCombinePlugin/trunk/lib/combine/swCombineBase.class.php   
2010-05-20 14:33:00 UTC (rev 29553)
+++ plugins/swCombinePlugin/trunk/lib/combine/swCombineBase.class.php   
2010-05-20 15:08:24 UTC (rev 29554)
@@ -17,9 +17,17 @@
 abstract class swCombineBase 
 {
   protected
-    $files = array();
+    $dispatcher = null,
+    $formatter  = null,
+    $files      = array();
     
+  public function __construct(sfEventDispatcher $dispatcher = null, 
sfFormatter $formatter = null)
+  {
     
+    $this->dispatcher = $dispatcher;
+    $this->formatter = $formatter;
+  }
+  
   public function addFile($file)
   {
     $this->files[] = $file;
@@ -41,12 +49,48 @@
     
     return $contents;
   }
-  
+
+  /**
+   *
+   * remove BOM file which break IE rendering when the BOM is
+   * found in the middle of a combined CSS file
+   *
+   * @param string $contents
+   * @return string
+   */
   public function removeBom($contents)
   {
     
     return str_replace(pack("CCC",0xef,0xbb,0xbf), '', $contents);
   }
   
+  /**
+   * Logs a message.
+   *
+   * @param mixed $messages  The message as an array of lines of a single 
string
+   */
+  public function log($messages)
+  {
+    if (!is_array($messages))
+    {
+      $messages = array($messages);
+    }
+
+    $this->dispatcher->notify(new sfEvent($this, 'command.log', $messages));
+  }
+
+  /**
+   * Logs a message in a section.
+   *
+   * @param string  $section  The section name
+   * @param string  $message  The message
+   * @param int     $size     The maximum size of a line
+   * @param string  $style    The color scheme to apply to the section string 
(INFO, ERROR, or COMMAND)
+   */
+  public function logSection($section, $message, $size = null, $style = 'INFO')
+  {
+    $this->dispatcher->notify(new sfEvent($this, 'command.log', 
array($this->formatter->formatSection($section, $message, $size, $style))));
+  }
+  
   abstract function getContents($filename);
 }
\ No newline at end of file

Modified: 
plugins/swCombinePlugin/trunk/lib/combine/swCombineStylesheet.class.php
===================================================================
--- plugins/swCombinePlugin/trunk/lib/combine/swCombineStylesheet.class.php     
2010-05-20 14:33:00 UTC (rev 29553)
+++ plugins/swCombinePlugin/trunk/lib/combine/swCombineStylesheet.class.php     
2010-05-20 15:08:24 UTC (rev 29554)
@@ -105,17 +105,24 @@
     // fix image path 
     $web_dir = sfConfig::get('sf_web_dir');
         
-    $file = $this->paths[$this->path_pos].'/'.($matches[2]{0} == '/' ? 
substr($matches[2], 1) : $matches[2]);
-    $t = $file;
-    $file = realpath($file);
+    if($matches[2]{0} == '/')
+    {
+      $file = $matches[2];
+    }
+    else
+    {
+      $file = $this->paths[$this->path_pos].'/'.$matches[2];
+      $file = realpath($file);
+      $file = str_replace($web_dir, '', $file);
+    }
     
     if($file)
     {
-      $file = str_replace($web_dir, '', $file);
-
       return 'url('.$file.')';
     }
     
+    $this->logSection('fix-image', 'unable to find the file : '.$matches[2]);
+    
     return 'none';
   }
   

Modified: 
plugins/swCombinePlugin/trunk/lib/task/swOptimizeCreateFilesTask.class.php
===================================================================
--- plugins/swCombinePlugin/trunk/lib/task/swOptimizeCreateFilesTask.class.php  
2010-05-20 14:33:00 UTC (rev 29553)
+++ plugins/swCombinePlugin/trunk/lib/task/swOptimizeCreateFilesTask.class.php  
2010-05-20 15:08:24 UTC (rev 29554)
@@ -180,8 +180,7 @@
       throw new sfException(sprintf('The combine class %s does not exist', 
$combine_class));
     }
     
-    // combine css files
-    $combine = new $combine_class;
+    $combine = new $combine_class($this->dispatcher, $this->formatter);
     $combined = array();
     foreach($assets as $asset)
     {

-- 
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