Announcement

Collapse
No announcement yet.

PHP gets mangled

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Forum] PHP gets mangled

    Hi,

    When copying and pasting some code for use in the [php] tags it seems to mess up the formatting. Here is the php code placed into [code] tags:

    Code:
    if (isset($_GET["sortby"])) {    if ($_GET['sortby'] == 'nameasc') {
                $sort = 'name ASC';
        }
        else if ($_GET['sortby'] == 'namedesc') {
            $sort = 'name DESC';
        }
        else if ($_GET['sortby'] == 'newest') {
            $sort = 'id DESC';
        }
        else if ($_GET['sortby'] == 'oldest') {
            $sort = 'id ASC';
        }
        else if ($_GET['sortby'] == 'rating') {
            $sort = 'rating DESC';
        }
    }
    else {
        $sort = 'id DESC';
    }
    Same thing in [php] tags:

    PHP Code:
    if (isset($_GET["sortby"])) {    if ($_GET['sortby'] == 'nameasc') {            $sort 'name ASC';    }    else if ($_GET['sortby'] == 'namedesc') {        $sort 'name DESC';    }    else if ($_GET['sortby'] == 'newest') {        $sort 'id DESC';    }    else if ($_GET['sortby'] == 'oldest') {        $sort 'id ASC';    }    else if ($_GET['sortby'] == 'rating') {        $sort 'rating DESC';    }}else {    $sort 'id DESC';} 
    As you can see, it's removed the formatting. Obviously this isn't just my site as it's happened here. Is there a fix?

  • #2
    Yeah, it's the WYSIWYG portion of the editor that kills it... Pasting in source mode works as intended...

    Please vote for it here... http://tracker.vbulletin.com/browse/VBIV-14052

    PHP Code:
    if (isset($_GET["sortby"])) {    if ($_GET['sortby'] == 'nameasc') {
                
    $sort 'name ASC';
        }
        else if (
    $_GET['sortby'] == 'namedesc') {
            
    $sort 'name DESC';
        }
        else if (
    $_GET['sortby'] == 'newest') {
            
    $sort 'id DESC';
        }
        else if (
    $_GET['sortby'] == 'oldest') {
            
    $sort 'id ASC';
        }
        else if (
    $_GET['sortby'] == 'rating') {
            
    $sort 'rating DESC';
        }
    }
    else {
        
    $sort 'id DESC';

    - Maurice Workin' in the Jira mine, goin' down, down, down

    Comment


    • #3
      I just pasted this in WYSIWYG mode (copied from notepad).

      Code:
      if (isset($_GET["sortby"])) {    if ($_GET['sortby'] == 'nameasc') {
                  $sort = 'name ASC';
          }
          else if ($_GET['sortby'] == 'namedesc') {
              $sort = 'name DESC';
          }
          else if ($_GET['sortby'] == 'newest') {
              $sort = 'id DESC';
          }
          else if ($_GET['sortby'] == 'oldest') {
              $sort = 'id ASC';
          }
          else if ($_GET['sortby'] == 'rating') {
              $sort = 'rating DESC';
          }
      }
      else {
          $sort = 'id DESC';
      }
      PHP Code:
      if (isset($_GET["sortby"])) {    if ($_GET['sortby'] == 'nameasc') {
                  
      $sort 'name ASC';
          }
          else if (
      $_GET['sortby'] == 'namedesc') {
              
      $sort 'name DESC';
          }
          else if (
      $_GET['sortby'] == 'newest') {
              
      $sort 'id DESC';
          }
          else if (
      $_GET['sortby'] == 'oldest') {
              
      $sort 'id ASC';
          }
          else if (
      $_GET['sortby'] == 'rating') {
              
      $sort 'rating DESC';
          }
      }
      else {
          
      $sort 'id DESC';

      Baby, I was born this way

      Comment


      • #4
        It does seem to depend on where you paste it from. In TextEdit on mac, it formats fine. From Coda, the program I use for development, it mangles it. It worked fine in 3.8, I just updated to 4.1 today. It is only when in the PHP tags it happens, not in plain text and not in code tags.

        Comment


        • #5
          Originally posted by Andy-V View Post
          It does seem to depend on where you paste it from. In TextEdit on mac, it formats fine. From Coda, the program I use for development, it mangles it. It worked fine in 3.8, I just updated to 4.1 today. It is only when in the PHP tags it happens, not in plain text and not in code tags.
          I just tried it from another editor I use, and it wont paste at all - however, that is a CKE issue, not a vBulletin issue - it does the same on the CKE demo (on their site).
          Baby, I was born this way

          Comment


          • #6
            Originally posted by Paul M View Post
            I just tried it from another editor I use, and it wont paste at all - however, that is a CKE issue, not a vBulletin issue - it does the same on the CKE demo (on their site).
            We have this issue as well. This seems odd because if we use the "CODE" bbcode the new lines will work fine. For us it is only the "PHP" tags.

            Also as a test I added:
            PHP Code:
            $this->config['forcePasteAsPlainText'] = 'true'
            To your ckeditor.php file and this fixes the problem. Any other ideas?

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...
            X