Changeset 8908
- Timestamp:
- 05/11/08 05:49:12 (2 months ago)
- Files:
-
- branches/dwhittle/1.1/lib/plugin/sfPearFrontendPlugin.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/plugin/sfPluginManager.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/task/plugin/sfPluginInstallTask.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/widget/sfWidgetFormDate.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/widget/sfWidgetFormDateTime.class.php (modified) (5 diffs)
- branches/dwhittle/1.1/lib/widget/sfWidgetFormSelect.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/widget/sfWidgetFormTime.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/test/unit/plugin/sfPearEnvironmentTest.php (modified) (1 diff)
- branches/dwhittle/1.1/test/unit/plugin/sfPearRestPluginTest.php (modified) (1 diff)
- branches/dwhittle/1.1/test/unit/plugin/sfPluginManagerTest.php (modified) (1 diff)
- branches/dwhittle/1.1/test/unit/widget/sfWidgetFormDateTest.php (modified) (2 diffs)
- branches/dwhittle/1.1/test/unit/widget/sfWidgetFormDateTimeTest.php (modified) (2 diffs)
- branches/dwhittle/1.1/test/unit/widget/sfWidgetFormSelectTest.php (modified) (2 diffs)
- branches/dwhittle/1.1/test/unit/widget/sfWidgetFormTimeTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dwhittle/1.1/lib/plugin/sfPearFrontendPlugin.class.php
r5257 r8908 42 42 public function _display($text) 43 43 { 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))); 45 45 } 46 46 47 47 protected function splitLongLine($text) 48 48 { 49 $ t= '';49 $lines = ''; 50 50 foreach (explode("\n", $text) as $longline) 51 51 { … … 54 54 if ($line = trim($line)) 55 55 { 56 $ t .= $line;56 $lines[] = $line; 57 57 } 58 58 } 59 59 } 60 60 61 return $ t;61 return $lines; 62 62 } 63 63 } branches/dwhittle/1.1/lib/plugin/sfPluginManager.class.php
r8851 r8908 433 433 if (is_null($version)) 434 434 { 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 } 436 444 } 437 445 branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php
r8851 r8908 82 82 { 83 83 $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 } 84 95 85 96 // 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 115 115 } 116 116 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) 119 118 { 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 } 121 124 } 122 125 } branches/dwhittle/1.1/lib/widget/sfWidgetFormDate.class.php
r6962 r8908 73 73 74 74 // 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)); 76 76 $date['%day%'] = $widget->render($name.'[day]', $value['day']); 77 77 78 78 // 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)); 80 80 $date['%month%'] = $widget->render($name.'[month]', $value['month']); 81 81 82 82 // 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)); 84 84 $date['%year%'] = $widget->render($name.'[year]', $value['year']); 85 85 branches/dwhittle/1.1/lib/widget/sfWidgetFormDateTime.class.php
r6419 r8908 19 19 class sfWidgetFormDateTime extends sfWidgetForm 20 20 { 21 protected22 $defaultAttributes = array('date' => array(), 'time' => array());23 24 21 /** 25 22 * Configures the current widget. … … 45 42 $this->addOption('with_time', true); 46 43 $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 }59 44 } 60 45 … … 65 50 { 66 51 // date 67 $date = $this->getDateWidget( )->render($name, $value);52 $date = $this->getDateWidget($attributes)->render($name, $value); 68 53 69 54 if (!$this->getOption('with_time')) … … 74 59 return strtr($this->getOption('format'), array( 75 60 '%date%' => $date, 76 '%time%' => $this->getTimeWidget( )->render($name, $value),61 '%time%' => $this->getTimeWidget($attributes)->render($name, $value), 77 62 )); 78 63 } 79 64 80 65 /** 81 * Returns the date widget 66 * Returns the date widget. 67 * 68 * @param array An array of attributes 82 69 * 83 70 * @return sfWidgetForm A Widget representing the date 84 71 */ 85 protected function getDateWidget( )72 protected function getDateWidget($attributes) 86 73 { 87 return new sfWidgetFormDate($this->getOptionsFor('date'), $this->getAttributesFor('date' ));74 return new sfWidgetFormDate($this->getOptionsFor('date'), $this->getAttributesFor('date', $attributes)); 88 75 } 89 76 90 77 /** 91 * Returns the time widget 78 * Returns the time widget. 79 * 80 * @param array An array of attributes 92 81 * 93 82 * @return sfWidgetForm A Widget representing the time 94 83 */ 95 protected function getTimeWidget( )84 protected function getTimeWidget($attributes) 96 85 { 97 return new sfWidgetFormTime($this->getOptionsFor('time'), $this->getAttributesFor('time' ));86 return new sfWidgetFormTime($this->getOptionsFor('time'), $this->getAttributesFor('time', $attributes)); 98 87 } 99 88 100 89 /** 101 * Returns an array of options for the given type 90 * Returns an array of options for the given type. 102 91 * 103 92 * @param string The type (date or time) … … 117 106 118 107 /** 119 * Returns an array of HTML attributes for the given type 108 * Returns an array of HTML attributes for the given type. 120 109 * 121 110 * @param string The type (date or time) 111 * @param array An array of attributes 122 112 * 123 113 * @return array An array of HTML attributes 124 114 */ 125 protected function getAttributesFor($type )115 protected function getAttributesFor($type, $attributes) 126 116 { 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; 128 120 } 129 121 } branches/dwhittle/1.1/lib/widget/sfWidgetFormSelect.class.php
r5969 r8908 59 59 } 60 60 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 */ 61 69 protected function getOptionsForSelect($value, $choices) 62 70 { 71 $mainAttributes = $this->attributes; 72 $this->attributes = array(); 73 63 74 $options = array(); 64 75 foreach ($choices as $key => $option) … … 80 91 } 81 92 93 $this->attributes = $mainAttributes; 94 82 95 return $options; 83 96 } branches/dwhittle/1.1/lib/widget/sfWidgetFormTime.class.php
r6962 r8908 76 76 77 77 // 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)); 79 79 $time['%hour%'] = $widget->render($name.'[hour]', $value['hour']); 80 80 81 81 // 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)); 83 83 $time['%minute%'] = $widget->render($name.'[minute]', $value['minute']); 84 84 … … 86 86 { 87 87 // 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)); 89 89 $time['%second%'] = $widget->render($name.'[second]', $value['second']); 90 90 } branches/dwhittle/1.1/test/unit/plugin/sfPearEnvironmentTest.php
r6188 r8908 12 12 13 13 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 14 15 $t = new lime_test(3, new lime_output_color()); 16 17 if (!class_exists('PEAR')) 18 { 19 $t->skip('PEAR must be installed', 3); 20 exit(0); 21 } 22 14 23 require_once dirname(__FILE__).'/sfPearDownloaderTest.class.php'; 15 24 require_once dirname(__FILE__).'/sfPearRestTest.class.php'; 16 25 require_once dirname(__FILE__).'/sfPluginTestHelper.class.php'; 17 18 $t = new lime_test(3, new lime_output_color());19 26 20 27 // setup branches/dwhittle/1.1/test/unit/plugin/sfPearRestPluginTest.php
r6188 r8908 12 12 13 13 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 14 15 $t = new lime_test(5, new lime_output_color()); 16 17 if (!class_exists('PEAR')) 18 { 19 $t->skip('PEAR must be installed', 5); 20 exit(0); 21 } 22 14 23 require_once dirname(__FILE__).'/sfPearDownloaderTest.class.php'; 15 24 require_once dirname(__FILE__).'/sfPearRestTest.class.php'; 16 25 require_once dirname(__FILE__).'/sfPluginTestHelper.class.php'; 17 18 $t = new lime_test(5, new lime_output_color());19 26 20 27 // setup branches/dwhittle/1.1/test/unit/plugin/sfPluginManagerTest.php
r8648 r8908 12 12 13 13 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 14 15 $t = new lime_test(40, new lime_output_color()); 16 17 if (!class_exists('PEAR')) 18 { 19 $t->skip('PEAR must be installed', 40); 20 exit(0); 21 } 22 14 23 require_once dirname(__FILE__).'/sfPearDownloaderTest.class.php'; 15 24 require_once dirname(__FILE__).'/sfPearRestTest.class.php'; 16 25 require_once dirname(__FILE__).'/sfPluginTestHelper.class.php'; 17 18 $t = new lime_test(40, new lime_output_color());19 26 20 27 // setup branches/dwhittle/1.1/test/unit/widget/sfWidgetFormDateTest.php
r6962 r8908 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(3 5, new lime_output_color());13 $t = new lime_test(37, new lime_output_color()); 14 14 15 15 $w = new sfWidgetFormDate(); … … 113 113 $t->is(count($css->matchAll('#foo_month option')->getNodes()), 4, '__construct() can change the default array used for months'); 114 114 $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 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(5 2, new lime_output_color());13 $t = new lime_test(54, new lime_output_color()); 14 14 15 15 $dom = new DomDocument('1.0', 'utf-8'); … … 120 120 $t->pass('__construct() throws a InvalidArgumentException if the date/time options is not an array'); 121 121 } 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 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(1 0, new lime_output_color());13 $t = new lime_test(14, new lime_output_color()); 14 14 15 15 $dom = new DomDocument('1.0', 'utf-8'); … … 68 68 $css = new sfDomCssSelector($dom); 69 69 $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 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(3 5, new lime_output_color());13 $t = new lime_test(37, new lime_output_color()); 14 14 15 15 $w = new sfWidgetFormTime(array('with_seconds' => true)); … … 124 124 $t->like($css->matchSingle('#foo_hour')->getNode()->nextSibling->nodeValue, '/^#/', '__construct() can change the default format'); 125 125 $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');