Development

Changeset 5999

You must first sign up to be able to contribute.

Changeset 5999

Show
Ignore:
Timestamp:
11/13/07 19:58:52 (1 year ago)
Author:
dwhittle
Message:

dwhittle: merged trunk changes to branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dwhittle/lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/templates/_filters.php

    r5248 r5999  
    1313<?php endif; ?> 
    1414    <div class="form-row"> 
    15     <label for="<?php echo $column->getName() ?>">[?php echo __('<?php echo str_replace("'", "\\'", $this->getParameterValue('list.fields.'.$column->getName().'.name')) ?>:') ?]</label> 
     15    <label for="filters_<?php echo $column->getName() ?>">[?php echo __('<?php echo str_replace("'", "\\'", $this->getParameterValue('list.fields.'.$column->getName().'.name')) ?>:') ?]</label> 
    1616    <div class="content"> 
    1717    [?php echo <?php echo $this->getColumnFilterTag($column) ?> ?] 
    1818<?php if ($this->getParameterValue('list.fields.'.$column->getName().'.filter_is_empty')): ?> 
    19     <div>[?php echo checkbox_tag('filters[<?php echo $column->getName() ?>_is_empty]', 1, isset($filters['<?php echo $column->getName() ?>_is_empty']) ? $filters['<?php echo $column->getName() ?>_is_empty'] : null) ?]&nbsp;<label for="filters[<?php echo $column->getName() ?>_is_empty]">[?php echo __('is empty') ?]</label></div> 
     19    <div>[?php echo checkbox_tag('filters[<?php echo $column->getName() ?>_is_empty]', 1, isset($filters['<?php echo $column->getName() ?>_is_empty']) ? $filters['<?php echo $column->getName() ?>_is_empty'] : null) ?]&nbsp;<label for="filters_<?php echo $column->getName() ?>_is_empty">[?php echo __('is empty') ?]</label></div> 
    2020<?php endif; ?> 
    2121    </div> 
  • branches/dwhittle/lib/plugins/sfPropelPlugin/test/functional/filterTest.php

    r5125 r5999  
    2424$b-> 
    2525  checkListCustomization('filters', array('filters' => array('title', 'body', 'online', 'category_id', 'created_at')))-> 
    26   checkResponseElement('div.sf_admin_filters label[for="title"]', 'Title:')-> 
     26  checkResponseElement('div.sf_admin_filters label[for="filters_title"]', 'Title:')-> 
    2727  checkResponseElement('div.sf_admin_filters input[name="filters[title]"][id="filters_title"]')-> 
    28   checkResponseElement('div.sf_admin_filters label[for="body"]', 'Body:')-> 
     28  checkResponseElement('div.sf_admin_filters label[for="filters_body"]', 'Body:')-> 
    2929  checkResponseElement('div.sf_admin_filters input[name="filters[body]"][id="filters_body"]')-> 
    30   checkResponseElement('div.sf_admin_filters label[for="online"]', 'Online:')-> 
     30  checkResponseElement('div.sf_admin_filters label[for="filters_online"]', 'Online:')-> 
    3131  checkResponseElement('div.sf_admin_filters select[name="filters[online]"][id="filters_online"] option', 3)-> 
    32   checkResponseElement('div.sf_admin_filters label[for="category_id"]', 'Category:')-> 
     32  checkResponseElement('div.sf_admin_filters label[for="filters_category_id"]', 'Category:')-> 
    3333  checkResponseElement('div.sf_admin_filters select[name="filters[category_id]"][id="filters_category_id"] option', 3)-> 
    34   checkResponseElement('div.sf_admin_filters label[for="created_at"]', 'Created at:')-> 
     34  checkResponseElement('div.sf_admin_filters label[for="filters_created_at"]', 'Created at:')-> 
    3535  checkResponseElement('div.sf_admin_filters input[name="filters[created_at][from]"][id="filters_created_at_from"]')-> 
    3636  checkResponseElement('div.sf_admin_filters input[name="filters[created_at][to]"][id="filters_created_at_to"]') 
     
    3939$b-> 
    4040  checkListCustomization('filters', array('filters' => array('title'), 'fields' => array('title' => array('filter_is_empty' => true))))-> 
    41   checkResponseElement('div.sf_admin_filters label[for="filters[title_is_empty]"]') 
     41  checkResponseElement('div.sf_admin_filters label[for="filters_title_is_empty"]') 
    4242; 
  • branches/dwhittle/lib/widget/sfWidgetFormSchema.class.php

    r5943 r5999  
    3232    $labels         = array(), 
    3333    $fields         = array(), 
    34     $positions      = array(); 
     34    $positions      = array(), 
     35    $helps          = array(); 
    3536 
    3637  /** 
     
    5152   * @param array An array of options 
    5253   * @param array An array of HTML labels 
     54   * @param array An array of help texts 
    5355   * 
    5456   * @see sfWidgetForm 
    5557   */ 
    56   public function __construct($fields = null, $options = array(), $attributes = array(), $labels = array()
     58  public function __construct($fields = null, $options = array(), $attributes = array(), $labels = array(), $helps = array()
    5759  { 
    5860    if (is_array($fields)) 
     
    186188   * 
    187189   * @param string The field name 
    188    * @param strgin The label name 
     190   * @param string The label name 
    189191   */ 
    190192  public function setLabel($name, $value) 
     
    203205  { 
    204206    return array_key_exists($name, $this->labels) ? $this->labels[$name] : ''; 
     207  } 
     208 
     209  /** 
     210   * Sets the help texts to render for each field. 
     211   * 
     212   * @param array An array of help texts 
     213   */ 
     214  public function setHelps($helps) 
     215  { 
     216    $this->helps = $helps; 
     217  } 
     218 
     219  /** 
     220   * Sets the help texts. 
     221   * 
     222   * @return array An array of help texts 
     223   */ 
     224  public function getHelps() 
     225  { 
     226    return $this->helps; 
     227  } 
     228 
     229  /** 
     230   * Sets a help text. 
     231   * 
     232   * @param string The field name 
     233   * @param string The help text 
     234   */ 
     235  public function setHelp($name, $help) 
     236  { 
     237    $this->helps[$name] = $help; 
     238  } 
     239 
     240  /** 
     241   * Gets a text help by field name. 
     242   * 
     243   * @param  string The field name 
     244   * 
     245   * @return string The help text or an empty string if it is not defined 
     246   */ 
     247  public function getHelp($name) 
     248  { 
     249    return array_key_exists($name, $this->helps) ? $this->helps[$name] : ''; 
    205250  } 
    206251 
     
    309354        $error = $widget instanceof sfWidgetFormSchema ? array() : $error; 
    310355 
    311         $rows[] = $formFormat->formatRow($label, $field, $error); 
     356        $rows[] = $formFormat->formatRow($label, $field, $error, $this->getHelp($name)); 
    312357      } 
    313358    } 
  • branches/dwhittle/lib/widget/sfWidgetFormSchemaFormatter.class.php

    r5943 r5999  
    1010 
    1111/** 
    12  *  
     12 * sfWidgetFormSchemaFormatter allows to format a form schema with HTML formats. 
    1313 * 
    1414 * @package    symfony 
     
    2121  protected 
    2222    $rowFormat                 = '', 
     23    $helpFormat                = '%help%', 
    2324    $errorRowFormat            = '', 
    2425    $errorListFormatInARow     = "  <ul class=\"error_list\">\n%errors%  </ul>\n", 
     
    3334      '%field%'         => $field, 
    3435      '%error%'         => $this->formatErrorsForRow($errors), 
    35       '%help%'          => $help
     36      '%help%'          => $this->formatHelp($help)
    3637      '%hidden_fields%' => is_null($hiddenFields) ? '%hidden_fields%' : $hiddenFields, 
    3738    )); 
     39  } 
     40 
     41  public function formatHelp($help) 
     42  { 
     43    if (!$help) 
     44    { 
     45      return ''; 
     46    } 
     47 
     48    return strtr($this->getHelpFormat(), array('%help%' => $help)); 
    3849  } 
    3950 
     
    150161    return $this->decoratorFormat; 
    151162  } 
     163 
     164  public function setHelpFormat($format) 
     165  { 
     166    $this->helpFormat = $format; 
     167  } 
     168 
     169  public function getHelpFormat() 
     170  { 
     171    return $this->helpFormat; 
     172  } 
    152173} 
  • branches/dwhittle/lib/widget/sfWidgetFormSchemaFormatterList.class.php

    r5943 r5999  
    2222    $rowFormat       = "<li>\n  %error%%label%\n  %field%%help%\n%hidden_fields%</li>\n", 
    2323    $errorRowFormat  = "<li>\n%errors%</li>\n", 
     24    $helpFormat      = '<br />%help%', 
    2425    $decoratorFormat = "<ul>\n  %content%</ul>"; 
    2526} 
  • branches/dwhittle/lib/widget/sfWidgetFormSchemaFormatterTable.class.php

    r5943 r5999  
    2222    $rowFormat       = "<tr>\n  <th>%label%</th>\n  <td>%error%%field%%help%%hidden_fields%</td>\n</tr>\n", 
    2323    $errorRowFormat  = "<tr><td colspan=\"2\">\n%errors%</td></tr>\n", 
     24    $helpFormat      = '<br />%help%', 
    2425    $decoratorFormat = "<table>\n  %content%</table>"; 
    2526} 
  • branches/dwhittle/test/unit/widget/sfWidgetFormSchemaFormatterListTest.php

    r5943 r5999  
    2020<li> 
    2121  label 
    22   <input />help 
     22  <input /><br />help 
    2323</li> 
    2424 
  • branches/dwhittle/test/unit/widget/sfWidgetFormSchemaFormatterTableTest.php

    r5943 r5999  
    2020<tr> 
    2121  <th>label</th> 
    22   <td><input />help</td> 
     22  <td><input /><br />help</td> 
    2323</tr> 
    2424 
  • branches/dwhittle/test/unit/widget/sfWidgetFormSchemaTest.php

    r5943 r5999  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(48, new lime_output_color()); 
     13$t = new lime_test(50, new lime_output_color()); 
    1414 
    1515$w1 = new sfWidgetFormInput(array(), array('class' => 'foo1')); 
     
    118118$t->is($w->generateLabelName('first_name'), 'A first name', '->setLabel() sets a label value'); 
    119119$t->is($w->getLabels(), array('first_name' => 'A first name'), '->getLabels() returns all current labels'); 
     120 
     121// ->setHelps() ->getHelps() ->setHelp() ->getHelp() 
     122$t->diag('->setHelps() ->getHelps() ->setHelp() ->getHelp()'); 
     123$w = new sfWidgetFormSchema(); 
     124$w->setHelps(array('first_name', 'Please, provide your first name')); 
     125$t->is($w->getHelps(), array('first_name', 'Please, provide your first name'), '->setHelps() changes all help messages'); 
     126$w->setHelp('last_name', 'Please, provide your last name'); 
     127$t->is($w->getHelp('last_name'), 'Please, provide your last name', '->setHelp() changes one help message'); 
    120128 
    121129// ->generateLabel()