Development

Changeset 18549

You must first sign up to be able to contribute.

Changeset 18549

Show
Ignore:
Timestamp:
05/22/09 17:54:25 (4 years ago)
Author:
bshaffer
Message:

fixes issue when switching slideshow renderers

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/csDoctrineSlideshowPlugin/trunk/lib/form/doctrine/PluginSlideshowForm.class.php

    r18546 r18549  
    2222        if (class_exists($optionsClass))  
    2323        { 
    24           $this->embedForm('options', $optionsForm); 
     24          $optionsForm = new $optionsClass($this->object->options, $this->object); 
    2525        } 
     26        else 
     27        { 
     28          $optionsForm = new sfSlideshowOptionsForm($this->object->options, $this->object); 
     29        } 
     30        $this->embedForm('options', $optionsForm); 
    2631      } 
    2732      else 
     
    4247  { 
    4348    //Do Special binding for slideshow options if options exist 
    44     if (array_key_exists('options', $taintedValues))  
     49    if (array_key_exists('options', $taintedValues) && array_key_exists('options', $this->embeddedForms))  
    4550    { 
    46       // Flattens the option form into a string 
    47       $taintedValues['options'] = $this->embeddedForms['options']->getFlattenedValues($taintedValues['options']); 
     51      //renderer is changed, pull in default rendering options 
     52      if ($taintedValues['renderer'] != $this->object->renderer)  
     53      { 
     54        $class = $taintedValues['renderer']; 
     55        $renderer = new $class(); 
     56        $taintedValues['options'] = $renderer->getDefaultOptions(); 
     57      } 
     58      else 
     59      { 
     60        // Flattens the option form into a string 
     61        $taintedValues['options'] = $this->embeddedForms['options']->getFlattenedValues($taintedValues['options']); 
     62      } 
     63      // replaces embedded form with a string widget 
    4864      unset($this['options']); 
    4965      $this->widgetSchema['options'] = new sfWidgetFormInput(); 
  • plugins/csDoctrineSlideshowPlugin/trunk/lib/form/renderer/sfOptionsForm.class.php

    r18546 r18549  
    77{ 
    88  public function __construct($defaults, $object = null, $options = array(), $CSRFSecret = null) 
    9   // public function __construct($defaults = array(), $options = array(), $CSRFSecret = null) 
    109  { 
    1110    if(!is_array($defaults)) 
     
    1514    $this->option_defaults = $defaults; 
    1615    return parent::__construct($object, $options, $CSRFSecret); 
    17     // return parent::__construct($defaults, $options, $CSRFSecret); 
    1816  } 
    1917  public function setup() 
  • plugins/csDoctrineSlideshowPlugin/trunk/lib/form/renderer/sfSlideshowOptionsForm.class.php

    r18546 r18549  
    44* Parses an options string into a form object 
    55*/ 
    6 abstract class sfSlideshowOptionsForm extends sfOptionsForm 
     6class sfSlideshowOptionsForm extends sfOptionsForm 
    77{ 
    88  public $renderer; 
     
    3535  public function getRendererClass() 
    3636  { 
    37     // Guesses the renderer class based on the name of the options form 
    38     // If classes follow naming conventions, this will work.  Otherwise, 
    3937    // this method can be overridden 
    40     return str_replace('OptionsForm', '', get_class($this))
     38    return $this->object->renderer
    4139  } 
    4240  public function getModelName() 
  • plugins/csDoctrineSlideshowPlugin/trunk/lib/renderer/BaseSlideshowRenderer.class.php

    r18546 r18549  
    7171    return $value; 
    7272  } 
     73  public function getDefaultOptions() 
     74  { 
     75    $opt = ''; 
     76    foreach ($this->options as $option => $default)  
     77    { 
     78      $opt .= "$option=$default\n"; 
     79    } 
     80    return $opt; 
     81  } 
    7382  public function getSlide($slide) 
    7483  { 
  • plugins/csDoctrineSlideshowPlugin/trunk/lib/renderer/SlideshowGoogleSlideshow2Renderer.class.php

    r18546 r18549  
    1515  "; 
    1616   
    17   // public $effects = array('blindX', 'growX', 'scrollLeft', 'zoom', 'fade', 'turnLeft', 'turnDown', 'curtainX', 'scrollRight'); 
    18   // public $defaults = array('fx' => 'fade'); 
    19    
    2017  public function __construct() 
    2118  { 
     
    2320    $this->addJavascript('/csDoctrineSlideshowPlugin/js/slideshow.min.js'); 
    2421    $this->addStylesheet('/csDoctrineSlideshowPlugin/css/google-slideshow.css'); 
     22    $this->addOption('thumbnails', array('true', 'false'), 'true'); 
     23    $this->addOption('paused', array('true', 'false'), 'false'); 
    2524  } 
    2625  public function render($slideshow) 
     
    5453            
    5554       var myShow = new Slideshow('slideshow', data, {controller: false, 
    56       height: %s, width: %s, thumbnails: true, paused: true}); 
     55      height: %s, width: %s, thumbnails: %s, paused: %s}); 
    5756 
    5857             if (myShow.options.thumbnails){ 
     
    6665EOF; 
    6766 
    68     return sprintf($js, $this->getThumbnails($slideshow), $slideshow->height, $slideshow->width); 
     67    return sprintf($js,  
     68        $this->getThumbnails($slideshow),  
     69        $slideshow->height,  
     70        $slideshow->width, 
     71        $this->getOption('thumbnails', $slideshow), 
     72        $this->getOption('paused', $slideshow) 
     73      ); 
    6974  } 
    7075}