Development

#3369: sfSimpleBlog.patch

You must first sign up to be able to contribute.

Ticket #3369: sfSimpleBlog.patch

File sfSimpleBlog.patch, 28.5 kB (added by Tero.Alen, 3 months ago)

Patch for use sfSimpleBlog without compat10 module enabled

  • a/plugins/sfSimpleBlogPlugin/config/schema.yml

    old new  
    11propel: 
    22  _attributes:       { package: plugins.sfSimpleBlogPlugin.lib.model } 
    3    
     3 
    44  sf_blog_post: 
    55    _attributes:     { phpName: sfSimpleBlogPost } 
    66    id:              ~ 
     
    1515    published_at:    { type: date } 
    1616    _uniques: 
    1717      stripped_title_published_at:  [stripped_title, published_at] 
    18      
     18 
    1919  sf_blog_comment: 
    2020    _attributes:     { phpName: sfSimpleBlogComment } 
    2121    id:              ~ 
    2222    sf_blog_post_id: { type: integer, foreignTable: sf_blog_post, foreignReference: id, onDelete: cascade } 
    23     author_name:     varchar(255) 
    24     author_email:    varchar(255) 
     23    author_name:     { type: varchar, size:255, required: true } 
     24    author_email:    { type: varchar, size:255, required: true } 
    2525    author_url:      varchar(255) 
    26     content:         longvarchar 
     26    content:         { type: longvarchar, required: true } 
    2727    is_moderated:    { type: boolean, default: false } 
    2828    created_at:      ~ 
    29      
     29 
    3030  sf_blog_tag: 
    3131    _attributes:     { phpName: sfSimpleBlogTag } 
    3232    sf_blog_post_id: { type: integer, primaryKey: true, foreignTable: sf_blog_post, foreignReference: id, onDelete: cascade } 
  • /dev/null

    old new  
     1<?php 
     2 
     3/** 
     4 * sfSimpleBlogComment form base class. 
     5 * 
     6 * @package    form 
     7 * @subpackage sf_simple_blog_comment 
     8 * @version    SVN: $Id: sfPropelFormGeneratedTemplate.php 8807 2008-05-06 14:12:28Z fabien $ 
     9 */ 
     10class BasesfSimpleBlogCommentForm extends BaseFormPropel 
     11{ 
     12  public function setup() 
     13  { 
     14    $this->setWidgets(array( 
     15      'id'              => new sfWidgetFormInputHidden(), 
     16      'sf_blog_post_id' => new sfWidgetFormPropelSelect(array('model' => 'sfSimpleBlogPost', 'add_empty' => true)), 
     17      'author_name'     => new sfWidgetFormInput(), 
     18      'author_email'    => new sfWidgetFormInput(), 
     19      'author_url'      => new sfWidgetFormInput(), 
     20      'content'         => new sfWidgetFormTextarea(), 
     21      'is_moderated'    => new sfWidgetFormInputCheckbox(), 
     22      'created_at'      => new sfWidgetFormDateTime(), 
     23    )); 
     24 
     25    $this->setValidators(array( 
     26      'id'              => new sfValidatorPropelChoice(array('model' => 'sfSimpleBlogComment', 'column' => 'id', 'required' => false)), 
     27      'sf_blog_post_id' => new sfValidatorPropelChoice(array('model' => 'sfSimpleBlogPost', 'column' => 'id', 'required' => false)), 
     28      'author_name'     => new sfValidatorString(array('max_length' => 255)), 
     29      'author_email'    => new sfValidatorString(array('max_length' => 255)), 
     30      'author_url'      => new sfValidatorString(array('max_length' => 255, 'required' => false)), 
     31      'content'         => new sfValidatorString(), 
     32      'is_moderated'    => new sfValidatorBoolean(array('required' => false)), 
     33      'created_at'      => new sfValidatorDateTime(array('required' => false)), 
     34    )); 
     35 
     36    $this->widgetSchema->setNameFormat('sf_simple_blog_comment[%s]'); 
     37 
     38    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); 
     39 
     40    parent::setup(); 
     41  } 
     42 
     43  public function getModelName() 
     44  { 
     45    return 'sfSimpleBlogComment'; 
     46  } 
     47 
     48 
     49} 
  • /dev/null

    old new  
     1<?php 
     2 
     3/** 
     4 * sfSimpleBlogPost form base class. 
     5 * 
     6 * @package    form 
     7 * @subpackage sf_simple_blog_post 
     8 * @version    SVN: $Id: sfPropelFormGeneratedTemplate.php 8807 2008-05-06 14:12:28Z fabien $ 
     9 */ 
     10class BasesfSimpleBlogPostForm extends BaseFormPropel 
     11{ 
     12  public function setup() 
     13  { 
     14    $this->setWidgets(array( 
     15      'id'             => new sfWidgetFormInputHidden(), 
     16      'author_id'      => new sfWidgetFormPropelSelect(array('model' => 'sfGuardUser', 'add_empty' => true)), 
     17      'title'          => new sfWidgetFormInput(), 
     18      'stripped_title' => new sfWidgetFormInput(), 
     19      'extract'        => new sfWidgetFormTextarea(), 
     20      'content'        => new sfWidgetFormTextarea(), 
     21      'is_published'   => new sfWidgetFormInputCheckbox(), 
     22      'allow_comments' => new sfWidgetFormInputCheckbox(), 
     23      'created_at'     => new sfWidgetFormDateTime(), 
     24      'published_at'   => new sfWidgetFormDate(), 
     25    )); 
     26 
     27    $this->setValidators(array( 
     28      'id'             => new sfValidatorPropelChoice(array('model' => 'sfSimpleBlogPost', 'column' => 'id', 'required' => false)), 
     29      'author_id'      => new sfValidatorPropelChoice(array('model' => 'sfGuardUser', 'column' => 'id', 'required' => false)), 
     30      'title'          => new sfValidatorString(array('max_length' => 255, 'required' => false)), 
     31      'stripped_title' => new sfValidatorString(array('max_length' => 255, 'required' => false)), 
     32      'extract'        => new sfValidatorString(array('required' => false)), 
     33      'content'        => new sfValidatorString(array('required' => false)), 
     34      'is_published'   => new sfValidatorBoolean(array('required' => false)), 
     35      'allow_comments' => new sfValidatorBoolean(array('required' => false)), 
     36      'created_at'     => new sfValidatorDateTime(array('required' => false)), 
     37      'published_at'   => new sfValidatorDate(array('required' => false)), 
     38    )); 
     39 
     40    $this->validatorSchema->setPostValidator( 
     41      new sfValidatorPropelUnique(array('model' => 'sfSimpleBlogPost', 'column' => array('stripped_title', 'published_at'))) 
     42    ); 
     43 
     44    $this->widgetSchema->setNameFormat('sf_simple_blog_post[%s]'); 
     45 
     46    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); 
     47 
     48    parent::setup(); 
     49  } 
     50 
     51  public function getModelName() 
     52  { 
     53    return 'sfSimpleBlogPost'; 
     54  } 
     55 
     56 
     57} 
  • /dev/null

    old new  
     1<?php 
     2 
     3/** 
     4 * sfSimpleBlogTag form base class. 
     5 * 
     6 * @package    form 
     7 * @subpackage sf_simple_blog_tag 
     8 * @version    SVN: $Id: sfPropelFormGeneratedTemplate.php 8807 2008-05-06 14:12:28Z fabien $ 
     9 */ 
     10class BasesfSimpleBlogTagForm extends BaseFormPropel 
     11{ 
     12  public function setup() 
     13  { 
     14    $this->setWidgets(array( 
     15      'sf_blog_post_id' => new sfWidgetFormInputHidden(), 
     16      'tag'             => new sfWidgetFormInputHidden(), 
     17      'created_at'      => new sfWidgetFormDateTime(), 
     18    )); 
     19 
     20    $this->setValidators(array( 
     21      'sf_blog_post_id' => new sfValidatorPropelChoice(array('model' => 'sfSimpleBlogPost', 'column' => 'id', 'required' => false)), 
     22      'tag'             => new sfValidatorPropelChoice(array('model' => 'sfSimpleBlogTag', 'column' => 'tag', 'required' => false)), 
     23      'created_at'      => new sfValidatorDateTime(array('required' => false)), 
     24    )); 
     25 
     26    $this->widgetSchema->setNameFormat('sf_simple_blog_tag[%s]'); 
     27 
     28    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); 
     29 
     30    parent::setup(); 
     31  } 
     32 
     33  public function getModelName() 
     34  { 
     35    return 'sfSimpleBlogTag'; 
     36  } 
     37 
     38 
     39} 
  • /dev/null

    old new  
     1<?php 
     2 
     3/** 
     4 * sfSimpleBlogComment form. 
     5 * 
     6 * @package    form 
     7 * @subpackage sf_blog_comment 
     8 * @version    SVN: $Id: sfPropelFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $ 
     9 */ 
     10class sfSimpleBlogCommentForm extends BasesfSimpleBlogCommentForm 
     11{ 
     12  public function configure() 
     13  { 
     14    unset($this->widgetSchema['sf_blog_post_id']); 
     15    unset($this->widgetSchema['is_moderated']); 
     16    unset($this->widgetSchema['created_at']); 
     17 
     18    $this->widgetSchema->setLabels(array_merge($this->widgetSchema->getLabels(), array( 
     19      'author_name'   => 'Name (required)', 
     20      'author_email'  => 'Mail (required) (will not be published)', 
     21      'author_url'    => 'Website', 
     22      'content'       => '' 
     23    ))); 
     24 
     25    $this->validatorSchema['author_name']->setOption('min_length', 4); 
     26    $this->validatorSchema['author_name']->setOption('max_length', 100); 
     27    $this->validatorSchema['author_name']->setMessage('required', 'You must provide a name to leave a comment'); 
     28    $this->validatorSchema['author_name']->setMessage('min_length', 'You must provide a longer name (4 characters minimum)'); 
     29    $this->validatorSchema['author_name']->setMessage('max_length', 'You must provide a shorter name (100 characters maximum)'); 
     30 
     31    $this->validatorSchema['author_email'] = new sfValidatorEmail(array('required' => true), array( 
     32      'required'  => 'You must provide an email to leave a comment', 
     33      'invalid'   => 'This email address is not valid' 
     34    )); 
     35 
     36    $this->validatorSchema['content']->setOption('min_length', 4); 
     37    $this->validatorSchema['content']->setMessage('required', 'You must provide a text content to leave a comment'); 
     38    $this->validatorSchema['content']->setMessage('min_length', 'You must provide a longer content (4 characters minimum)'); 
     39 
     40    $this->widgetSchema->setFormFormatterName('div'); 
     41  } 
     42 
     43  public function updateObject() 
     44  { 
     45    parent::updateObject(); 
     46 
     47    $automoderation = sfConfig::get('app_sfSimpleBlog_comment_automoderation', 'first_post'); 
     48    if($automoderation === true || (($automoderation == 'first_post') && !DbFinder::from('sfSimpleBlogComment')->isAuthorApproved($this->object->getAuthorName(),$this->object->getAuthorEmail()))) 
     49    { 
     50      $this->object->setIsModerated(true); 
     51    } 
     52  } 
     53} 
  • /dev/null

    old new  
     1<?php 
     2 
     3/** 
     4 * sfSimpleBlogPost form. 
     5 * 
     6 * @package    form 
     7 * @subpackage sf_blog_post 
     8 * @version    SVN: $Id: sfPropelFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $ 
     9 */ 
     10class sfSimpleBlogPostForm extends BasesfSimpleBlogPostForm 
     11{ 
     12  public function configure() 
     13  { 
     14  } 
     15} 
  • /dev/null

    old new  
     1<?php 
     2 
     3/** 
     4 * sfSimpleBlogTag form. 
     5 * 
     6 * @package    form 
     7 * @subpackage sf_blog_tag 
     8 * @version    SVN: $Id: sfPropelFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $ 
     9 */ 
     10class sfSimpleBlogTagForm extends BasesfSimpleBlogTagForm 
     11{ 
     12  public function configure() 
     13  { 
     14  } 
     15} 
  • a/plugins/sfSimpleBlogPlugin/lib/model/map/sfSimpleBlogCommentMapBuilder.php

    old new  
    3636 
    3737        $tMap->addForeignKey('SF_BLOG_POST_ID', 'SfBlogPostId', 'int', CreoleTypes::INTEGER, 'sf_blog_post', 'ID', false, null); 
    3838 
    39         $tMap->addColumn('AUTHOR_NAME', 'AuthorName', 'string', CreoleTypes::VARCHAR, false, 255); 
     39        $tMap->addColumn('AUTHOR_NAME', 'AuthorName', 'string', CreoleTypes::VARCHAR, true, 255); 
    4040 
    41         $tMap->addColumn('AUTHOR_EMAIL', 'AuthorEmail', 'string', CreoleTypes::VARCHAR, false, 255); 
     41        $tMap->addColumn('AUTHOR_EMAIL', 'AuthorEmail', 'string', CreoleTypes::VARCHAR, true, 255); 
    4242 
    4343        $tMap->addColumn('AUTHOR_URL', 'AuthorUrl', 'string', CreoleTypes::VARCHAR, false, 255); 
    4444 
    45         $tMap->addColumn('CONTENT', 'Content', 'string', CreoleTypes::LONGVARCHAR, false, null); 
     45        $tMap->addColumn('CONTENT', 'Content', 'string', CreoleTypes::LONGVARCHAR, true, null); 
    4646 
    4747        $tMap->addColumn('IS_MODERATED', 'IsModerated', 'boolean', CreoleTypes::BOOLEAN, false, null); 
    4848 
  • a/plugins/sfSimpleBlogPlugin/lib/model/plugin/PluginsfSimpleBlogPost.php

    old new  
    33/** 
    44 * Subclass for representing a row from the 'sf_blog_post' table. 
    55 * 
    6  *  
     6 * 
    77 * 
    88 * @package plugins.sfSimpleBlogPlugin.lib.model 
    9  */  
     9 */ 
    1010class PluginsfSimpleBlogPost extends BasesfSimpleBlogPost 
    1111{ 
    1212  protected $nbComments = null; 
    13    
     13 
     14  public function __toString() 
     15  { 
     16    return $this->getTitle(); 
     17  } 
     18 
    1419  public function setTitle($text) 
    1520  { 
    1621    parent::setTitle($text); 
    1722 
    18     $this->setStrippedTitle(sfSimpleBlogTools::stripText($text));  
     23    $this->setStrippedTitle(sfSimpleBlogTools::stripText($text)); 
    1924  } 
    2025 
    2126  public function getAuthor() 
     
    2328    $getUserMethod = 'get'.sfConfig::get('app_sfSimpleBlog_user_class', 'sfGuardUser'); 
    2429    if (!method_exists($this, $getUserMethod)) 
    2530    { 
    26       throw new sfException(sprintf('Method sfSimpleBlogPost::%s does not exist - check the sfSimpleBlog_user_class parameter of the app.yml file', $getUserMethod));  
     31      throw new sfException(sprintf('Method sfSimpleBlogPost::%s does not exist - check the sfSimpleBlog_user_class parameter of the app.yml file', $getUserMethod)); 
    2732    } 
    2833 
    2934    return call_user_func(array($this, $getUserMethod)); 
     
    4045 
    4146  public function getNbComments() 
    4247  { 
    43     if ($this->nbComments === null)  
     48    if ($this->nbComments === null) 
    4449    { 
    4550      $this->nbComments = DbFinder::from('sfSimpleBlogComment')-> 
    4651        relatedTo($this)-> 
    4752        where('IsModerated', false)-> 
    4853        count(); 
    4954    } 
    50      
     55 
    5156    return $this->nbComments; 
    5257  } 
    5358 
     
    5762      relatedTo($this)-> 
    5863      orderBy('Tag')-> 
    5964      find(); 
    60      
     65 
    6166    return implode($tags, ' '); 
    6267  } 
    6368 
     
    108113    { 
    109114      $this->setPublishedAt(date("Y-m-d")); 
    110115    } 
    111      
     116 
    112117    parent::setIsPublished($flag); 
    113118  } 
    114119 
  • a/plugins/sfSimpleBlogPlugin/modules/sfSimpleBlog/lib/BasesfSimpleBlogActions.class.php

    old new  
    4040    $posts = DbFinder::from('sfSimpleBlogPost')-> 
    4141      recent()-> 
    4242      find($this->getRequestParameter('nb', sfConfig::get('app_sfSimpleBlog_feed_count', 5))); 
    43        
     43 
    4444    $this->feed = sfFeedPeer::createFromObjects( 
    4545      $posts, 
    4646      array( 
     
    6060    $comments = DbFinder::from('sfSimpleBlogComment')-> 
    6161      recent()-> 
    6262      find($this->getRequestParameter('nb', sfConfig::get('app_sfSimpleBlog_feed_count', 5))); 
    63        
     63 
    6464    $this->feed = sfFeedPeer::createFromObjects( 
    6565      $comments, 
    6666      array( 
     
    8686      relatedTo($post)-> 
    8787      recent()-> 
    8888      find($this->getRequestParameter('nb', sfConfig::get('app_sfSimpleBlog_feed_count', 5))); 
    89      
     89 
    9090    $this->feed = sfFeedPeer::createFromObjects( 
    9191      $comments, 
    9292      array( 
     
    107107    $this->post_pager = DbFinder::from('sfSimpleBlogPost')-> 
    108108      recent()-> 
    109109      tagged($tag)-> 
    110       paginate($this->getRequestParameter('page', 1), sfConfig::get('app_sfSimpleBlog_post_max_per_page', 5));  
     110      paginate($this->getRequestParameter('page', 1), sfConfig::get('app_sfSimpleBlog_post_max_per_page', 5)); 
    111111  } 
    112    
     112 
    113113  public function executePostsForTagFeed() 
    114114  { 
    115115    sfLoader::loadHelpers(array('I18N')); 
     
    119119      recent()-> 
    120120      tagged($tag)-> 
    121121      find($this->getRequestParameter('nb', sfConfig::get('app_sfSimpleBlog_feed_count', 5))); 
    122      
     122 
    123123    $this->feed = sfFeedPeer::createFromObjects( 
    124124      $posts, 
    125125      array( 
     
    132132    ); 
    133133    $this->setTemplate('feed'); 
    134134  } 
    135       
     135 
    136136  public function executeShow() 
    137137  { 
    138138    $this->post = DbFinder::from('sfSimpleBlogPost')->findByStrippedTitleAndDate( 
     
    141141    ); 
    142142    $this->forward404Unless($this->post); 
    143143    $this->comments = $this->post->getComments(); 
     144 
     145    $this->comment_form = $this->getRequest()->getAttribute('comment_form', new sfSimpleBlogCommentForm()); 
    144146  } 
    145147 
    146148  protected function getDateFromRequest() 
    147149  { 
    148150    return $this->getRequestParameter('date') != null ? $this->getRequestParameter('date') : $this->getRequestParameter('year').'-'.$this->getRequestParameter('month').'-'.$this->getRequestParameter('day'); 
    149151  } 
    150    
     152 
    151153  public function executeAddComment() 
    152154  { 
    153155    $this->forward404Unless(sfConfig::get('app_sfSimpleBlog_comment_enabled', true)); 
     
    158160    $this->forward404Unless($post); 
    159161    $this->forward404Unless($post->allowComments()); 
    160162 
    161     $comment = new sfSimpleBlogComment(); 
    162     $comment->setSfBlogPostId($post->getId()); 
    163     $automoderation = sfConfig::get('app_sfSimpleBlog_comment_automoderation', 'first_post'); 
    164     if($automoderation === true || (($automoderation == 'first_post') && !DbFinder::from('sfSimpleBlogComment')->isAuthorApproved($this->getRequestParameter('name'),$this->getRequestParameter('mail')))) 
    165     { 
    166       $comment->setIsModerated(true); 
    167       $this->setFlash('add_comment', 'moderated'); 
    168     } 
    169     else 
    170     { 
    171       $this->setFlash('add_comment', 'normal');  
    172     } 
    173     $comment->setAuthorName($this->getRequestParameter('name')); 
    174     $comment->setAuthorEmail($this->getRequestParameter('mail')); 
    175     if($url = $this->getRequestParameter('website', '')) 
     163    $this->comment_form = new sfSimpleBlogCommentForm(); 
     164    $this->comment_form->bind(array_merge($this->getRequestParameter('sf_simple_blog_comment'), array('sf_blog_post_id' => $post->getId()))); 
     165 
     166    if($this->comment_form->isValid()) 
    176167    { 
    177       if(strpos($url, 'http://') !== 0) 
     168      $comment = $this->comment_form->save(); 
     169 
     170      if($comment->getIsModerated()) 
    178171      { 
    179         $url = 'http://'.$url;  
     172        $this->getUser()->setFlash('add_comment', 'moderated'); 
     173      } 
     174      else 
     175      { 
     176        $this->getUser()->setFlash('add_comment', 'normal'); 
     177      } 
     178 
     179      $email_pref = sfConfig::get('app_sfSimpleBlog_comment_mail_alert', 1); 
     180      if($email_pref == 1 || ($email_pref == 'moderated' && $comment->getIsModerated())) 
     181      { 
     182        $this->sendMailOnComment($comment); 
     183      } 
     184 
     185      if($this->getRequest()->isXmlHttpRequest()) 
     186      { 
     187        $this->post = $post; 
     188        $this->comments = $post->getComments(); 
     189        return 'Ajax'; 
     190      } 
     191      else 
     192      { 
     193        $this->redirect(sfSimpleBlogTools::generatePostUri($post)); 
    180194      } 
    181       $comment->setAuthorUrl($url); 
    182     } 
    183     $comment->setContent(strip_tags($this->getRequestParameter('content'))); 
    184     $comment->save(); 
    185      
    186     $email_pref = sfConfig::get('app_sfSimpleBlog_comment_mail_alert', 1); 
    187     if($email_pref == 1 || ($email_pref == 'moderated' && $comment->getIsModerated())) 
    188     { 
    189       $this->getRequest()->setAttribute('comment', $comment); 
    190       $raw_email = $this->sendEmail('sfSimpleBlog', 'sendMailOnComment');   
    191       $this->logMessage($raw_email, 'debug'); 
    192     } 
    193      
    194     if($this->getRequest()->isXmlHttpRequest()) 
    195     { 
    196       $this->post = $post; 
    197       $this->comments = $post->getComments(); 
    198       return 'Ajax'; 
    199195    } 
    200196    else 
    201197    { 
    202       $this->redirect(sfSimpleBlogTools::generatePostUri($post)); 
     198      $this->getRequest()->setAttribute('comment_form', $this->comment_form); 
     199      $this->forward('sfSimpleBlog', 'show'); 
    203200    } 
    204201  } 
    205    
    206   public function executeSendMailOnComment(
     202 
     203  protected function sendMailOnComment($comment
    207204  { 
    208     // Mail action cannot be called directly from the outside 
    209     $this->forward404If($this->getController()->getActionStack()->getSize() == 1); 
    210      
    211205    sfLoader::loadHelpers(array('I18N')); 
    212     $this->comment = $this->getRequest()->getAttribute('comment'); 
    213  
    214     $mail = new sfMail(); 
    215     $mail->setCharset('utf-8');       
    216     $mail->setSender('no-reply@'.$this->getRequest()->getHost()); 
    217     $mail->setMailer('mail'); 
    218     $mail->setFrom($mail->getSender(), sfConfig::get('app_sfSimpleBlog_title')); 
    219  
    220     $mail->addAddresses(sfConfig::get('app_sfSimpleBlog_email')); 
     206    $this->comment = $comment; 
    221207 
    222208    if($this->comment->getIsModerated()) 
    223209    { 
     
    225211    } 
    226212    else 
    227213    { 
    228       $subject_string = '[%1%] New comment on "%2%"';       
     214      $subject_string = '[%1%] New comment on "%2%"'; 
    229215    } 
    230     $mail->setSubject(__($subject_string, array( 
     216    $mailSubject = __($subject_string, array( 
    231217        '%1%' => sfConfig::get('app_sfSimpleBlog_title'), 
    232218        '%2%' => $this->comment->getPostTitle() 
    233     ))); 
    234      
    235     $this->mail = $mail;   
     219    )); 
     220 
     221    $mailBody = $this->getPartial('commentMail', array('comment' => $this->comment)); 
     222    $this->logMessage($mailBody, 'debug'); 
     223 
     224    $mailer = new Swift(new Swift_Connection_NativeMail()); 
     225    $message = new Swift_Message($mailSubject, $mailBody, 'text/html'); 
     226 
     227    $mailer->send($message, sfConfig::get('app_sfSimpleBlog_email'), 'no-reply@'.$this->getRequest()->getHost()); 
     228    $mailer->disconnect(); 
    236229  } 
    237    
     230 
    238231  public function handleErrorAddComment() 
    239232  { 
    240233    if($this->getRequest()->isXmlHttpRequest()) 
     
    246239      $this->forward404Unless($this->post); 
    247240      $this->comments = $this->post->getComments(); 
    248241      $this->getResponse()->setContentType('text/html; charset=utf-8'); 
    249       return 'Ajax';  
     242      return 'Ajax'; 
    250243    } 
    251244    else 
    252245    { 
    253       $this->forward('sfSimpleBlog', 'show');  
     246      $this->forward('sfSimpleBlog', 'show'); 
    254247    } 
    255248  } 
    256249 
  • a/plugins/sfSimpleBlogPlugin/modules/sfSimpleBlog/templates/_add_comment.php

    old new  
    11<?php use_helper('Validation') ?> 
    22<h3><?php echo __('Leave a reply') ?></h3> 
    3 <?php echo form_tag('sfSimpleBlog/addComment', 'name=add_comment class=add_comment id=sfSimpleBlog_add_comment_form') ?> 
    4   <?php echo input_hidden_tag('stripped_title', $post->getStrippedTitle()) ?> 
    5   <?php echo input_hidden_tag('date', $post->getPublishedAt()) ?> 
    6   <div class="form_control"> 
    7     <?php echo form_error('name') ?> 
    8     <?php echo input_tag('name', '', 'id= class=text') ?> 
    9     <label for="name"><?php echo __('Name (required)') ?></label> 
    10   </div> 
    11   <div class="form_control"> 
    12     <?php echo form_error('mail') ?> 
    13     <?php echo input_tag('mail', '', 'id= class=text') ?> 
    14     <label for="mail"><?php echo __('Mail (required) (will not be published)') ?></label> 
    15   </div> 
    16   <div class="form_control"> 
    17     <?php echo form_error('website') ?> 
    18     <?php echo input_tag('website', '', 'id= class=text') ?> 
    19     <label for="url"><?php echo __('Website') ?></label> 
    20   </div> 
    21   <div class="form_control"> 
    22     <?php echo form_error('content') ?> 
    23     <?php echo textarea_tag('content', '', 'id=') ?> 
    24     <label for="content"></label> 
    25   </div> 
    26   <div class="form_control"> 
    27     <?php echo submit_tag(__('Submit comment')) ?> 
    28   </div> 
     3<form id="sfSimpleBlog_add_comment_form" name="add_comment" action="<?php echo url_for('sfSimpleBlog/addComment') ?>" method="POST" class="add_comment"> 
     4  <?php echo $comment_form ?> 
    295</form> 
    306 
    317<?php if(sfConfig::get('app_sfSimpleBlog_use_ajax', true)): ?> 
    328<script> 
    33   document.getElementById('sfSimpleBlog_add_comment_form').onsubmit = function () {  
     9  document.getElementById('sfSimpleBlog_add_comment_form').onsubmit = function () { 
    3410    new Ajax.Updater( 
    3511      'sfSimpleBlog_comment_list', 
    36       document.getElementById('sfSimpleBlog_add_comment_form').action,  
     12      document.getElementById('sfSimpleBlog_add_comment_form').action, 
    3713      { parameters: Form.serialize(this), evalScripts: true, encoding: 'UTF-8' } 
    38     );  
    39     return false;  
    40   };   
     14    ); 
     15    return false; 
     16  }; 
    4117</script> 
    4218<?php endif; ?> 
  • /dev/null

    old new  
     1<?php use_helper('Date', 'I18N') ?> 
     2 
     3<?php echo __('A new comment has been posted on the post "%1%".', array('%1%' => $comment->getPostTitle())) ?> 
     4 
     5 
     6<?php echo __('Author: ').$comment->getAuthorName() ?> 
     7 
     8<?php echo __('Email: ').$comment->getAuthorEmail() ?> 
     9 
     10<?php echo __('Website: ').$comment->getAuthorUrl() ?> 
     11 
     12<?php echo __('Comment: ').$comment->getContent() ?> 
     13 
     14 
     15<?php if($comment->getIsModerated()): ?> 
     16<?php echo __('This comment was automatically moderated and is waiting for your approval.') ?> 
     17 
     18<?php echo __('Accept this comment:') ?> 
     19<?php else: ?> 
     20<?php echo __('Moderate this comment:') ?> 
     21<?php endif; ?> 
     22 
     23<?php echo url_for('sfSimpleBlogCommentAdmin/togglePublish?from_email=1&id='.$comment->getId(), true) ?> 
  • a/plugins/sfSimpleBlogPlugin/modules/sfSimpleBlog/templates/_comment_list.php

    old new  
    88<?php elseif($sf_user->getFlash('add_comment') == 'moderated'): ?> 
    99  <div class="comment moderated"><?php echo __('Your comment has been submitted and is awaiting moderation') ?></div> 
    1010<?php elseif($sf_user->getFlash('add_comment') != 'normal'): ?> 
    11   <?php include_partial('sfSimpleBlog/add_comment', array('post' => $post)) ?> 
     11  <?php include_partial('sfSimpleBlog/add_comment', array('post' => $post, 'comment_form' => $comment_form)) ?> 
    1212<?php endif; ?> 
  • a/plugins/sfSimpleBlogPlugin/modules/sfSimpleBlog/templates/showSuccess.php

    old new  
    1313<span class="sfSimpleBlog"> 
    1414 
    1515  <?php include_partial('sfSimpleBlog/post', array('post' => $post, 'in_list' => false)) ?> 
    16    
     16 
    1717  <div class="comments" id="comments"> 
    1818 
    1919    <?php if($nb_comments = count($comments)): ?> 
    2020      <h3><?php echo format_number_choice('[1]One comment so far|(1,+Inf]%1% comments so far', array('%1%' => $nb_comments), $nb_comments) ?></h3> 
    2121    <?php endif; ?> 
    2222    <div id="sfSimpleBlog_comment_list"> 
    23       <?php include_partial('sfSimpleBlog/comment_list', array('post' => $post, 'comments' => $comments)) ?> 
     23      <?php include_partial('sfSimpleBlog/comment_list', array('post' => $post, 'comments' => $comments, 'comment_form' => $comment_form)) ?> 
    2424    </div> 
    2525 
    2626  </div>