From: Michael Vogel Date: Thu, 20 Dec 2012 23:08:58 +0000 (+0100) Subject: New option to enable and disable the "share" element X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f4bc5c57f33236e0e46517f5c2b618374667b9fd;p=friendica.git New option to enable and disable the "share" element Changes to "vier" to use more "font awesome" icons --- diff --git a/htconfig.php b/htconfig.php index bb0f47727a..e8aec10909 100644 --- a/htconfig.php +++ b/htconfig.php @@ -92,5 +92,5 @@ $a->config['system']['lockpath'] = ""; // If enabled, the MyBB fulltext engine is used // $a->config['system']['use_fulltext_engine'] = true; -// Let reshared messages look like wall-to-wall posts -// $a->config['system']['diaspora_newreshare'] = true; +// Use the new "share" element +// $a->config['system']['new_share'] = true; diff --git a/include/bbcode.php b/include/bbcode.php index e09b1ed342..f3c4e360d5 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -3,6 +3,14 @@ require_once("include/oembed.php"); require_once('include/event.php'); +function bb_cleanstyle($st) { + return "".$st[2].""; +} + +function bb_cleanclass($st) { + return "".$st[2].""; +} + function cleancss($input) { $cleaned = ""; @@ -385,10 +393,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $Text = str_replace("[*]", "
  • ", $Text); // Check for style sheet commands - $Text = preg_replace("(\[style=(.*?)\](.*?)\[\/style\])ism","$2",$Text); + $Text = preg_replace_callback("(\[style=(.*?)\](.*?)\[\/style\])ism","bb_cleanstyle",$Text); // Check for CSS classes - $Text = preg_replace("(\[class=(.*?)\](.*?)\[\/class\])ism","$2",$Text); + $Text = preg_replace_callback("(\[class=(.*?)\](.*?)\[\/class\])ism","bb_cleanclass",$Text); // handle nested lists $endlessloop = 0; diff --git a/include/diaspora.php b/include/diaspora.php index b14402b5a2..5fd4a4d3fd 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -960,12 +960,12 @@ function diaspora_reshare($importer,$xml,$msg) { $person = find_diaspora_person_by_handle($orig_author); - if(is_array($person) && x($person,'name') && x($person,'url')) + /*if(is_array($person) && x($person,'name') && x($person,'url')) $details = '[url=' . $person['url'] . ']' . $person['name'] . '[/url]'; else $details = $orig_author; - $prefix = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . $details . "\n"; + $prefix = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . $details . "\n";*/ // allocate a guid on our system - we aren't fixing any collisions. @@ -1012,7 +1012,7 @@ function diaspora_reshare($importer,$xml,$msg) { } } } - + $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $contact['id']; $datarray['wall'] = 0; @@ -1024,15 +1024,7 @@ function diaspora_reshare($importer,$xml,$msg) { $datarray['owner-name'] = $contact['name']; $datarray['owner-link'] = $contact['url']; $datarray['owner-avatar'] = ((x($contact,'thumb')) ? $contact['thumb'] : $contact['photo']); - if (intval(get_config('system','diaspora_newreshare'))) { - // Let reshared messages look like wall-to-wall posts - // we have to set an additional value in the item in the future - // to distinct the wall-to-wall-posts from reshared/repeated messages - $datarray['author-name'] = $person['name']; - $datarray['author-link'] = $person['url']; - $datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']); - $datarray['body'] = $body; - } else { + if (intval(get_config('system','new_share'))) { $prefix = "[share author='".$person['name']. "' profile='".$person['url']. "' avatar='".((x($person,'thumb')) ? $person['thumb'] : $person['photo']). @@ -1041,6 +1033,12 @@ function diaspora_reshare($importer,$xml,$msg) { $datarray['author-link'] = $contact['url']; $datarray['author-avatar'] = $contact['thumb']; $datarray['body'] = $prefix.$body."[/share]"; + } else { + // Let reshared messages look like wall-to-wall posts + $datarray['author-name'] = $person['name']; + $datarray['author-link'] = $person['url']; + $datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']); + $datarray['body'] = $body; } $datarray['tag'] = $str_tags; diff --git a/include/items.php b/include/items.php index b5e6062b23..65c04f0a2f 100755 --- a/include/items.php +++ b/include/items.php @@ -808,20 +808,22 @@ function get_atom_elements($feed,$item) { if (($name != "") and ($uri != "") and ($avatar != "") and ($message != "")) { logger('get_atom_elements: fixing sender of repeated message.'); - /*$res["owner-name"] = $res["author-name"]; - $res["owner-link"] = $res["author-link"]; - $res["owner-avatar"] = $res["author-avatar"]; - - $res["author-name"] = $name; - $res["author-link"] = $uri; - $res["author-avatar"] = $avatar;*/ - - $prefix = "[share author='".$name. - "' profile='".$uri. - "' avatar='".$avatar. - "' link='".$orig_uri."']"; - - $res["body"] = $prefix.html2bbcode($message)."[/share]"; + if (intval(get_config('system','new_share'))) { + $prefix = "[share author='".$name. + "' profile='".$uri. + "' avatar='".$avatar. + "' link='".$orig_uri."']"; + + $res["body"] = $prefix.html2bbcode($message)."[/share]"; + } else { + $res["owner-name"] = $res["author-name"]; + $res["owner-link"] = $res["author-link"]; + $res["owner-avatar"] = $res["author-avatar"]; + + $res["author-name"] = $name; + $res["author-link"] = $uri; + $res["author-avatar"] = $avatar; + } } } diff --git a/mod/share.php b/mod/share.php index 761220ad7f..e372031bbf 100644 --- a/mod/share.php +++ b/mod/share.php @@ -18,15 +18,30 @@ function share_init(&$a) { if(! count($r) || ($r[0]['private'] == 1)) killme(); - $o = ''; - - $o .= "\xE2\x99\xb2" . ' [url=' . $r[0]['author-link'] . ']' . $r[0]['author-name'] . '[/url]' . "\n"; - if($r[0]['title']) - $o .= '[b]' . $r[0]['title'] . '[/b]' . "\n"; - $o .= $r[0]['body'] . "\n" ; - - $o .= (($r[0]['plink']) ? '[url=' . $r[0]['plink'] . ']' . t('link') . '[/url]' . "\n" : ''); - + if (intval(get_config('system','new_share'))) { + if (strpos($r[0]['body'], "[/share]") !== false) { + $pos = strpos($r[0]['body'], "[share"); + $o = substr($r[0]['body'], $pos); + } else { + $o = "[share author='".$r[0]['author-name']. + "' profile='".$r[0]['author-link']. + "' avatar='".$r[0]['author-avatar']. + "' link='".$r[0]['plink']."']\n"; + if($r[0]['title']) + $o .= '[b]'.$r[0]['title'].'[/b]'."\n"; + $o .= $r[0]['body']; + $o.= "[/share]"; + } + } else { + $o = ''; + + $o .= "\xE2\x99\xb2" . ' [url=' . $r[0]['author-link'] . ']' . $r[0]['author-name'] . '[/url]' . "\n"; + if($r[0]['title']) + $o .= '[b]' . $r[0]['title'] . '[/b]' . "\n"; + $o .= $r[0]['body'] . "\n" ; + + $o .= (($r[0]['plink']) ? '[url=' . $r[0]['plink'] . ']' . t('link') . '[/url]' . "\n" : ''); + } echo $o; - killme(); + killme(); } diff --git a/view/theme/vier/nav.tpl b/view/theme/vier/nav.tpl index f615be85f0..8a8b53dd80 100644 --- a/view/theme/vier/nav.tpl +++ b/view/theme/vier/nav.tpl @@ -35,7 +35,7 @@
  • {{ endif }} - {{ if $nav.notifications }} -