public function configure()
  {
    parent::configure();

    $user = $this->getOption('user', null);
    
    if ($user && $user->isAuthenticated()) {
      $this->useFields(array('id', 'author_name', 'author_email', 'author_url', 'content', 'sf_comment_id', 'user_id'));
      
      $this->widgetSchema['author_name'] = new sfWidgetFormInputHidden();
      $this->widgetSchema['author_email'] = new sfWidgetFormInputHidden();
      $this->widgetSchema['author_url'] = new sfWidgetFormInputHidden();
      $this->widgetSchema['user_id'] = new sfWidgetFormInputHidden();
    } else {
      $this->useFields(array('id', 'author_name', 'author_email', 'author_url', 'content', 'sf_comment_id'));

      $this->widgetSchema['author_name']->setLabel('Name (required)');
      $this->widgetSchema['author_email']->setLabel('Mail (required) (will not be published)');
      $this->widgetSchema['author_url']->setLabel('Website');
    }
    
    $this->validatorSchema['author_name'] = new sfValidatorString(array('required' => true));
    $this->validatorSchema['author_email'] = new sfValidatorEmail(array('required' => true));
    $this->validatorSchema['author_url'] = new sfValidatorUrl(array('required' => false));
    $this->validatorSchema['content'] = new sfValidatorString(array('required' => true));
    
    $this->widgetSchema['content']->setAttributes(array('rows' => 10, 'class' => 'resizable'));
    $this->widgetSchema['content']->setLabel('Comment (required)');
    if ($allowedTags = sfNestedCommentConfig::getAllowedTags())
    {
      $this->widgetSchema->setHelp('content', 'You may use these HTML tags and attributes: '.htmlentities(implode(' ', $allowedTags)));
    }

    $this->widgetSchema['commentable_model'] = new sfWidgetFormInputHidden();
    $this->widgetSchema['commentable_id'] = new sfWidgetFormInputHidden();
    $this->validatorSchema['commentable_model'] = new sfValidatorString();
    $this->validatorSchema['commentable_id'] = new sfValidatorInteger();

    if (sfNestedCommentConfig::isRecaptchaEnabled())
    {
      $this->widgetSchema['captcha'] = new sfWidgetFormReCaptcha(array(
        'public_key' => sfConfig::get('app_recaptcha_public_key')
      ));

      $this->validatorSchema['captcha'] = new sfValidatorReCaptcha(array(
        'private_key' => sfConfig::get('app_recaptcha_private_key')
      ));
    }
    
    $this->validatorSchema->setOption('allow_extra_fields', true);
    $this->validatorSchema->setOption('filter_extra_fields', true);

    $this->getWidgetSchema()->setFormFormatterName('comment');
  }
  static public function clean($text)
  {
    $allowed_html_tags = sfNestedCommentConfig::getAllowedTags();
    $config = HTMLPurifier_Config::createDefault();
    $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
    $config->set('HTML.Allowed', implode(',', array_keys($allowed_html_tags)));

    if (isset($allowed_html_tags['a']))
    {
      $config->set('HTML.AllowedAttributes', 'a.href');
      $config->set('AutoFormat.Linkify', true);
    }

    if (isset($allowed_html_tags['p']))
    {
      $config->set('AutoFormat.AutoParagraph', true);
    }

    $purifier = new HTMLPurifier($config);
    return str_replace('<a href', '<a rel="nofollow" href', $purifier->purify($text));
  }