Author: tkoomzaaskz
Date: 2010-02-07 23:27:13 +0100 (Sun, 07 Feb 2010)
New Revision: 27681

Modified:
   plugins/tdAudioPlugin/trunk/README
   plugins/tdAudioPlugin/trunk/config/tdAudioPluginConfiguration.class.php
   
plugins/tdAudioPlugin/trunk/lib/form/doctrine/PlugintdTrackAlbumForm.class.php
   plugins/tdAudioPlugin/trunk/lib/form/doctrine/PlugintdTrackForm.class.php
   plugins/tdAudioPlugin/trunk/modules/tdSampleAudio/templates/indexSuccess.php
   plugins/tdAudioPlugin/trunk/modules/tdSampleAudio/templates/showSuccess.php
   plugins/tdAudioPlugin/trunk/modules/td_track_album/config/generator.yml
   plugins/tdAudioPlugin/trunk/package.xml
Log:
[td][audio] preparing for release 0.1.3

Modified: plugins/tdAudioPlugin/trunk/README
===================================================================
--- plugins/tdAudioPlugin/trunk/README  2010-02-07 22:16:52 UTC (rev 27680)
+++ plugins/tdAudioPlugin/trunk/README  2010-02-07 22:27:13 UTC (rev 27681)
@@ -41,13 +41,13 @@
 
         $ ./symfony doctrine:data-load
 
-    Now you have to create a directory for audio uploads:
+    Now you have to create upload directories for audio and cover files:
 
-        $ mkdir web/uploads/td/audio
+        $ mkdir web/uploads/td/audio web/uploads/td/cover
 
     and make it writeable:
 
-        $ chmod 777 web/uploads/td/audio
+        $ chmod 777 web/uploads/td/audio web/uploads/td/cover
 
     Now you have to copy the mp3 sample files from _tdAudioPlugin/data/samples_
     to the audio upload directory created above. Everything is ready to run the

Modified: 
plugins/tdAudioPlugin/trunk/config/tdAudioPluginConfiguration.class.php
===================================================================
--- plugins/tdAudioPlugin/trunk/config/tdAudioPluginConfiguration.class.php     
2010-02-07 22:16:52 UTC (rev 27680)
+++ plugins/tdAudioPlugin/trunk/config/tdAudioPluginConfiguration.class.php     
2010-02-07 22:27:13 UTC (rev 27681)
@@ -20,6 +20,9 @@
     // audio files upload dir
     sfConfig::set('td_audio_upload_dir', 
sfConfig::get('sf_web_dir').'/uploads/td/audio');
 
+    // audio album cover upload dir
+    sfConfig::set('td_audio_cover_upload_dir', 
sfConfig::get('sf_web_dir').'/uploads/td/cover');
+
     // track album short description sign count
     sfConfig::set('td_audio_short_text_sign_count', 200);
   }

Modified: 
plugins/tdAudioPlugin/trunk/lib/form/doctrine/PlugintdTrackAlbumForm.class.php
===================================================================
--- 
plugins/tdAudioPlugin/trunk/lib/form/doctrine/PlugintdTrackAlbumForm.class.php  
    2010-02-07 22:16:52 UTC (rev 27680)
+++ 
plugins/tdAudioPlugin/trunk/lib/form/doctrine/PlugintdTrackAlbumForm.class.php  
    2010-02-07 22:27:13 UTC (rev 27681)
@@ -3,10 +3,10 @@
 /**
  * PlugintdTrackAlbum form.
  *
- * @package    ##PROJECT_NAME##
+ * @package    tdAudioPlugin
  * @subpackage form
- * @author     ##AUTHOR_NAME##
- * @version    SVN: $Id: sfDoctrineFormPluginTemplate.php 23810 2009-11-12 
11:07:44Z Kris.Wallsmith $
+ * @author     Tomasz Ducin <[email protected]>
+ * @version    SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
  */
 abstract class PlugintdTrackAlbumForm extends BasetdTrackAlbumForm
 {
@@ -20,6 +20,12 @@
 
     $this->manageValidators();
 
+    $this->embedRelation('Tracks');
+
+    $new_track_form = new tdTrackForm();
+    $new_track_form->setDefault('td_track_album_id', $this->object->id);
+    $this->embedForm('new', $new_track_form);
+
 //    $this->setValidator('author',
 //      new sfValidatorString(array(), array('required' => 'Musisz podać 
autora wpisu.')));
 //
@@ -40,8 +46,7 @@
     $this->setWidget('file_cover', new sfWidgetFormInputFileEditable(array(
       'with_delete' => false,
       'delete_label' => 'usuń okładkę albumu',
-      'label'     => 'album cover',
-      'file_src'  => '/uploads/images/'.$this->getObject()->getFileCover(),
+      'file_src'  => '/uploads/td/cover/'.$this->getObject()->getFileCover(),
       'is_image'  => true,
       'edit_mode' => !$this->isNew(),
       'template'  => '%file%<br />%input%<br />%delete% %delete_label%',
@@ -57,11 +62,95 @@
       new sfValidatorString(array(), array('required' => 'Musisz podać 
autora.')));
 
     $this->setValidator('file_cover', new sfValidatorFile(array(
-      'required'   => true,
-      'path'       => sfConfig::get('td_visual_factory_image_dir'),
+      'required'   => false,
+      'path'       => sfConfig::get('td_audio_cover_upload_dir'),
       'mime_types' => 'web_images',
     ), array(
       'required' => 'Musisz wybrać plik',
     )));
   }
+
+  protected function doBind(array $values)
+  {
+//    var_dump($values['new']); exit;
+    if ($this->isValid()
+            && '' === trim($values['new']['file']['name'])
+            && '' === trim($values['new']['title'])
+            && '' === trim($values['new']['description'])
+            && '' === trim($values['new']['position']))
+    {
+      unset($values['new'], $this['new']);
+    }
+
+    if (isset($values['Tracks']))
+    {
+      foreach ($values['Tracks'] as $i => $bookmarkValues)
+      {
+        if (isset($bookmarkValues['delete']) && $bookmarkValues['id'])
+        {
+          $this->scheduledForDeletion[$i] = $bookmarkValues['id'];
+        }
+      }
+    }
+
+    parent::doBind($values);
+  }
+
+  /**
+   * Updates object with provided values, dealing with evantual relation 
deletion
+   *
+   * @see sfFormDoctrine::doUpdateObject()
+   */
+  protected function doUpdateObject($values)
+  {
+    if (isset($this->scheduledForDeletion))
+    {
+      foreach ($this->scheduledForDeletion as $index => $id)
+      {
+        unset($values['Tracks'][$index]);
+        unset($this->object['Tracks'][$index]);
+        $track = Doctrine::getTable('tdTrack')->findOneById($id);
+        unlink(sfConfig::get('td_audio_upload_dir').'/'.$track->getFile());
+        $track->delete();
+      }
+    }
+
+    $this->getObject()->fromArray($values);
+  }
+
+
+  /**
+   * Saves embedded form objects.
+   *
+   * @param mixed $con   An optional connection object
+   * @param array $forms An array of forms
+   */
+  public function saveEmbeddedForms($con = null, $forms = null)
+  {
+    if (null === $con)
+    {
+      $con = $this->getConnection();
+    }
+
+    if (null === $forms)
+    {
+      $forms = $this->embeddedForms;
+    }
+
+    foreach ($forms as $form)
+    {
+      if ($form instanceof sfFormObject)
+      {
+        if (!in_array($form->getObject()->getId(), 
$this->scheduledForDeletion))
+        {
+          $form->saveEmbeddedForms($con);
+          $form->getObject()->save($con);
+        }
+      }
+      else
+      {
+        $this->saveEmbeddedForms($con, $form->getEmbeddedForms());
+      }
+    }
+  }
 }

Modified: 
plugins/tdAudioPlugin/trunk/lib/form/doctrine/PlugintdTrackForm.class.php
===================================================================
--- plugins/tdAudioPlugin/trunk/lib/form/doctrine/PlugintdTrackForm.class.php   
2010-02-07 22:16:52 UTC (rev 27680)
+++ plugins/tdAudioPlugin/trunk/lib/form/doctrine/PlugintdTrackForm.class.php   
2010-02-07 22:27:13 UTC (rev 27681)
@@ -2,12 +2,71 @@
 
 /**
  * PlugintdTrack form.
- *
- * @package    ##PROJECT_NAME##
+ * *
+ * @package    tdAudioPlugin
  * @subpackage form
- * @author     ##AUTHOR_NAME##
- * @version    SVN: $Id: sfDoctrineFormPluginTemplate.php 23810 2009-11-12 
11:07:44Z Kris.Wallsmith $
+ * @author     Tomasz Ducin <[email protected]>
+ * @version    SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
  */
 abstract class PlugintdTrackForm extends BasetdTrackForm
 {
+
+  public function setup()
+  {
+    parent::setup();
+    $this->removeFields();
+    $this->manageHidden();
+    $this->manageDelete();
+    $this->manageFiles();
+    $this->manageLabels();
+  }
+
+  protected function removeFields()
+  {
+    unset($this['created_at'], $this['updated_at']);
+  }
+
+  protected function manageHidden()
+  {
+    $this->widgetSchema['td_track_album_id'] = new sfWidgetFormInputHidden();
+  }
+
+  protected function manageDelete()
+  {
+    if ($this->object->exists())
+    {
+      $this->widgetSchema['delete'] = new sfWidgetFormInputCheckbox();
+      $this->validatorSchema['delete'] = new sfValidatorPass();
+    }
+  }
+
+  protected function manageFiles()
+  {
+    $this->setWidget('file', new sfWidgetFormInputFileEditable(array(
+      'with_delete' => false,
+      'delete_label' => 'usuń plik',
+      'file_src'  => '/uploads/td/audio/'.$this->getObject()->getFile(),
+      'is_image'  => false,
+      'edit_mode' => !$this->isNew(),
+      'template'  => '%file%<br />%input%<br />%delete% %delete_label%',
+    )));
+
+    $this->setValidator('file', new sfValidatorFile(array(
+      'required'   => false,
+      'path'       => sfConfig::get('td_audio_upload_dir'),
+    ), array(
+      'required' => 'Musisz wybrać plik',
+    )));
+  }
+
+  protected function manageLabels()
+  {
+    $this->widgetSchema->setLabels(array(
+      'file'        => 'Plik',
+      'title'       => 'Tytuł',
+      'description' => 'Opis',
+      'position'    => 'Pozycja',
+      'delete'      => 'Usuń',
+    ));
+  }
 }

Modified: 
plugins/tdAudioPlugin/trunk/modules/tdSampleAudio/templates/indexSuccess.php
===================================================================
--- 
plugins/tdAudioPlugin/trunk/modules/tdSampleAudio/templates/indexSuccess.php    
    2010-02-07 22:16:52 UTC (rev 27680)
+++ 
plugins/tdAudioPlugin/trunk/modules/tdSampleAudio/templates/indexSuccess.php    
    2010-02-07 22:27:13 UTC (rev 27681)
@@ -7,7 +7,7 @@
   <?php foreach ($audios as $audio): ?>
     <li class="list">
       <div class="cover">
-        <?php echo image_tag(audio_path('images/'.$audio['file_cover'])) ?>
+        <?php echo image_tag('/uploads/td/cover/'.$audio['file_cover']) ?>
       </div>
       <div class="rest">
         <div class="name">

Modified: 
plugins/tdAudioPlugin/trunk/modules/tdSampleAudio/templates/showSuccess.php
===================================================================
--- plugins/tdAudioPlugin/trunk/modules/tdSampleAudio/templates/showSuccess.php 
2010-02-07 22:16:52 UTC (rev 27680)
+++ plugins/tdAudioPlugin/trunk/modules/tdSampleAudio/templates/showSuccess.php 
2010-02-07 22:27:13 UTC (rev 27681)
@@ -5,7 +5,7 @@
 <ul id="audio">
   <li class="single">
       <div class="cover">
-        <?php echo image_tag(audio_path('images/'.$audio['file_cover'])) ?>
+        <?php echo image_tag('/uploads/td/cover/'.$audio['file_cover']) ?>
       </div>
       <div class="rest">
         <div class="released_at">

Modified: 
plugins/tdAudioPlugin/trunk/modules/td_track_album/config/generator.yml
===================================================================
--- plugins/tdAudioPlugin/trunk/modules/td_track_album/config/generator.yml     
2010-02-07 22:16:52 UTC (rev 27680)
+++ plugins/tdAudioPlugin/trunk/modules/td_track_album/config/generator.yml     
2010-02-07 22:27:13 UTC (rev 27681)
@@ -37,6 +37,11 @@
           label: Utworzono
         updated_at:
           label: Zmieniono
+# embedded forms and relations
+        Tracks:
+          label: Utwory
+        new:
+          label: Nowy utwór
       list:
         title: Track album list
         batch_actions:
@@ -78,6 +83,6 @@
             attributes: { cols: 80, rows: 16 }
       edit:
         title: Edit track album
-        display: [ name, author, description, file_cover, released_at, active ]
+        display: [ name, author, description, file_cover, released_at, active, 
Tracks, new ]
       new:
         title: New track album

Modified: plugins/tdAudioPlugin/trunk/package.xml
===================================================================
--- plugins/tdAudioPlugin/trunk/package.xml     2010-02-07 22:16:52 UTC (rev 
27680)
+++ plugins/tdAudioPlugin/trunk/package.xml     2010-02-07 22:27:13 UTC (rev 
27681)
@@ -180,6 +180,9 @@
     <notes>
      * NOT RELEASED YET
      * updated random audio albums - fixed blocked website bug
+     * added album cover upload directory
+     * track forms embedded in album form
+     * fixed album cover upload directory (with setup)
     </notes>
    </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