Author: Jonathan.Wage
Date: 2010-03-21 03:45:51 +0100 (Sun, 21 Mar 2010)
New Revision: 28637

Modified:
   plugins/sfSympalPlugin/trunk/config/app.yml
   
plugins/sfSympalPlugin/trunk/lib/events/sfSympalTaskClearCacheListener.class.php
   
plugins/sfSympalPlugin/trunk/lib/form/doctrine/PluginsfSympalContentSlotForm.class.php
   
plugins/sfSympalPlugin/trunk/lib/form/doctrine/PluginsfSympalContentSlotTranslationForm.class.php
   
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContent.class.php
   
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContentSlot.class.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/_slot_editor_form.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/transformer/sfSympalContentSlotTransformer.class.php
   plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php
   plugins/sfSympalPlugin/trunk/web/markitup/skins/markitup/style.css
Log:
[sfSympalPlugin] Synchronizing git repository to Symfony Plugins SVN

Modified: plugins/sfSympalPlugin/trunk/config/app.yml
===================================================================
--- plugins/sfSympalPlugin/trunk/config/app.yml 2010-03-20 20:32:11 UTC (rev 
28636)
+++ plugins/sfSympalPlugin/trunk/config/app.yml 2010-03-21 02:45:51 UTC (rev 
28637)
@@ -229,6 +229,7 @@
       #  widget_options: []
       #  validator_class: MySlotTypeValidator    default: 
sfValidatorFormSympalXXXXXXType
       #  validator_options: []
+      #  transformers:    []
       Text:
         label: Single Line of Text
         transformers:  [replacer]

Modified: 
plugins/sfSympalPlugin/trunk/lib/events/sfSympalTaskClearCacheListener.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/events/sfSympalTaskClearCacheListener.class.php
    2010-03-20 20:32:11 UTC (rev 28636)
+++ 
plugins/sfSympalPlugin/trunk/lib/events/sfSympalTaskClearCacheListener.class.php
    2010-03-21 02:45:51 UTC (rev 28637)
@@ -1,20 +1,64 @@
 <?php
 
+/**
+ * Adds a listener on the task.cache.clear to clear the combiner css
+ * and js cache in the web/cache directory
+ * 
+ * @package     sfSympalPlugin
+ * @subpackage  listener
+ * @author      Jonathan H. Wage <[email protected]>
+ * @author      Ryan Weaver <[email protected]>
+ * @since       2010-03-18
+ * @version     svn:$Id$ $Author$
+ */
 class sfSympalTaskClearCacheListener extends sfSympalListener
 {
+  /**
+   * A boolean for if this process has been run yet, since the task.cache.clear
+   * event will be called multiple times (once per environment) on a cache
+   * clear (and this task only needs to be called once)
+   */
+  protected static $_isProcessed = false;
+  
   public function getEventName()
   {
-    return 'task.clear_cache';
+    return 'task.cache.clear';
   }
 
   public function run(sfEvent $event)
   {
+    if (self::$_isProcessed)
+    {
+      return;
+    }
+    
     $event->getSubject()->logSection('sympal', 'Clearing web cache folder');
 
+    $failures = array();
     $cacheDir = sfConfig::get('sf_web_dir').'/cache';
     if (is_dir($cacheDir))
     {
-      
$event->getSubject()->getFilesystem()->remove(sfFinder::type('file')->ignore_version_control()->discard('.sf')->in($cacheDir));
+      $filesystem = $event->getSubject()->getFilesystem();
+      
+      $finder = 
sfFinder::type('file')->ignore_version_control()->discard('.sf');
+      foreach ($finder->in($cacheDir) as $file)
+      {
+        @$filesystem->remove($file);
+        
+        if (file_exists($file))
+        {
+          $failures[] = $file;
+        }
+      }
     }
+    self::$_isProcessed = true;
+    
+    if (count($failures) > 0)
+    {
+      $event->getSubject()->logBlock(array_merge(
+        array('Could not clear cache on the following files:', ''),
+        array_map(create_function('$f', 'return \' - 
\'.sfDebug::shortenFilePath($f);'), $failures)
+      ), 'ERROR_LARGE');
+    }
   }
 }
\ No newline at end of file

Modified: 
plugins/sfSympalPlugin/trunk/lib/form/doctrine/PluginsfSympalContentSlotForm.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/form/doctrine/PluginsfSympalContentSlotForm.class.php
      2010-03-20 20:32:11 UTC (rev 28636)
+++ 
plugins/sfSympalPlugin/trunk/lib/form/doctrine/PluginsfSympalContentSlotForm.class.php
      2010-03-21 02:45:51 UTC (rev 28637)
@@ -29,7 +29,21 @@
     if (isset($this['value']))
     {
       $this->useFields(array('value', 'type'));
-      sfSympalFormToolkit::changeContentSlotValueWidget($this->object->type, 
$this);
+      sfSympalFormToolkit::changeContentSlotValueWidget($this->object, $this);
     }
   }
+  
+  public function doSave($con = null)
+  {
+    parent::doSave($con);
+    
+    /*
+     * If this is a column slot, then the value was actually set on the
+     * content record, meaning that we need to save that record
+     */
+    if ($this->getObject()->is_column)
+    {
+      $this->getObject()->getContentRenderedFor()->save($con);
+    }
+  }
 }
\ No newline at end of file

Modified: 
plugins/sfSympalPlugin/trunk/lib/form/doctrine/PluginsfSympalContentSlotTranslationForm.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/form/doctrine/PluginsfSympalContentSlotTranslationForm.class.php
   2010-03-20 20:32:11 UTC (rev 28636)
+++ 
plugins/sfSympalPlugin/trunk/lib/form/doctrine/PluginsfSympalContentSlotTranslationForm.class.php
   2010-03-21 02:45:51 UTC (rev 28637)
@@ -15,7 +15,7 @@
 
     if (isset($this['value']))
     {
-      
sfSympalFormToolkit::changeContentSlotValueWidget($this->object->sfSympalContentSlot->type,
 $this);
+      
sfSympalFormToolkit::changeContentSlotValueWidget($this->object->sfSympalContentSlot,
 $this);
     }
   }
 }
\ No newline at end of file

Modified: 
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContent.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContent.class.php 
    2010-03-20 20:32:11 UTC (rev 28636)
+++ 
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContent.class.php 
    2010-03-21 02:45:51 UTC (rev 28637)
@@ -176,13 +176,20 @@
    */
   public function getOrCreateSlot($name, $options = array())
   {
-    $type = isset($options['type']) ? $options['type'] : null;
-    
     if (!$hasSlot = $this->hasSlot($name))
     {
       $isColumn = $this->hasField($name) ? true : false;
-      $type = $type ? $type : 'Text';
       
+      // if type isn't specified, give it a type of Column or Text
+      if (isset($options['type']))
+      {
+        $type = $options['type'];
+      }
+      else
+      {
+        $type = $isColumn ? 'Column' : 'Text';
+      }
+      
       if (!$isColumn && $type == 'Column')
       {
         throw new sfException('Cannot set a non-column slot to type "Column"');

Modified: 
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContentSlot.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContentSlot.class.php
 2010-03-20 20:32:11 UTC (rev 28636)
+++ 
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContentSlot.class.php
 2010-03-21 02:45:51 UTC (rev 28637)
@@ -53,40 +53,26 @@
    */
   public function getEditForm()
   {
-    if ($this->is_column)
-    {
-      $form = $this->_getContentSlotColumnForm();
-      
-      /*
-       * For "column" slots, the widget and validator of the type are
-       * not set automatically in the form itself (as opposed to true
-       * slots who use sfSympalContentSlotForm, where the widget and
-       * validator are setup automatically. This is a shortcoming. We
-       * manually set the widget and validator here for content slots
-       */
-      sfSympalFormToolkit::changeContentSlotValueWidget($this->type, $form, 
$this->name);
-    }
-    else
-    {
-      $contentSlotTypes = sfSympalConfig::get('content_slot_types');
-      $className = isset($contentSlotTypes[$this->type]['form']) ? 
$contentSlotTypes[$this->type]['form'] : sfSympalConfig::get('inline_editing', 
'default_slot_form', 'sfSympalInlineEditContentSlotForm');
-      $form = new $className($this);
-    }
+    $contentSlotTypes = sfSympalConfig::get('content_slot_types');
+    $className = isset($contentSlotTypes[$this->type]['form']) ? 
$contentSlotTypes[$this->type]['form'] : sfSympalConfig::get('inline_editing', 
'default_slot_form', 'sfSympalInlineEditContentSlotForm');
+    
+    $form = new $className($this);
+    $form->setDefault('value', $this->getRawValue());
     
$form->getWidgetSchema()->setNameFormat('sf_sympal_content_slot_'.$this->id.'[%s]');
 
     return $form;
   }
-
+  
   /**
    * Retrieves the form class used to edit slot for "column slots".
    * 
-   * Solumn slots are defined as those whose value is actually stored as
-   * a column on either the sfSympalContent model or the model of the
-   * content type
+   * This is used by sfSympalFormToolkit::changeContentSlotValueWidget()
+   * to extract the widget & validator out so we can put it into the 
+   * content slot form
    * 
    * @return sfForm
    */
-  protected function _getContentSlotColumnForm()
+  public function getContentSlotColumnForm()
   {
     $content = $this->getContentRenderedFor();
     $contentTable = $content->getTable();
@@ -141,7 +127,6 @@
 
     return $form;
   }
-  
   /**
    * Renders this slot, which uses the slot's renderer class and runs
    * it through the transformers
@@ -152,8 +137,11 @@
   {
     if (!$this->_rendered)
     {
-      $transformer = new sfSympalContentSlotTransformer($this);
-      $this->_rendered = $transformer->render();
+      $slotTypeConfig = sfSympalConfig::get('content_slot_types', $this->type, 
array());
+      $rendererClass = isset($slotTypeConfig['renderer']) ? 
$slotTypeConfig['renderer'] : 'sfSympalContentSlotTransformer';
+      
+      $renderer = new $rendererClass($this);
+      $this->_rendered = $renderer->render($this->getRawValue());
     }
 
     return $this->_rendered;
@@ -204,14 +192,18 @@
 
   public function setValue($value)
   {
+    $this->_rendered = null;
+    
     if ($this->is_column)
     {
       $name = $this->name;
-      $this->_contentRenderedFor->$name = $value;
-    }
 
-    $this->_rendered = null;
-    return $this->_set('value', $value);
+      return $this->_contentRenderedFor->$name = $value;
+    }
+    else
+    {
+      return $this->_set('value', $value);
+    }
   }
 
   public function getRawValue()

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/_slot_editor_form.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/_slot_editor_form.php
      2010-03-20 20:32:11 UTC (rev 28636)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/_slot_editor_form.php
      2010-03-21 02:45:51 UTC (rev 28637)
@@ -1,17 +1,9 @@
 <?php include_partial('sympal_edit_slot/slot_messages'); ?>
 
-<?php if ($contentSlot->getIsColumn()): ?>
-  <?php if (sfSympalConfig::isI18nEnabled('sfSympalContentSlot') && 
!isset($form[$contentSlot->getName()])): ?>
-    <?php echo $form[$sf_user->getEditCulture()][$contentSlot->getName()] ?>
-  <?php else: ?>
-    <?php echo $form[$contentSlot->getName()] ?>
-  <?php endif; ?>
+<?php if (sfSympalConfig::isI18nEnabled('sfSympalContentSlot')): ?>
+  <?php echo $form[$sf_user->getEditCulture()]['value'] ?>
 <?php else: ?>
-  <?php if (sfSympalConfig::isI18nEnabled('sfSympalContentSlot')): ?>
-    <?php echo $form[$sf_user->getEditCulture()]['value'] ?>
-  <?php else: ?>
-    <?php echo $form['value'] ?>
-  <?php endif; ?>
+  <?php echo $form['value'] ?>
 <?php endif; ?>
 
 <script type="text/javascript">

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/transformer/sfSympalContentSlotTransformer.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/transformer/sfSympalContentSlotTransformer.class.php
   2010-03-20 20:32:11 UTC (rev 28636)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/transformer/sfSympalContentSlotTransformer.class.php
   2010-03-21 02:45:51 UTC (rev 28637)
@@ -54,10 +54,16 @@
   /**
    * The public-facing method that will return the transformed content
    * 
+   * @param The value to transform
    * @return string The transformed content
    */
-  public function render()
+  public function render($value)
   {
+    if ($value !== null)
+    {
+      $this->setTransformedContent($value);
+    }
+    
     $this->process();
     
     $replacements = $this->getTokenReplacementValues();
@@ -77,8 +83,6 @@
    */
   protected function process()
   {
-    
$this->setTransformedContent($this->getContentSlot()->getValueForRendering());
-    
     foreach ($this->getTransformerCallbacks() as $callback)
     {
       $this->setTransformedContent(call_user_func($callback, 
$this->getTransformedContent(), $this));

Modified: plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php 
2010-03-20 20:32:11 UTC (rev 28636)
+++ plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php 
2010-03-21 02:45:51 UTC (rev 28637)
@@ -174,14 +174,13 @@
    * @param string $fieldName The name of the "slot" field on the form
    * @return void
    */
-  public static function changeContentSlotValueWidget($type = 'Text', sfForm 
$form, $fieldName = 'value')
+  public static function changeContentSlotValueWidget(sfSympalContentSlot 
$slot, sfForm $form)
   {
     // in case the type is blank
-    $type = ($type) ? $type : 'Text';
+    $type = ($slot->type) ? $slot->type : 'Text';
     
     $widgetSchema = $form->getWidgetSchema();
     $validatorSchema = $form->getValidatorSchema();
-
     $contentSlotTypes = sfSympalConfig::get('content_slot_types', null, 
array());
     $options = isset($contentSlotTypes[$type]) ? $contentSlotTypes[$type] : 
array();
 
@@ -191,15 +190,26 @@
     $validatorClass = isset($options['validator_class']) ? 
$options['validator_class'] : 'sfValidatorFormSympal'.$type;
     $validatorOptions = isset($options['validator_options']) ? 
$options['validator_options'] : array();
     $validatorOptions['required'] = false;
-
-    if ($widgetClass)
+    
+    /*
+     * Setup the widget and validator: 3 cases:
+     *   1) widget_class & is validator_class are not false, so we setup 
widget/validator using those
+     *   2) widget_class & validator_class ARE false, the slot is a column - 
get the widget/validator from the content form
+     *   3) All else fails, leave widget & validator alone
+     */
+    if ($widgetClass && $validatorClass)
     {
-      $widgetSchema[$fieldName] = new $widgetClass($widgetOptions, 
array('class'=> 'slot_'.strtolower($type)));
+      $widgetSchema['value'] = new $widgetClass($widgetOptions, 
array('class'=> 'slot_'.strtolower($type)));
+      $validatorSchema['value'] = new $validatorClass($validatorOptions);
     }
-    
-    if ($validatorClass)
+    elseif ($slot->is_column)
     {
-      $validatorSchema[$fieldName] = new $validatorClass($validatorOptions);
+      $contentForm = $slot->getContentSlotColumnForm();
+      $contentWidgetSchema = $contentForm->getWidgetSchema();
+      $contentValidatorSchema = $contentForm->getValidatorSchema();
+      
+      $widgetSchema['value'] = 
$contentForm->getWidgetSchema()->offsetGet($slot->name);
+      $validatorSchema['value'] = 
$contentForm->getValidatorSchema()->offsetGet($slot->name);
     }
   }
 

Modified: plugins/sfSympalPlugin/trunk/web/markitup/skins/markitup/style.css
===================================================================
--- plugins/sfSympalPlugin/trunk/web/markitup/skins/markitup/style.css  
2010-03-20 20:32:11 UTC (rev 28636)
+++ plugins/sfSympalPlugin/trunk/web/markitup/skins/markitup/style.css  
2010-03-21 02:45:51 UTC (rev 28637)
@@ -12,7 +12,6 @@
        text-decoration:none;
 }
 .markItUp  {
-       width:700px;
        margin:5px 0 5px 0;
        border:5px solid #F5F5F5;       
 }
@@ -20,13 +19,13 @@
        border:1px solid #3C769D;       
        background:#FFF url(images/bg-container.png) repeat-x top left;
        padding:5px 5px 2px 5px;
-       font:11px Verdana, Arial, Helvetica, sans-serif;
+       font:14px Verdana, Arial, Helvetica, sans-serif;
 }
 .markItUpEditor {
-       font:12px 'Courier New', Courier, monospace;
+       font:14px 'Courier New', Courier, monospace;
        padding:5px 5px 5px 35px;
        border:3px solid #3C769D;
-       width:643px;
+       width: 92%;
        height:320px;
        background-image:url(images/bg-editor.png);
        background-repeat:no-repeat;

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