XF 1.4 Rebuild Links?

Here is what I was able to do,

Before:
============
rebuild_links_before.webp

=============
After:
===========

rebuild_links_after.webp
Under the regular express textbox enter this
Code:
#(\s|^)((https?://)?(\w|-)+(\.(\w+|-)*)+(?<=\.net|org|edu|com|cc|br|jp|dk|gs|de|in)(\:[0-9]+)?(?:/[^\s]*)?)(?=\s|\b)#is

and for the replacement string enter this:
Code:
[url]$0[/url]

You'll need to do the edit to the file for success of the Post Content Find, replace the library\PostReplace\ControllerAdmin\PostReplace.php content with this
PHP:
<?php

class PostReplace_ControllerAdmin_PostReplace extends XenForo_ControllerAdmin_Abstract
{
    public function actionIndex()
    {
        return $this->responseView('PostReplace_ViewAdmin_PostReplace_Index', 'postreplace_index');
    }

    public function actionReplace()
    {
        $this->_assertPostOnly();

        $input = $this->_input->filter(array(
            'find' => XenForo_Input::STRING,
            'regex' => XenForo_Input::STRING,
            'replace' => XenForo_Input::STRING,
            'commit' => XenForo_Input::UINT,
            'page' => XenForo_Input::UINT,
        ));

        $posts = $this->_getPRPostModel()->getPostsContaining($input['find']);

        foreach ($posts AS $postId => &$post)
        {
            if (preg_match_all($input['regex'], $post['message'], $matches))
            {
                $post['found'] = $matches[0];
               
                foreach ($post['found'] as $pf => &$pp)
                {
                    if (substr($pp, strlen($pp) - 1, strlen($pp)) == '/')
                    {
                        $pp = trim(substr($pp, 0, strlen($pp) - 1));
                        $pp = str_replace(array("\r\n", "\r", "\n", "\t", "\s"), '', $pp);
                    }
                }
               
                $post['replaced'] = preg_replace($input['regex'], $input['replace'], $post['found']);

                $message = preg_replace($input['regex'], $input['replace'], $post['message']);

                if ($input['commit'])
                {
                    $dw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post');

                    $dw->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_IS_AUTOMATED, true);
                    $dw->setExistingData($post, true);

                    $dw->set('message', $message);

                    $dw->save();
                }
            }
            else
            {
                unset($posts[$postId]);
            }
        }

        $viewParams = array(
            'input' => $input,
            'posts' => $posts
        );

        return $this->responseView('PostReplace_ViewAdmin_PostReplace_Replace', 'postreplace_index', $viewParams);
    }

    /**
     * @return PostReplace_Model_Post
     */
    protected function _getPRPostModel()
    {
        return $this->getModelFromCache('PostReplace_Model_Post');
    }
}
 
Top Bottom