Development

Changeset 8908

You must first sign up to be able to contribute.

Changeset 8908

Show
Ignore:
Timestamp:
05/11/08 05:49:12 (2 months ago)
Author:
dwhittle
Message:

dwhittle: merged changes to branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dwhittle/1.1/lib/plugin/sfPearFrontendPlugin.class.php

    r5257 r8908  
    4242  public function _display($text) 
    4343  { 
    44     $this->dispatcher->notify(new sfEvent($this, 'application.log', array($this->splitLongLine($text)))); 
     44    $this->dispatcher->notify(new sfEvent($this, 'application.log', $this->splitLongLine($text))); 
    4545  } 
    4646 
    4747  protected function splitLongLine($text) 
    4848  { 
    49     $t = ''; 
     49    $lines = ''; 
    5050    foreach (explode("\n", $text) as $longline) 
    5151    { 
     
    5454        if ($line = trim($line)) 
    5555        { 
    56           $t .= $line; 
     56          $lines[] = $line; 
    5757        } 
    5858      } 
    5959    } 
    6060 
    61     return $t
     61    return $lines
    6262  } 
    6363} 
  • branches/dwhittle/1.1/lib/plugin/sfPluginManager.class.php

    r8851 r8908  
    433433    if (is_null($version)) 
    434434    { 
    435       $version = $this->getPluginVersion($plugin, $stability); 
     435      try 
     436      { 
     437        $version = $this->getPluginVersion($plugin, $stability); 
     438      } 
     439      catch (Exception $e) 
     440      { 
     441        // no release available 
     442        return false; 
     443      } 
    436444    } 
    437445 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php

    r8851 r8908  
    8282    { 
    8383      $this->table = $table; 
     84 
     85      try 
     86      { 
     87        // trigger the include_once of any behaviors now, and catch the 
     88        // exception that is thrown due to no plugin behaviors having been 
     89        // registered 
     90        class_exists($table->getPhpName()); 
     91      } 
     92      catch (sfConfigurationException $e) 
     93      { 
     94      } 
    8495 
    8596      // find the package to store forms in the same directory as the model classes 
  • branches/dwhittle/1.1/lib/task/plugin/sfPluginInstallTask.class.php

    r8851 r8908  
    115115      } 
    116116 
    117       $temp = trim(str_replace('license', '', strtolower($license))); 
    118       if (!is_null($license) && !in_array($temp, array('mit', 'bsd', 'lgpl', 'php', 'apache'))) 
     117      if (false !== $license) 
    119118      { 
    120         throw new sfCommandException(sprintf('The license of this plugin "%s" is not MIT like (use --force-license to force installation).', $license)); 
     119        $temp = trim(str_replace('license', '', strtolower($license))); 
     120        if (!is_null($license) && !in_array($temp, array('mit', 'bsd', 'lgpl', 'php', 'apache'))) 
     121        { 
     122          throw new sfCommandException(sprintf('The license of this plugin "%s" is not MIT like (use --force-license to force installation).', $license)); 
     123        } 
    121124      } 
    122125    } 
  • branches/dwhittle/1.1/lib/widget/sfWidgetFormDate.class.php

    r6962 r8908  
    7373 
    7474    // days 
    75     $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['day']) + $this->getOption('days') : $this->getOption('days'))); 
     75    $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['day']) + $this->getOption('days') : $this->getOption('days')), array_merge($this->attributes, $attributes)); 
    7676    $date['%day%'] = $widget->render($name.'[day]', $value['day']); 
    7777 
    7878    // months 
    79     $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['month']) + $this->getOption('months') : $this->getOption('months'))); 
     79    $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['month']) + $this->getOption('months') : $this->getOption('months')), array_merge($this->attributes, $attributes)); 
    8080    $date['%month%'] = $widget->render($name.'[month]', $value['month']); 
    8181 
    8282    // years 
    83     $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['year']) + $this->getOption('years') : $this->getOption('years'))); 
     83    $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['year']) + $this->getOption('years') : $this->getOption('years')), array_merge($this->attributes, $attributes)); 
    8484    $date['%year%'] = $widget->render($name.'[year]', $value['year']); 
    8585 
  • branches/dwhittle/1.1/lib/widget/sfWidgetFormDateTime.class.php

    r6419 r8908  
    1919class sfWidgetFormDateTime extends sfWidgetForm 
    2020{ 
    21   protected 
    22     $defaultAttributes = array('date' => array(), 'time' => array()); 
    23  
    2421  /** 
    2522   * Configures the current widget. 
     
    4542    $this->addOption('with_time', true); 
    4643    $this->addOption('format', '%date% %time%'); 
    47  
    48     if (isset($attributes['date'])) 
    49     { 
    50       $defaultAttributes['time'] = $attributes['date']; 
    51       unset($attributes['date']); 
    52     } 
    53  
    54     if (isset($attributes['time'])) 
    55     { 
    56       $defaultAttributes['time'] = $attributes['time']; 
    57       unset($attributes['time']); 
    58     } 
    5944  } 
    6045 
     
    6550  { 
    6651    // date 
    67     $date = $this->getDateWidget()->render($name, $value); 
     52    $date = $this->getDateWidget($attributes)->render($name, $value); 
    6853 
    6954    if (!$this->getOption('with_time')) 
     
    7459    return strtr($this->getOption('format'), array( 
    7560      '%date%' => $date, 
    76       '%time%' => $this->getTimeWidget()->render($name, $value), 
     61      '%time%' => $this->getTimeWidget($attributes)->render($name, $value), 
    7762    )); 
    7863  } 
    7964 
    8065  /** 
    81    * Returns the date widget 
     66   * Returns the date widget. 
     67   * 
     68   * @param  array  An array of attributes 
    8269   * 
    8370   * @return sfWidgetForm A Widget representing the date 
    8471   */ 
    85   protected function getDateWidget(
     72  protected function getDateWidget($attributes
    8673  { 
    87     return new sfWidgetFormDate($this->getOptionsFor('date'), $this->getAttributesFor('date')); 
     74    return new sfWidgetFormDate($this->getOptionsFor('date'), $this->getAttributesFor('date', $attributes)); 
    8875  } 
    8976 
    9077  /** 
    91    * Returns the time widget 
     78   * Returns the time widget. 
     79   * 
     80   * @param  array  An array of attributes 
    9281   * 
    9382   * @return sfWidgetForm A Widget representing the time 
    9483   */ 
    95   protected function getTimeWidget(
     84  protected function getTimeWidget($attributes
    9685  { 
    97     return new sfWidgetFormTime($this->getOptionsFor('time'), $this->getAttributesFor('time')); 
     86    return new sfWidgetFormTime($this->getOptionsFor('time'), $this->getAttributesFor('time', $attributes)); 
    9887  } 
    9988 
    10089  /** 
    101    * Returns an array of options for the given type 
     90   * Returns an array of options for the given type. 
    10291   * 
    10392   * @param  string The type (date or time) 
     
    117106 
    118107  /** 
    119    * Returns an array of HTML attributes for the given type 
     108   * Returns an array of HTML attributes for the given type. 
    120109   * 
    121110   * @param  string The type (date or time) 
     111   * @param  array  An array of attributes 
    122112   * 
    123113   * @return array  An array of HTML attributes 
    124114   */ 
    125   protected function getAttributesFor($type
     115  protected function getAttributesFor($type, $attributes
    126116  { 
    127     return isset($attributes[$type]) ? array_merge($this->defaultAttributes[$type], $attributes[$type]) : $this->defaultAttributes[$type]; 
     117    $defaults = isset($this->attributes[$type]) ? $this->attributes[$type] : array(); 
     118 
     119    return isset($attributes[$type]) ? array_merge($defaults, $attributes[$type]) : $defaults; 
    128120  } 
    129121} 
  • branches/dwhittle/1.1/lib/widget/sfWidgetFormSelect.class.php

    r5969 r8908  
    5959  } 
    6060 
     61  /** 
     62   * Returns an array of option tags for the given choices 
     63   * 
     64   * @param  string The selected value 
     65   * @param  array  An array of choices 
     66   * 
     67   * @return array  An array of option tags 
     68   */ 
    6169  protected function getOptionsForSelect($value, $choices) 
    6270  { 
     71    $mainAttributes = $this->attributes; 
     72    $this->attributes = array(); 
     73 
    6374    $options = array(); 
    6475    foreach ($choices as $key => $option) 
     
    8091    } 
    8192 
     93    $this->attributes = $mainAttributes; 
     94 
    8295    return $options; 
    8396  } 
  • branches/dwhittle/1.1/lib/widget/sfWidgetFormTime.class.php

    r6962 r8908  
    7676 
    7777    // hours 
    78     $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['hour']) + $this->getOption('hours') : $this->getOption('hours'))); 
     78    $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['hour']) + $this->getOption('hours') : $this->getOption('hours')), array_merge($this->attributes, $attributes)); 
    7979    $time['%hour%'] = $widget->render($name.'[hour]', $value['hour']); 
    8080 
    8181    // minutes 
    82     $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['minute']) + $this->getOption('minutes') : $this->getOption('minutes'))); 
     82    $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['minute']) + $this->getOption('minutes') : $this->getOption('minutes')), array_merge($this->attributes, $attributes)); 
    8383    $time['%minute%'] = $widget->render($name.'[minute]', $value['minute']); 
    8484 
     
    8686    { 
    8787      // seconds 
    88       $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['second']) + $this->getOption('seconds') : $this->getOption('seconds'))); 
     88      $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['second']) + $this->getOption('seconds') : $this->getOption('seconds')), array_merge($this->attributes, $attributes)); 
    8989      $time['%second%'] = $widget->render($name.'[second]', $value['second']); 
    9090    } 
  • branches/dwhittle/1.1/test/unit/plugin/sfPearEnvironmentTest.php

    r6188 r8908  
    1212 
    1313require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
     14 
     15$t = new lime_test(3, new lime_output_color()); 
     16 
     17if (!class_exists('PEAR')) 
     18{ 
     19  $t->skip('PEAR must be installed', 3); 
     20  exit(0); 
     21} 
     22 
    1423require_once dirname(__FILE__).'/sfPearDownloaderTest.class.php'; 
    1524require_once dirname(__FILE__).'/sfPearRestTest.class.php'; 
    1625require_once dirname(__FILE__).'/sfPluginTestHelper.class.php'; 
    17  
    18 $t = new lime_test(3, new lime_output_color()); 
    1926 
    2027// setup 
  • branches/dwhittle/1.1/test/unit/plugin/sfPearRestPluginTest.php

    r6188 r8908  
    1212 
    1313require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
     14 
     15$t = new lime_test(5, new lime_output_color()); 
     16 
     17if (!class_exists('PEAR')) 
     18{ 
     19  $t->skip('PEAR must be installed', 5);  
     20  exit(0); 
     21} 
     22 
    1423require_once dirname(__FILE__).'/sfPearDownloaderTest.class.php'; 
    1524require_once dirname(__FILE__).'/sfPearRestTest.class.php'; 
    1625require_once dirname(__FILE__).'/sfPluginTestHelper.class.php'; 
    17  
    18 $t = new lime_test(5, new lime_output_color()); 
    1926 
    2027// setup 
  • branches/dwhittle/1.1/test/unit/plugin/sfPluginManagerTest.php

    r8648 r8908  
    1212 
    1313require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
     14 
     15$t = new lime_test(40, new lime_output_color()); 
     16 
     17if (!class_exists('PEAR')) 
     18{ 
     19  $t->skip('PEAR must be installed', 40);  
     20  exit(0); 
     21} 
     22 
    1423require_once dirname(__FILE__).'/sfPearDownloaderTest.class.php'; 
    1524require_once dirname(__FILE__).'/sfPearRestTest.class.php'; 
    1625require_once dirname(__FILE__).'/sfPluginTestHelper.class.php'; 
    17  
    18 $t = new lime_test(40, new lime_output_color()); 
    1926 
    2027// setup 
  • branches/dwhittle/1.1/test/unit/widget/sfWidgetFormDateTest.php

    r6962 r8908  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(35, new lime_output_color()); 
     13$t = new lime_test(37, new lime_output_color()); 
    1414 
    1515$w = new sfWidgetFormDate(); 
     
    113113$t->is(count($css->matchAll('#foo_month option')->getNodes()), 4, '__construct() can change the default array used for months'); 
    114114$t->is(count($css->matchAll('#foo_day option')->getNodes()), 3, '__construct() can change the default array used for days'); 
     115 
     116// attributes 
     117$t->diag('attributes'); 
     118$dom->loadHTML($w->render('foo', '2005-10-15', array('disabled' => 'disabled'))); 
     119$t->is(count($css->matchAll('select[disabled="disabled"]')->getNodes()), 3, '->render() takes the attributes into account for all the three embedded widgets'); 
     120 
     121$w->setAttribute('disabled', 'disabled'); 
     122$dom->loadHTML($w->render('foo', '2005-10-15')); 
     123$t->is(count($css->matchAll('select[disabled="disabled"]')->getNodes()), 3, '->render() takes the attributes into account for all the three embedded widgets'); 
  • branches/dwhittle/1.1/test/unit/widget/sfWidgetFormDateTimeTest.php

    r6962 r8908  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(52, new lime_output_color()); 
     13$t = new lime_test(54, new lime_output_color()); 
    1414 
    1515$dom = new DomDocument('1.0', 'utf-8'); 
     
    120120  $t->pass('__construct() throws a InvalidArgumentException if the date/time options is not an array'); 
    121121} 
     122 
     123// attributes 
     124$t->diag('attributes'); 
     125$w = new sfWidgetFormDateTime(); 
     126$dom->loadHTML($w->render('foo', '2005-10-15 12:30:35', array('date' => array('disabled' => 'disabled'), 'time' => array('disabled' => 'disabled')))); 
     127$t->is(count($css->matchAll('select[disabled="disabled"]')->getNodes()), 5, '->render() takes the attributes into account for all the five embedded widgets'); 
     128 
     129$w->setAttribute('date', array('disabled' => 'disabled')); 
     130$w->setAttribute('time', array('disabled' => 'disabled')); 
     131$dom->loadHTML($w->render('foo', '2005-10-15 12:30:35')); 
     132$t->is(count($css->matchAll('select[disabled="disabled"]')->getNodes()), 5, '->render() takes the attributes into account for all the five embedded widgets'); 
  • branches/dwhittle/1.1/test/unit/widget/sfWidgetFormSelectTest.php

    r6198 r8908  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(10, new lime_output_color()); 
     13$t = new lime_test(14, new lime_output_color()); 
    1414 
    1515$dom = new DomDocument('1.0', 'utf-8'); 
     
    6868$css = new sfDomCssSelector($dom); 
    6969$t->is(count($css->matchAll('#foo option')->getNodes()), 3, '->render() accepts a sfCallable as a choices option'); 
     70 
     71// attributes 
     72$t->diag('attributes'); 
     73$w = new sfWidgetFormSelect(array('choices' => array(0, 1, 2))); 
     74$dom->loadHTML($w->render('foo', null, array('disabled' => 'disabled'))); 
     75$css = new sfDomCssSelector($dom); 
     76$t->is(count($css->matchAll('select[disabled="disabled"]')->getNodes()), 1, '->render() does not pass the select HTML attributes to the option tag'); 
     77$t->is(count($css->matchAll('option[disabled="disabled"]')->getNodes()), 0, '->render() does not pass the select HTML attributes to the option tag'); 
     78 
     79$w = new sfWidgetFormSelect(array('choices' => array(0, 1, 2)), array('disabled' => 'disabled')); 
     80$dom->loadHTML($w->render('foo')); 
     81$css = new sfDomCssSelector($dom); 
     82$t->is(count($css->matchAll('select[disabled="disabled"]')->getNodes()), 1, '->render() does not pass the select HTML attributes to the option tag'); 
     83$t->is(count($css->matchAll('option[disabled="disabled"]')->getNodes()), 0, '->render() does not pass the select HTML attributes to the option tag'); 
  • branches/dwhittle/1.1/test/unit/widget/sfWidgetFormTimeTest.php

    r6962 r8908  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(35, new lime_output_color()); 
     13$t = new lime_test(37, new lime_output_color()); 
    1414 
    1515$w = new sfWidgetFormTime(array('with_seconds' => true)); 
     
    124124$t->like($css->matchSingle('#foo_hour')->getNode()->nextSibling->nodeValue, '/^#/', '__construct() can change the default format'); 
    125125$t->ok(!count($css->matchSingle('#foo_second')->getNodes()), '__construct() can change the default format'); 
     126 
     127// attributes 
     128$t->diag('attributes'); 
     129$w->setOption('with_seconds', true); 
     130$dom->loadHTML($w->render('foo', '12:30:35', array('disabled' => 'disabled'))); 
     131$t->is(count($css->matchAll('select[disabled="disabled"]')->getNodes()), 3, '->render() takes the attributes into account for all the three embedded widgets'); 
     132 
     133$w->setAttribute('disabled', 'disabled'); 
     134$dom->loadHTML($w->render('foo', '12:30:35')); 
     135$t->is(count($css->matchAll('select[disabled="disabled"]')->getNodes()), 3, '->render() takes the attributes into account for all the three embedded widgets');