namespace Friendica\Model;
use Friendica\Core\System;
+use Friendica\Database\dba;
use Friendica\Database\DBM;
-use Friendica\Model\Item;
-use dba;
require_once 'boot.php';
require_once 'include/conversation.php';
return $tag_text;
}
+ public static function fileTextFromItemId($itemid)
+ {
+ $file_text = '';
+ $condition = ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_FILE, TERM_CATEGORY]];
+ $tags = dba::select('term', [], $condition);
+ while ($tag = dba::fetch($tags)) {
+ if ($tag['type'] == TERM_CATEGORY) {
+ $file_text .= '<' . $tag['term'] . '>';
+ } else {
+ $file_text .= '[' . $tag['term'] . ']';
+ }
+ }
+ return $file_text;
+ }
+
public static function insertFromTagFieldByItemId($itemid, $tags)
{
$profile_base = System::baseUrl();
* @param integer $itemid item id
* @return void
*/
- public static function insertFromFileFieldByItemId($itemid)
+ public static function insertFromFileFieldByItemId($itemid, $files)
{
- $message = Item::selectFirst(['uid', 'deleted', 'file'], ['id' => $itemid]);
+ $message = Item::selectFirst(['uid', 'deleted'], ['id' => $itemid]);
if (!DBM::is_result($message)) {
return;
}
return;
}
+ $message['file'] = $files;
+
if (preg_match_all("/\[(.*?)\]/ism", $message["file"], $files)) {
foreach ($files[1] as $file) {
dba::insert('term', [
$orig_tag = $tag["url"];
- $tag["url"] = Contact::magicLinkById($item['author-id'], $tag['url']);
+ $author = ['uid' => 0, 'id' => $item['author-id'],
+ 'network' => $item['author-network'], 'url' => $item['author-link']];
+ $tag["url"] = Contact::magicLinkByContact($author, $tag['url']);
if ($tag["type"] == TERM_HASHTAG) {
if ($orig_tag != $tag["url"]) {