Need help to parse bbcode at xs


Subject: Need help to parse bbcode at xs
I'm installing a new bbcode for my xs and i need help :mrgreen:
I don't know how to parse this like xs bbcode.php

OPEN

Code: [Download] [Hide] [Select]
[code linenumbers=false]templates/subSilver/bbcode.tpl[/code]


FIND

Code: [Download] [Hide] [Select]
<!-- BEGIN img --><img src="{URL}" border="0" /><!-- END img -->


AFTER, ADD

Code: [Download] [Hide] [Select]
<!-- BEGIN imgreflect --><img src="{URL}" class="reflect rheight33" /><!-- END imgreflect -->


OPEN

Code: [Download] [Hide] [Select]
includes/bbcode.php


FIND

Code: [Download] [Hide] [Select]
$bbcode_tpl['img'] = str_replace('{URL}', '1', $bbcode_tpl['img']);



AFTER, ADD

Code: [Download] [Hide] [Select]
$bbcode_tpl['imgreflect'] = str_replace('{URL}', '1', $bbcode_tpl['imgreflect']);


FIND

Code: [Download] [Hide] [Select]
// [img]image_url_here[/img] code..
// This one gets first-passed..
$patterns[] = "#[img:$uid]([^?](?:[^[]+|[(?!url))*?)[/img:$uid]#i";
$replacements[] = $bbcode_tpl['img'];



AFTER, ADD


Code: [Download] [Hide] [Select]
$patterns[] = "#[imgreflect:$uid]([^?](?:[^[]+|[(?!url))*?)[/imgreflect:$uid]#i";
$replacements[] = $bbcode_tpl['imgreflect'];



FIND

Code: [Download] [Hide] [Select]
// [img]image_url_here[/img] code..
$text = preg_replace("#[img]((http|ftp|https|ftps)://)([^ ?&=#"nrt<]*?(.(jpg|jpeg|gif|png)))[/img]#sie", "'[img:$uid]1' . str_replace(' ', '%20', '3') . '[/img:$uid]'", $text);



AFTER, ADD

Code: [Download] [Hide] [Select]
$text = preg_replace("#[imgreflect]((http|ftp|https|ftps)://)([^ ?&=#"nrt<]*?(.(jpg|jpeg|gif|png)))[/imgreflect]#sie", "'[imgreflect:$uid]1' . str_replace(' ', '%20', '3') . '[/imgreflect:$uid]'", $text);

Subject: Re: Need Help To Parse Bbcode At Xs
in bbcode.php

find:
// LIST

before add:
if($tag === 'imgreflect')
{
if($this->is_sig)
{
return $error;
}
// generate html
$html = '<div id="reflect rheight33"><img src="' . $content . '" width="' . $width . '" height="' . $height . '" class="reflect rheight33" /></div>';
return array(
'valid' => true,
'html' => $html
);
}

Use this tag when post:
Code: [Download] [Hide]
  1. [imgreflect]link img[/imgreflect]  
  2.  

Profile PM  
Subject: Re: Need help to parse bbcode at xs
with that only change doesn't work

Subject: Re: Need Help To Parse Bbcode At Xs
Zuker wrote: [View Post]
with that only change doesn't work


you will need additional JS upload to your root server , and in overall_header.tpl add this line:

<script type="text/javascript" src="reflection.js"></script>

Profile PM  
Subject: Re: Need help to parse bbcode at xs
It is for vanilla bbcode :wink:

Subject: Re: Need Help To Parse Bbcode At Xs
I did this and it works => check the demo link : http://www.tinhoi.exofire.net/forum/viewtopic.php?t=5


Here is my version, not sure if i did it right way but at least it works :

first upload reflection.js to forum root

open includes/bbcode.php

Code: [Download] [Hide] [Select]
find:
'img' => array(
'nested' => false,
'inurl' => true,
),
after add:
'imgreflect' => array(
'nested' => false,
'inurl' => true,
),

find:
// ALBUMIMG

before add:
// IMG REFLECT
if($tag === 'imgreflect')
{
if($this->is_sig)
{
return $error;
}
// main parameters
$params = array(
'src' => false,
'alt' => false,
'slide' => false,
);

// additional allowed parameters
$extras = $this->allow_styling ? array('width', 'height', 'border', 'style', 'class', 'title', 'align') : array('width', 'height', 'border', 'title', 'align');

// [img=blah]blah2[/img]
if(isset($item['params']['param']))
{
$params['src'] = $item['params']['param'];
if ( $config_mg['thumbnail_posts'] == 1 )
{
$params['src'] = "image_thumbnail.php?pic_id=" . $params['src'];
}
$params['alt'] = $content;
$params['slide'] = isset($item['params']['slide']) ? $item['params']['slide'] : '';
$slideshow = ($params['slide']) ? 'lightbox[' . $item['params']['slide'] . ']' : 'lightbox';
}
// [img src=blah alt=blah width=123][/img ]
elseif(isset($item['params']['src']))
{
$params['src'] = $item['params']['src'];
if ( $config_mg['thumbnail_posts'] == 1 )
{
$params['src'] = "image_thumbnail.php?pic_id=" . $params['src'];
}
$params['alt'] = isset($item['params']['alt']) ? $item['params']['alt'] : $content;
$params['slide'] = isset($item['params']['slide']) ? $item['params']['slide'] : '';
$slideshow = ($params['slide']) ? 'lightbox[' . $item['params']['slide'] . ']': 'lightbox';
for($i=0; $i<count($extras); $i++)
{
if(!empty($item['params'][$extras[$i]]))
{
if($extras[$i] === 'style')
{
$style = $this->valid_style($item['params']['style']);
if($style !== false)
{
$params['style'] = $style;
}
}
else
{
$params[$extras[$i]] = $item['params'][$extras[$i]];
}
}
}
}
// [img]blah[/img], [img width=blah]blah[/img ]
elseif(!empty($content))
{
$link_url = $content;
$params['src'] = $content;
// LIW - BEGIN
if ( ($board_config['liw_enabled'] == 1) && ($max_image_width > 0) && ($config_mg['thumbnail_posts'] == 0) )
{
if ( isset($item['params']['width']) )
{
$item['params']['width'] = ( $item['params']['width'] > $max_image_width ) ? $max_image_width : $item['params']['width'];
}
else
{
$image_size = @getimagesize($content);
$item['params']['width'] = ( $image_size[0] > $max_image_width ) ? $max_image_width : $image_size[0];
}
}
elseif ( $config_mg['thumbnail_posts'] == 1 )
{
/*
$image_size = @getimagesize($content);
if ($image_size[0] > $config_mg['thumbnail_size'])
{
$params['src'] = "image_thumbnail.php?pic_id=" . $params['src'];
}
*/
$params['src'] = "image_thumbnail.php?pic_id=" . $params['src'];
}
// LIW - END
$params['alt'] = isset($item['params']['alt']) ? $item['params']['alt'] : (isset($params['title']) ? $params['title'] : 'Image');
$params['slide'] = isset($item['params']['slide']) ? $item['params']['slide'] : '';
$slideshow = ($params['slide']) ? 'lightbox[' . $item['params']['slide'] . ']': 'lightbox';
for($i=0; $i<count($extras); $i++)
{
if(!empty($item['params'][$extras[$i]]))
{
if($extras[$i] === 'style')
{
$style = $this->valid_style($item['params']['style']);
if($style !== false)
{
$params['style'] = $style;
}
}
else
{
$params[$extras[$i]] = $item['params'][$extras[$i]];
}
}
}
}

// generate html
$html = '<img';
foreach($params as $var => $value)
{
$html .= ' ' . $var . '="' . $this->process_text($value) . '"';
}
if(!isset($params['title']))
{
$html .= ' title="' . $this->process_text($params['alt']) . '"';
}
$html .= ' class="reflect rheight33" />';

// add url
if(empty($item['inurl']))
{
if ( $config_mg['thumbnail_posts'] == 1 && $config_mg['thumbnail_lightbox'] == 1 )
{
$html = '<a href="' . $link_url . '" rel="' . $slideshow . '" title="' . $params['alt'] . '">' . $html . '</a>';
}
else
{
$html = '<a href="' . $params['src'] . '" target="_blank" title="' . $lang['OpenNewWindow'] . '">' . $html . '</a>';
}
}
return array(
'valid' => true,
'html' => $html,
'allow_nested' => false,
);
}



Open templates/ca_adphrodite/viewtopic_body.tpl
find:
<div class="forumline nav-div">

before add:
<script type="text/javascript" src="reflection.js"></script>

that's it

Download reflection.js here :
http://www.tinhoi.exofire.net/forum/reflection.js <=== Right click on link and Save Target As

Profile PM  
Subject: Re: Need help to parse bbcode at xs
i can't make it run

take a look plz at my bbcode.php

www.superzuker.com.ar/shared/bbcode.rar

Subject: Re: Need Help To Parse Bbcode At Xs
I looked on your bbcode file, looks like you did everything right though, make sure you add JS in viewtopic_body.tpl too

here is the post on my main forum you can look at, the above demo link is on my test forum

http://tinhthienthu.ath.cx/viewtopic.php?p=490#490

or here:
http://tinhthienthu.ath.cx/viewtopic.php?p=486#486

Profile PM  
Subject: Re: Need help to parse bbcode at xs
:LOL:

it was working, but the bbcode doens't got a preview, that's because i said it didnt work

Subject: Re: Need Help To Parse Bbcode At Xs
Zuker wrote: [View Post]
:LOL:

it was working, but the bbcode doens't got a preview, that's because i said it didnt work



it should work if you add this line
<script type="text/javascript" src="reflection.js"></script>

to posting_topic_review.tpl

Profile PM  
Subject: Re: Need help to parse bbcode at xs
adding to overall header it isn't enought?

why don't u add the efecto to the "js's" folder??
Later, you must got this
<script type="text/javascript" src="templates/ca_aphrodite/js/reflection.js"></script>

Subject: Re: Need Help To Parse Bbcode At Xs
i dont know but when i add it to overall_header.tpl it doesnt work ...so i dont mind to add it in vewtopic_body.tpl instead

and i think if you put the effect in root folder it will respond faster

Profile PM  
Subject: Re: Need help to parse bbcode at xs
Nice effect... can you try to attach here premodified files so I can have a look?

Thank you! :wink:

Subject: Re: Need help to parse bbcode at xs
yes mighty

i'm working on a bottom also, but i'll attach here premodified files in a moment

Subject: Re: Need help to parse bbcode at xs
:mrgreen: files working for old a69


reflection.rar
Description: Based in a69_20061208_1044 files 
Download
Filename: reflection.rar
Filesize: 27.44 KB
Downloaded: 160 Time(s)


Page 1 of 2


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Generation Time: 0.1274s (PHP: 17% SQL: 83%)
SQL queries: 13 - Debug Off - GZIP Enabled