Author: tkoomzaaskz
Date: 2010-02-24 12:12:31 +0100 (Wed, 24 Feb 2010)
New Revision: 28249

Removed:
   plugins/tdVisualFactoryPlugin/trunk/config/app.yml
   plugins/tdVisualFactoryPlugin/trunk/web/images/donate-button.gif
   plugins/tdVisualFactoryPlugin/trunk/web/images/download-icon.gif
Modified:
   
plugins/tdVisualFactoryPlugin/trunk/config/tdVisualFactoryPluginConfiguration.class.php
   
plugins/tdVisualFactoryPlugin/trunk/lib/form/doctrine/PlugintdImageForm.class.php
   
plugins/tdVisualFactoryPlugin/trunk/lib/model/doctrine/PlugintdImage.class.php
   
plugins/tdVisualFactoryPlugin/trunk/lib/model/doctrine/PlugintdImageAlbum.class.php
   
plugins/tdVisualFactoryPlugin/trunk/lib/model/doctrine/PlugintdWatermark.class.php
   plugins/tdVisualFactoryPlugin/trunk/lib/vendor/VisualFactory.class.php
   
plugins/tdVisualFactoryPlugin/trunk/modules/td_image_album/config/generator.yml
   plugins/tdVisualFactoryPlugin/trunk/package.xml
Log:
[td][visual_factory] preparing for initial release

Deleted: plugins/tdVisualFactoryPlugin/trunk/config/app.yml
===================================================================
--- plugins/tdVisualFactoryPlugin/trunk/config/app.yml  2010-02-24 10:26:22 UTC 
(rev 28248)
+++ plugins/tdVisualFactoryPlugin/trunk/config/app.yml  2010-02-24 11:12:31 UTC 
(rev 28249)
@@ -1,4 +0,0 @@
-all:
-  td_visual_factory:
-    mode: im # im (imagemagick) or gd
-    image_dir_relative: /uploads/images
\ No newline at end of file

Modified: 
plugins/tdVisualFactoryPlugin/trunk/config/tdVisualFactoryPluginConfiguration.class.php
===================================================================
--- 
plugins/tdVisualFactoryPlugin/trunk/config/tdVisualFactoryPluginConfiguration.class.php
     2010-02-24 10:26:22 UTC (rev 28248)
+++ 
plugins/tdVisualFactoryPlugin/trunk/config/tdVisualFactoryPluginConfiguration.class.php
     2010-02-24 11:12:31 UTC (rev 28249)
@@ -34,8 +34,5 @@
 
     // visual mode
     sfConfig::set('td_visual_factory_mode', 'gd');
-
-    // short description sign count
-    sfConfig::set('td_visual_factory_short_text_sign_count', 200);
   }
 }
\ No newline at end of file

Modified: 
plugins/tdVisualFactoryPlugin/trunk/lib/form/doctrine/PlugintdImageForm.class.php
===================================================================
--- 
plugins/tdVisualFactoryPlugin/trunk/lib/form/doctrine/PlugintdImageForm.class.php
   2010-02-24 10:26:22 UTC (rev 28248)
+++ 
plugins/tdVisualFactoryPlugin/trunk/lib/form/doctrine/PlugintdImageForm.class.php
   2010-02-24 11:12:31 UTC (rev 28249)
@@ -26,6 +26,7 @@
   protected function removeFields()
   {
     unset($this['created_at'], $this['updated_at']);
+    unset($this['horizontal']);
   }
 
   protected function manageHidden()
@@ -72,19 +73,4 @@
       'delete'      => 'Usuń',
     ));
   }
-
-//  protected function doSave($con = null)
-//  {
-//    if (file_exists($this->getObject()->getFile()))
-//    {
-//      unlink($this->getObject()->getFile());
-//    }
-//    var_dump($this); exit;
-//
-//    $file = $this->getValue('file');
-//    $filename = 
sha1($file->getOriginalName()).'.dupa'.$file->getExtension($file->getOriginalExtension());
-//    $file->save(sfConfig::get('sf_upload_dir').'/'.$filename);
-//
-//    return parent::doSave($con);
-//  }
 }

Modified: 
plugins/tdVisualFactoryPlugin/trunk/lib/model/doctrine/PlugintdImage.class.php
===================================================================
--- 
plugins/tdVisualFactoryPlugin/trunk/lib/model/doctrine/PlugintdImage.class.php  
    2010-02-24 10:26:22 UTC (rev 28248)
+++ 
plugins/tdVisualFactoryPlugin/trunk/lib/model/doctrine/PlugintdImage.class.php  
    2010-02-24 11:12:31 UTC (rev 28249)
@@ -12,6 +12,16 @@
  */
 abstract class PlugintdImage extends BasetdImage
 {
+  protected function setOrientation()
+  {
+    $sf_upload_dir = sfConfig::get('td_visual_factory_image_dir');
+    $file = $sf_upload_dir.'/'.$this->getFile();
+
+//    var_dump($file, $this); exit;
+  }
+
+/*============================================================================*/
+
   public function postSave($event)
   {
     $sf_upload_dir = sfConfig::get('td_visual_factory_image_dir');
@@ -34,8 +44,14 @@
     }
   }
 
-//  public function preUpdate($event)
-//  { // nie działa...
+  public function preInsert($event)
+  {
+    $this->setOrientation();
+  }
+
+  public function preUpdate($event)
+  {
+    $this->setOrientation();
 //      var_dump($this->isNew());
 //    if (! $this->isNew())
 //    {
@@ -45,7 +61,7 @@
 //        unlink($sf_upload_dir.'/'.$size.'/'.$this->getFile());
 //      }
 //    }
-//  }
+  }
 
   public function postUpdate($event)
   {

Modified: 
plugins/tdVisualFactoryPlugin/trunk/lib/model/doctrine/PlugintdImageAlbum.class.php
===================================================================
--- 
plugins/tdVisualFactoryPlugin/trunk/lib/model/doctrine/PlugintdImageAlbum.class.php
 2010-02-24 10:26:22 UTC (rev 28248)
+++ 
plugins/tdVisualFactoryPlugin/trunk/lib/model/doctrine/PlugintdImageAlbum.class.php
 2010-02-24 11:12:31 UTC (rev 28249)
@@ -12,5 +12,13 @@
  */
 abstract class PlugintdImageAlbum extends BasetdImageAlbum
 {
-
+  /**
+   * Returns short description of the image album.
+   *
+   * @return String - short description.
+   */
+  public function getDescriptionShort()
+  {
+    return tdTools::getMbShortenedString($this->getDescription(), 
sfConfig::get('td_short_text_sign_count'));
+  }
 }
\ No newline at end of file

Modified: 
plugins/tdVisualFactoryPlugin/trunk/lib/model/doctrine/PlugintdWatermark.class.php
===================================================================
--- 
plugins/tdVisualFactoryPlugin/trunk/lib/model/doctrine/PlugintdWatermark.class.php
  2010-02-24 10:26:22 UTC (rev 28248)
+++ 
plugins/tdVisualFactoryPlugin/trunk/lib/model/doctrine/PlugintdWatermark.class.php
  2010-02-24 11:12:31 UTC (rev 28249)
@@ -19,6 +19,6 @@
    */
   public function getDescriptionShort()
   {
-    return tdTools::getMbShortenedString($this->getDescription(), 
sfConfig::get('td_visual_factory_short_text_sign_count'));
+    return tdTools::getMbShortenedString($this->getDescription(), 
sfConfig::get('td_short_text_sign_count'));
   }
 }
\ No newline at end of file

Modified: plugins/tdVisualFactoryPlugin/trunk/lib/vendor/VisualFactory.class.php
===================================================================
--- plugins/tdVisualFactoryPlugin/trunk/lib/vendor/VisualFactory.class.php      
2010-02-24 10:26:22 UTC (rev 28248)
+++ plugins/tdVisualFactoryPlugin/trunk/lib/vendor/VisualFactory.class.php      
2010-02-24 11:12:31 UTC (rev 28249)
@@ -1,40 +1,96 @@
 <?php
 
 /**
+ * Visual Factory
  *
+ * Class performing basic image transforming operations using GD and Imagick
+ * libraries.
+ *
+ * @package    VisualFactory
+ * @author     Tomasz Ducin <[email protected]>
  */
 class VisualFactory
 {
- /**
-  *
-  *
-  * @param <type> $wm_file
-  * @param <type> $in_file
-  * @param <type> $out_file
-  */
-  public static function putWatermark($wm_file, $in_file, $out_file)
+  /**
+   * Reads image from the filepath given by the parameter using gd built-in
+   * functions.
+   *
+   * @param String $filepath
+   * @return resource an image resource identifier on success, false on errors.
+   */
+  protected static function imageCreateFrom($filepath)
   {
-    $watermark = imagecreatefrompng($wm_file);
+    // file extension
+    $path_arr = explode('.', $filepath);
+    $ext = $path_arr[count($path_arr)-1];
 
-    $in_ext = explode('.', $in_file);
-    switch(strtolower($in_ext[count($in_ext)-1]))
+    // reading image
+    switch(strtolower($ext))
     {
       case 'jpg': case 'jpeg':
-        $image = imagecreatefromjpeg($in_file);
+        $image = imagecreatefromjpeg($filepath);
         break;
       case 'gif':
-        $image = imagecreatefromgif($in_file);
+        $image = imagecreatefromgif($filepath);
         break;
       case 'bmp': case 'wbmp':
-        $image = imagecreatefromwbmp($in_file);
+        $image = imagecreatefromwbmp($filepath);
         break;
       case 'png':
-        $image = imagecreatefrompng($in_file);
+        $image = imagecreatefrompng($filepath);
         break;
       default:
-        throw new Exception('nieznany rodzaj pliku graficznego');
+        throw new Exception('nieznany rodzaj pliku graficznego 
'.strtolower($ext).': '.$filepath);
     }
+    return $image;
+  }
 
+  /**
+   * Writes image to the filepath given by the parameter using gd built-in
+   * functions.
+   *
+   * @param resource an image resource identifier on success, false on errors.
+   * @param String $filepath
+   */
+  protected static function imagePut($image, $filepath)
+  {
+    // file extension
+    $path_arr = explode('.', $filepath);
+    $ext = $path_arr[count($path_arr)-1];
+
+    // reading image
+    switch(strtolower($ext))
+    {
+      case 'jpg': case 'jpeg':
+        imagejpeg($image, $filepath);
+        break;
+      case 'gif':
+        imagegif($image, $filepath);
+        break;
+      case 'bmp': case 'wbmp':
+        imagewbmp($image, $filepath);
+        break;
+      case 'png':
+        imagepng($image, $filepath);
+        break;
+      default:
+        throw new Exception('nieznany rodzaj pliku graficznego 
'.strtolower($ext).': '.$filepath);
+    }
+  }
+
+ /**
+  * Performs WATERMARK operation using GD library.
+  *
+  * @param String $wm_file - watermark file path
+  * @param String $in_file - input file path
+  * @param String $out_file - output file path
+  */
+  protected static function putWatermark($wm_file, $in_file, $out_file)
+  {
+    $watermark = imagecreatefrompng($wm_file);
+
+    $image = self::imageCreateFrom($in_file);
+
     $margin_right = 5;
     $margin_bottom = 5;
     $wm_sx = imagesx($watermark);
@@ -48,59 +104,25 @@
       $wm_sx, $wm_sy // cały watermark bierzesz
     );
 
-    $out_ext = explode('.', $out_file);
-    switch(strtolower($out_ext[count($out_ext)-1]))
-    {
-      case 'jpg': case 'jpeg':
-        imagejpeg($image, $out_file);
-        break;
-      case 'gif':
-        imagegif($image, $out_file);
-        break;
-      case 'bmp': case 'wbmp':
-        imagewbmp($image, $out_file);
-        break;
-      case 'png':
-        imagepng($image, $out_file);
-        break;
-      default:
-        throw new Exception('nieznany rodzaj pliku graficznego');
-    }
+    self::imagePut($image, $out_file);
 
     imagedestroy($image);
     imagedestroy($watermark);
   }
 
  /**
-  * 
+  * Performs RESIZE operation using GD library.
   *
-  * @param <type> $in_file
-  * @param <type> $out_file
-  * @param <type> $new_width
-  * @param <type> $new_height
+  * @param String $in_file - input file path
+  * @param String $out_file - output file path
+  * @param Integer $new_width - new width value of the output image
+  * @param Integer $new_height - new height value of the output image
   */
-  public static function putResized($in_file, $out_file, $new_width, 
$new_height)
+  protected static function putResized($in_file, $out_file, $new_width, 
$new_height)
   {
     $destination = imagecreatetruecolor($new_width, $new_height);
 
-    $in_ext = explode('.', $in_file);
-    switch(strtolower($in_ext[count($in_ext)-1]))
-    {
-      case 'jpg': case 'jpeg':
-        $source = imagecreatefromjpeg($in_file);
-        break;
-      case 'gif':
-        $source = imagecreatefromgif($in_file);
-        break;
-      case 'bmp': case 'wbmp':
-        $source = imagecreatefromwbmp($in_file);
-        break;
-      case 'png':
-        $source = imagecreatefrompng($in_file);
-        break;
-      default:
-        throw new Exception('nieznany rodzaj pliku graficznego: 
'.strtolower($in_ext[1]).' '.$in_file);
-    }
+    $image = self::imageCreateFrom($in_file);
 
     $src_width = imagesx($source);
     $src_height = imagesy($source);
@@ -134,34 +156,20 @@
       $fin_width, $fin_height
     );
 
-    $out_ext = explode('.', $out_file);
-    switch(strtolower($out_ext[count($out_ext)-1]))
-    {
-      case 'jpg': case 'jpeg':
-        imagejpeg($destination, $out_file);
-        break;
-      case 'gif':
-        imagegif($destination, $out_file);
-        break;
-      case 'bmp': case 'wbmp':
-        imagewbmp($destination, $out_file);
-        break;
-      case 'png':
-        imagepng($destination, $out_file);
-        break;
-      default:
-        throw new Exception('nieznany rodzaj pliku graficznego');
-    }
+    self::imagePut($destination, $out_file);
+
+    imagedestroy($image);
   }
 
-/*==========================================================================*/
+/*============================================================================*/
+/*============================ Imagick library 
===============================*/
 
  /**
+  * Performs RESIZE operation on given input and output files using GD library.
   *
-  *
-  * @param <type> $in_file
-  * @param <type> $out_file
-  * @param <type> $format
+  * @param String $in_file - input file path
+  * @param String $out_file - output file path
+  * @param String $format - output file format, e. g. '800x600'
   */
   protected static function ImageMagickResize($in_file, $out_file, $format)
   {
@@ -175,13 +183,14 @@
   }
 
  /**
+  * Performs WATERMARK operation on given input, output and watermark files
+  * using Imagick library.
   *
-  *
-  * @param <type> $wm_file
-  * @param <type> $in_file
-  * @param <type> $mid_file
-  * @param <type> $out_file
-  * @param <type> $format
+  * @param String $wm_file - watermark file path
+  * @param String $in_file - input file path
+  * @param String $mid_file - auxiliary file path (created after resize and 
used to put a watermark on)
+  * @param String $out_file - output file path
+  * @param String $format - output file format, e. g. '800x600'
   */
   protected static function ImageMagickWatermark($wm_file, $in_file, 
$mid_file, $out_file, $format)
   {
@@ -203,46 +212,50 @@
     shell_exec($command_composite);
   }
 
-/*==========================================================================*/
+/*============================================================================*/
+/*============================ GD library 
====================================*/
 
  /**
+  * Performs RESIZE operation on given input and output files using GD library.
   *
-  *
-  * @param <type> $in_file
-  * @param <type> $out_file
-  * @param <type> $format
+  * @param String $in_file - input file path
+  * @param String $out_file - output file path
+  * @param String $format - output file format, e. g. '800x600'
   */
   protected static function GDResize($in_file, $out_file, $format)
   {
     $f = explode('x', $format);
-    VisualFactory::putResized($in_file, $out_file, $f[0], $f[1]);
+    self::putResized($in_file, $out_file, $f[0], $f[1]);
   }
 
  /**
+  * Performs WATERMARK operation on given input, output and watermark files
+  * using GD library.
   *
-  *
-  * @param <type> $wm_file
-  * @param <type> $in_file
-  * @param <type> $mid_file
-  * @param <type> $out_file
-  * @param <type> $format
+  * @param String $wm_file - watermark file path
+  * @param String $in_file - input file path
+  * @param String $mid_file - auxiliary file path (created after resize and 
used to put a watermark on)
+  * @param String $out_file - output file path
+  * @param String $format - output file format, e. g. '800x600'
   */
   protected static function GDWatermark($wm_file, $in_file, $mid_file, 
$out_file, $format)
   {
     $f = explode('x', $format);
-    VisualFactory::putResized($in_file, $mid_file, $f[0], $f[1]);
-    VisualFactory::putWatermark($wm_file, $mid_file, $out_file);
+    self::putResized($in_file, $mid_file, $f[0], $f[1]);
+    self::putWatermark($wm_file, $mid_file, $out_file);
   }
 
-/*==========================================================================*/
+/*============================================================================*/
+/*================================ interface 
=================================*/
 
  /**
+  * Performs RESIZE operation on given input and output files with library mode
+  * specified ('mode' parameter with value either 'gd' or 'im').
   *
-  *
-  * @param <type> $mode
-  * @param <type> $in_file
-  * @param <type> $out_file
-  * @param <type> $format
+  * @param String $mode - external library mode - either 'gd' or 'im'
+  * @param String $in_file - input file path
+  * @param String $out_file - output file path
+  * @param String $format - output file format, e. g. '800x600'
   */
   public static function Resize($mode, $in_file, $out_file, $format)
   {
@@ -258,14 +271,16 @@
   }
 
  /**
+  * Performs WATERMARK operation on given input, output and watermark files
+  * with library mode specified ('mode' parameter with value either 'gd' or
+  * 'im').
   *
-  *
-  * @param <type> $mode
-  * @param <type> $wm_file
-  * @param <type> $in_file
-  * @param <type> $mid_file
-  * @param <type> $out_file
-  * @param <type> $format
+  * @param String $mode - external library mode - either 'gd' or 'im'
+  * @param String $wm_file - watermark file path
+  * @param String $in_file - input file path
+  * @param String $mid_file - auxiliary file path (created after resize 
andused to put a watermark on)
+  * @param String $out_file - output file path
+  * @param String $format - output file format, e. g. '800x600'
   */
   public static function Watermark($mode, $wm_file, $in_file, $mid_file, 
$out_file, $format)
   {

Modified: 
plugins/tdVisualFactoryPlugin/trunk/modules/td_image_album/config/generator.yml
===================================================================
--- 
plugins/tdVisualFactoryPlugin/trunk/modules/td_image_album/config/generator.yml 
    2010-02-24 10:26:22 UTC (rev 28248)
+++ 
plugins/tdVisualFactoryPlugin/trunk/modules/td_image_album/config/generator.yml 
    2010-02-24 11:12:31 UTC (rev 28249)
@@ -33,14 +33,8 @@
         title: List of galleries
         layout: stacked
         params: |
-          <img src="/uploads/td/watermarks/%%file%%" />
-          <br />
           <strong>Nazwa</strong>: <i>%%name%%</i> %%active%%
           <br />
-          <strong>Autor</strong>: <i>%%author%%</i>
-          <br />
-          <strong>Wydano</strong>: <i>%%released_at%%</i>
-          <br />
           <strong>Opis</strong>: <div 
class="text_box">%%description_short%%</div>
           <br />
           <strong>Utworzono</strong>: <i>%%created_at%%</i>

Modified: plugins/tdVisualFactoryPlugin/trunk/package.xml
===================================================================
--- plugins/tdVisualFactoryPlugin/trunk/package.xml     2010-02-24 10:26:22 UTC 
(rev 28248)
+++ plugins/tdVisualFactoryPlugin/trunk/package.xml     2010-02-24 11:12:31 UTC 
(rev 28249)
@@ -10,7 +10,7 @@
   <email>[email protected]</email>
   <active>yes</active>
  </lead>
- <date>2010-01-03</date>
+ <date>2010-02-24</date>
  <time>11:00:00</time>
  <version>
    <release>0.1.0</release>
@@ -59,24 +59,26 @@
            <file name="PlugintdWatermarkTable.class.php" role="data" />
          </dir>
        </dir>
+       <dir name="vendor">
+         <file name="VisualFactory.class.php" role="data" />
+       </dir>
      </dir>
 
      <dir name="modules">
-       <dir name="td_image">
+       <dir name="tdSampleImage">
          <dir name="actions">
            <file name="actions.class.php" role="data" />
          </dir>
          <dir name="config">
-           <file name="generator.yml" role="data" />
+           <file name="view.yml" role="data" />
          </dir>
          <dir name="i18n">
-           <file name="sf_admin.pl.xml" role="data" />
+           <file name="td.pl.xml" role="data" />
          </dir>
-         <dir name="lib">
-           <file name="td_imageGeneratorConfiguration.class.php" role="data" />
-           <file name="td_imageGeneratorHelper.class.php" role="data" />
+         <dir name="templates">
+           <file name="indexSuccess.php" role="data" />
+           <file name="showSuccess.php" role="data" />
          </dir>
-         <dir name="templates" />
        </dir>
        <dir name="td_image_album">
          <dir name="actions">
@@ -114,8 +116,26 @@
 
      <dir name="web">
        <dir name="css">
-         <file name="admin_watermark.css" role="data" />
+         <file name="lightbox.css" role="data" />
+         <file name="td_image.css" role="data" />
        </dir>
+       <dir name="images">
+         <file name="bullet.gif" role="data" />
+         <file name="close.gif" role="data" />
+         <file name="closelabel.gif" role="data" />
+         <file name="left.jpeg" role="data" />
+         <file name="loading.gif" role="data" />
+         <file name="nextlabel.gif" role="data" />
+         <file name="prevlabel.gif" role="data" />
+         <file name="right.jpeg" role="data" />
+       </dir>
+       <dir name="js">
+         <file name="builder.js" role="data" />
+         <file name="effects.js" role="data" />
+         <file name="lightbox.js" role="data" />
+         <file name="prototype.js" role="data" />
+         <file name="scriptaculous.js" role="data" />
+       </dir>
      </dir>
 
      <file name="LICENSE" role="data" />
@@ -138,6 +158,12 @@
      <max>1.5.0</max>
      <exclude>1.5.0</exclude>
     </package>
+    <package>
+     <name>tdCorePlugin</name>
+     <channel>plugins.symfony-project.org</channel>
+     <min>0.1.9</min>
+    </package>
+
    </required>
   </dependencies>
 

Deleted: plugins/tdVisualFactoryPlugin/trunk/web/images/donate-button.gif
===================================================================
(Binary files differ)

Deleted: plugins/tdVisualFactoryPlugin/trunk/web/images/download-icon.gif
===================================================================
(Binary files differ)

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