JoshyPHP Thank you for your reply.
I managed to understand how to translate most of the SMF bbcode into flarum XML, and I can migrate correctly almost everythig with the script we released yesterday.
It makes a lot of sense to not re-invent the wheel though, so I'll definitively try to update it in the next few days to make use of your beautiful library.

marcozambi changed the title to SMF2 to Flarum migration script - alpha 3 .
16 days later

JoshyPHP Hi there! I'm working again on the code for a better Board-to-Tag conversion, and I decided to abandon the "do-it-yourself" bbcode to XML translation and go fully with your fantastic library s9e/TextFormatter.

I'm using the Forum bundle at the moment, with excellent results, but I noticed that for some reason the emoticons/emoji are not converted.
I tried an experiment, doing a small quick conversion using, instead of the Forum bundle, only the emoji Plugin.

If I try this code

$configurator = new s9e\TextFormatter\Configurator;
$configurator->Emoji->useEmojiOne();
extract($configurator->finalize());

they are converted perfectly.

I was wondering, is there a way (I tried all sort of things) to tweak some settings in the Forum bundle,to set explicitly for example the usage of Emoji->useEmojiOne(); in the Bundle itself?

You did a superb job with this library, but if I may suggest you an improvement that would immensely help potential users,, some extra usage about "mixing" Bundles with Configurator examples would be great!

Thanks in advance!

The Emoji plugin was only added recently to the Forum bundle, it's possible your version doesn't include it. Bundles are read-only snapshots of a particular configuration. It's not possible to modify them.

However, you can get a configured instance of s9e\TextFormatter\Configurator that you can use to generate your own instance of the parser and render. You can also save them as your own bundle if you want to reuse them more easily. Or you may want to just serialize the parser/renderer and reuse those instead, as Flarum does. That's the preferred method.

$configurator = s9e\TextFormatter\Configurator\Bundles\Forum::getConfigurator();
$configurator->Emoji->addAlias('x.x', '😵');
$configurator->saveBundle('MyBundle', '/tmp/MyBundle.php');

include '/tmp/MyBundle.php';

$text = '[center]x.x[/center]';
$xml  = MyBundle::parse($text);
$html = MyBundle::render($xml);

die("$html\n");
<div style="text-align:center"><img alt="x.x" class="emoji" draggable="false" width="16" height="16" src="//cdn.jsdelivr.net/emojione/assets/png/1f635.png"></div>
    18 days later
    3 months later

    I'm waiting for the release of flarum to migrate my SMF2 forum to flarum so please continue your great job ?

    I will test it as soon as possible

    23 days later

    Well done, nice script. In an alternative version, I did not notice any bugs with the display of HTML ? Working perfectly
    But i found 1 weirdness - only 61 users was converted from ~502

    marcozambi no passwords are exported. Migrated users will have to ask for a new one

    This one makes me cry too ?

      -ExotiC- But i found 1 weirdness - only 61 users was converted from ~502

      Can you see any commonality among those users? That would help a lot to fix a possible bug.
      I'm waiting for the first stable to release an updated importer script ?

        marcozambi
        I do not find any common attributes in old SMF database and in a new Flarum db for imported users ?

        P.S.: When i run script i have some note for all users, which was founded to export from SMF:

        Notice: Undefined offset: 1 in W:\domains\flarum.local\smf2_to_flarum_alternative.php on line 251
        User 000018 - lausin2

        And after 100 imported discussions i have

        Notice: ob_flush(): failed to flush buffer. No buffer to flush in W:\domains\flarum.local\smf2_to_flarum_alternative.php on line 533

        How I can rerun it and clear db of flarum for test the script again? Another clean install of flarum without any entry in DB? Or i can just delete all tuples in DB from 'users' table, 'users_discussions', 'user_groups', 'discussions' and 'posts'? And just reopen the script? Thanks.
        Sorry for my English.

        marcozambi I make screenshot of my old SMF database, maybe I missed something.
        Orange highlighted users which have been successfully imported to Flarum database.

        WARNING! 7013x751 screenshot size ?
        http://i.imgur.com/PP0kCYg.jpg

        2 months later

        @marcozambi So you have any idea what the problem could be? I still can not find a flaw in the code ?

          11 days later

          -ExotiC- @marcozambi
          I'm also trying to use this script to test the migration of a SMF board to Flarum and came across this issue (and a bunch of others). Although I can't say why, the user list is being limited by the last part of the query (the WHERE part):

          WHERE 
          			".$table_prefix."attachments.attachment_type = 0

          If you remove that, it will at least select every member instead of just a few (in my case ~100 in a little over 10000).

          On other issues:

          • I don't think anyone has mentioned importing attachments other than images using flagrow/upload, the replacement for flagrow/flarum-ext-image-upload which the script is using. I have no idea on how to approach this, so if anyone has any pointers I'd be welcome to try.

          • This line makes no sense: $src_dir = $attachments_dir[$idx_src_dir];and I replaced it by $src_dir = $attachments_dir[0]; and along with removing the WHEREstatement I mentioned earlier makes the import output clean and tidy. But making that change leaves me thinking what is the $idx_src_dirvariable for.

          That said, so far I've imported Users, Categories (boards/sub-boards) and Posts. I'm going to check on these to see if everything is passing on as it should or not, and later on I'll try the attachments part.


          Edit: Posts imported more or less ok, but it timed-out and I'm yet to verify what's missing.

            0E800
            Last Edit on: 24th Mar 2017

            For organisation purposes, I'm editing this post as I go along using the Alternative version of the script and adding short new posts referring back here:

            SCRIPT USAGE RESULTS:

            Users:

            • All Users are imported to the same Member group (group id 3): i.e. you'll have no admins, mods, etc., you'll have to set those manually, and it will be overwritten every time you run the script (unusable password hash included)
            • Avatars: ?? None of my forum's avatars were imported (does the script process them or not? Also, there are local avatars and external ones!)
            • User Signatures in Posts: No (missing from flarum?)_

            Boards:

            • Permissions: All of those will be gone, permissions default for all categories

            Posts - Text (mostly bbcode):

            • Post migration: it works, but my database is quite large and the script breaks every time. To be checked later on
            • Paragraph Text: Mostly Ok, though there is something off with the paragraph spacing, it doesn't seem to be as neat as the one in these posts at this forum. Edit: the script is converting double line break tags <br><br> to single line <br>, making posts less readable (no spacing between paragraphs). Edit #2: it's by default in the script, read mode here
            • Quotes: Ok as well as Quotes within Quotes
            • Links: Mostly Ok, BUT the internal URLs are not being corrected. That's to be fixed with rewrites, I guess, but it would be great if the URLs could migrate to the new Flarum URL...
            • Code: Ok
            • Bold text: Ok
            • The script removes all non converted BBcode by default (// Delete all non converted bbcode)

            Posts - Media/Other:

            • Polls: No, polls are not available in flarum, read more here
            • Embedded Youtube Video URLs: Ok
            • Images:
              • I have yet to run this part of the script, as I would like to try using the flagrow/upload extension instead (to import all attachments, not only images)
              • However, images inline to posts are displaying correctly, while linked to their original location/URL
            • Other Attachments: not possible with the current extension the script supports, needs to be updated to use flagrow/upload

            AFTER MIGRATION BOARD FUNCTIONALITY:

            • Board Permissions: to check
            • User (Guest) Permissions: to check
            • Support for Google Analytics
            • ...

            INSTALLED EXTENSIONS:

            Unrelated to the script, but as I am testing it I should mention I have installed these extensions so far, and they seem to work well:

              One additional thing: the script keeps timing-out when importing Posts. My database is pretty large, so that's the reason, but still there should be a way of knowing what's happening and limiting it.

              I've checked what I mentioned earlier about the paragraphs being off: there is definitely something wrong, as (for example) double break tags ( <br><br> ) are being imported as only one.

              Edit: found it in the code, it's there by definition (but in my case i'll comment it out):
              // Replace multiple (one ore more) line breaks with a single one.
              $text = preg_replace('/[\r\n]{2,}/s', "\n", $text);

                The script will need some continuous work when Flarum releases a new build, in which case extensions are inclined to break because of naming convention changes, API changes, etc.