Development

Changeset 31070

You must first sign up to be able to contribute.

Changeset 31070

Show
Ignore:
Timestamp:
10/07/10 10:53:47 (3 years ago)
Author:
jp_morvan
Message:

version 1.2.1

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/vjCommentPlugin/TRUNK/README

    r31056 r31070  
    9090            #10 by default 
    9191            max_per_page: 5 
     92 
     93How to allow or disallow HTML tags in comments 
     94------------- 
     95 
     96Before 1.2.0 version, we used ESC_RAW to render comment's content and only used blockquote, div, br and strong HTML tags. 
     97In 1.2.0, we let your escaping strategy working but in most of the cases, HTML tags were escaped. 
     98 
     99Since 1.2.1, we've introduced HTML Purifier to do the job. The plugin embeds version 4.2.0 of the library (released on 2010-09-15). 
     100By default, we allow blockquote, strong, div and br tags but you can override these. 
     101 
     102  * edit apps/your_frontend_app/config/app.yml 
     103 
     104        all: 
     105          purifier: 
     106            #set to false use only your allowed tags 
     107            merge: true 
     108            #by default, [blockquote,strong,div,br] are allowed 
     109            #set to [i,u] with merge to true allows [blockquote,strong,div,br,i,u] 
     110            #set to [] with merge to false disables allowed tags 
     111            allowed_tags: [i,u] 
    92112 
    93113Logged users, comments and profile options 
  • plugins/vjCommentPlugin/TRUNK/config/app.yml

    r29082 r31070  
    1111    default_size:   40 
    1212    default_image:  ../web/images/gravatar_default.png 
     13  purifier: 
     14    #set to false use only your allowed tags 
     15    merge: true 
     16    #by default, [blockquote,strong,div,br] are allowed 
     17    #set to [i,u] with merge to true allows [blockquote,strong,div,br,i,u] 
     18    #set to [] with merge to false disables allowed tags 
     19    allowed_tags: []  
  • plugins/vjCommentPlugin/TRUNK/config/vjCommentPluginConfiguration.class.php

    r31056 r31070  
    88class vjCommentPluginConfiguration extends sfPluginConfiguration 
    99{ 
     10  static protected $HTMLPurifierLoaded = false; 
     11   
    1012  /** 
    1113   * @see sfPluginConfiguration 
     
    2224      $this->dispatcher->connect('routing.load_configuration', array('vjCommentRouting', 'addRouteForAdminReportedComments')); 
    2325    } 
     26    self::registerHTMLPurifier(); 
     27  } 
     28 
     29  static public function registerHTMLPurifier() 
     30  { 
     31    if(self::$HTMLPurifierLoaded) { 
     32      return; 
     33    } 
     34 
     35    require_once(sfConfig::get('sf_plugins_dir').'/vjCommentPlugin/lib/tools/htmlpurifier/library/HTMLPurifier/Bootstrap.php'); 
     36 
     37    spl_autoload_register(array('HTMLPurifier_Bootstrap', 'autoload')); 
     38 
     39    self::$HTMLPurifierLoaded = true; 
    2440  } 
    2541} 
  • plugins/vjCommentPlugin/TRUNK/i18n/fr/vjComment.xml

    r31056 r31070  
    141141        <target>(page %%page%%/%%nb_pages%%)</target> 
    142142      </trans-unit> 
     143      <trans-unit> 
     144        <source>Back to top</source> 
     145        <target>Retour en haut</target> 
     146      </trans-unit> 
    143147    </body> 
    144148  </file> 
  • plugins/vjCommentPlugin/TRUNK/lib/form/doctrine/PluginCommentCommonForm.class.php

    r29634 r31070  
    6666      $values['reply'] = null; 
    6767    } 
     68    $purifier = new vjCommentPurifier(); 
     69    $values['body'] = $purifier->purify($values['body']); 
    6870    parent::doUpdateObject($values); 
    6971  } 
  • plugins/vjCommentPlugin/TRUNK/lib/tools/commentTools.class.php

    r31056 r31070  
    5656  { 
    5757    return <<<EOF 
    58 %%QUOTE_START%% 
    59   %%DIV_START%% 
    60     %%STRONG_START%%$author%%STRONG_END%% 
    61   %%DIV_END%% 
     58<blockquote> 
     59  <div> 
     60    <strong>$author</strong> 
     61  </div> 
    6262  $body 
    63 %%QUOTE_END%% 
    64 %%BREAK%% 
     63</blockquote> 
     64<br /> 
    6565EOF; 
    6666  } 
     
    7474  public static function cleanQuote($content = "", $cut = false) 
    7575  { 
    76     if(preg_match("/%{2}BREAK%{2}/", $content)) 
     76    if(preg_match("/<br />/", $content)) 
    7777    { 
    78       $content = substr(strip_tags(strrchr($content, '%%BREAK%%')), 1); 
     78      $content = substr(strip_tags(strrchr($content, '<br />')), 1); 
    7979    } 
    8080    if($cut === true) 
     
    9595   * @return string  
    9696   */ 
    97   public static function parseQuoting($string) 
    98   { 
    99     foreach(self::$patterns as $pattern => $replace) 
    100     { 
    101       $exp = "/%{2}$pattern%{2}/"; 
    102       if(preg_match($exp, $string, $matches)) 
    103       { 
    104         $string = preg_replace($exp, $replace, $string); 
    105       } 
    106     } 
    107     return $string; 
    108   } 
     97//  public static function parseQuoting($string) 
     98//  { 
     99//    foreach(self::$patterns as $pattern => $replace) 
     100//    { 
     101//      $exp = "/%{2}$pattern%{2}/"; 
     102//      if(preg_match($exp, $string, $matches)) 
     103//      { 
     104//        $string = preg_replace($exp, $replace, $string); 
     105//      } 
     106//    } 
     107//    return $string; 
     108//  } 
    109109 
    110110  public static function rewriteUrlForPage($uri, $page) 
     
    120120      $uri .= 'page='.$page; 
    121121    } 
    122     return $uri
     122    return $uri."#comments"
    123123  } 
    124124} 
  • plugins/vjCommentPlugin/TRUNK/modules/comment/templates/_comment_body.php

    r31056 r31070  
    33      <td class="body"> 
    44        <?php if(!$obj->is_delete): ?> 
    5         <div id="body_<?php echo $obj->id ?>"><?php echo commentTools::parseQuoting($obj->getBody()) ?></div> 
     5        <div id="body_<?php echo $obj->id ?>"><?php echo $obj->getBody(ESC_RAW) ?></div> 
    66        <?php else: ?> 
    77          <div class="msg-deleted"><?php echo __('Comment deleted by moderator', array(), 'vjComment') ?></div> 
  • plugins/vjCommentPlugin/TRUNK/modules/comment/templates/_formComment.php

    r31056 r31070  
    33<?php use_stylesheet("/vjCommentPlugin/css/formComment.min.css") ?> 
    44<?php $sf_user->setAttribute('nextComment', $object->getNbComments()+1) ?> 
    5 <a name="top"></a> 
     5<a name="comments"></a> 
    66<div class="form-comment"> 
    77<?php if( vjComment::checkAccessToForm($sf_user) ): ?> 
  • plugins/vjCommentPlugin/TRUNK/modules/comment/templates/_list.php

    r31056 r31070  
    1111  </div> 
    1212<?php if ($pager->haveToPaginate()): ?> 
    13 <?php include_partial('comment/pagination', array('pager' => $pager, 'route' => $sf_request->getUri())) ?> 
     13<?php include_partial('comment/pagination', array('pager' => $pager, 'route' => $sf_request->getUri(), 'position' => 'top')) ?> 
    1414<?php endif ?> 
    1515  <table class="list-comments" summary=""> 
     
    1919  </table> 
    2020<?php if ($pager->haveToPaginate()): ?> 
    21 <?php include_partial('comment/pagination', array('pager' => $pager, 'route' => $sf_request->getUri())) ?> 
     21<?php include_partial('comment/pagination', array('pager' => $pager, 'route' => $sf_request->getUri(), 'position' => 'back')) ?> 
     22<?php else: ?> 
     23<?php include_partial('comment/back_to_top', array('route' => $sf_request->getUri(), 'text' => true)) ?> 
    2224<?php endif ?> 
    2325<?php else: ?> 
  • plugins/vjCommentPlugin/TRUNK/modules/comment/templates/_pagination.php

    r31056 r31070  
    11<div class="pagination"> 
     2<?php if($position == "back"): ?> 
     3<?php include_partial('comment/back_to_top', array('route' => $route, 'text' => false)) ?> 
     4<?php endif; ?> 
    25  <a href="<?php echo url_for(commentTools::rewriteUrlForPage($route, 1)) ?>"> 
    36    <?php echo image_tag('/vjCommentPlugin/images/resultset_first.png', array('alt' => __('First page of comments', array(), 'vjComment'), 'title' => __('First page of comments', array(), 'vjComment'))) ?> 
  • plugins/vjCommentPlugin/TRUNK/modules/commentAdmin/templates/_body.php

    r31056 r31070  
    11<?php use_stylesheet('/vjCommentPlugin/css/infoBulle.min.css') ?> 
    22<a class="info"> 
    3   <?php echo commentTools::cleanQuote($comment->getBody(), true) ?> 
     3  <?php echo commentTools::cleanQuote($comment->getBody(ESC_RAW), true) ?> 
    44  <span class="body"> 
    5     <?php echo commentTools::parseQuoting($comment->getBody()) ?> 
     5    <?php echo $comment->getBody(ESC_RAW) ?> 
    66  </span> 
    77</a> 
  • plugins/vjCommentPlugin/TRUNK/modules/commentAdmin/templates/_bodyReply.php

    r31056 r31070  
    66    <div class="content"> 
    77      <a class="info"> 
    8         <?php echo commentTools::cleanQuote($comment->getBody()) ?> 
     8        <?php echo commentTools::cleanQuote($comment->getBody(ESC_RAW)) ?> 
    99        <span class="body"> 
    10           <?php echo commentTools::parseQuoting($comment->getBody()) ?> 
     10          <?php echo $comment->getBody(ESC_RAW) ?> 
    1111        </span> 
    1212      </a> 
  • plugins/vjCommentPlugin/TRUNK/package.xml.tmpl

    r31056 r31070  
    6767      <license uri="http://www.symfony-project.org/license">MIT license</license> 
    6868      <date>##CURRENT_DATE##</date> 
     69      <license>MIT</license> 
     70      <notes> 
     71        * jp_morvan: integrate HTML Purifier 
     72        * jp_morvan: rollback to raw escaping because of HTML Purifier 
     73        * jp_morvan: add back to top link and auto scroll on comments when switching pages (thanks to Tristan for the idea) 
     74        * jp_morvan: update i18n french translations 
     75      </notes> 
     76    </release> 
     77    <release> 
     78      <version> 
     79        <release>1.2.0</release> 
     80        <api>1.2.0</api> 
     81      </version> 
     82      <stability> 
     83        <release>stable</release> 
     84        <api>stable</api> 
     85      </stability> 
     86      <license uri="http://www.symfony-project.org/license">MIT license</license> 
     87      <date>2010-10-04</date> 
    6988      <license>MIT</license> 
    7089      <notes> 
  • plugins/vjCommentPlugin/TRUNK/web/css/pagination.css

    r31056 r31070  
    77  text-align: center; 
    88  font-weight: bold; 
    9   color: #000000; 
    109  background-color: #cccccc; 
    1110} 
    1211 
    13 div.pagination a{ 
     12div.pagination a, div.backtop a{ 
     13  font-weight: normal; 
     14  background-color: #cccccc; 
     15  text-decoration: none; 
    1416  color: #000000; 
    15   font-weight: normal; 
    1617} 
     18 
     19div.backtop{ 
     20  float:right; 
     21} 
     22 
     23div.backtopmax{ 
     24  float:left; 
     25  width:500px; 
     26  text-align: center; 
     27  padding: 3px; 
     28  background-color: #cccccc; 
     29} 
  • plugins/vjCommentPlugin/TRUNK/web/css/pagination.min.css

    r31056 r31070  
    1 img{ border:0;}div.pagination{ width:500px;text-align:center;font-weight:bold;color:#000000;background-color: #cccccc;}div.pagination a{ color:#000000;font-weight: normal;} 
     1img{ border:0;}div.pagination{ width:500px;text-align:center;font-weight:bold;background-color:#cccccc;}div.pagination a,div.backtop a{ font-weight: normal;background-color:#cccccc;text-decoration: none;color:#000000;}div.backtop{ float:right;}div.backtopmax{ float:left;width:500px;text-align:center;padding:3px;background-color:#cccccc;}