aboutsummaryrefslogtreecommitdiffstats
path: root/include/bbcode.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/bbcode.php')
-rw-r--r--include/bbcode.php158
1 files changed, 82 insertions, 76 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index 021f2ac27..82d25ffc8 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -101,93 +101,101 @@ function bb_replace_images($body, $images) {
function bb_ShareAttributes($match) {
- $attributes = $match[1];
+ $attributes = $match[1];
- $author = "";
- preg_match("/author='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
+ $author = "";
+ preg_match("/author='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
- preg_match('/author="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $author = $matches[1];
+ preg_match('/author="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $author = $matches[1];
- $link = "";
- preg_match("/link='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $link = $matches[1];
+ $link = "";
+ preg_match("/link='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $link = $matches[1];
- preg_match('/link="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $link = $matches[1];
+ preg_match('/link="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $link = $matches[1];
- $avatar = "";
- preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $avatar = $matches[1];
+ $avatar = "";
+ preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $avatar = $matches[1];
- preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $avatar = $matches[1];
+ preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $avatar = $matches[1];
- $profile = "";
- preg_match("/profile='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $profile = $matches[1];
+ $profile = "";
+ preg_match("/profile='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $profile = $matches[1];
- preg_match('/profile="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $profile = $matches[1];
+ preg_match('/profile="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $profile = $matches[1];
- $posted = "";
- preg_match("/posted='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $posted = $matches[1];
+ $posted = "";
+ preg_match("/posted='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $posted = $matches[1];
- preg_match('/posted="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $posted = $matches[1];
- $reldate = (($posted) ? " " . relative_date($posted) : '');
+ preg_match('/posted="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $posted = $matches[1];
- $headline = '<div class="shared_header">';
+ // FIXME - this should really be a wall-item-ago so it will get updated on the client
+ $reldate = (($posted) ? relative_date($posted) : '');
+
+ $headline = '<div class="shared_header">';
if ($avatar != "")
- $headline .= '<img src="'.$avatar.'" height="32" width="32" >';
+ $headline .= '<img src="' . $avatar . '" alt="' . $author . '" height="32" width="32" />';
+
+ // Bob Smith wrote the following post 2 hours ago
- $headline .= sprintf(t('<span><a href="%s" target="external-link">%s</a> wrote the following <a href="%s" target="external-link">post</a>'.$reldate.':</span>'), $profile, $author, $link);
+ $fmt = sprintf( t('%1$s wrote the following %2$s %3$s'),
+ '<a href="' . zid($profile) . '" >' . $author . '</a>',
+ '<a href="' . zid($link) . '" >' . t('post') . '</a>',
+ $reldate
+ );
- $headline .= "</div>";
+ $headline .= '<span>' . $fmt . '</span></div>';
- $text = $headline.'<blockquote class="shared_content">'.trim($match[2])."</blockquote>";
+ $text = $headline . '<div class="reshared-content">' . trim($match[2]) . '</div>';
- return($text);
+ return($text);
}
function bb_ShareAttributesSimple($match) {
- $attributes = $match[1];
+ $attributes = $match[1];
- $author = "";
- preg_match("/author='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
+ $author = "";
+ preg_match("/author='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
- preg_match('/author="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $author = $matches[1];
+ preg_match('/author="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $author = $matches[1];
- $profile = "";
- preg_match("/profile='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $profile = $matches[1];
+ $profile = "";
+ preg_match("/profile='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $profile = $matches[1];
- preg_match('/profile="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $profile = $matches[1];
+ preg_match('/profile="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $profile = $matches[1];
- $text = "<br />".html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8').' <a href="'.$profile.'">'.$author."</a>: <br />»".$match[2]."«";
+ $text = "<br />".html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8').' <a href="'.$profile.'">'.$author."</a>: div class=\"reshared-content\">" .$match[2]."</div>";
- return($text);
+ return($text);
}
// BBcode 2 HTML was written by WAY2WEB.net
@@ -195,7 +203,6 @@ function bb_ShareAttributesSimple($match) {
function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
-
$a = get_app();
// Extract the private images which use data url's since preg has issues with
@@ -232,9 +239,6 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$Text = str_replace("<", "&lt;", $Text);
$Text = str_replace(">", "&gt;", $Text);
- // This only matters when looking for tags - otherwise has no meaning
-
- $Text = str_replace(array('[share]','[/share]'), array('',''), $Text);
// Convert new line chars to html <br /> tags
@@ -259,13 +263,15 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
// Perform URL Search
- $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" >$2</a>', $Text);
+ $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" >$2</a>', $Text);
if ($tryoembed)
$Text = preg_replace_callback("/\[bookmark\=([^\]]*)\].*?\[\/bookmark\]/ism",'tryoembed',$Text);
$Text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",'[url=$1]$2[/url]',$Text);
+ $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributes",$Text);
+
if ($tryoembed)
$Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism",'tryoembed',$Text);
@@ -296,7 +302,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$Text = preg_replace("(\[color=(.*?)\](.*?)\[\/color\])ism","<span style=\"color: $1;\">$2</span>",$Text);
// Check for sized text
- // [size=50] --> font-size: 50px (with the unit).
+ // [size=50] --> font-size: 50px (with the unit).
$Text = preg_replace("(\[size=(\d*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1px;\">$2</span>",$Text);
$Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1;\">$2</span>",$Text);
@@ -316,9 +322,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$endlessloop = 0;
while ((((strpos($Text, "[/list]") !== false) && (strpos($Text, "[list") !== false)) ||
- ((strpos($Text, "[/ol]") !== false) && (strpos($Text, "[ol]") !== false)) ||
- ((strpos($Text, "[/ul]") !== false) && (strpos($Text, "[ul]") !== false)) ||
- ((strpos($Text, "[/li]") !== false) && (strpos($Text, "[li]") !== false))) && (++$endlessloop < 20)) {
+ ((strpos($Text, "[/ol]") !== false) && (strpos($Text, "[ol]") !== false)) ||
+ ((strpos($Text, "[/ul]") !== false) && (strpos($Text, "[ul]") !== false)) ||
+ ((strpos($Text, "[/li]") !== false) && (strpos($Text, "[li]") !== false))) && (++$endlessloop < 20)) {
$Text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '<ul class="listbullet" style="list-style-type: circle;">$1</ul>' ,$Text);
$Text = preg_replace("/\[list=\](.*?)\[\/list\]/ism", '<ul class="listnone" style="list-style-type: none;">$1</ul>' ,$Text);
$Text = preg_replace("/\[list=1\](.*?)\[\/list\]/ism", '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>' ,$Text);
@@ -371,8 +377,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$endlessloop = 0;
while ((strpos($Text, "[/spoiler]")!== false) and (strpos($Text, "[spoiler=") !== false) and (++$endlessloop < 20))
$Text = preg_replace("/\[spoiler=[\"\']*(.*?)[\"\']*\](.*?)\[\/spoiler\]/ism",
- "<br /><strong class=".'"spoiler"'.">" . $t_wrote . "</strong><blockquote class=".'"spoiler"'.">$2</blockquote>",
- $Text);
+ "<br /><strong class=".'"spoiler"'.">" . $t_wrote . "</strong><blockquote class=".'"spoiler"'.">$2</blockquote>",
+ $Text);
// Declare the format for [quote] layout
$QuoteLayout = '<blockquote>$1</blockquote>';
@@ -391,8 +397,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$endlessloop = 0;
while ((strpos($Text, "[/quote]")!== false) and (strpos($Text, "[quote=") !== false) and (++$endlessloop < 20))
$Text = preg_replace("/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism",
- "<br /><strong class=".'"author"'.">" . $t_wrote . "</strong><blockquote>$2</blockquote>",
- $Text);
+ "<br /><strong class=".'"author"'.">" . $t_wrote . "</strong><blockquote>$2</blockquote>",
+ $Text);
// [img=widthxheight]image source[/img]
//$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="height: $2px; width: $1px;" >', $Text);
@@ -402,7 +408,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
// [img]pathtoimage[/img]
$Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text);
- $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributes",$Text);
+
$Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br />', $Text);
$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
@@ -429,8 +435,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
// Youtube extensions
if ($tryoembed) {
- $Text = preg_replace_callback("/\[youtube\](https?:\/\/www.youtube.com\/watch\?v\=.*?)\[\/youtube\]/ism", 'tryoembed', $Text);
- $Text = preg_replace_callback("/\[youtube\](www.youtube.com\/watch\?v\=.*?)\[\/youtube\]/ism", 'tryoembed', $Text);
+ $Text = preg_replace_callback("/\[youtube\](https?:\/\/www.youtube.com\/watch\?v\=.*?)\[\/youtube\]/ism", 'tryoembed', $Text);
+ $Text = preg_replace_callback("/\[youtube\](www.youtube.com\/watch\?v\=.*?)\[\/youtube\]/ism", 'tryoembed', $Text);
$Text = preg_replace_callback("/\[youtube\](https?:\/\/youtu.be\/.*?)\[\/youtube\]/ism",'tryoembed',$Text);
}