Page 1 of 1

[DEV] Copy Text Into Clipboard "[copy][/copy]" MOD

Posted: Mon Jun 03, 2002 4:35 pm
by GraphixMaster
I am starting development on a new MOD for phpBB.

This is what I want it to do...

[copy=some text]Link Name[/copy]

Link Name

When clicked, the URL will call a JavaScript fuction that will load the text inside the URL into the clipboard. This can then be pasted into a text file, or something, later.

I haven't written the JavaScript file yet - that is the easy part. The hard part is getting this [copy=text][/copy] to produce an active hyperlink. I am using the already existing URL fuction as a template of how to go about this.

When I put the code into the files, all hell breaks loose. The URL fuction that I am using as a template doesn't want to produce an active hyperlink - but, the [copy][/copy] does. I have stolen the results from the original. That, needless to say, is a problem. Here is the modified URL code I used.

Code: Select all


	// []phpBB[/url] code.. (no xxxx:// prefix).
	$patterns[4] = "#\[url=([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)\](.*?)\[/url\]#si";
	$replacements[4] = $bbcode_tpl['url4'];


	// [copy=the text to be copied]Link Name[/copy] code..
	$patterns[4] = "#\[copy=([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)\](.*?)\[/copy\]#si";
	$replacements[4] = $bbcode_tpl['copy1'];


	$bbcode_tpl['url3'] = str_replace('{URL}', '\\1\\2', $bbcode_tpl['url']);
	$bbcode_tpl['url3'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url3']);


	$bbcode_tpl['copy1'] = str_replace('{js_copy}', '\\1\\2', $bbcode_tpl['copy1']);
	$bbcode_tpl['copy1'] = str_replace('{LINK_NAME}', '\\3', $bbcode_tpl['copy1']);
That is from the includes/bbcode.php file

This is from the templates/template name/bbcode.tpl file

Code: Select all

	<!-- BEGIN copy --><a href="{js_copy}" 	class="postlink">{LINK_NAME}</a><!-- END copy -->
I hope that makes sense to you - it kind of does to me.

Like I said, I am only interested right now in getting the hyperlink to be clickable and launch a new window. The JavaScript function i am planning on using will go into the <a href= > tag.

Please, look at the code and tell me why the url function gets screwed when I insert my [copy] function. I am new to PHP as you no doubt can tell - as a matter of fact I installed PHP 4 and MySQL on my server less than a week ago. The upside to this? Well, is helping me learn an entirely new language... so, even if I fail miserabley at this MOD. I will have had the pleasure of getting to know a new language.

Thank you for your help.

If this belongs in a questons section - I am very sorry.