Can't fix Redactor is no longer maintaining tabs

Chris D

XenForo developer
Staff member
Noticed it yesterday too but again, today. I am trying to paste this bit of code:

upload_2013-7-11_19-5-45.webp

But it produces this instead:

PHP:
<?php



class YourAddOn_Listener

{

public static function extendThreadController($class, array &$extend)

{

$extend[] = 'YourAddOn_ControllerPublic_Thread';

}

}

I suspect some sort of bug fix has broken this as this is now back to TinyMCE behaviour, unfortunately. When Redactor first launched here, it kept indentations via tabs etc. by converting the tabs to 4-5 spaces. Worked great.

I'm using Chrome 28 on Mac OS X Mountain Lion. Haven't tested it on Windows yet.
 
Code:
{
        if ($line =~ /(?:\d)\s(?:\d)\s(\d{4}\-\d{2}\-\d{2})\s(\d{2}\:\d{2}\:\d{2})\s(\d+\.\d)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\w+|\*)\s([A-Z,0-9]\w+|\*)\s(\d+)\s(\d+)\s(\w+)\s(\d{1,2})\s\d+/)
        {
                my ($date,$time,$dur,$nac,$mod,$et,$chan,$baud,$calling,$called,$btx,$brx,$flag)=($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13);
                my $dtime = $date . " " . $time;
                if ($called =~ /^([1-3])\d+/)            #strip off DI
                {
                $called =~ s/^([1-3])(\d+)/$2/;
                $dial=$1;                              #put DI in its own column
                }
                else
                {
                $dial="undef";
                }
                $sthins2->execute(undef,$dtime,$dur,$nac,$et,$chan,$mod,$baud,$calling,$called,$dial,$btx,$brx,$flag);
        }
        else
        {
                #print LOGERROR "$line ";
        }
}

Windows 7 Chrome
 
PHP:
// Pull the data for the dial attempts and the totals
while ($row = mysqli_fetch_assoc($result)) {
        extract($row);
        $percent = number_format($totals / $payp_total_calls * 100, 2);
        if ( $dial == "1" && $percent < "94" )
        {
        echo '<tr><td class="error">'. $dial . '</td>
        <td class="error">' . number_format($totals) . '</td>
        <td class="error">' . $percent.'%</td></tr>';
        } else {
        echo '<tr><td>'. $dial . '</td>
        <td>' . number_format($totals) . '</td>
        <td>' . $percent.'%</td></tr>';
        }
}
mysqli_free_result($result);
 
Win 8/Chrome 28

PHP:
    public static function extendDataWriter($class, array &$extend)
    {
        if (!self::$_addedUsernameChange && $class == 'XenForo_DataWriter_User')
        {
            self::$_addedUsernameChange = true;
            XenForo_DataWriter_User::$usernameChangeUpdates['permanent']['showcase_username'] =
                array('xf_nflj_showcase_item', 'username', 'user_id');
        }
               
        switch ($class)
        {
            case 'XenForo_DataWriter_AttachmentData':
   
                $extend[] = 'NFLJ_Showcase_DataWriter_AttachmentData';
                break;
        }
    }
 
Tabs working here when I wrap the text in [ PHP ] tags.

Damn. Are you using Mac OS X?

EDIT: Seems to be exclusive to my IDE. Copy pasting from there messes something up.

EDIT 2: It seems to be getting confused because if I post as plain text is fine. So that would suggest it's trying to copy formatting over from the IDE or something. Which is odd. And never happened before.

Thanks for confirming guys.
 
Win 7, ff21, pasted from notepad++

Code:
<?php
class MediaSites_Soundcloud
{
    public static function buildEmbed($mediaKey, array $site)
    {
        $urlKey = urlencode($mediaKey);
        $scUrl = 'http://soundcloud.com/oembed?iframe=true&url=http%3A%2F%2F' . $urlKey;
       
       
        $ci = curl_init();
        curl_setopt($ci, CURLOPT_URL, $scUrl); 
        curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
        $datas = curl_exec($ci);
        curl_close($ci);   
        if (!isset($datas)) {
            $datas = @file_get_contents($scUrl);
        }
        $xObj = simplexml_load_string($datas);
        $embedHtml5 = $xObj->html;
        if (isset($embedHtml5)) {
                return $embedHtml5;   
        }   
        else return '<a href="http://' . $mediaKey . '">http://' . $mediaKey . '</a>';
    }
}
PHP:
<?php
class MediaSites_Soundcloud
{
    public static function buildEmbed($mediaKey, array $site)
    {
        $urlKey = urlencode($mediaKey);
        $scUrl = 'http://soundcloud.com/oembed?iframe=true&url=http%3A%2F%2F' . $urlKey;
       
       
        $ci = curl_init();
        curl_setopt($ci, CURLOPT_URL, $scUrl); 
        curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
        $datas = curl_exec($ci);
        curl_close($ci);   
        if (!isset($datas)) {
            $datas = @file_get_contents($scUrl);
        }
        $xObj = simplexml_load_string($datas);
        $embedHtml5 = $xObj->html;
        if (isset($embedHtml5)) {
                return $embedHtml5;   
        }   
        else return '<a href="http://' . $mediaKey . '">http://' . $mediaKey . '</a>';
    }
}

Have you tried copying from your ide and pasting it to an editor, then copy something else to clear ide text from your clipboard, then copy that same text in your ide from the text editor in which you pasted it in?

Just curious what happens there.
 
I've had to do that in the past. Copy from Zend Studio to UltraEdit/Notepad, and then past here, I assumed it was an editor issue on xF copying the formatting incorrectly.

Haven't had that problem in a long while though (Windows)
 
What IDE are we talking about? It might be how it's copying (and then being converted to HTML). It may not be detectable though.
 
I've had this same problem with Eclipse PDT itself, in the past on my windows machine, copying and pasting code with tabs. A PDT update fixed it I think, (only PHP files were affected), or maybe that's when I moved to Zend Studio, which doesn't have the problem. Do you use Indigo, Juno, Helios(?)?

I originally thought that the problem was that PDT didn't recognize the END-IF structure that PHP supports, but it wasn't that.
 
Last edited:
It's the same with the most recent version of Aptana (on Mac).

I'm still to test it on Windows.

As for Eclipse I have tried it in Juno with PDT and the latest version 4.3... Kepler without PDT installed... so it basically seems to be Eclipse exclusive. If someone can confirm if it's the same on Windows too that would be useful.

This should mean it affects Zend Studio as well, in theory.
 
Doesn't seem to happen in Windows PDT (though admittedly, my PDT isn't totally updated as I stopped using it a while a go).
 
So finally got a chance to dig into this and it's not something we can fix without compromising other things.

Eclipse (in Mac) actually pastes <p> tags which mean something different. In Windows, it seems to only copy the plain text version (which then gets formatted by the browser on paste).

Nothing that we can really do unfortunately.
 
Top Bottom