Development

Changeset 8851

You must first sign up to be able to contribute.

Changeset 8851

Show
Ignore:
Timestamp:
05/08/08 00:45:35 (5 months ago)
Author:
dwhittle
Message:

dwhittle: merged changes to branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dwhittle/1.0/lib/helper/JavascriptHelper.php

    r8723 r8851  
    266266    $options['form'] = true; 
    267267 
    268     $options_html['onsubmit'] = remote_function($options).'; return false;'; 
     268    $options_html['onsubmit'] = remote_function($options).' return false;'; 
    269269    $options_html['action'] = isset($options_html['action']) ? $options_html['action'] : url_for($options['url']); 
    270270    $options_html['method'] = isset($options_html['method']) ? $options_html['method'] : 'post'; 
     
    288288 
    289289    $options_html['type'] = 'button'; 
    290     $options_html['onclick'] = remote_function($options).'; return false;'; 
     290    $options_html['onclick'] = remote_function($options).' return false;'; 
    291291    $options_html['name'] = $name; 
    292292    $options_html['value'] = $value; 
     
    447447    } 
    448448 
    449     return $function
     449    return $function.';'
    450450  } 
    451451 
  • branches/dwhittle/1.0/lib/helper/ObjectAdminHelper.php

    r6598 r8851  
    11<?php 
    22 
    3 use_helper('Form', 'Javascript', 'Helper'); 
     3use_helper('Form', 'Javascript', 'Helper', 'I18N'); 
    44 
    55/* 
  • branches/dwhittle/1.0/lib/helper/UrlHelper.php

    r8007 r8851  
    239239 * @see    url_for, link_to 
    240240 */ 
    241 function button_to($name, $internal_uri, $options = array()) 
    242 { 
    243   $html_options = _convert_options($options); 
     241function button_to($name, $internal_uri ='', $options = array()) 
     242{ 
     243  $html_options = _parse_attributes($options); 
    244244  $html_options['value'] = $name; 
    245245 
     
    256256    return form_tag($internal_uri, array('method' => 'post', 'class' => 'button_to')).content_tag('div', tag('input', $html_options)).'</form>'; 
    257257  } 
    258   else if (isset($html_options['popup'])) 
    259   { 
    260     $html_options['type'] = 'button'; 
    261     $html_options = _convert_options_to_javascript($html_options, $internal_uri); 
    262  
    263     return tag('input', $html_options); 
     258 
     259  $url = url_for($internal_uri); 
     260  if (isset($html_options['query_string'])) 
     261  { 
     262    $url = $url.'?'.$html_options['query_string']; 
     263    unset($html_options['query_string']); 
     264  } 
     265  $url = "'".$url."'"; 
     266  $html_options['type'] = 'button'; 
     267 
     268  if (isset($html_options['popup'])) 
     269  { 
     270    $html_options = _convert_options_to_javascript($html_options, $url); 
     271    unset($html_options['popup']); 
    264272  } 
    265273  else 
    266274  { 
    267     $html_options['type']    = 'button'; 
    268     $html_options['onclick'] = "document.location.href='".url_for($internal_uri)."';"; 
     275    $html_options['onclick'] = "document.location.href=".$url.";"; 
    269276    $html_options = _convert_options_to_javascript($html_options); 
    270  
    271     return tag('input', $html_options); 
    272   } 
     277  } 
     278 
     279  return tag('input', $html_options); 
    273280} 
    274281 
     
    333340} 
    334341 
    335 function _convert_options_to_javascript($html_options, $internal_uri = '') 
     342function _convert_options_to_javascript($html_options, $url = 'this.href') 
    336343{ 
    337344  // confirm 
     
    355362  else if ($confirm && $popup) 
    356363  { 
    357     $html_options['onclick'] = $onclick.'if ('._confirm_javascript_function($confirm).') { '._popup_javascript_function($popup, $internal_uri).' };return false;'; 
     364    $html_options['onclick'] = $onclick.'if ('._confirm_javascript_function($confirm).') { '._popup_javascript_function($popup, $url).' };return false;'; 
    358365  } 
    359366  else if ($confirm && $post) 
     
    378385  else if ($popup) 
    379386  { 
    380     $html_options['onclick'] = $onclick._popup_javascript_function($popup, $internal_uri).'return false;'; 
     387    $html_options['onclick'] = $onclick._popup_javascript_function($popup, $url).'return false;'; 
    381388  } 
    382389 
     
    389396} 
    390397 
    391 function _popup_javascript_function($popup, $internal_uri = '') 
    392 
    393   $url = $internal_uri == '' ? 'this.href' : "'".url_for($internal_uri)."'"; 
    394  
     398function _popup_javascript_function($popup, $url = '') 
     399
    395400  if (is_array($popup)) 
    396401  { 
  • branches/dwhittle/1.0/lib/helper/sfRichTextEditorFCK.class.php

    r6598 r8851  
    8787    $content = $fckeditor->CreateHtml(); 
    8888 
     89    //fix for http://trac.symfony-project.com/ticket/732 
     90    //fields need to be of type text to be picked up by fillin. they are hidden by inline css anyway: 
     91    //<input type="hidden" id="name" name="name" style="display:none" value="&lt;p&gt;default&lt;/p&gt;"> 
     92    $content = str_replace('type="hidden"','type="text"',$content); 
     93 
    8994    return $content; 
    9095  } 
  • branches/dwhittle/1.0/lib/helper/sfRichTextEditorTinyMCE.class.php

    r6598 r8851  
    4242    // we need to know the id for things the rich text editor 
    4343    // in advance of building the tag 
    44     $id = _get_option($options, 'id', $this->name); 
     44    $id = _get_option($options, 'id', get_id_from_name($this->name, null)); 
    4545 
    4646    // use tinymce's gzipped js? 
     
    110110    return 
    111111      content_tag('script', javascript_cdata_section($tinymce_js), array('type' => 'text/javascript')). 
    112       content_tag('textarea', $this->content, array_merge(array('name' => $this->name, 'id' => get_id_from_name($id, null)), _convert_options($options))); 
     112      content_tag('textarea', $this->content, array_merge(array('name' => $this->name, 'id' => $id), _convert_options($options))); 
    113113  } 
    114114} 
  • branches/dwhittle/1.0/lib/request/sfWebRequest.class.php

    r8486 r8851  
    758758 
    759759  /** 
    760    * Returns true id the request is a XMLHttpRequest (via prototype 'HTTP_X_REQUESTED_WITH' header). 
    761    * 
    762    * @return boolean 
     760   * Returns true if the request is a XMLHttpRequest. 
     761   * 
     762   * It works if your JavaScript library set an X-Requested-With HTTP header. 
     763   * Works with Prototype, Mootools, jQuery, and perhaps others. 
     764   * 
     765   * @return Boolean true if the request is an XMLHttpRequest, false otherwise 
    763766   */ 
    764767  public function isXmlHttpRequest() 
  • branches/dwhittle/1.0/test/unit/helper/FormHelperTest.php

    r6598 r8851  
    9494} 
    9595 
    96 $t = new lime_test(85, new lime_output_color()); 
     96$t = new lime_test(87, new lime_output_color()); 
    9797 
    9898$context = sfContext::getInstance(); 
     
    203203$t->like(textarea_tag('name', 'content', array('rich' => 'TinyMCE')), '/tinyMCE\.init/', 'textarea_tag() can create a rich textarea tag based on tinyMCE'); 
    204204$t->like(textarea_tag('name', 'content', array('rich' => true)), '/tinyMCE\.init/', 'textarea_tag() can create a rich textarea tag based on tinyMCE'); 
     205//regression for http://trac.symfony-project.com/ticket/3474 
     206$t->like(textarea_tag('name[]', 'content', array('rich' => true)), '/elements: "name",/', 'textarea_tag() can create a rich textarea tag based on tinyMCE using correct id'); 
     207$t->like(textarea_tag('name[]', 'content', array('rich' => true, 'id' => 'test')), '/elements: "test",/', 'textarea_tag() can create a rich textarea tag based on tinyMCE using correct id'); 
    205208 
    206209class sfRichTextEditorSample extends sfRichTextEditor 
  • branches/dwhittle/1.0/test/unit/helper/UrlHelperTest.php

    r7809 r8851  
    4343} 
    4444 
    45 $t = new lime_test(26, new lime_output_color()); 
     45$t = new lime_test(32, new lime_output_color()); 
    4646 
    4747$context = sfContext::getInstance(); 
     
    6161$t->is(link_to('test', '', array('query_string' => 'foo=bar')), '<a href="module/action?foo=bar">test</a>', 'link_to() can take an "query_string" option'); 
    6262$t->is(link_to(''), '<a href="module/action">module/action</a>', 'link_to() takes the url as the link name if the first argument is empty'); 
     63 
     64//button_to() 
     65$t->diag('button_to()'); 
     66$t->is(button_to('test'), '<input value="test" type="button" onclick="document.location.href=\'module/action\';" />', 'button_to() returns an HTML "input" tag'); 
     67$t->is(button_to('test','', array('query_string' => 'foo=bar')), '<input value="test" type="button" onclick="document.location.href=\'module/action?foo=bar\';" />', 'button_to() returns an HTML "input" tag'); 
     68$t->is(button_to('test','', array('popup' => 'true', 'query_string' => 'foo=bar')), '<input value="test" type="button" onclick="var w=window.open(\'module/action?foo=bar\');w.focus();return false;" />', 'button_to() returns an HTML "input" tag'); 
     69$t->is(button_to('test','', 'popup=true'), '<input value="test" type="button" onclick="var w=window.open(\'module/action\');w.focus();return false;" />', 'button_to() accepts options as string'); 
     70$t->is(button_to('test','', 'confirm=really?'), '<input value="test" type="button" onclick="if (confirm(\'really?\')) { return document.location.href=\'module/action\';} else return false;" />', 'button_to() works with confirm option'); 
     71$t->is(button_to('test','', 'popup=true confirm=really?'), '<input value="test" type="button" onclick="if (confirm(\'really?\')) { var w=window.open(\'module/action\');w.focus(); };return false;" />', 'button_to() works with confirm and popup option'); 
     72 
    6373class testObject 
    6474{ 
  • branches/dwhittle/1.1/lib/cache/sfAPCCache.class.php

    r6419 r8851  
    3030  public function initialize($options = array()) 
    3131  { 
    32     parent::initialize($options); 
    33  
    3432    if (!function_exists('apc_store') || !ini_get('apc.enabled')) 
    3533    { 
    3634      throw new sfInitializationException('You must have APC installed and enabled to use sfAPCCache class.'); 
    3735    } 
     36 
     37    parent::initialize($options); 
    3838  } 
    3939 
  • branches/dwhittle/1.1/lib/cache/sfMemcacheCache.class.php

    r6419 r8851  
    4141  public function initialize($options = array()) 
    4242  { 
     43    if (!class_exists('Memcache')) 
     44    { 
     45      throw new sfInitializationException('You must have memcache installed and enabled to use sfMemcacheCache class.'); 
     46    } 
     47 
    4348    parent::initialize($options); 
    44  
    45     if (!class_exists('Memcache')) 
    46     { 
    47       throw new sfInitializationException('You must have memcache installed and enabled to use sfMemcacheCache class.'); 
    48     } 
    4949 
    5050    if ($this->getOption('memcache')) 
  • branches/dwhittle/1.1/lib/cache/sfXCacheCache.class.php

    r6258 r8851  
    2626   * Available parameters: 
    2727   * 
    28    * * see sfCache for default parameters available for all drivers 
     28   * * see sfCache for default options available for all drivers 
    2929   * 
    3030   * @see sfCache 
    3131   */ 
    32   public function initialize($parameters = array()) 
     32  public function initialize($options = array()) 
    3333  { 
    34     parent::initialize($parameters); 
    35  
    3634    if (!function_exists('xcache_set')) 
    3735    { 
     
    3937    } 
    4038 
    41     $this->prefix = md5($this->getParameter('prefix', sfConfig::get('sf_app'))).self::SEPARATOR; 
     39    if (!ini_get('xcache.var_size')) 
     40    { 
     41      throw new sfInitializationException('You must set the "xcache.var_size" variable to a value greater than 0 to use sfXCacheCache class.'); 
     42    } 
     43 
     44    parent::initialize($options); 
    4245  } 
    4346 
  • branches/dwhittle/1.1/lib/helper/FormHelper.php

    r7775 r8851  
    231231 
    232232  $option_tags = options_for_select($countries, $selected, $options); 
    233  
    234233  unset($options['include_blank'], $options['include_custom']); 
    235234 
     
    280279 
    281280  $option_tags = options_for_select($languages, $selected, $options); 
    282  
    283281  unset($options['include_blank'], $options['include_custom']); 
    284282 
     
    669667  $jss = array( 
    670668    sfConfig::get('sf_calendar_web_dir').'/calendar', 
    671     sfConfig::get('sf_calendar_web_dir').'/lang/calendar-en', 
    672     $langFile, 
     669    is_readable(sfConfig::get('sf_symfony_data_dir').'/web/'.$langFile.'.js') || is_readable(sfConfig::get('sf_web_dir').'/'.$langFile.'.js') ? $langFile : sfConfig::get('sf_calendar_web_dir').'/lang/calendar-en', 
    673670    sfConfig::get('sf_calendar_web_dir').'/calendar-setup', 
    674671  ); 
  • branches/dwhittle/1.1/lib/helper/JavascriptHelper.php

    r8723 r8851  
    273273  $options_html = _parse_attributes($options_html); 
    274274 
     275 
    275276  $options['form'] = true; 
    276277 
    277   $options_html['onsubmit'] = remote_function($options).'; return false;'; 
     278  $options_html['onsubmit'] = remote_function($options).' return false;'; 
    278279  $options_html['action'] = isset($options_html['action']) ? $options_html['action'] : url_for($options['url']); 
    279280  $options_html['method'] = isset($options_html['method']) ? $options_html['method'] : 'post'; 
     
    297298 
    298299  $options_html['type'] = 'button'; 
    299   $options_html['onclick'] = remote_function($options).'; return false;'; 
     300  $options_html['onclick'] = remote_function($options).' return false;'; 
    300301  $options_html['name'] = $name; 
    301302  $options_html['value'] = $value; 
     
    319320 
    320321  $options_html['type'] = 'image'; 
    321   $options_html['onclick'] = remote_function($options).'; return false;'; 
     322  $options_html['onclick'] = remote_function($options).' return false;'; 
    322323  $options_html['name'] = $name; 
    323324  $options_html['src'] = image_path($source); 
     
    512513  } 
    513514 
    514   return $function
     515  return $function.';'
    515516} 
    516517 
     
    952953{ 
    953954  $javascript = "new Ajax.Autocompleter("; 
    954     if (isset($options['param_name']))  
     955    if (isset($options['param_name'])) 
    955956    { 
    956957      $js_options['paramName'] = "'".$options['param_name']."'"; 
  • branches/dwhittle/1.1/lib/helper/ObjectAdminHelper.php

    r8800 r8851  
    11<?php 
    22 
    3 use_helper('Form', 'Javascript', 'Helper'); 
     3use_helper('Form', 'Javascript', 'Helper', 'I18N'); 
    44 
    55/* 
     
    4242    if ($include_remove = _get_option($options, 'include_remove')) 
    4343    { 
    44       $html .= checkbox_tag(strpos($name, ']') !== false ? substr($name, 0, -1).'_remove]' : $name).' '.($include_remove != true ? __($include_remove) : __('remove file'))."\n"; 
     44      $html .= checkbox_tag(strpos($name, ']') !== false ? substr($name, 0, -1).'_remove]' : $name).' '.($include_remove !== true ? __($include_remove) : __('remove file'))."\n"; 
    4545    } 
    4646  } 
  • branches/dwhittle/1.1/lib/helper/UrlHelper.php

    r8467 r8851  
    6767 *  echo link_to('Delete this page', 'my_module/my_action'); 
    6868 *    => <a href="/path/to/my/action">Delete this page</a> 
    69  *  echo link_to('Visit Hoogle', 'http://www.hoogle.com'); 
    70  *    => <a href="http://www.hoogle.com">Visit Hoogle</a> 
     69 *  echo link_to('Visit google', 'http://www.google.com'); 
     70 *    => <a href="http://www.google.com">Visit google</a> 
    7171 *  echo link_to('Delete this page', 'my_module/my_action', array('id' => 'myid', 'confirm' => 'Are you sure?', 'absolute' => true)); 
    7272 *    => <a href="http://myapp.example.com/path/to/my/action" id="myid" onclick="return confirm('Are you sure?');">Delete this page</a> 
     
    232232 * @see    url_for, link_to 
    233233 */ 
    234 function button_to($name, $internal_uri, $options = array()) 
    235 
    236   $html_options = _convert_options($options); 
     234function button_to($name, $internal_uri ='', $options = array()) 
     235
     236  $html_options = _parse_attributes($options); 
     237 
    237238  $html_options['value'] = $name; 
    238239 
     
    271272    return form_tag($internal_uri, array('method' => 'post', 'class' => 'button_to')).content_tag('div', tag('input', $html_options)).'</form>'; 
    272273  } 
    273   else if (isset($html_options['popup'])) 
    274   { 
    275     $html_options['type'] = 'button'; 
    276     $html_options = _convert_options_to_javascript($html_options, $internal_uri, $absolute); 
    277  
    278     return tag('input', $html_options); 
     274 
     275  $url = url_for($internal_uri, $absolute); 
     276  $url = "'".$url.$query_string."'"; 
     277 
     278  $html_options['type'] = 'button'; 
     279  if (isset($html_options['popup'])) 
     280  { 
     281    $html_options = _convert_options_to_javascript($html_options, $url); 
     282    unset($html_options['popup']); 
    279283  } 
    280284  else 
    281285  { 
    282     $html_options['type']    = 'button'; 
    283     $html_options['onclick'] = "document.location.href='".url_for($internal_uri, $absolute).$query_string."';"; 
     286    $html_options['onclick'] = "document.location.href=".$url.";"; 
    284287    $html_options = _convert_options_to_javascript($html_options); 
    285  
    286     return tag('input', $html_options); 
    287   } 
     288  } 
     289 
     290  return tag('input', $html_options); 
    288291} 
    289292 
     
    348351} 
    349352 
    350 function _convert_options_to_javascript($html_options, $internal_uri = '', $absolute = false
     353function _convert_options_to_javascript($html_options, $url = 'this.href'
    351354{ 
    352355  // confirm 
     
    370373  else if ($confirm && $popup) 
    371374  { 
    372     $html_options['onclick'] = $onclick.'if ('._confirm_javascript_function($confirm).') { '._popup_javascript_function($popup, $internal_uri, $absolute).' };return false;'; 
     375    $html_options['onclick'] = $onclick.'if ('._confirm_javascript_function($confirm).') { '._popup_javascript_function($popup, $url).' };return false;'; 
    373376  } 
    374377  else if ($confirm && $post) 
     
    393396  else if ($popup) 
    394397  { 
    395     $html_options['onclick'] = $onclick._popup_javascript_function($popup, $internal_uri, $absolute).'return false;'; 
     398    $html_options['onclick'] = $onclick._popup_javascript_function($popup, $url).'return false;'; 
    396399  } 
    397400 
     
    404407} 
    405408 
    406 function _popup_javascript_function($popup, $internal_uri = '', $absolute = false) 
    407 
    408   $url = $internal_uri == '' ? 'this.href' : "'".url_for($internal_uri, $absolute)."'"; 
    409  
     409 
     410function _popup_javascript_function($popup, $url = '') 
     411
    410412  if (is_array($popup)) 
    411413  { 
  • branches/dwhittle/1.1/lib/helper/sfRichTextEditorFCK.class.php

    r7772 r8851  
    44 * This file is part of the symfony package. 
    55 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 
    6  *  
     6 * 
    77 * For the full copyright and license information, please view the LICENSE 
    88 * file that was distributed with this source code. 
     
    8787    $content = $fckeditor->CreateHtml(); 
    8888 
     89    //fix for http://trac.symfony-project.com/ticket/732 
     90    //fields need to be of type text to be picked up by fillin. they are hidden by inline css anyway: 
     91    //<input type="hidden" id="name" name="name" style="display:none" value="&lt;p&gt;default&lt;/p&gt;"> 
     92    $content = str_replace('type="hidden"','type="text"', $content); 
     93 
    8994    return $content; 
    9095  } 
  • branches/dwhittle/1.1/lib/helper/sfRichTextEditorTinyMCE.class.php

    r7772 r8851  
    4242    // we need to know the id for things the rich text editor 
    4343    // in advance of building the tag 
    44     $id = _get_option($options, 'id', $this->name); 
     44    $id = _get_option($options, 'id', get_id_from_name($this->name, null)); 
    4545 
    4646    // use tinymce's gzipped js? 
     
    110110    return 
    111111      content_tag('script', javascript_cdata_section($tinymce_js), array('type' => 'text/javascript')). 
    112       content_tag('textarea', $this->content, array_merge(array('name' => $this->name, 'id' => get_id_from_name($id, null)), _convert_options($options))); 
     112      content_tag('textarea', $this->content, array_merge(array('name' => $this->name, 'id' => $id), _convert_options($options))); 
    113113  } 
    114114} 
  • branches/dwhittle/1.1/lib/plugin/sfPearRestPlugin.class.php

    r5257 r8851  
    7373 
    7474  /** 
     75   * Returns the license for a given plugin and version. 
     76   * 
     77   * @param string The plugin name 
     78   * @param string The version 
     79   * 
     80   * @param string The license 
     81   */ 
     82  public function getPluginLicense($plugin, $version) 
     83  { 
     84    $info = $this->packageInfo($this->restBase, $plugin); 
     85 
     86    if (is_null($info)) 
     87    { 
     88      // plugin does not exist 
     89      return null; 
     90    } 
     91 
     92    if (!isset($info['license']) || is_null($info['license'])) 
     93    { 
     94      throw new Exception('No license found for this plugin!'); 
     95    } 
     96 
     97    return $info['releases'][$version]['license']; 
     98  } 
     99 
     100  /** 
    75101   * Gets the all available versions for a given plugin. 
    76102   * 
  • branches/dwhittle/1.1/lib/plugin/sfPluginManager.class.php

    r7671 r8851  
    413413 
    414414  /** 
     415   * Returns the license for a given plugin. 
     416   * 
     417   * @param string The plugin name 
     418   * @param array  An array of options 
     419   * 
     420   * @param string The license 
     421   * 
     422   * @see installPlugin() for available options 
     423   */ 
     424  public function getPluginLicense($plugin, $options = array()) 
     425  { 
     426    $channel   = isset($options['channel']) ? $options['channel'] : $this->environment->getConfig()->get('default_channel'); 
     427    $stability = isset($options['stability']) ? $options['stability'] : $this->environment->getConfig()->get('preferred_state', null, $channel); 
     428    $version   = isset($options['version']) ? $options['version'] : null; 
     429 
     430    $rest = $this->environment->getRest(); 
     431    $rest->setChannel(is_null($channel) ? $this->environment->getConfig()->get('default_channel') : $channel); 
     432 
     433    if (is_null($version)) 
     434    { 
     435      $version = $this->getPluginVersion($plugin, $stability); 
     436    } 
     437 
     438    return $rest->getPluginLicense($plugin, $version); 
     439  } 
     440 
     441  /** 
    415442   * Returns true if the plugin is comptatible with the dependency. 
    416443   * 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/actions/actions.class.php

    r8315 r8851  
    9191    try 
    9292    { 
    93       <?php echo $this->getClassName() ?>Peer::doDelete($this->selectedItems); 
     93      foreach (<?php echo $this->getClassName() ?>Peer::retrieveByPks($this->selectedItems) as $object) 
     94      { 
     95        $object->delete(); 
     96      } 
    9497    } 
    9598    catch (PropelException $e) 
     
    468471    if ($sort_column = $this->getUser()->getAttribute('sort', null, 'sf_admin/<?php echo $this->getSingularName() ?>/sort')) 
    469472    { 
    470  
    471       $sort_column = sfInflector::camelize(strtolower($sort_column)); 
    472       $sort_column = <?php echo $this->getClassName() ?>Peer::translateFieldName($sort_column, BasePeer::TYPE_PHPNAME, BasePeer::TYPE_COLNAME); 
     473      // camelize lower case to be able to compare with BasePeer::TYPE_PHPNAME translate field name 
     474      $sort_column = <?php echo $this->getClassName() ?>Peer::translateFieldName(sfInflector::camelize(strtolower($sort_column)), BasePeer::TYPE_PHPNAME, BasePeer::TYPE_COLNAME); 
     475 
    473476      if ($this->getUser()->getAttribute('type', null, 'sf_admin/<?php echo $this->getSingularName() ?>/sort') == 'asc') 
    474477      { 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/data/generator/sfPropelForm/default/template/sfPropelFormGeneratedTemplate.php

    r8511 r8851  
    3333    )); 
    3434 
     35<?php if ($uniqueColumns = $this->getUniqueColumnNames()): ?> 
     36    $this->validatorSchema->setPostValidator( 
     37<?php if (count($uniqueColumns) > 1): ?> 
     38      new sfValidatorAnd(array( 
     39<?php foreach ($uniqueColumns as $uniqueColumn): ?> 
     40        new sfValidatorPropelUnique(array('model' => '<?php echo $this->table->getPhpName() ?>', 'column' => array('<?php echo strtolower(implode("', '", $uniqueColumn)) ?>'))), 
     41<?php endforeach; ?> 
     42      )) 
     43<?php else: ?> 
     44      new sfValidatorPropelUnique(array('model' => '<?php echo $this->table->getPhpName() ?>', 'column' => array('<?php echo strtolower(implode("', '", $uniqueColumns[0])) ?>'))) 
     45<?php endif; ?> 
     46    ); 
     47 
     48<?php endif; ?> 
    3549    $this->widgetSchema->setNameFormat('<?php echo $this->underscore($this->table->getPhpName()) ?>[%s]'); 
    3650 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/addon/sfPropelDatabaseSchema.class.php

    r8630 r8851  
    148148                  $classes[$phpName]['behaviors'] = $column_params; 
    149149                  break; 
     150                case '_inheritance': 
     151                  $classes[$phpName]['inheritance'] = $column_params; 
     152                  break; 
    150153                case '_foreignKeys': 
    151154                  $classes[$phpName]['foreignKeys'] = $column_params; 
     
    233236        } 
    234237 
     238        // Inheritance 
     239        if (isset($classParams['inheritance'])) 
     240        { 
     241          $tableParams['_inheritance'] = $classParams['inheritance']; 
     242          unset($classParams['inheritance']); 
     243        } 
     244 
    235245        // Table attributes 
    236246        $tableAttributes = array(); 
     
    294304      foreach ($this->getChildren($table) as $col_name => $column) 
    295305      { 
     306        // inheritance 
     307        if (isset($table['_inheritance']) && 
     308            isset($table['_inheritance']['column']) && 
     309            $col_name == $table['_inheritance']['column'] && 
     310            isset($table['_inheritance']['classes']) && 
     311            is_array($table['_inheritance']['classes'])) 
     312        { 
     313          $column['inheritance'] = $table['_inheritance']['classes']; 
     314          unset($table['_inheritance']); 
     315        } 
     316 
    296317        $xml .= "    <column name=\"$col_name\"".$this->getAttributesForColumn($tb_name, $col_name, $column); 
    297318      } 
     
    612633      foreach ($column as $key => $value) 
    613634      { 
    614         if (!in_array($key, array('foreignClass', 'foreignTable', 'foreignReference', 'onDelete', 'onUpdate', 'index', 'unique', 'sequence'))) 
     635        if (!in_array($key, array('foreignClass', 'foreignTable', 'foreignReference', 'onDelete', 'onUpdate', 'index', 'unique', 'sequence', 'inheritance'))) 
    615636        { 
    616637          $attributes_string .= " $key=\"".htmlspecialchars($this->getCorrectValueFor($key, $value), ENT_QUOTES, sfConfig::get('sf_charset'))."\""; 
    617638        } 
    618639      } 
    619       $attributes_string .= " />\n"; 
     640      if (isset($column['inheritance'])) 
     641      { 
     642        $attributes_string .= ' inheritance="single">'."\n"; 
     643 
     644        $extended_package = isset($this->database[$tb_name]['_attributes']['package']) ? 
     645          $this->database[$tb_name]['_attributes']['package'] : 
     646          $this->database['_attributes']['package']; 
     647        $extended_class = $this->database[$tb_name]['_attributes']['phpName']; 
     648 
     649        foreach ($column['inheritance'] as $key => $class) 
     650        { 
     651          $attributes_string .= sprintf('      <inheritance extends="%s.%s" key="%s" class="%s" />%s', 
     652            $extended_package, $extended_class, $key, $class, "\n"); 
     653        } 
     654        $attributes_string .= '    </column>'."\n"; 
     655      } 
     656      else 
     657      { 
     658        $attributes_string .= " />\n"; 
     659      } 
    620660    } 
    621661    else 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/builder/SfPeerBuilder.php

    r7497 r8851  
    5656      $this->addI18nMethods($script); 
    5757    } 
     58 
     59    $this->addUniqueColumnNamesMethod($script); 
    5860  } 
    5961 
     
    411413    } 
    412414  } 
     415 
     416  protected function addUniqueColumnNamesMethod(&$script) 
     417  { 
     418    $unices = array(); 
     419    foreach ($this->getTable()->getUnices() as $unique) 
     420    { 
     421      $unices[] = sprintf("array('%s')", implode("', '", $unique->getColumns())); 
     422    } 
     423 
     424    $unices = implode(', ', $unices); 
     425    $script .= <<<EOF 
     426 
     427 
     428  static public function getUniqueColumnNames() 
     429  { 
     430    return array($unices); 
     431  } 
     432EOF; 
     433  } 
    413434} 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/form/sfFormPropel.class.php

    r7853 r8851  
    6565  { 
    6666    return Propel::getConnection(constant(sprintf('%s::DATABASE_NAME', get_class($this->object->getPeer())))); 
    67     return Propel::getConnection(constant(sprintf('%s::DATABASE_NAME', get_class($this->object->getPeer())))); 
    6867  } 
    6968 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php

    r8800 r8851  
    1515 * 
    1616 * @package    symfony 
    17  * @subpackage propel 
     17 * @subpackage generator 
    1818 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
    1919 * @version    SVN: $Id$ 
     
    6767 
    6868    // create the project base class for all forms 
    69     $file = sfConfig::get('sf_lib_dir').DIRECTORY_SEPARATOR.'form'.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR.'BaseFormPropel.class.php'; 
     69    $file = sfConfig::get('sf_lib_dir').'/form/base/BaseFormPropel.class.php'; 
    7070    if (!file_exists($file)) 
    7171    { 
    72       if (!is_dir(sfConfig::get('sf_lib_dir').DIRECTORY_SEPARATOR.'form'.DIRECTORY_SEPARATOR.'base')) 
    73       { 
    74         mkdir(sfConfig::get('sf_lib_dir').DIRECTORY_SEPARATOR.'form'.DIRECTORY_SEPARATOR.'base', 0777, true);