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 .= '