vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Graveyard (https://vborg.vbsupport.ru/forumdisplay.php?f=224)
-   -   Text Replacement Links 1.1 (Updated!) (https://vborg.vbsupport.ru/showthread.php?t=71191)

Jolten 12-30-2004 08:13 PM

I'll reiterate. I've applied all changes posted here in this thread. And it still does not work. However, as I posted above, I believe it won't work for me due to admin ability to post html on my forums. For me, admins posting html is more important that text replacements, especially since these replacements can be handled in the built-in vb3 replacement variables.

MajorFm.com 01-01-2005 10:44 PM

you cannot do this in the built-in vb3 replacement variables.

e.g.

If i replace

Code:

value
with

Code:

[url = http://www.value.com]value[/url]
it will replace the word value everywhere, in the thread titles, anywhere and it actually replaces it with the text which the forum doesn't pick up as vb code.

I actually need this hack! and was looking for it, its a shame its not finished, i know that Geographic2 has tried to help, however, when i did the test on your forum, the word pumpkin did not replace with a link.

I need this hack asap and would love for someone to finish it!

p.s. i added a few spaces coz this forum kept picking it up as vb code

eXtremeTim 01-02-2005 12:06 AM

Im planning to install this hack tonight. I will see about releasing what code I use that works correctly. I will then talk with my man livewire and see if he cares about me releasing a new version of this hack for him.

Geographic2 01-02-2005 04:25 PM

Quote:

so it only works if you go thru this thread and try and figure out all of the additional changes that others have made? to me that means this thing needs to go back to the beta forum or the hack developler needs to update his instructions. I should not have to read thru a thread and guess which additional changes need to be made to the code to make the hack work, that is silly.
If you can't take the idea and run with it to get it working to your desires it's certainly not my problem. The concept works. The code as posted throughout the thread works.

I agree though move it to beta so people who can't program or stand to read a thread will stay away from it. :)





Quote:

it will replace the word value everywhere, in the thread titles, anywhere and it actually replaces it with the text which the forum doesn't pick up as vb code.

I actually need this hack! and was looking for it, its a shame its not finished, i know that Geographic2 has tried to help, however, when i did the test on your forum, the word pumpkin did not replace with a link.
I have added additional logic to the code to avoid what would ultimately become way too many links. As you can see on the AI Growbot's reply to you that the Quoted text from your posts WAS linked. And therefore this hack still does work. :ermm:

http://www.giantvegenetics.com/gv/showthread.php?t=2390

Jolten 01-02-2005 05:18 PM

I'm not a php idiot. I've coded quite a bit. I've followed everyone's advice here, installed and reinstalled. I still can not get this hack to work in any form on my site. I can not rule out that it's my site that is the problem. However, this is the first release by anyone at vb.org that I could not get to function.

Souli 01-04-2005 09:56 AM

Works great - no problems :squareeyed:

wkhalaf 01-06-2005 12:23 AM

This hack is not working .. everything is installed word by word .. but the hack it self wouldn't work .. and the links wouldn't show ..

Prince 01-06-2005 02:23 AM

I agree, I have been hacking vB for 3 years and I cannot get this one to work either.

dhurd 01-21-2005 01:08 AM

I couldn't get it to work initially but I added the changes that Geographic2 had posted and then it did work. However, it appears that if the text that is to be replaced is at the last text of the post or if the text is followed by a punctuation mark it doesn't not work.

Skyline_GT 01-24-2005 06:11 PM

thanks.. will install this for sure..

Skyline_GT 01-27-2005 08:34 AM

this hack doesn't work at all..

Sal Collaziano 01-28-2005 10:00 PM

Somebody should continue to work on this. It's a really great option for advertisers. Not only does their banner ad show (if they have one), but any time their company name is addressed, it can link to their web site...

Robert Basil 02-09-2005 07:44 PM

The hack works great for me. But with the "spaces" addition it will not work if the word to be replaced is the first or last word in a post.

aspen0 02-18-2005 12:38 PM

Got it working with the code (case insensitive) posted by Geographic2.

One bug I noticed though -- it doesn't handle phrases.

I can't replace 2 word phrases. So I couldn't replace say "Golden Retreiver" with a link to a description of the breed.

Limitation of the system? Or something easily fixed?

Geographic2 03-26-2005 05:42 PM

If you don't like the way it is parsing things then come up with a better regular expression to cover what you are looking for. I'm happy with the way this one has performed for me. Here it is running on my Glossary of Botanical Terms which is integrated with my WIKI. I personally feel there are already enough links being made without including the ones which appear with punctuation etc. I'd actually think of making it limit the # of links more that create more than there is like this.


If you want to check to see if it's at the end of a sentence or followed by a comma simply define it in the regex:
Code:

                    $findtext[] = "/\s".$link['text']."\s/i";
Instead of looking for just a space at the end, you need to look for space or any punction marks ? , . ! etc... Or....

Instead of blocking the replacement of what are already URL's which is the reason I introduced the search for " word " instead of "word" in the first place way back when, you could search for "Not [" and "Not ]" to prevent the url bbcode from being broken. I'm a big fan of people learning how to do things, so somebody learn and figure it out.

I can get mine to cover 2 word phrases, not sure why yours will not.
I am using the same regex I posted here... Here I am replacing the phrase "Giant Vegetables", when I put it in via the admin CP i don't include the quotation marks.
http://www.giantvegenetics.com/gv/sh...9&page=3&pp=10

Code:

                    $findtext[] = "/\s".$link['text']."\s/i";
                    $replacetext[] = " " . $link['text'] . " ";


lewekleonek 04-19-2005 03:44 AM

Here is another fix to the fix of the fix (just kidding).
Yet another thought before I'll move on to the fixed code posting - make sure that the version of the php your server is runing has PCRE enabled; navigate to your admin control panel, go to 'Import & Maintenance' section; click on 'View PHP Info' link. Once you are able to view PHP info in the main panel please search for 'pcre':
PCRE (Perl Compatible Regular Expressions) Support enabled
If the line is missing the code may not work for you.

What's fixed:
- now it works with phrases
- works with both words and phrases at the beggining or the end of the post
Enjoy it:
Code:

static $customReplaceInit = false;
        static $findtext = array();
        static $replacetext = array();

    if (!$customReplaceInit)
    {
            $textlinks = $DB_site->query(" SELECT text, link FROM " . TABLE_PREFIX . "textlink");
            while($link = $DB_site->fetch_array($textlinks))
            {
                    $findtext[] = "/(\s+|^)".$link['text']."(\s+|$)/i";
                    $replacetext[] = " " . $link['text'] . " ";
            }
        $customReplaceInit = true;
    }

        $bbcode=preg_replace($findtext, $replacetext, $bbcode);

/LL

Logikos 04-28-2005 11:28 AM

Hey everyone, i'm back for good now and i'll be able to start updating and supporting my hacks. I just read the thread and i have to thank everyone who has contributed there time to trying to make this hack work while i was away. I am going over the code now and will have an update very shortly with all fixes. Thanks again!

Marco van Herwaarden 04-28-2005 01:48 PM

Nice to see you back (for good???).

Prince 04-28-2005 03:04 PM

It works! :)

Thanks!

Prince 04-28-2005 04:14 PM

everything works great, but I do get an error every time I add a new text link in the redirect window:

Cannot find phrase: "saved_text_link_x_successfully'

Prince 04-28-2005 04:55 PM

actually, none of the redirect window phrases work, they all give he "could not find phrase" error.

Logikos 04-28-2005 07:07 PM

I noticed that, but the thing is the phrase is there. If you search the phrase it is in the database but for some reason its given me that error. I'll check it out after work.

Yes for good.... :)

Prince 04-29-2005 12:29 AM

yes the phrase is there and as far as I can tell the code is calling the correct phrase, but there is definitely something coded wrong.

Prince 05-03-2005 03:42 AM

figure anything out yet? :)

Logikos 05-03-2005 05:51 AM

Havn't even worked on it, its not a top priority on my list. As long as the hack work for now. Next version will be the fix.

j_86 05-03-2005 06:05 AM

Is this compatiable with the Geek Auto Linker?

Logikos 05-03-2005 09:49 AM

Not sure what that does

-=Sniper=- 05-16-2005 04:47 PM

Quote:

Originally Posted by Live Wire
Not sure what that does

its similar to your hack with loads of features...

Logikos 05-16-2005 06:09 PM

hmmm, came out 2 months after mine. Have to take a look at it.

-=Sniper=- 05-21-2005 05:48 PM

just a question, lets say I have amazon linking to amazon.com

a user makes a post and types "AMAZON" all in CAPS, the hack links but converts it back to lowecase, is it possible to avoide this problem?

also is this one query per page or per post.

Logikos 05-22-2005 06:24 AM

One query per page. That isn't possiable. If you have the word "Soda" as a link going to coke.com, and a user says. I like to drink soda. It will show up as a link. There isn't a way around it unless you deigne something where it can tell the PHP how the user is using the word.

-=Sniper=- 05-22-2005 08:28 PM

I think the geek auto linker only has one query per page.

Logikos 05-22-2005 10:24 PM

As this one does also.

-=Sniper=- 05-22-2005 10:29 PM

hehe what you wrote didnt make sense...anyway I just tested auto linker again, and it seems to do what I described above.

not sure which system to use :)

Logikos 05-22-2005 10:45 PM

Quote:

Originally Posted by -=Sniper=-
I think the geek auto linker only has one query per page.

You said that the geek auto linker only has one guery per page, as this hack does also.

I would use whatever fits your needs, this isn't any sort of competition. :)

tylercruz 06-04-2005 03:19 AM

I installed it, but it's not working as well as I hoped, so I'll be removing it. My beef with it is that it messes up the formatting of posts right now.... Sometimes it removes the newlines in posts, and sometimes it removes the preceeding space, making posts really cluttery...

Let me know when you beef this up and fix the errors..

Logikos 06-04-2005 05:55 AM

i acually never seen this error. Got a screenshot?

Supernature 07-23-2005 10:27 AM

At first, I have to say "Thank you" for this excellent work!
I found out why the redirect phrases are not working - they phrasetypeid is wrong. I use the german vB3, so I don't know how the type is called in the english version, must be something like "Control Panel: Messages" - the phrasetypeid is "9000" (as sayed, in the german version).

After installing the hack, i asked myself:
If someone asks "Where do I find the homepage of XYZ", and XYZ is in the TextReplacement-Table, the other users will think he is completely insane, because there is no option to tell this automatic link from the others.

So I did the following modification:

I changed one line in the code to insert in functions_bbcodeparse.php from

PHP Code:

$replacetext[] = " [url=" $link['link'] . "]" $link['text'] . "[/url] "

to
PHP Code:

$replacetext[] = " [autolink=" $link['link'] . "]" $link['text'] . "[/autolink] "



Next, I created a custom vb-Code:

Name: autolink
Tag: autolink
Code to insert:
Code:

<span class="autolink"><a title="this link has been created automatically" href="{option}" target="_blank">{param}</a>*</span>
Use option: yes



At last, I went to the custom CSS-Definitions and inserted the following:
Code:

.autolink a:link
{
  text-decoration:underline;
}
.autolink a:visited
{
text-decoration:underline;
}
.autolink a:hover
{
text-decoration:underline;
}

The result is that the generated links are marked with a '*', and on mouseover, the text "this link has been created automatically" will appear.
Additionally, the links will be underlined.
If you alreade use "underline" for the normal Links, you should use any other CSS-Definition.

Logikos 07-23-2005 10:49 AM

Thank you for that! I will definitly be looking at your above post when I port this to 3.5.0! :)

Supernature 07-23-2005 01:51 PM

Feel free to do so :)
Just found another problem: If the text to replace is followed by a ".", it will not work.
And if the word to replace is the first in a line, the link will "jump" to the end of the line before, even if there are one ore more blank lines in between.
(Tried this also with the original hack without my modifications, same behaviour).
Any idea?


All times are GMT. The time now is 10:57 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01368 seconds
  • Memory Usage 1,831KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_code_printable
  • (2)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete