]> git.mxchange.org Git - friendica.git/blobdiff - include/text.php
Several improvements
[friendica.git] / include / text.php
index ed37326df3190760708f63ba3d3df88cee1fb606..6d557ed84e8c62706cca664776d0e71337137055 100644 (file)
@@ -712,6 +712,7 @@ function smilies($s, $sample = false) {
                ';-)', 
                ':-(', 
                ':-P', 
+               ':-p', 
                ':-"', 
                ':-"', 
                ':-x', 
@@ -732,9 +733,8 @@ function smilies($s, $sample = false) {
                ':homebrew', 
                ':coffee', 
                ':facepalm',
-               ':headdesk',
                '~friendika', 
-               '~friendica'
+               '~friendica'
 
        );
 
@@ -746,6 +746,7 @@ function smilies($s, $sample = false) {
                '<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-tongue-out.gif" alt=":-P" />',
+               '<img src="' . $a->get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-p" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-\"" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-\"" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-x" />',
@@ -767,7 +768,7 @@ function smilies($s, $sample = false) {
                '<img src="' . $a->get_baseurl() . '/images/coffee.gif" alt=":coffee" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-facepalm.gif" alt=":facepalm" />',
                '<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/friendica-16.png" alt="~friendica" /></a>',
+               '<a href="http://friendica.com">~friendica <img src="' . $a->get_baseurl() . '/images/friendica-16.png" alt="~friendica" /></a>'
        );
 
        $params = array('texts' => $texts, 'icons' => $icons, 'string' => $s);
@@ -939,6 +940,36 @@ function prepare_body($item,$attach = false) {
                        $s .= '<div class="filesavetags"><span>' . t('Filed under:') . ' </span>' . $x . '</div>'; 
        }
 
+       // Look for spoiler
+       $spoilersearch = '<blockquote class="spoiler">';
+
+       // Remove line breaks before the spoiler
+       while ((strpos($s, "\n".$spoilersearch) !== false))
+               $s = str_replace("\n".$spoilersearch, $spoilersearch, $s);
+       while ((strpos($s, "<br />".$spoilersearch) !== false))
+               $s = str_replace("<br />".$spoilersearch, $spoilersearch, $s);
+
+       while ((strpos($s, $spoilersearch) !== false)) {
+
+               $pos = strpos($s, $spoilersearch);
+               $rnd = random_string(8);
+               $spoilerreplace = '<br /> <span id="spoiler-wrap-'.$rnd.'" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'spoiler-'.$rnd.'\');">'.sprintf(t('Click to open/close')).'</span>'.
+                                       '<blockquote class="spoiler" id="spoiler-'.$rnd.'" style="display: none;">';
+               $s = substr($s, 0, $pos).$spoilerreplace.substr($s, $pos+strlen($spoilersearch));
+       }
+
+       // Look for quote with author
+       $authorsearch = '<blockquote class="author">';
+
+       while ((strpos($s, $authorsearch) !== false)) {
+
+               $pos = strpos($s, $authorsearch);
+               $rnd = random_string(8);
+               $authorreplace = '<br /> <span id="author-wrap-'.$rnd.'" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'author-'.$rnd.'\');">'.sprintf(t('Click to open/close')).'</span>'.
+                                       '<blockquote class="author" id="author-'.$rnd.'" style="display: block;">';
+               $s = substr($s, 0, $pos).$authorreplace.substr($s, $pos+strlen($authorsearch));
+       }
+
        $prep_arr = array('item' => $item, 'html' => $s);
        call_hooks('prepare_body_final', $prep_arr);
 
@@ -1299,6 +1330,7 @@ function file_tag_save_file($uid,$item,$file) {
                $saved = get_pconfig($uid,'system','filetags');
                if((! strlen($saved)) || (! stristr($saved,'[' . file_tag_encode($file) . ']')))
                        set_pconfig($uid,'system','filetags',$saved . '[' . file_tag_encode($file) . ']');
+               info( t('Item filed') );
        }
        return true;
 }
@@ -1337,3 +1369,16 @@ function file_tag_unsave_file($uid,$item,$file) {
 function normalise_openid($s) {
        return trim(str_replace(array('http://','https://'),array('',''),$s),'/');
 }
+
+
+function undo_post_tagging($s) {
+       $matches = null;
+       $cnt = preg_match_all('/([@#])\[url=(.*?)\](.*?)\[\/url\]/ism',$s,$matches,PREG_SET_ORDER);
+       if($cnt) {
+               foreach($matches as $mtch) {
+                       $s = str_replace($mtch[0], $mtch[1] . $mtch[3],$s);
+               }
+       }
+       return $s;
+}
+