WordPress.org

Plugin Directory

Changeset 545690


Ignore:
Timestamp:
05/18/12 09:36:08 (2 years ago)
Author:
nbachiyski
Message:

Extract the CSS classes into an instance variable

Also, pass them as an argument to ICE_Span_Filter,
don't hardcode them there

Location:
ice/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ice/trunk/class-ice-span-filter.php

    r545262 r545690  
    1717    const STATE_IN_DEL = 'in-del'; 
    1818 
    19     const CLASS_INS = 'ice-wp-ins'; 
    20     const CLASS_DEL = 'ice-wp-del'; 
     19    var $tracking_css_classes; 
     20    var $del_css_class; 
    2121 
    22     function __construct( $text ) { 
     22    function __construct( $text, $tracking_css_classes ) { 
    2323        $this->text = $text; 
     24        $this->tracking_css_classes = $tracking_css_classes; 
    2425    } 
    2526 
     
    8081     * Tokenizes (splits) the HTML into: 
    8182     *  - normal spans: opening span tag, which is neither an <code>ins</code>, not a <code>del</code> 
    82      *  - ins spans: opening span tag with class ice-wp-ins 
    83      *  - del spans: opening span tag with class ice-wp-del 
     83     *  - ins spans: opening span tag with the insert tracking CSS class 
     84     *  - del spans: opening span tag with the delete tracking CSS class 
    8485     *  - closing: a closing span tag 
    8586     *  - text: any other text or tags, which aren't relevant to our parsing 
     
    9798                $css_classes = self::get_css_classes($token_text); 
    9899 
    99                 if ( in_array( self::CLASS_INS, $css_classes, true ) ) 
     100                if ( in_array( $this->tracking_css_classes['ins'], $css_classes, true ) ) 
    100101                    $id = self::TOKEN_INS; 
    101                 elseif ( in_array( self::CLASS_DEL, $css_classes, true ) ) 
     102                elseif ( in_array( $this->tracking_css_classes['del'], $css_classes, true ) ) 
    102103                    $id = self::TOKEN_DEL; 
    103104                else 
  • ice/trunk/ice.php

    r545677 r545690  
    2525 
    2626class ICE_Visual_Revisions { 
     27 
     28    var $tracking_css_classes = array( 'ins' => 'ice-wp-ins', 'del' => 'ice-wp-del' ); 
    2729 
    2830    function __construct() { 
     
    134136            'manualInit' => true, 
    135137            'isTracking' => !$new_post, 
    136             'deleteClass' => 'ice-wp-del', 
    137             'insertClass' => 'ice-wp-ins', 
     138            'deleteClass' => $this->tracking_css_classes['del'], 
     139            'insertClass' => $this->tracking_css_classes['ins'], 
    138140            'css' => '../icerevisions/css/ice-revisions.css' 
    139141        ); 
     
    179181            ?> 
    180182            <style type="text/css"> 
    181             span.ice-wp-ins, 
    182             span.ice-wp-del { 
     183            <?php echo $this->tracking_css_classes['ins']; ?>, 
     184            <?php echo $this->tracking_css_classes['del']; ?> { 
    183185                -webkit-border-radius: 3px; 
    184186                border-radius: 3px; 
     
    186188                padding: 1px 0 2px; 
    187189            } 
    188             span.ice-wp-ins { 
     190            <?php echo $this->tracking_css_classes['ins']; ?> { 
    189191                background-color: #e5ffcd; 
    190192            } 
    191             span.ice-wp-del { 
     193            <?php echo $this->tracking_css_classes['del']; ?> { 
    192194                text-decoration: line-through; 
    193195                color: #555; 
     
    221223            return $content; 
    222224 
    223         $span_filter = new ICE_Span_Filter( stripslashes($content) ); 
     225        $span_filter = new ICE_Span_Filter( stripslashes($content), $this->tracking_css_classes ); 
    224226        return addslashes( $span_filter->filter() ); 
    225227    } 
  • ice/trunk/tests/test-ice-span-filter.php

    r545262 r545690  
    44class Test_ICE_Span_Filter extends PHPUnit_Framework_TestCase { 
    55 
     6    var $tracking_classes = array( 'ins' => 'ice-wp-ins', 'del' => 'ice-wp-del' ); 
     7 
    68    function filter( $text ) { 
    7         $span_filter = new ICE_Span_Filter( $text ); 
     9        $span_filter = new ICE_Span_Filter( $text, $this->tracking_classes ); 
    810        return $span_filter->filter(); 
    911    } 
    1012 
    1113    function get_tokens( $text ) { 
    12         $span_filter = new ICE_Span_Filter( $text ); 
     14        $span_filter = new ICE_Span_Filter( $text, $this->tracking_classes ); 
    1315        return $span_filter->get_tokens(); 
    1416    } 
    1517 
    1618    function test_construct() { 
    17         $span_filter = new ICE_Span_Filter( 'baba' ); 
     19        $span_filter = new ICE_Span_Filter( 'baba', array( 'ins' => 'ins', 'del' => 'del' ) ); 
    1820    } 
    1921 
Note: See TracChangeset for help on using the changeset viewer.