Area51 @ 4seven.de

Mod Base and Testarea
It is currently 23 Feb 2025, 15:38

All times are UTC + 1 hour




Post new topic TOPIC_LOCKED  [ 2 posts ] 
Author Message
PostPosted: 21 Apr 2012, 13:55 
Offline
Tiptop
Tiptop
User avatar

Joined: 11 Feb 2008, 11:49
Posts: 241
Convert magic_urls to code tags V1

V1 converts all external links in a post without [url] tags grouped into code box.

Demo: http://4seven.bplaced.net/forum/3/viewtopic.php?p=72#p72

Screen:

Attachment:
url_to_code.png
url_to_code.png [ 5.41 KiB | Viewed 2157 times ]

Note:
Bcs. of technical reasons the code box was append to the bottom of each posting.
Altering the message directly seems not to work, bcs. it gives wired results,
if a normal code box with links is also present. May another provide a trick,
but after some tests this seems the only solution to get rid of this behaviour.

Instruction

open

viewtopic.php

find

Code:
    // Parse the message and subject
    $message = censor_text($row['post_text']);


before add

Code:
// URLs to Code / 4seven / 2012
$url_code  = '';

if (strpos($row['post_text'], 'postlink') !== false){

preg_match_all('#<a(.*?)class="postlink"(.*?)>(.*?)<\/a>#is', $row['post_text'], $message_urls);

$row['post_text'] = preg_replace('#<a(.*?)class="postlink"(.*?)>(.*?)<\/a>#is', '', $row['post_text']);

// var_dump($message_urls);

if (!empty($message_urls[0])){

$url_code .= '<dl class="codebox"><dt>' . $user->lang['CODE'] . ': <a href="#" onclick="selectCode(this); return false;">' . $user->lang['SELECT_ALL_CODE'] . '</a></dt><dd><code>';

foreach(
$message_urls[0] as $mess_urls){
$url_code .= preg_replace('#<a(.*?)class="postlink"(.*?)>(.*?)<\/a>#is', '$3<br />', $mess_urls);
}

$url_code .= '</code></dd></dl>';

}}
// URLs to Code Block / 4seven / 2012          


find

Code:
        'MESSAGE'            => $message,


after add

Code:
        'MESSAGE'            => $message . $url_code,

_________________
Mod-Bot / Service-Team


Top
 Profile  
 
PostPosted: 21 Apr 2012, 17:01 
Offline
Tiptop
Tiptop
User avatar

Joined: 11 Feb 2008, 11:49
Posts: 241
Convert magic_urls to code tags V2

V2 converts all external links in a post without [url] tags into its own code box.

Screen:
Attachment:
url_code_v2.png
url_code_v2.png [ 5.65 KiB | Viewed 2136 times ]

Instruction

open

viewtopic.php

find

Code:
    // Parse the message and subject
    $message = censor_text($row['post_text']);


before add

Code:
$row['post_text'] = preg_replace('#<a(.*?)class="postlink"(.*?)>(.*?)<\/a>#is', '<dl class="codebox"><dt>' . $user->lang['CODE'] . ': <a href="#" onclick="selectCode(this); return false;">' . $user->lang['SELECT_ALL_CODE'] . '</a></dt><dd><code>$3</code></dd></dl>', $row['post_text']); 

_________________
Mod-Bot / Service-Team


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic TOPIC_LOCKED  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
[ Time : 0.069s | 23 Queries | GZIP : Off ]