ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Ignore:
Timestamp:
Jan 7, 2009, 9:50:04 PM (12 years ago)
Author:
ebihara
Message:

#3324:changed the SnsConfigForm? class to comformity the OpenPNEFormAutoGenerate class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/lib/form/SnsConfigForm.class.php

    r10025 r10030  
    1212 * SnsConfig form.
    1313 *
    14  * @package    form
    15  * @subpackage sns_config
     14 * @package    OpenPNE
     15 * @subpackage form
    1616 * @author     Kousuke Ebihara <ebihara@tejimaya.com>
    1717 */
    18 class SnsConfigForm extends sfForm
     18class SnsConfigForm extends OpenPNEFormAutoGenerate
    1919{
    2020  public function configure()
    2121  {
    22     $widgets = array();
    23     $validators = array();
    24     $labels = array();
    25     $defaults = array();
    26 
    2722    foreach (sfConfig::get('openpne_sns_config') as $key => $value)
    2823    {
    29       $widgets[$key] = $this->generateWidget($value);
    30       $validators[$key] = $this->generateValidator($value);
    31       $labels[$key] = $value['caption'];
    32       $defaults[$key] = opConfig::get($key);
     24      $this->setWidget($key, $this->generateWidget($value));
     25      $this->setValidator($key, $this->generateValidator($value));
     26      $this->widgetSchema->setLabel($key, $value['Caption']);
     27      $this->setDefault($key, opConfig::get($key));
    3328    }
    3429
    35     $this->setWidgets($widgets);
    36     $this->setValidators($validators);
    37     $this->widgetSchema->setLabels($labels);
    38     $this->setDefaults($defaults);
    39 
    4030    $this->widgetSchema->setNameFormat('sns_config[%s]');
    41   }
    42 
    43   public function generateWidget($config)
    44   {
    45     switch ($config['type']) {
    46       case 'select':
    47         $obj = new sfWidgetFormSelect(array('choices' => $this->generateChoices($config['choices_type'])));
    48         break;
    49       case 'selectMany':
    50         $obj = new sfWidgetFormSelectMany(array('choices' => $this->generateChoices($config['choices_type'])));
    51         break;
    52       case 'input':
    53       default:
    54         $obj = new sfWidgetFormInput();
    55     }
    56 
    57     return $obj;
    58   }
    59 
    60   public function generateValidator($config)
    61   {
    62     switch ($config['type']) {
    63       case 'select':
    64       case 'selectMany':
    65         $obj = new sfValidatorChoiceMany(array('choices' => $this->generateChoices($config['choices_type'])));
    66         break;
    67       case 'input':
    68       default:
    69         $obj = new sfValidatorString(array_merge($config['option'], array('trim' => true)));
    70     }
    71 
    72     return $obj;
    7331  }
    7432
     
    7634  {
    7735    $config = sfConfig::get('openpne_sns_config');
    78     foreach ($this->getValues() as $key => $value) {
     36    foreach ($this->getValues() as $key => $value)
     37    {
    7938      $snsConfig = SnsConfigPeer::retrieveByName($key);
    80       if (!$snsConfig) {
     39      if (!$snsConfig)
     40      {
    8141        $snsConfig = new SnsConfig();
    8242        $snsConfig->setName($key);
    8343      }
    84 
    8544      $snsConfig->setValue($value);
    8645      $snsConfig->save();
    8746    }
    8847  }
    89 
    90   public function generateChoices($mode)
    91   {
    92   }
    9348}
Note: See TracChangeset for help on using the changeset viewer.