Plugin Directory

Changeset 669301


Ignore:
Timestamp:
02/17/2013 04:11:32 PM (13 years ago)
Author:
ltnow
Message:

cleanup

Location:
facebook-comments-notifier
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • facebook-comments-notifier/tags/1.2/facebook-comments-notifier.php

    r669072 r669301  
    3333
    3434// fcn_htmlencode: options for whitespace conversion
    35 define( 'FCN_HTML_NBSP', 1 );   // " " -> " "
    36 define( 'FCN_HTML_BR', 2 );     // "\r" -> "<br />"
    37 define( 'FCN_HTML_NBSP_BR', 3); // 1 + 2
    38 define( 'FCN_HTML_BR_NBSP', 3); // 1 + 2
    39 define( 'FCN_HTML_ATTRIB', 4);  // "\n" -> &#10; "\r" -> &#13;
     35// default: \n -> &x10;  \r -> &x13;
     36define( 'FCN_HTML_BR', 1 );      // "\n" -> "<br />"
     37define( 'FCN_HTML_NBSP', 2 );    // " " -> "&nbsp;"
     38define( 'FCN_HTML_NBSP_BR', 3);  // 1 + 2
     39define( 'FCN_HTML_BR_NBSP', 3);  // 1 + 2
     40define( 'FCN_HTML_PRESERVE', 4); // no change
    4041
    4142
     
    401402
    402403    // handle whitespace conversion
    403     if ( $ws == 1 || $ws == 3 )
    404     {
    405         $html = str_replace( "\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $html );
    406         $html = str_replace( ' ', '&nbsp;', $html );
    407     }
    408 
    409     if ( $ws == 2 || $ws == 3 )
    410     {
    411         $html = str_replace( "\r\n", "\n", $html ); // pc
    412         $html = str_replace( "\r", "\n", $html );   // mac (old <= 9)
    413         $html = str_replace( "\n", '<br />', $html );
    414     }
    415 
    416     if ( $ws == 4 )
     404    if ( $ws )
     405    {
     406        if ( $ws == 2 || $ws == 3 )
     407        {
     408            $html = str_replace( "\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $html );
     409            $html = str_replace( ' ', '&nbsp;', $html );
     410        }
     411
     412        if ( $ws == 1 || $ws == 3 )
     413        {
     414            $html = str_replace( "\r\n", "\n", $html ); // pc
     415            $html = str_replace( "\r", "\n", $html );   // mac (old <= 9)
     416            $html = str_replace( "\n", '<br />', $html );
     417        }
     418    }
     419    else   
    417420    {
    418421        $html = str_replace( "\n", '&#10;', $html );
     
    430433    foreach ( $def as $key => $value )
    431434    {
    432         $attrs .= ' '.$key.'="'.fcn_htmlencode($value,FCN_HTML_ATTRIB).'"';
     435        $attrs .= ' '.$key.'="'.fcn_htmlencode($value).'"';
    433436    }
    434437    return $attrs;
     
    564567                    }
    565568
    566                     $html .= '<option value="'. fcn_htmlencode($key, FCN_HTML_ATTRIB) . '" ';
     569                    $html .= '<option value="'. fcn_htmlencode($key) . '" ';
    567570
    568571                    // allow single or multiple selected values
  • facebook-comments-notifier/tags/1.2/fb-comments.js

    r669291 r669301  
    11// encode data for html context
    2 var FCN_HTML_NBSP    = 1; // ' ' -> &nbsp;
    3 var FCN_HTML_BR      = 2; // \n \r -> <br />
    4 var FCN_HTML_NBSP_BR = 3; // 1 + 2
    5 var FCN_HTML_BR_NBSP = 3; // 1 + 2
    6 var FCN_HTML_ATTRIB  = 4; // \n -> &x10; \r -> &x13;
     2// default: \n -> &x10;  \r -> &x13;
     3var FCN_HTML_BR       = 1; // \n -> <br />
     4var FCN_HTML_NBSP     = 2; // ' ' -> &nbsp;
     5var FCN_HTML_NBSP_BR  = 3; // 1 + 2
     6var FCN_HTML_BR_NBSP  = 3; // 1 + 2
     7var FCN_HTML_PRESERVE = 4; // preserve
    78
    89function fcn_htmlencode (str, ws) {
     
    1819    // encode whitespace
    1920    if ( ws ) {
    20         if ( ws == 1 || ws == 3 ) {
     21        // translate space
     22        if ( ws == 2 || ws == 3 ) {
    2123            str = str.replace(/ /g, "&nbsp;");
    2224            str = str.replace(/\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;");
    2325        }
    24         // also insert line breaks
    25         if ( ws == 2 || ws == 3 ) {
     26        // htmlify line breaks
     27        if ( ws == 1 || ws == 3 ) {
     28            str = str.replace(/\r\n/g, "\n"); //pc
     29            str = str.replace(/\r/g, "\r");   // mac <= 9
    2630            str = str.replace(/\n/g, "<br />");
    2731        }
    28         // also insert line breaks
    29         if ( ws == 4 ) {
    30             str = str.replace(/\n/g, "&#10;");
    31             str = str.replace(/\r/g, "&#13;");
    32         }
     32    } else {
     33        // for attributes/general
     34        str = str.replace(/\n/g, "&#10;");
     35        str = str.replace(/\r/g, "&#13;");
    3336    }
    3437    return str.valueOf();
  • facebook-comments-notifier/trunk/facebook-comments-notifier.php

    r669072 r669301  
    3333
    3434// fcn_htmlencode: options for whitespace conversion
    35 define( 'FCN_HTML_NBSP', 1 );   // " " -> "&nbsp;"
    36 define( 'FCN_HTML_BR', 2 );     // "\r" -> "<br />"
    37 define( 'FCN_HTML_NBSP_BR', 3); // 1 + 2
    38 define( 'FCN_HTML_BR_NBSP', 3); // 1 + 2
    39 define( 'FCN_HTML_ATTRIB', 4);  // "\n" -> &#10; "\r" -> &#13;
     35// default: \n -> &x10;  \r -> &x13;
     36define( 'FCN_HTML_BR', 1 );      // "\n" -> "<br />"
     37define( 'FCN_HTML_NBSP', 2 );    // " " -> "&nbsp;"
     38define( 'FCN_HTML_NBSP_BR', 3);  // 1 + 2
     39define( 'FCN_HTML_BR_NBSP', 3);  // 1 + 2
     40define( 'FCN_HTML_PRESERVE', 4); // no change
    4041
    4142
     
    401402
    402403    // handle whitespace conversion
    403     if ( $ws == 1 || $ws == 3 )
    404     {
    405         $html = str_replace( "\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $html );
    406         $html = str_replace( ' ', '&nbsp;', $html );
    407     }
    408 
    409     if ( $ws == 2 || $ws == 3 )
    410     {
    411         $html = str_replace( "\r\n", "\n", $html ); // pc
    412         $html = str_replace( "\r", "\n", $html );   // mac (old <= 9)
    413         $html = str_replace( "\n", '<br />', $html );
    414     }
    415 
    416     if ( $ws == 4 )
     404    if ( $ws )
     405    {
     406        if ( $ws == 2 || $ws == 3 )
     407        {
     408            $html = str_replace( "\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $html );
     409            $html = str_replace( ' ', '&nbsp;', $html );
     410        }
     411
     412        if ( $ws == 1 || $ws == 3 )
     413        {
     414            $html = str_replace( "\r\n", "\n", $html ); // pc
     415            $html = str_replace( "\r", "\n", $html );   // mac (old <= 9)
     416            $html = str_replace( "\n", '<br />', $html );
     417        }
     418    }
     419    else   
    417420    {
    418421        $html = str_replace( "\n", '&#10;', $html );
     
    430433    foreach ( $def as $key => $value )
    431434    {
    432         $attrs .= ' '.$key.'="'.fcn_htmlencode($value,FCN_HTML_ATTRIB).'"';
     435        $attrs .= ' '.$key.'="'.fcn_htmlencode($value).'"';
    433436    }
    434437    return $attrs;
     
    564567                    }
    565568
    566                     $html .= '<option value="'. fcn_htmlencode($key, FCN_HTML_ATTRIB) . '" ';
     569                    $html .= '<option value="'. fcn_htmlencode($key) . '" ';
    567570
    568571                    // allow single or multiple selected values
  • facebook-comments-notifier/trunk/fb-comments.js

    r669291 r669301  
    11// encode data for html context
    2 var FCN_HTML_NBSP    = 1; // ' ' -> &nbsp;
    3 var FCN_HTML_BR      = 2; // \n \r -> <br />
    4 var FCN_HTML_NBSP_BR = 3; // 1 + 2
    5 var FCN_HTML_BR_NBSP = 3; // 1 + 2
    6 var FCN_HTML_ATTRIB  = 4; // \n -> &x10; \r -> &x13;
     2// default: \n -> &x10;  \r -> &x13;
     3var FCN_HTML_BR       = 1; // \n -> <br />
     4var FCN_HTML_NBSP     = 2; // ' ' -> &nbsp;
     5var FCN_HTML_NBSP_BR  = 3; // 1 + 2
     6var FCN_HTML_BR_NBSP  = 3; // 1 + 2
     7var FCN_HTML_PRESERVE = 4; // preserve
    78
    89function fcn_htmlencode (str, ws) {
     
    1819    // encode whitespace
    1920    if ( ws ) {
    20         if ( ws == 1 || ws == 3 ) {
     21        // translate space
     22        if ( ws == 2 || ws == 3 ) {
    2123            str = str.replace(/ /g, "&nbsp;");
    2224            str = str.replace(/\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;");
    2325        }
    24         // also insert line breaks
    25         if ( ws == 2 || ws == 3 ) {
     26        // htmlify line breaks
     27        if ( ws == 1 || ws == 3 ) {
     28            str = str.replace(/\r\n/g, "\n"); //pc
     29            str = str.replace(/\r/g, "\r");   // mac <= 9
    2630            str = str.replace(/\n/g, "<br />");
    2731        }
    28         // also insert line breaks
    29         if ( ws == 4 ) {
    30             str = str.replace(/\n/g, "&#10;");
    31             str = str.replace(/\r/g, "&#13;");
    32         }
     32    } else {
     33        // for attributes/general
     34        str = str.replace(/\n/g, "&#10;");
     35        str = str.replace(/\r/g, "&#13;");
    3336    }
    3437    return str.valueOf();
Note: See TracChangeset for help on using the changeset viewer.