aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rwxr-xr-xinclude/bb2diaspora.php2
-rwxr-xr-xinclude/bbcode.php6
-rwxr-xr-xinclude/conversation.php28
-rwxr-xr-xinclude/text.php81
4 files changed, 99 insertions, 18 deletions
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index 9a29b05a2..c26b0c334 100755
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -212,7 +212,7 @@ function bb2diaspora($Text,$preserve_nl = false) {
$Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", 'http://vimeo.com/$1',$Text);
-
+ $Text = str_replace('[nosmile]','',$Text);
// oembed tag
// $Text = oembed_bbcode2html($Text);
diff --git a/include/bbcode.php b/include/bbcode.php
index 118be1298..cae867eb8 100755
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -173,7 +173,11 @@ upper-alpha;">$2</ul>' ,$Text);
$Text = preg_replace("/\[table border=1\](.*?)\[\/table\]/sm", '<table border="1" >$1</table>' ,$Text);
$Text = preg_replace("/\[table border=0\](.*?)\[\/table\]/sm", '<table border="0" >$1</table>' ,$Text);
-
+ $Text = str_replace('[hr]','<hr />', $Text);
+
+ // This is actually executed in prepare_body()
+
+ $Text = str_replace('[nosmile]','',$Text);
// Check for font change text
$Text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/sm","<span style=\"font-family: $1;\">$2</span>",$Text);
diff --git a/include/conversation.php b/include/conversation.php
index b44d4acd6..2ea9b603f 100755
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -4,6 +4,28 @@
* Render actions localized
*/
function localize_item(&$item){
+
+ $Text = $item['body'];
+ $saved_image = '';
+ $img_start = strpos($Text,'[img]data:');
+ $img_end = strpos($Text,'[/img]');
+
+ if($img_start !== false && $img_end !== false && $img_end > $img_start) {
+ $start_fragment = substr($Text,0,$img_start);
+ $img_start += strlen('[img]');
+ $saved_image = substr($Text,$img_start,$img_end - $img_start);
+ $end_fragment = substr($Text,$img_end + strlen('[/img]'));
+ $Text = $start_fragment . '[!#saved_image#!]' . $end_fragment;
+ $search = '/\[url\=(.*?)\]\[!#saved_image#!\]\[\/url\]' . '/is';
+ $replace = '[url=' . z_path() . '/redir/' . $item['contact-id']
+ . '?f=1&url=' . '$1' . '][!#saved_image#!][/url]' ;
+
+ $Text = preg_replace($search,$replace,$Text);
+
+ if(strlen($saved_image))
+ $item['body'] = str_replace('[!#saved_image#!]', '[img]' . $saved_image . '[/img]',$Text);
+ }
+
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
if ($item['verb']=== ACTIVITY_LIKE || $item['verb']=== ACTIVITY_DISLIKE){
@@ -500,6 +522,9 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
if ($shareable) $likebuttons['share'] = array( t('Share this'), t('share'));
}
+// $qcomment = array(':-)','LOL','ROTFL','[smile]');
+ $qcomment = null;
+
if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) {
$comment = replace_macros($cmnt_tpl,array(
'$return_path' => '',
@@ -507,6 +532,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
'$type' => (($mode === 'profile') ? 'wall-comment' : 'net-comment'),
'$id' => $item['item_id'],
'$parent' => $item['parent'],
+ '$qcomment' => $qcomment,
'$profile_uid' => $profile_owner,
'$mylink' => $a->contact['url'],
'$mytitle' => t('This is you'),
@@ -609,11 +635,9 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
if ($tag!="") $tags[] = bbcode($tag);
}
-
// Build the HTML
$body = prepare_body($item,true);
-
$tmp_item = replace_macros($template,array(
'$type' => implode("",array_slice(split("/",$item['verb']),-1)),
diff --git a/include/text.php b/include/text.php
index 6beb5c9b2..0d99e6f4a 100755
--- a/include/text.php
+++ b/include/text.php
@@ -678,21 +678,56 @@ function linkify($s) {
*/
if(! function_exists('smilies')) {
-function smilies($s) {
+function smilies($s, $sample = false) {
$a = get_app();
- $s = str_replace(
- array( '&lt;3', '&lt;/3', '&lt;\\3', ':-)', ':)', ';-)', ';)', ':-(', ':(', ':-P', ':P', ':-"', ':-&quot;', ':-x', ':-X', ':-D', ':D', '8-|', '8-O', ':-O', '\\o/', 'o.O', 'O.o', '\\.../', '\\ooo/',
- ':beer', ':homebrew', ':coffee',
- '~friendika', '~friendica', 'Diaspora*' ),
- array(
+ $texts = array(
+ '&lt;3',
+ '&lt;/3',
+ '&lt;\\3',
+ ':-)',
+ ':)',
+ ';-)',
+ ';)',
+ ':-(',
+ ':(',
+ ':-P',
+ ':P',
+ ':-"',
+ ':-&quot;',
+ ':-x',
+ ':-X',
+ ':-D',
+ ':D',
+ '8-|',
+ '8-O',
+ ':-O',
+ '\\o/',
+ 'o.O',
+ 'O.o',
+ '\\.../',
+ '\\ooo/',
+ ":'(",
+ ":-!",
+ ":-/",
+ ":-[",
+ "8-)",
+ ':beer',
+ ':homebrew',
+ ':coffee',
+ '~friendika',
+ '~friendica',
+ 'Diaspora*'
+ );
+
+ $icons = array(
'<img src="' . $a->get_baseurl() . '/images/smiley-heart.gif" alt="<3" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-brokenheart.gif" alt="</3" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-brokenheart.gif" alt="<\\3" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-smile.gif" alt=":-)" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-smile.gif" alt=":)" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-wink.gif" alt=";-)" />',
- '<img src="' . $a->get_baseurl() . '/images/smiley-wink.gif" alt=";)"/>',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-wink.gif" alt=";)"/>',
'<img src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":-(" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":(" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-P" />',
@@ -702,7 +737,7 @@ function smilies($s) {
'<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-x" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-X" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-laughing.gif" alt=":-D" />',
- '<img src="' . $a->get_baseurl() . '/images/smiley-laughing.gif" alt=":D"/>',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-laughing.gif" alt=":D"/>',
'<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt="8-|" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt="8-O" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt=":-O" />',
@@ -710,19 +745,34 @@ function smilies($s) {
'<img src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="o.O" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="O.o" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-shaka.gif" alt="\\.../" />',
- '<img src="' . $a->get_baseurl() . '/images/smiley-shaka.gif" alt="\\ooo/" />',
-
+ '<img src="' . $a->get_baseurl() . '/images/smiley-shaka.gif" alt="\\ooo/" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-cry.gif" alt=":\'(" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-foot-in-mouth.gif" alt=":-!" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-undecided.gif" alt=":-/" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-embarassed.gif" alt=":-[" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-cool.gif" alt="8-)" />',
'<img src="' . $a->get_baseurl() . '/images/beer_mug.gif" alt=":beer" />',
'<img src="' . $a->get_baseurl() . '/images/beer_mug.gif" alt=":homebrew" />',
'<img src="' . $a->get_baseurl() . '/images/coffee.gif" alt=":coffee" />',
-
'<a href="http://project.friendika.com">~friendika <img src="' . $a->get_baseurl() . '/images/friendika-16.png" alt="~friendika" /></a>',
'<a href="http://friendica.com">~friendica <img src="' . $a->get_baseurl() . '/images/friendika-16.png" alt="~friendica" /></a>',
'<a href="http://diasporafoundation.org">Diaspora<img src="' . $a->get_baseurl() . '/images/diaspora.png" alt="Diaspora*" /></a>',
- ), $s);
+ );
+
+ $params = array('texts' => $texts, 'icons' => $icons, 'string' => $s);
+ call_hooks('smilie', $params);
- call_hooks('smilie', $s);
+ if($sample) {
+ $s = '<div class="smiley-sample">';
+ for($x = 0; $x < count($params['texts']); $x ++) {
+ $s .= '<dl><dt>' . $params['texts'][$x] . '</dt><dd>' . $params['icons'][$x] . '</dd></dl>';
+ }
+ }
+ else {
+ $s = str_replace($params['texts'],$params['icons'],$params['string']);
+ }
+
return $s;
}}
@@ -828,7 +878,10 @@ function prepare_text($text) {
require_once('include/bbcode.php');
- $s = smilies(bbcode($text));
+ if(stristr($text,'[nosmile]'))
+ $s = bbcode($text);
+ else
+ $s = smilies(bbcode($text));
return $s;
}}