X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Ftext.php;h=829e37c2ce97f8088bbd1e2a480454ff681f7c8d;hb=68e565889d2e019b67d4e00a03076ec042bcf5ff;hp=4aa529d31667c8abe4135130599ba805e776b7af;hpb=35f623ae4f82ac8167ad98b38fab39e449ffa1ea;p=friendica.git diff --git a/include/text.php b/include/text.php index 4aa529d316..829e37c2ce 100644 --- a/include/text.php +++ b/include/text.php @@ -2,8 +2,10 @@ require_once("include/template_processor.php"); require_once("include/friendica_smarty.php"); +require_once("include/map.php"); require_once("mod/proxy.php"); + if(! function_exists('replace_macros')) { /** * This is our template processor @@ -218,7 +220,7 @@ function xmlify($str) { $buffer = mb_ereg_replace("<", "<", $buffer); $buffer = mb_ereg_replace(">", ">", $buffer); */ - $buffer = htmlspecialchars($str, ENT_QUOTES); + $buffer = htmlspecialchars($str, ENT_QUOTES, "UTF-8"); $buffer = trim($buffer); return($buffer); @@ -270,7 +272,7 @@ if(! function_exists('paginate_data')) { * @return Array data for pagination template */ function paginate_data(&$a, $count=null) { - $stripped = preg_replace('/(&page=[0-9]*)/','',$a->query_string); + $stripped = preg_replace('/([&?]page=[0-9]*)/','',$a->query_string); $stripped = str_replace('q=','',$stripped); $stripped = trim($stripped,'/'); @@ -833,10 +835,16 @@ function get_mentions($item) { foreach($arr as $x) { $matches = null; if(preg_match('/@\[url=([^\]]*)\]/',$x,$matches)) { - $o .= "\t\t" . '' . "\r\n"; $o .= "\t\t" . '' . "\r\n"; + $o .= "\t\t" . '' . "\r\n"; } } + + if (!$item['private']) { + $o .= "\t\t".''."\r\n"; + $o .= "\t\t".''."\r\n"; + } + return $o; }} @@ -920,7 +928,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) { if($redirect) { $a = get_app(); $redirect_url = $a->get_baseurl() . '/redir/' . $contact['id']; - if(local_user() && ($contact['uid'] == local_user()) && ($contact['network'] === 'dfrn')) { + if(local_user() && ($contact['uid'] == local_user()) && ($contact['network'] === NETWORK_DFRN)) { $redir = true; $url = $redirect_url; $sparkle = ' sparkle'; @@ -958,19 +966,18 @@ if(! function_exists('search')) { * @param string $s search query * @param string $id html id * @param string $url search url - * @param boolean $save show save search button - * @return string html for search box #FIXME: remove html + * @param boolean $savedsearch show save search button */ function search($s,$id='search-box',$url='/search',$save = false) { $a = get_app(); - $o = '
'; - $o .= '
'; - $o .= ''; - $o .= ''; - if($save) - $o .= ''; - $o .= '
'; - return $o; + return replace_macros(get_markup_template('searchbox.tpl'), array( + '$s' => $s, + '$id' => $id, + '$action_url' => $a->get_baseurl((stristr($url,'network')) ? true : false) . $url, + '$search_label' => t('Search'), + '$save_label' => t('Save'), + '$savedsearch' => feature_enabled(local_user(),'savedsearch'), + )); }} if(! function_exists('valid_email')) { @@ -1131,9 +1138,9 @@ function smilies($s, $sample = false) { ); $icons = array( - '<3', - '</3', - '<\\3', + '<3', + '</3', + '<\\3', ':-)', ';-)', ':-(', @@ -1210,7 +1217,7 @@ function preg_heart($x) { return $x[0]; $t = ''; for($cnt = 0; $cnt < strlen($x[1]); $cnt ++) - $t .= '<3'; + $t .= '<3'; $r = str_replace($x[0],$t,$x[0]); return $r; } @@ -1461,6 +1468,14 @@ function prepare_body(&$item,$attach = false, $preview = false) { } $s = $s . $as; + // map + if(strpos($s,'
') !== false && $item['coord']) { + $x = generate_map(trim($item['coord'])); + if($x) { + $s = preg_replace('/\
/','$0' . $x,$s); + } + } + // Look for spoiler $spoilersearch = '
'; @@ -2267,3 +2282,15 @@ function deindent($text, $chr="[\t ]", $count=NULL) { return implode("\n", $lines); } + +function formatBytes($bytes, $precision = 2) { + $units = array('B', 'KB', 'MB', 'GB', 'TB'); + + $bytes = max($bytes, 0); + $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); + $pow = min($pow, count($units) - 1); + + $bytes /= pow(1024, $pow); + + return round($bytes, $precision) . ' ' . $units[$pow]; +}