<?php
use Friendica\App;
+use Friendica\Core\System;
require_once "include/template_processor.php";
require_once "include/friendica_smarty.php";
$a = get_app();
// pass $baseurl to all templates
- $r['$baseurl'] = App::get_baseurl();
+ $r['$baseurl'] = System::baseUrl();
$t = $a->template_engine();
try {
function item_new_uri($hostname, $uid, $guid = "") {
do {
- $dups = false;
-
if ($guid == "") {
$hash = get_guid(32);
} else {
$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;
$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);
}
}
}
$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 ($orig_tag != $tag["url"]) {
+ $item['body'] = str_replace($orig_tag, $tag["url"], $item['body']);
+ }
+
if ($tag["type"] == TERM_HASHTAG) {
$hashtags[] = "#<a href=\"".$tag["url"]."\" target=\"_blank\">".$tag["term"]."</a>";
$prefix = "#";
}
$tags[] = $prefix."<a href=\"".$tag["url"]."\" target=\"_blank\">".$tag["term"]."</a>";
}
+ dba::close($taglist);
}
$item['tags'] = $tags;
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(),
));
}
if (! dbm::is_result($x)) {
$found = false;
}
- } while ($found == true );
+ } while ($found == true);
return $guid;
}