PEAR Packages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPEAR Packages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old September 25th, 2009, 10:28 AM
irishbuzz irishbuzz is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Posts: 1 irishbuzz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 10 m 12 sec
Reputation Power: 0
HTML_BBCodeParser problem with [img] tag

Hi All,

I'm quite new to PEAR and only recently set it up on a shared linux account using the go-pear.php web interface.

After this I successfully installed the HTML_BBCodeParser package and set up PEAR in PHP path.

I began testing out the package with a simple script and everything seemed to work fine for most tags, but for some reason the [img] tag does not seem to parse correctly.

My code is below (please note that as a new poster, the forum has blocked me from posting the image url):

Code:
/* For the PHP code below please just assume that
{absolute url here} = http://www.sitepoint.com/images/sitepoint-logo.gif


PHP Code:
<?php
require_once("PEAR.php");
require_once(
"HTML/BBCodeParser.php");

/* get options from the ini file */
$config parse_ini_file('BBCodeParser.ini'true);
$options = &PEAR::getStaticProperty('HTML_BBCodeParser''_options');
$options $config['HTML_BBCodeParser'];
unset(
$options);

$parser = new HTML_BBCodeParser();

$text 'hello [b]world[/b]
[i]italics[/i]
[quote]Here is a quote[/quote]
[color=red]red[/color]
[img="{absolute url here}"][/img]
[img={absolute url here}][/img]
[img=\'{absolute url here}\'][/img]
[img]{absolute url here}[/img]'
;

$parser->setText($text);
$parser->parse();
$parsed $parser->getParsed();

echo 
nl2br($parsed );

?>


As you can see I've made various attempts to get the image tag working unfortunately to no avail. As you will see in the HTML below:


Code:
hello <strong>world</strong><br />
<em>italics</em>
<q>Here is a quote</q><br />
<a href="http://bbShowcase.org/">bbShowcase</a><br />
<span style="color:red">red</span>
<img src=""="http://www.sitepoint.com/images/sitepoint-logo.gif" /><br />
[img="<a href="http://www.sitepoint.com/images/sitepoint-logo.gif">http://www.sitepoint.com/images/sitepoint-logo.gif</a>"=200x200]<br />
<img /><br />
<img /><br />
[img="[url=http://www.sitepoint.com/images/sitepoint-logo.gif]http://www.sitepoint.com/images/sitepoint-logo.gif</a>"]<br />


Can anyone help me figure out what might be going wrong here?

Any help would be very much appreciated.


P.S. Incase someone was wondering my BBCodeParser.ini looks like this:

PHP Code:
[HTML_BBCodeParser]

possible valuessingle|double
; use single or double quotes for attributes
quotestyle  
double

possible valuesall|nothing|strings
quote all attribute valuesnone, or only the strings
quotewhat   
all

the opening tag character
open        
"["

the closing tag character
close       
"]"

possible valuestrue|false
; use xml style closing tags for single html tags (<img> or <img />)
xmlclose    true

possible valuesa comma seperated list of filters
comma seperated list of filters to use
filters     Basic,Extended,Links,Images,Lists,Email 

Reply With Quote
  #2  
Old October 13th, 2009, 09:46 AM
aland aland is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 1 aland User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 40 m 39 sec
Reputation Power: 0
I have done it like this

PHP Code:
require_once('HTML/BBCodeParser.php');

$parser = new HTML_BBCodeParser();
$parser->addFilter('images');
$parser->addFilter('extended');

$parser->setText('hello [b]world[/b]
[i]italics[/i]
[quote]Here is a quote[/quote]
[color=red]red[/color]
[img]absolute url here[/img]'
);
$parser->parse();
$parsed $parser->getParsed();

echo 
nl2br($parsed); 


Output:
hello <strong>world</strong>
<em>italics</em>
<q>Here is a quote</q>
<span style="color:red">red</span>
<img src="absolute url here" />


If someone knows how to get addFilter working for customised filters, I'd like to hear about it.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPEAR Packages > HTML_BBCodeParser problem with [img] tag


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek