Jump to content
php.lv forumi

Recommended Posts

Posted

Sveiki, esmu man ir problēma ar bbcode.

Itkā viss iet, bet, protams, līdz tam brīdim, kad bbkods ir pa 2 rindām, piemēram:

[b]pirmā rinda
otrā rinda[/b]

 

Varbūt kāds var palīdzēt, dot padomu, kas nogājis greizi?

 

function clean($value,$v=0,$w=96) {

$bb_replace = array(
//'/(\www.)(.+)(\.)(.+)/',
'/(\[url=)(.+)(\])(.+)(\[\/url\])/',
'/(\[url])(.+)(\[\/url\])/',
'/(\[img])(.+)(\[\/img\])/',
'/(\[quote=)(.+)(\])(.+)(\[\/quote\])/iU',
'/(\[quote])(.+)(\[\/quote\])/',
'/(\[yt])(.+)(\[\/yt\])/',
'/(\[center])(.+)(\[\/center\])/',
'/(\[color=)(.+)(\])(.+)(\[\/color\])/',
'/(\[size=)(.+)(\])(.+)(\[\/size\])/',
'/(\[h])(.+)(\[\/h\])/',
'/(\[b])(.+)(\[\/b\])/',
'/(\[u])(.+)(\[\/u\])/',
'/(\[i])(.+)(\[\/i\])/',
'/(\[s])(.+)(\[\/s\])/',
'/(\[skype=)(.+)(\])/',
'/(\[mail=)(.+)(\])/'
);
$bb_replacements = array(
//'<a href="http://www.\\2.\\4" target="_blank" style="color:#987654;">www.\\2.\\4</a>',
'<a href="\\2" target="_blank" style="color:#987654;">\\4</a>',
'<a href="\\2" target="_blank" style="color:#987654;">\\2</a>',
'<img src="\\2" style="" alt="image" border="0" >',
'<div class="quoted_text"><span><b>\\2 rakstīja:</b></span><br>\\4</div>',
'<div class="quoted_text"><span><b>Citāts.</b></span><br>\\4</div>',
'<center style="margin:5px;"><object width="430" height="245"><param name="movie" value="http://www.youtube.com/v/\\2&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/\\2&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="430" height="245"></embed></object></center><br >',
'<center>\\2</center>',
'<font style="color:\\2;">\\4</font>',
'<font style="font-size:\\2;">\\4</font>',
'<font style="background-color:#E2E200;padding:1px;">\\2</font>',
'<b>\\2</b>',
'<u>\\2</u>',
'<i>\\2</i>',
'<s>\\2</s>',
'<a href="skype:\\2?chat">\\2</a>',
'<a href="mailto:\\2">\\2</a>'
);
$value = preg_replace($bb_replace, $bb_replacements, $value);
   if($v == 0) {
       $i = 0;
       $quotes = substr_count(strtolower($value),'[quote=');
       if($quotes == 1) {
           return preg_replace($bb_replace, $bb_replacements, $value);
       } else {
           while($i != $quotes) {
               if($i > 0) {
                   $w-=2;
               }
               $value = clean($value,1,$w);
               $i++;
           }
           return $value;
       }
   } else {
$value = preg_replace($bb_replace, $bb_replacements, $value);
return $value;
   }
}

Posted

Plus vēl šīs nedēļas laikā šajā forumā ir bijušas vairākas tēmas par bb kodu, kur tika atbildēts uz tevis uzdotajiem jautājumiem.

 

Manis veidotas tēmas xD

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...