Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-21-2010, 12:20 AM
cory_booth cory_booth is offline
 
Join Date: Jul 2006
Posts: 224
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default BBCode Remove

I am working on a widget.

The widget is based on several examples on the net that render a slideshow for articles.
The widget works like this site: http://demo.webdeveloperplus.com/fea...ontent-slider/

The problem I have is reading the data from the database. I am turning all parsing to false (no bbcode) but it leaves things like in the output.

If I render the HTML or BBCode, my output is uncontrollable - especially for the cut off where the cutoff could happen in the middle of a tag and cause errors.

Is there a method to remove the [ATTACH] [HTML] [IMG] tags when they are not rendered as BBCode? I was thinking kind along the lines as the email output and/or archive output.

Oh and any improvements to the code I would be gratefull!

PHP Code:
<style>
#featured{
    width:400px;
    padding-right:150px;
    position:relative;
    border:5px solid #ccc;
    height:250px;
    background:#fff;
}
#featured ul.ui-tabs-nav{
    position:absolute;
    top:0; left:400px;
    list-style:none;
    padding:0; margin:0;
    width:150px;
}
#featured ul.ui-tabs-nav li{
    padding:1px 0; padding-left:13px;
    font-size:12px;
    color:#666;
}
#featured ul.ui-tabs-nav li img{
    float:left; margin:2px 5px;
    background:#fff;
    padding:2px;
    border:1px solid #eee;
}
#featured ul.ui-tabs-nav li span{
    font-size:9px; font-family:Verdana;
    line-height:18px;
}
#featured li.ui-tabs-nav-item a{
    display:block;
    height:60px;
    color:#333;  background:#fff;
    line-height:20px;
}
#featured li.ui-tabs-nav-item a:hover{
    background:#f2f2f2;
}
#featured li.ui-tabs-selected{
    background:url('images/selected-item.gif') top left no-repeat;
}
#featured ul.ui-tabs-nav li.ui-tabs-selected a{
    background:#ccc;
}
#featured .ui-tabs-panel{
    width:400px;
    height:250px;
    background:#999; position:relative;
}
#featured .ui-tabs-panel .info{
    position:absolute;
    top:180px; left:0;
    height:70px;
    background: url('images/transparent-bg.png');
    color:#fff;
}
#featured .info h2{
    font-size:18px; font-family:Georgia, serif;
    color:#fff; padding:5px; margin:0;
    overflow:hidden;
}
#featured .info p{
    margin:0 5px;
    font-family:Verdana; font-size:11px;
    line-height:15px; color:#f0f0f0;
}
#featured .info a{
    text-decoration:none;
    color:#fff;
}
#featured .info a:hover{
    text-decoration:underline;
}
#featured .ui-tabs-hide{
    display:none;
}
</style>
<!-- jQuery - Rotating Code -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.3/jquery-ui.min.js" ></script>

<!-- Rotating Code -->
<script type="text/javascript">
    $(document).ready(function(){
        $("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
    });
</script>
<!-- / Rotating Code -->
<?php
$curdir 
getcwd ();
chdir('/home/xxxxx/public_html');
global 
$db,$vbulletin,$sess$std$INFO$vboptions$session$bbcode;
// vBulletin: Parse BBCode
if (!is_object($bbcode_parser)){
    require_once(
'http://xxxxx.com/includes/class_bbcode.php');
    
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
}

$forumid                = array(184,149);            // Set forum IDs here.
$limit                    '2';                // Limit the displayed slides
$chars                    120;            // Character limit for the slide text, e.g. 100 is 100 characters limit.
$words                    20;            // Word limit for the slide text, e.g. 20 is 20 words limit
/* ------------------------------ NOTHING TO CHANGE BELOW THIS LINE ------------------------------ */
// Start loop
$forumid implode(',',$forumid);
$getnews $db->query_read("SELECT threadid from ".TABLE_PREFIX."thread WHERE attach !='0' AND forumid in($forumid) ORDER by sticky DESC, threadid DESC LIMIT $limit");
while (
$news $db->fetch_array($getnews)) {
    
$myid[]=$news['threadid'];
}
$tabhtml="";
$contenthtml="";
$div_id 1;

if (
$myid) {
foreach (
$myid as $threadid) {
$getpics $db->query_read("SELECT t.threadid as tid, t.title as title,t.replycount as rcount, p.pagetext as pagetext,a.attachmentid as attach,f.forumid as forumid,f.title as forum from ".TABLE_PREFIX."thread as t
    LEFT JOIN "
.TABLE_PREFIX."post as p on(t.firstpostid=p.postid)
    LEFT JOIN "
.TABLE_PREFIX."attachment as a on(a.contentid=p.postid)
    LEFT JOIN "
.TABLE_PREFIX."forum as f on(t.forumid=f.forumid)
    where t.threadid='
$threadid'
    ORDER BY attach DESC
    LIMIT 1"
);

while (
$pic $db->fetch_array($getpics)) {
$replies=$pic['rcount'];
if (
$replies=='1') {
$update="- (1 update)";
} elseif (
$replies>'1') {
$update="- ($replies updates)";
} else {
$update="";
}

$pic['pagetext'] = $bbcode_parser->do_parse($pic['pagetext'],false,false,false,false,false,false);
$link "../showthread.php?t=".$threadid."";
$imagepath "../attachment.php?attachmentid=".$pic['attach'];
$titleContent ucwords($pic['title']);
$introtext $pic['pagetext'];

 
// clean images
$introtext preg_replace("/<img.+?>/"""$introtext);
 
// HTML cleanup
if ($striptags) {
$introtext strip_tags($introtext$allowed_tags);
}
// if character limitation is defined
 
if ($chars) {
 if(
function_exists("mb_string")) {
 
$introtext mb_substr($introtext0$chars).'...';
} else {
 
$introtext substr($introtext0$chars).'...';
}
}
// if word limitation is defined
if ($words) {
$word_arr str_word_count($introtext2);
$c 0;
foreach (
$word_arr AS $k => $v) {
if (
$c == $words) {
if(
function_exists("mb_string")) {
$introtext mb_substr($introtext0$k).'...';
} else {
$introtext substr($introtext0$k).'...';
}
break;
}
$c++;
}
}

$tabhtml .= "<li class='ui-tabs-nav-item' id='nav-fragment-".$div_id."'><a href='#fragment-".$div_id."'>";
$tabhtml .="<img src='".$imagepath."' height='25px' width='40px' alt='' />";
$tabhtml .="<span class=''>".$titleContent." ".$update."</span></a></li>";

$centerhtml .="<div id='fragment-".$div_id."' class='ui-tabs-panel' style=''>";
$centerhtml .="<img src='".$imagepath."' alt=''/>";
$centerhtml .="<div class='info'>";
$centerhtml .="<h2><a href='#'>".$titleContent."</a></h2>";
$centerhtml .="<p>".$introtext."</p></div></div>";


$div_id++;
}
}

$db->free_result($getpics);
unset(
$pic);
$db->free_result($getnews);
unset(
$news);
// End loop

$tabhtml "<div id=\"featured\"><ul class=\"ui-tabs-nav\">".$tabhtml."</ul>";

echo 
$tabhtml.$centerhtml."</div>";
}
?>
Attached Images
File Type: jpg slideshow.JPG (30.9 KB, 0 views)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:48 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.03692 seconds
  • Memory Usage 2,232KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_attachment
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete