diff options
author | fabrixxm <fabrix.xm@gmail.com> | 2011-02-12 18:31:13 +0100 |
---|---|---|
committer | fabrixxm <fabrix.xm@gmail.com> | 2011-02-12 18:31:13 +0100 |
commit | 53dff2204bf2cbe46b6cbdb7174fa0cf1a7162b1 (patch) | |
tree | eee6bc94d474e327a233c7053beb46d33036a65d /include | |
parent | 26dfb73f48d4fcd4671d136e53f52bb81995ea34 (diff) | |
parent | 89cbd17c721dae57b18686fd7f3e5f8c74a279d9 (diff) | |
download | volse-hubzilla-53dff2204bf2cbe46b6cbdb7174fa0cf1a7162b1.tar.gz volse-hubzilla-53dff2204bf2cbe46b6cbdb7174fa0cf1a7162b1.tar.bz2 volse-hubzilla-53dff2204bf2cbe46b6cbdb7174fa0cf1a7162b1.zip |
Merge branch 'friendika-master'
Diffstat (limited to 'include')
-rw-r--r-- | include/acl_selectors.php | 22 | ||||
-rw-r--r-- | include/bbcode.php | 10 | ||||
-rw-r--r-- | include/html2bbcode.php | 53 | ||||
-rw-r--r-- | include/items.php | 6 | ||||
-rw-r--r-- | include/notifier.php | 18 | ||||
-rw-r--r-- | include/oembed.php | 5 |
6 files changed, 94 insertions, 20 deletions
diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 269dc3e34..953243a43 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -3,6 +3,8 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { + $a = get_app(); + $o = ''; $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n"; @@ -11,6 +13,13 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { $_SESSION['uid'] ); + + $arr = array('group' => $r, 'entry' => $o); + + // e.g. 'network_pre_group_deny', 'profile_pre_group_allow' + + call_hooks($a->module . '_pre_' . $selname, $arr); + if(count($r)) { foreach($r as $rr) { if((is_array($preselected)) && in_array($rr['id'], $preselected)) @@ -25,6 +34,8 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { } $o .= "</select>\r\n"; + call_hooks($a->module . '_post_' . $selname, $o); + return $o; } @@ -60,6 +71,15 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p intval(local_user()) ); + + $arr = array('contact' => $r, 'entry' => $o); + + // e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow' + + call_hooks($a->module . '_pre_' . $selname, $arr); + + + if(count($r)) { foreach($r as $rr) { if((is_array($preselected)) && in_array($rr['id'], $preselected)) @@ -73,8 +93,10 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p } } + $o .= "</select>\r\n"; + call_hooks($a->module . '_post_' . $selname, $o); return $o; } diff --git a/include/bbcode.php b/include/bbcode.php index eb0806dc5..c55ebab00 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -15,14 +15,14 @@ function bbcode($Text) { $Text = nl2br($Text); // Set up the parameters for a URL search string - $URLSearchString = " a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%"; + $URLSearchString = "^\[\]"; // Set up the parameters for a MAIL search string - $MAILSearchString = $URLSearchString . " a-zA-Z0-9\.@"; + $MAILSearchString = $URLSearchString; // Perform URL Search - $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%]+)/", ' <a href="$2" target="external-link">$2</a>', $Text); + $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%\$\!]+)/", ' <a href="$2" target="external-link">$2</a>', $Text); $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href="$1" target="external-link">$1</a>', $Text); $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '<a href="$1" target="external-link">$2</a>', $Text); @@ -49,10 +49,10 @@ function bbcode($Text) { $Text = preg_replace("(\[o\](.+?)\[\/o\])is",'<span class="overline">$1</span>',$Text); // Check for colored text - $Text = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is","<span style=\"color: $1\">$2</span>",$Text); + $Text = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is","<span style=\"color: $1;\">$2</span>",$Text); // Check for sized text - $Text = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is","<span style=\"font-size: $1px\">$2</span>",$Text); + $Text = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is","<span style=\"font-size: $1;\">$2</span>",$Text); // Check for list text $Text = preg_replace("/\[list\](.+?)\[\/list\]/is", '<ul class="listbullet">$1</ul>' ,$Text); diff --git a/include/html2bbcode.php b/include/html2bbcode.php index 6af8df824..734282d95 100644 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -7,10 +7,15 @@ function html2bbcode($s) { + + // only keep newlines from source that are within pre tags + + $s = stripnl_exceptinpre($s); + + // Tags to Find $htmltags = array( - '/\n/is', '/\<pre\>(.*?)\<\/pre\>/is', '/\<p(.*?)\>/is', '/\<\/p\>/is', @@ -26,6 +31,7 @@ function html2bbcode($s) { '/\<a (.*?)href=\"(.*?)\"(.*?)\>(.*?)\<\/a\>/is', '/\<code\>(.*?)\<\/code\>/is', '/\<span style=\"color:(.*?)\"\>(.*?)\<\/span\>/is', + '/\<span style=\"font-size:(.*?)\"\>(.*?)\<\/span\>/is', '/\<blockquote\>(.*?)\<\/blockquote\>/is', '/\<video(.*?) src=\"(.*?)\" (.*?)\>(.*?)\<\/video\>/is', '/\<audio(.*?) src=\"(.*?)\" (.*?)\>(.*?)\<\/audio\>/is', @@ -35,7 +41,6 @@ function html2bbcode($s) { // Replace with $bbtags = array( - '', '[code]$1[/code]', '', "\n", @@ -51,6 +56,7 @@ function html2bbcode($s) { '[url=$2]$4[/url]', '[code]$1[/code]', '[color="$1"]$2[/color]', + '[size=$1]$2[/size]', '[quote]$1[/quote]', '[video]$1[/video]', '[audio]$1[/audio]', @@ -64,5 +70,48 @@ function html2bbcode($s) { // Strip all other HTML tags $text = strip_tags($text); return $text; + +} + +function stripnl_exceptinpre($string) +{ + // First, check for <pre> tag + if(strpos($string, '<pre>') === false) + { + return str_replace("\n","", $string); + } + + // If there is a <pre>, we have to split by line + // and manually replace the linebreaks + + $strArr=explode("\n", $string); + + $output=""; + $preFound=false; + + // Loop over each line + foreach($strArr as $line) + { // See if the line has a <pre>. If it does, set $preFound to true + if(strpos($line, "<pre>") !== false) + { + $preFound=true; + } + elseif(strpos($line, "</pre>") !== false) + { + $preFound=false; + } + + // If we are in a pre tag, add line and also add \n, else add the line without \n + if($preFound) + { + $output .= $line . "\n"; + } + else + { + $output .= $line ; + } + } + + return $output; } diff --git a/include/items.php b/include/items.php index cffd13a01..b5bdd7833 100644 --- a/include/items.php +++ b/include/items.php @@ -1128,15 +1128,16 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { } if(($is_reply) && is_array($contact)) { - + // Have we seen it? If not, import it. $item_id = $item->get_id(); - + $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), intval($importer['uid']) ); + // FIXME update content if 'updated' changes if(count($r)) { $allow = $item->get_item_tags( NAMESPACE_DFRN, 'comment-allow'); @@ -1155,6 +1156,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { } continue; } + $datarray = get_atom_elements($feed,$item); $force_parent = false; if($contact['network'] === 'stat') { diff --git a/include/notifier.php b/include/notifier.php index b6c4ca571..648a07062 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -40,6 +40,7 @@ function notifier_run($argv, $argc){ break; } + $top_level = false; $recipients = array(); $url_recipients = array(); @@ -79,12 +80,16 @@ function notifier_run($argv, $argc){ return; } + // avoid race condition with deleting entries if($items[0]['deleted']) { foreach($items as $item) $item['deleted'] = 1; } + + if(count($items) == 1 && $items[0]['uri'] === $items[0]['parent-uri']) + $top_level = true; } $r = q("SELECT `contact`.*, `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, `user`.`page-flags` @@ -167,9 +172,6 @@ function notifier_run($argv, $argc){ $r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) AND `blocked` = 0 AND `pending` = 0"); -// if( ! count($r)){ -// return; -// } if(count($r)) $contacts = $r; @@ -242,12 +244,8 @@ function notifier_run($argv, $argc){ $atom .= atom_entry($item,'text',$contact,$owner,true); - // There's a problem here - we *were* going to use salmon to provide semi-authenticated - // communication to OStatus, but unless we're the item author they won't verify. - // commented out for now, though we'll still send local replies (and any mentions - // that they contain) upstream. Rethinking the problem space. - -// $slaps[] = atom_entry($item,'html',$contact,$owner,true); + if(($top_level) && ($notify_hub) && ($item['author-link'] === $item['owner-link'])) + $slaps[] = atom_entry($item,'html',$contact,$owner,true); } } } @@ -255,7 +253,7 @@ function notifier_run($argv, $argc){ logger('notifier: ' . $atom, LOGGER_DATA); -// logger('notifier: slaps: ' . print_r($slaps,true), LOGGER_DATA); + logger('notifier: slaps: ' . print_r($slaps,true), LOGGER_DATA); if($followup) $recip_str = $parent['contact-id']; diff --git a/include/oembed.php b/include/oembed.php index 37923a877..4d6b0af16 100644 --- a/include/oembed.php +++ b/include/oembed.php @@ -79,7 +79,10 @@ function oe_get_inner_html( $node ) { * and replace it with [embed]url[/embed] */ function oembed_html2bbcode($text) { - $dom = DOMDocument::loadHTML($text); + // If it doesn't parse at all, just return the text. + $dom = @DOMDocument::loadHTML($text); + if(! $dom) + return $text; $xpath = new DOMXPath($dom); $attr = "oembed"; |