X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Ftext.php;h=66d4f17ea66ac5b20ef9c486f207d23dfa65e68a;hb=5d0e7d24babf345431df73472fc0d1c7c80996f9;hp=ea5deb4c1442a7c43ebb8929dbac66f64209290a;hpb=ea88e15a8cc10f99621720ca0e5a9598d0e64e0f;p=friendica.git diff --git a/include/text.php b/include/text.php index ea5deb4c14..66d4f17ea6 100644 --- a/include/text.php +++ b/include/text.php @@ -1,6 +1,7 @@ template_engine(); try { @@ -488,8 +489,6 @@ if (! function_exists('item_new_uri')) { function item_new_uri($hostname, $uid, $guid = "") { do { - $dups = false; - if ($guid == "") { $hash = get_guid(32); } else { @@ -499,11 +498,7 @@ function item_new_uri($hostname, $uid, $guid = "") { $uri = "urn:X-dfrn:" . $hostname . ':' . $uid . ':' . $hash; - $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1", - dbesc($uri)); - if (dbm::is_result($r)) { - $dups = true; - } + $dups = dba::exists('item', array('uri' => $uri)); } while ($dups == true); return $uri; @@ -753,7 +748,7 @@ function logger($msg, $level = 0) { $callers = debug_backtrace(); $logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n", - datetime_convert(), + datetime_convert('UTC', 'UTC', 'now', 'Y-m-d\TH:i:s\Z'), $process_id, $LOGGER_LEVELS[$level], basename($callers[0]['file']), @@ -1290,9 +1285,9 @@ function put_item_in_cache(&$item, $update = false) { $item["rendered-hash"] = hash("md5", $item["body"]); $item["body"] = $body; - if ($update && ($item["id"] != 0)) { - q("UPDATE `item` SET `rendered-html` = '%s', `rendered-hash` = '%s' WHERE `id` = %d", - dbesc($item["rendered-html"]), dbesc($item["rendered-hash"]), intval($item["id"])); + if ($update && ($item["id"] > 0)) { + dba::update('item', array('rendered-html' => $item["rendered-html"], 'rendered-hash' => $item["rendered-hash"]), + array('id' => $item["id"]), false); } } } @@ -1317,23 +1312,29 @@ function prepare_body(&$item, $attach = false, $preview = false) { $a = get_app(); call_hooks('prepare_body_init', $item); - $searchpath = z_root() . "/search?tag="; + $searchpath = System::baseUrl() . "/search?tag="; $tags = array(); $hashtags = array(); $mentions = array(); if (!get_config('system','suppress_tags')) { - $taglist = q("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d) ORDER BY `tid`", + $taglist = dba::p("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = ? AND `oid` = ? AND `type` IN (?, ?) ORDER BY `tid`", intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION)); - foreach ($taglist as $tag) { - + while ($tag = dba::fetch($taglist)) { if ($tag["url"] == "") { $tag["url"] = $searchpath.strtolower($tag["term"]); } + $orig_tag = $tag["url"]; + + $tag["url"] = best_link_url($item, $sp, $tag["url"]); + if ($tag["type"] == TERM_HASHTAG) { + if ($orig_tag != $tag["url"]) { + $item['body'] = str_replace($orig_tag, $tag["url"], $item['body']); + } $hashtags[] = "#".$tag["term"].""; $prefix = "#"; } elseif ($tag["type"] == TERM_MENTION) { @@ -1342,6 +1343,7 @@ function prepare_body(&$item, $attach = false, $preview = false) { } $tags[] = $prefix."".$tag["term"].""; } + dba::close($taglist); } $item['tags'] = $tags; @@ -1374,7 +1376,6 @@ function prepare_body(&$item, $attach = false, $preview = false) { $vhead = false; $arr = explode('[/attach],', $item['attach']); if (count($arr)) { - $as .= '
'; foreach ($arr as $r) { $matches = false; $icon = ''; @@ -1393,10 +1394,10 @@ function prepare_body(&$item, $attach = false, $preview = false) { if (!$vhead) { $vhead = true; $a->page['htmlhead'] .= replace_macros(get_markup_template('videos_head.tpl'), array( - '$baseurl' => z_root(), + '$baseurl' => System::baseUrl(), )); $a->page['end'] .= replace_macros(get_markup_template('videos_end.tpl'), array( - '$baseurl' => z_root(), + '$baseurl' => System::baseUrl(), )); } @@ -1411,39 +1412,27 @@ function prepare_body(&$item, $attach = false, $preview = false) { )); } - $filetype = strtolower(substr( $mime, 0, strpos($mime,'/') )); + $filetype = strtolower(substr($mime, 0, strpos($mime,'/'))); if ($filetype) { - $filesubtype = strtolower(substr( $mime, strpos($mime,'/') + 1 )); + $filesubtype = strtolower(substr($mime, strpos($mime,'/') + 1)); $filesubtype = str_replace('.', '-', $filesubtype); } else { $filetype = 'unkn'; $filesubtype = 'unkn'; } - $icon = '
'; - /*$icontype = strtolower(substr($mtch[3],0,strpos($mtch[3],'/'))); - switch($icontype) { - case 'video': - case 'audio': - case 'image': - case 'text': - $icon = '
'; - break; - default: - $icon = '
'; - break; - }*/ - $title = ((strlen(trim($mtch[4]))) ? escape_tags(trim($mtch[4])) : escape_tags($mtch[1])); $title .= ' ' . $mtch[2] . ' ' . t('bytes'); + $icon = '
'; $as .= '' . $icon . ''; } } } - $as .= '
'; } - $s = $s . $as; + if ($as != '') { + $s .= '
'.$as.'
'; + } // map if (strpos($s, '
') !== false && x($item, 'coord')) { @@ -1672,7 +1661,7 @@ function generate_user_guid() { if (! dbm::is_result($x)) { $found = false; } - } while ($found == true ); + } while ($found == true); return $guid; }