]> git.mxchange.org Git - friendica.git/blobdiff - include/text.php
quattro: in post display page, scroll to and flash selected comment
[friendica.git] / include / text.php
index 4ec59a66589c05ec8509d53da9e37ec46741fc79..cc4bee268fc79ebfd174fa7b50e5a672e63f5e44 100644 (file)
@@ -558,7 +558,7 @@ function contact_block() {
 
        if((! is_array($a->profile)) || ($a->profile['hide-friends']))
                return $o;
-       $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0",
+       $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0",
                        intval($a->profile['uid'])
        );
        if(count($r)) {
@@ -569,7 +569,7 @@ function contact_block() {
                $micropro = Null;
                
        } else {
-               $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 ORDER BY RAND() LIMIT %d",
+               $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0 ORDER BY RAND() LIMIT %d",
                                intval($a->profile['uid']),
                                intval($shown)
                );
@@ -646,7 +646,7 @@ function search($s,$id='search-box',$url='/search',$save = false) {
        $a = get_app();
        $o  = '<div id="' . $id . '">';
        $o .= '<form action="' . $a->get_baseurl((stristr($url,'network')) ? true : false) . $url . '" method="get" >';
-       $o .= '<input type="text" name="search" id="search-text" value="' . $s .'" />';
+       $o .= '<input type="text" name="search" id="search-text" placeholder="' . t('Search') . '" value="' . $s .'" />';
        $o .= '<input type="submit" name="submit" id="search-submit" value="' . t('Search') . '" />'; 
        if($save)
                $o .= '<input type="submit" name="save" id="search-save" value="' . t('Save') . '" />'; 
@@ -742,6 +742,8 @@ function smilies($s, $sample = false) {
                ':homebrew', 
                ':coffee', 
                ':facepalm',
+               ':like',
+               ':dislike',
                '~friendika', 
                '~friendica'
 
@@ -778,6 +780,8 @@ function smilies($s, $sample = false) {
                '<img src="' . $a->get_baseurl() . '/images/beer_mug.gif" alt=":homebrew" />',
                '<img src="' . $a->get_baseurl() . '/images/coffee.gif" alt=":coffee" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-facepalm.gif" alt=":facepalm" />',
+               '<img src="' . $a->get_baseurl() . '/images/like.gif" alt=":like" />',
+               '<img src="' . $a->get_baseurl() . '/images/dislike.gif" alt=":dislike" />',
                '<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>'
        );
@@ -887,6 +891,7 @@ function prepare_body($item,$attach = false) {
        } else
                $s = prepare_text($item['body']);
 
+
        $prep_arr = array('item' => $item, 'html' => $s);
        call_hooks('prepare_body', $prep_arr);
        $s = $prep_arr['html'];
@@ -901,24 +906,30 @@ function prepare_body($item,$attach = false) {
                foreach($arr as $r) {
                        $matches = false;
                        $icon = '';
-                       $cnt = preg_match('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"\[\/attach\]|',$r,$matches);
+                       $cnt = preg_match_all('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"\[\/attach\]|',$r,$matches, PREG_SET_ORDER);
                        if($cnt) {
-                               $icontype = strtolower(substr($matches[3],0,strpos($matches[3],'/')));
-                               switch($icontype) {
-                                       case 'video':
-                                       case 'audio':
-                                       case 'image':
-                                       case 'text':
-                                               $icon = '<div class="attachtype icon s22 type-' . $icontype . '"></div>';
-                                               break;
-                                       default:
-                                               $icon = '<div class="attachtype icon s22 type-unkn"></div>';
-                                               break;
+                               foreach($matches as $mtch) {
+                                       $icontype = strtolower(substr($mtch[3],0,strpos($mtch[3],'/')));
+                                       switch($icontype) {
+                                               case 'video':
+                                               case 'audio':
+                                               case 'image':
+                                               case 'text':
+                                                       $icon = '<div class="attachtype icon s22 type-' . $icontype . '"></div>';
+                                                       break;
+                                               default:
+                                                       $icon = '<div class="attachtype icon s22 type-unkn"></div>';
+                                                       break;
+                                       }
+                                       $title = ((strlen(trim($mtch[4]))) ? escape_tags(trim($mtch[4])) : escape_tags($mtch[1]));
+                                       $title .= ' ' . $mtch[2] . ' ' . t('bytes');
+                                       if((local_user() == $item['uid']) && $item['contact-id'] != $a->contact['id'])
+                                               $the_url = $a->get_baseurl() . '/redir/' . $item['contact-id'] . '?f=1&url=' . $mtch[1];
+                                       else
+                                               $the_url = $mtch[1];
+
+                                       $s .= '<a href="' . strip_tags($the_url) . '" title="' . $title . '" class="attachlink" target="external-link" >' . $icon . '</a>';
                                }
-                               $title = ((strlen(trim($matches[4]))) ? escape_tags(trim($matches[4])) : escape_tags($matches[1]));
-                               $title .= ' ' . $matches[2] . ' ' . t('bytes');
-
-                               $s .= '<a href="' . strip_tags($matches[1]) . '" title="' . $title . '" class="attachlink" target="external-link" >' . $icon . '</a>';
                        }
                }
                $s .= '<div class="clear"></div></div>';
@@ -930,7 +941,8 @@ function prepare_body($item,$attach = false) {
                foreach($matches as $mtch) {
                        if(strlen($x))
                                $x .= ',';
-                       $x .= xmlify(file_tag_decode($mtch[1]));
+                       $x .= xmlify(file_tag_decode($mtch[1])) 
+                               . ((local_user() == $item['uid']) ? ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&cat=' . xmlify(file_tag_decode($mtch[1])) . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>' : '');
                }
                if(strlen($x))
                        $s .= '<div class="categorytags"><span>' . t('Categories:') . ' </span>' . $x . '</div>'; 
@@ -1047,7 +1059,7 @@ function feed_salmonlinks($nick) {
 if(! function_exists('get_plink')) {
 function get_plink($item) {
        $a = get_app(); 
-       if (x($item,'plink') && (! $item['private'])){
+       if (x($item,'plink') && ((! $item['private']) || ($item['network'] === NETWORK_FEED))){
                return array(
                        'href' => $item['plink'],
                        'title' => t('link to source'),
@@ -1068,10 +1080,12 @@ function unamp($s) {
 if(! function_exists('lang_selector')) {
 function lang_selector() {
        global $lang;
-       $o = '<div id="lang-select-icon" class="icon language" title="' . t('Select an alternate language') . '" onclick="openClose(\'language-selector\');" ></div>';
-       $o .= '<div id="language-selector" style="display: none;" >';
-       $o .= '<form action="#" method="post" ><select name="system_language" onchange="this.form.submit();" >';
+       
        $langs = glob('view/*/strings.php');
+       
+       $lang_options = array();
+       $selected = "";
+       
        if(is_array($langs) && count($langs)) {
                $langs[] = '';
                if(! in_array('view/en/strings.php',$langs))
@@ -1079,17 +1093,22 @@ function lang_selector() {
                asort($langs);
                foreach($langs as $l) {
                        if($l == '') {
-                               $default_selected = ((! x($_SESSION,'language')) ? ' selected="selected" ' : '');
-                               $o .= '<option value="" ' . $default_selected . '>' . t('default') . '</option>';
+                               $lang_options[""] = t('default');
                                continue;
                        }
                        $ll = substr($l,5);
                        $ll = substr($ll,0,strrpos($ll,'/'));
-                       $selected = (($ll === $lang && (x($_SESSION, 'language'))) ? ' selected="selected" ' : '');
-                       $o .= '<option value="' . $ll . '"' . $selected . '>' . $ll . '</option>';
+                       $selected = (($ll === $lang && (x($_SESSION, 'language'))) ? $ll : $selected);
+                       $lang_options[$ll]=$ll;
                }
        }
-       $o .= '</select></form></div>';
+
+       $tpl = get_markup_template("lang_selector.tpl");        
+       $o = replace_macros($tpl, array(
+               '$title' => t('Select an alternate language'),
+               '$langs' => array($lang_options, $selected),
+               
+       ));
        return $o;
 }}
 
@@ -1236,13 +1255,13 @@ function bb_translate_video($s) {
 
 function html2bb_video($s) {
 
-       $s = preg_replace('#<object[^>]+>(.*?)https+://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+)(.*?)</object>#ism',
+       $s = preg_replace('#<object[^>]+>(.*?)https?://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+)(.*?)</object>#ism',
                        '[youtube]$2[/youtube]', $s);
 
-       $s = preg_replace('#<iframe[^>](.*?)https+://www.youtube.com/embed/([A-Za-z0-9\-_=]+)(.*?)</iframe>#ism',
+       $s = preg_replace('#<iframe[^>](.*?)https?://www.youtube.com/embed/([A-Za-z0-9\-_=]+)(.*?)</iframe>#ism',
                        '[youtube]$2[/youtube]', $s);
 
-       $s = preg_replace('#<iframe[^>](.*?)https+://player.vimeo.com/video/([0-9]+)(.*?)</iframe>#ism',
+       $s = preg_replace('#<iframe[^>](.*?)https?://player.vimeo.com/video/([0-9]+)(.*?)</iframe>#ism',
                        '[vimeo]$2[/vimeo]', $s);
 
        return $s;
@@ -1459,12 +1478,16 @@ function file_tag_save_file($uid,$item,$file) {
        return true;
 }
 
-function file_tag_unsave_file($uid,$item,$file) {
+function file_tag_unsave_file($uid,$item,$file,$cat = false) {
        $result = false;
        if(! intval($uid))
                return false;
 
-       $pattern = '[' . file_tag_encode($file) . ']' ;
+       if($cat == true)
+               $pattern = '<' . file_tag_encode($file) . '>' ;
+       else
+               $pattern = '[' . file_tag_encode($file) . ']' ;
+
 
        $r = q("select file from item where id = %d and uid = %d limit 1",
                intval($item),
@@ -1479,13 +1502,14 @@ function file_tag_unsave_file($uid,$item,$file) {
                intval($uid)
        );
 
-       $r = q("select file from item where uid = %d " . file_tag_file_query('item',$file),
+       $r = q("select file from item where uid = %d and deleted = 0 " . file_tag_file_query('item',$file,(($cat) ? 'category' : 'file')),
                intval($uid)
        );
 
        if(! count($r)) {
                $saved = get_pconfig($uid,'system','filetags');
                set_pconfig($uid,'system','filetags',str_replace($pattern,'',$saved));
+
        }
        return true;
 }
@@ -1510,4 +1534,23 @@ function fix_mce_lf($s) {
        $s = str_replace("\r\n","\n",$s);
        $s = str_replace("\n\n","\n",$s);
        return $s;
-}
\ No newline at end of file
+}
+
+
+function protect_sprintf($s) {
+       return(str_replace('%','%%',$s));
+}
+
+
+function is_a_date_arg($s) {
+       $i = intval($s);
+       if($i > 1900) {
+               $y = date('Y');
+               if($i <= $y+1 && strpos($s,'-') == 4) {
+                       $m = intval(substr($s,5));
+                       if($m > 0 && $m <= 12)
+                               return true;
+               }
+       }
+       return false;
+}