From: Michael Date: Mon, 13 Apr 2020 19:24:22 +0000 (+0000) Subject: Term constants updated X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=661dd43b0ddac517ac254b68a2ab7a58b3c48153;p=friendica.git Term constants updated --- diff --git a/boot.php b/boot.php index 348e1b2c41..0637ff3fea 100644 --- a/boot.php +++ b/boot.php @@ -178,29 +178,6 @@ define('NOTIFY_SHARE', Notify\Type::SHARE); define('NOTIFY_SYSTEM', Notify\Type::SYSTEM); /* @}*/ - -/** @deprecated since 2019.03, use Term::UNKNOWN instead */ -define('TERM_UNKNOWN', Term::UNKNOWN); -/** @deprecated since 2019.03, use Term::HASHTAG instead */ -define('TERM_HASHTAG', Term::HASHTAG); -/** @deprecated since 2019.03, use Term::MENTION instead */ -define('TERM_MENTION', Term::MENTION); -/** @deprecated since 2019.03, use Term::CATEGORY instead */ -define('TERM_CATEGORY', Term::CATEGORY); -/** @deprecated since 2019.03, use Term::PCATEGORY instead */ -define('TERM_PCATEGORY', Term::PCATEGORY); -/** @deprecated since 2019.03, use Term::FILE instead */ -define('TERM_FILE', Term::FILE); -/** @deprecated since 2019.03, use Term::SAVEDSEARCH instead */ -define('TERM_SAVEDSEARCH', Term::SAVEDSEARCH); -/** @deprecated since 2019.03, use Term::CONVERSATION instead */ -define('TERM_CONVERSATION', Term::CONVERSATION); - -/** @deprecated since 2019.03, use Term::OBJECT_TYPE_POST instead */ -define('TERM_OBJ_POST', Term::OBJECT_TYPE_POST); -/** @deprecated since 2019.03, use Term::OBJECT_TYPE_PHOTO instead */ -define('TERM_OBJ_PHOTO', Term::OBJECT_TYPE_PHOTO); - /** * @name Gravity * diff --git a/include/api.php b/include/api.php index 8291d18926..75e66349eb 100644 --- a/include/api.php +++ b/include/api.php @@ -41,6 +41,7 @@ use Friendica\Model\Item; use Friendica\Model\Mail; use Friendica\Model\Notify; use Friendica\Model\Photo; +use Friendica\Model\Term; use Friendica\Model\User; use Friendica\Model\UserItem; use Friendica\Network\FKOAuth1; @@ -1541,7 +1542,7 @@ function api_search($type) $condition = ["`oid` > ? AND (`uid` = 0 OR (`uid` = ? AND NOT `global`)) AND `otype` = ? AND `type` = ? AND `term` = ?", - $since_id, local_user(), TERM_OBJ_POST, TERM_HASHTAG, $searchTerm]; + $since_id, local_user(), Term::OBJECT_TYPE_POST, Term::HASHTAG, $searchTerm]; if ($max_id > 0) { $condition[0] .= ' AND `oid` <= ?'; $condition[] = $max_id; diff --git a/mod/network.php b/mod/network.php index d252175df1..6c02c4f843 100644 --- a/mod/network.php +++ b/mod/network.php @@ -793,7 +793,7 @@ function networkThreadedView(App $a, $update, $parent) STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id` WHERE `item`.`uid` = 0 AND `item`.$ordering < ? AND `item`.$ordering > ? AND `item`.`gravity` = ? AND NOT `author`.`hidden` AND NOT `author`.`blocked`" . $sql_tag_nets, - local_user(), TERM_OBJ_POST, TERM_HASHTAG, + local_user(), Term::OBJECT_TYPE_POST, Term::HASHTAG, $top_limit, $bottom_limit, GRAVITY_PARENT); $data = DBA::toArray($items); diff --git a/mod/tagger.php b/mod/tagger.php index a6f35cea12..e3ae6b9b5c 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -28,6 +28,7 @@ use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; +use Friendica\Model\Term; use Friendica\Protocol\Activity; use Friendica\Util\Strings; use Friendica\Util\XML; @@ -168,7 +169,7 @@ EOT; Item::update(['visible' => true], ['id' => $item['id']]); } - $term_objtype = ($item['resource-id'] ? TERM_OBJ_PHOTO : TERM_OBJ_POST); + $term_objtype = ($item['resource-id'] ? Term::OBJECT_TYPE_PHOTO : Term::OBJECT_TYPE_POST); $t = q("SELECT count(tid) as tcount FROM term WHERE oid=%d AND term='%s'", intval($item['id']), @@ -179,7 +180,7 @@ EOT; q("INSERT INTO term (oid, otype, type, term, url, uid) VALUE (%d, %d, %d, '%s', '%s', %d)", intval($item['id']), $term_objtype, - TERM_HASHTAG, + Term::HASHTAG, DBA::escape($term), '', intval($owner_uid) @@ -201,7 +202,7 @@ EOT; q("INSERT INTO term (`oid`, `otype`, `type`, `term`, `url`, `uid`) VALUE (%d, %d, %d, '%s', '%s', %d)", intval($original_item['id']), $term_objtype, - TERM_HASHTAG, + Term::HASHTAG, DBA::escape($term), '', intval($owner_uid) diff --git a/src/Content/Widget/TagCloud.php b/src/Content/Widget/TagCloud.php index 006aef9161..5bdf7d8346 100644 --- a/src/Content/Widget/TagCloud.php +++ b/src/Content/Widget/TagCloud.php @@ -25,6 +25,7 @@ use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; +use Friendica\Model\Term; /** * TagCloud widget @@ -45,7 +46,7 @@ class TagCloud * @return string HTML formatted output. * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function getHTML($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HASHTAG) + public static function getHTML($uid, $count = 0, $owner_id = 0, $flags = '', $type = Term::HASHTAG) { $o = ''; $r = self::tagadelic($uid, $count, $owner_id, $flags, $type); @@ -84,7 +85,7 @@ class TagCloud * @return array Alphabetical sorted array of used tags of an user. * @throws \Exception */ - private static function tagadelic($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HASHTAG) + private static function tagadelic($uid, $count = 0, $owner_id = 0, $flags = '', $type = Term::HASHTAG) { $sql_options = Item::getPermissionsSQLByUserId($uid); $limit = $count ? sprintf('LIMIT %d', intval($count)) : ''; @@ -109,7 +110,7 @@ class TagCloud GROUP BY `term` ORDER BY `total` DESC $limit", $uid, $type, - TERM_OBJ_POST + Term::OBJECT_TYPE_POST ); if (!DBA::isResult($tag_stmt)) { return []; diff --git a/src/Model/FileTag.php b/src/Model/FileTag.php index 02eee8aeda..3539f2b96d 100644 --- a/src/Model/FileTag.php +++ b/src/Model/FileTag.php @@ -23,6 +23,7 @@ namespace Friendica\Model; use Friendica\Database\DBA; use Friendica\DI; +use Friendica\Model\Term; /** * This class handles FileTag related functions @@ -195,11 +196,11 @@ class FileTag if ($type == 'file') { $lbracket = '['; $rbracket = ']'; - $termtype = TERM_FILE; + $termtype = Term::FILE; } else { $lbracket = '<'; $rbracket = '>'; - $termtype = TERM_CATEGORY; + $termtype = Term::CATEGORY; } $filetags_updated = $saved; diff --git a/src/Model/Term.php b/src/Model/Term.php index 84cb1bea7a..928c35f207 100644 --- a/src/Model/Term.php +++ b/src/Model/Term.php @@ -40,10 +40,7 @@ class Term const HASHTAG = 1; const MENTION = 2; const CATEGORY = 3; - const PCATEGORY = 4; const FILE = 5; - const SAVEDSEARCH = 6; - const CONVERSATION = 7; /** * An implicit mention is a mention in a comment body that is redundant with the threading information. */ diff --git a/src/Model/UserItem.php b/src/Model/UserItem.php index 0b0a4d2033..d38ed6d55e 100644 --- a/src/Model/UserItem.php +++ b/src/Model/UserItem.php @@ -26,6 +26,7 @@ use Friendica\Core\Hook; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Util\Strings; +use Friendica\Model\Term; class UserItem { @@ -206,7 +207,7 @@ class UserItem } // Or the contact is a mentioned forum - $tags = DBA::select('term', ['url'], ['otype' => TERM_OBJ_POST, 'oid' => $item['id'], 'type' => TERM_MENTION, 'uid' => $uid]); + $tags = DBA::select('term', ['url'], ['otype' => term::OBJECT_TYPE_POST, 'oid' => $item['id'], 'type' => Term::MENTION, 'uid' => $uid]); while ($tag = DBA::fetch($tags)) { $condition = ['nurl' => Strings::normaliseLink($tag['url']), 'uid' => $uid, 'notify_new_posts' => true, 'contact-type' => Contact::TYPE_COMMUNITY]; if (DBA::exists('contact', $condition)) { diff --git a/src/Module/Hashtag.php b/src/Module/Hashtag.php index 50719774fb..06c6374e34 100644 --- a/src/Module/Hashtag.php +++ b/src/Module/Hashtag.php @@ -25,6 +25,7 @@ use Friendica\BaseModule; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Util\Strings; +use Friendica\Model\Term; /** * Hashtag module. @@ -43,7 +44,7 @@ class Hashtag extends BaseModule $taglist = DBA::p("SELECT DISTINCT(`term`) FROM `term` WHERE `term` LIKE ? AND `type` = ? ORDER BY `term`", $t . '%', - intval(TERM_HASHTAG) + intval(Term::HASHTAG) ); while ($tag = DBA::fetch($taglist)) { $result[] = ['text' => $tag['term']]; diff --git a/src/Module/Profile/Status.php b/src/Module/Profile/Status.php index 338cf6ef4e..bb19be2b9c 100644 --- a/src/Module/Profile/Status.php +++ b/src/Module/Profile/Status.php @@ -31,6 +31,7 @@ use Friendica\DI; use Friendica\Model\Item; use Friendica\Model\Profile as ProfileModel; use Friendica\Model\User; +use Friendica\Model\Term; use Friendica\Module\BaseProfile; use Friendica\Module\Security\Login; use Friendica\Util\DateTimeFormat; @@ -142,12 +143,12 @@ class Status extends BaseProfile if (!empty($category)) { $sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ", - DBA::escape(Strings::protectSprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($a->profile['uid'])); + DBA::escape(Strings::protectSprintf($category)), intval(Term::OBJECT_TYPE_POST), intval(Term::CATEGORY), intval($a->profile['uid'])); } if (!empty($hashtags)) { $sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ", - DBA::escape(Strings::protectSprintf($hashtags)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval($a->profile['uid'])); + DBA::escape(Strings::protectSprintf($hashtags)), intval(Term::OBJECT_TYPE_POST), intval(Term::HASHTAG), intval($a->profile['uid'])); } if (!empty($datequery)) { diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index ecda2dc683..e35d833615 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -1218,7 +1218,7 @@ class Transmitter */ private static function isSensitive($item_id) { - $condition = ['otype' => TERM_OBJ_POST, 'oid' => $item_id, 'type' => TERM_HASHTAG, 'term' => 'nsfw']; + $condition = ['otype' => Term::OBJECT_TYPE_POST, 'oid' => $item_id, 'type' => Term::HASHTAG, 'term' => 'nsfw']; return DBA::exists('term', $condition); } diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 4c71de4d57..6fb63c3d46 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -24,9 +24,7 @@ namespace Friendica\Protocol; use DOMDocument; use DOMXPath; use Friendica\App\BaseURL; -use Friendica\Content\OEmbed; use Friendica\Content\Text\BBCode; -use Friendica\Content\Text\HTML; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Protocol; @@ -41,6 +39,7 @@ use Friendica\Model\Mail; use Friendica\Model\Notify\Type; use Friendica\Model\PermissionSet; use Friendica\Model\Profile; +use Friendica\Model\Term; use Friendica\Model\User; use Friendica\Network\Probe; use Friendica\Util\Crypto; @@ -49,8 +48,6 @@ use Friendica\Util\Images; use Friendica\Util\Network; use Friendica\Util\Strings; use Friendica\Util\XML; -use HTMLPurifier; -use HTMLPurifier_Config; /** * This class contain functions to create and send DFRN XML files @@ -252,8 +249,8 @@ class DFRN $sql_post_table = sprintf( "INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ", DBA::escape(Strings::protectSprintf($category)), - intval(TERM_OBJ_POST), - intval(TERM_CATEGORY), + intval(Term::OBJECT_TYPE_POST), + intval(Term::CATEGORY), intval($owner_id) ); } diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 828333b41f..8bb407ebd8 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -38,6 +38,7 @@ use Friendica\Model\Item; use Friendica\Model\ItemDeliveryData; use Friendica\Model\Mail; use Friendica\Model\Profile; +use Friendica\Model\Term; use Friendica\Model\User; use Friendica\Network\Probe; use Friendica\Util\Crypto; @@ -123,7 +124,7 @@ class Diaspora } // All tags of the current post - $condition = ['otype' => TERM_OBJ_POST, 'type' => TERM_HASHTAG, 'oid' => $parent['parent']]; + $condition = ['otype' => Term::OBJECT_TYPE_POST, 'type' => Term::HASHTAG, 'oid' => $parent['parent']]; $tags = DBA::select('term', ['term'], $condition); $taglist = []; while ($tag = DBA::fetch($tags)) { diff --git a/src/Worker/TagUpdate.php b/src/Worker/TagUpdate.php index d7ad4462c3..1b4ba8d79f 100644 --- a/src/Worker/TagUpdate.php +++ b/src/Worker/TagUpdate.php @@ -23,6 +23,7 @@ namespace Friendica\Worker; use Friendica\Core\Logger; use Friendica\Database\DBA; +use Friendica\Model\Term; class TagUpdate { @@ -35,14 +36,14 @@ class TagUpdate if ($message['uid'] == 0) { $global = true; - DBA::update('term', ['global' => true], ['otype' => TERM_OBJ_POST, 'guid' => $message['guid']]); + DBA::update('term', ['global' => true], ['otype' => Term::OBJECT_TYPE_POST, 'guid' => $message['guid']]); } else { - $global = (DBA::count('term', ['uid' => 0, 'otype' => TERM_OBJ_POST, 'guid' => $message['guid']]) > 0); + $global = (DBA::count('term', ['uid' => 0, 'otype' => Term::OBJECT_TYPE_POST, 'guid' => $message['guid']]) > 0); } $fields = ['guid' => $message['guid'], 'created' => $message['created'], 'received' => $message['received'], 'global' => $global]; - DBA::update('term', $fields, ['otype' => TERM_OBJ_POST, 'oid' => $message['oid']]); + DBA::update('term', $fields, ['otype' => Term::OBJECT_TYPE_POST, 'oid' => $message['oid']]); } DBA::close($messages);