Preparations for a new tag structure. Tags are now stored in a dedicated table.
This commit is contained in:
parent
82820d8e95
commit
61c78711df
2
boot.php
2
boot.php
|
@ -14,7 +14,7 @@ require_once('include/features.php');
|
||||||
define ( 'FRIENDICA_PLATFORM', 'Friendica');
|
define ( 'FRIENDICA_PLATFORM', 'Friendica');
|
||||||
define ( 'FRIENDICA_VERSION', '3.1.1572' );
|
define ( 'FRIENDICA_VERSION', '3.1.1572' );
|
||||||
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
|
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
|
||||||
define ( 'DB_UPDATE_VERSION', 1157 );
|
define ( 'DB_UPDATE_VERSION', 1158 );
|
||||||
|
|
||||||
define ( 'EOL', "<br />\r\n" );
|
define ( 'EOL', "<br />\r\n" );
|
||||||
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
||||||
|
|
14
database.sql
14
database.sql
|
@ -1118,3 +1118,17 @@ CREATE TABLE IF NOT EXISTS `userd` (
|
||||||
`username` char(255) NOT NULL,
|
`username` char(255) NOT NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `tag`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `tag` (
|
||||||
|
`iid` int(11) NOT NULL,
|
||||||
|
`tag` char(255) NOT NULL,
|
||||||
|
`link` char(255) NOT NULL,
|
||||||
|
PRIMARY KEY (`iid`, `tag`),
|
||||||
|
KEY `tag` (`tag`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
|
@ -5,7 +5,7 @@ require_once('include/oembed.php');
|
||||||
require_once('include/salmon.php');
|
require_once('include/salmon.php');
|
||||||
require_once('include/crypto.php');
|
require_once('include/crypto.php');
|
||||||
require_once('include/Photo.php');
|
require_once('include/Photo.php');
|
||||||
|
require_once('include/tags.php');
|
||||||
|
|
||||||
function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) {
|
function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) {
|
||||||
|
|
||||||
|
@ -1072,6 +1072,7 @@ function item_store($arr,$force_parent = false) {
|
||||||
|
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
$current_post = $r[0]['id'];
|
$current_post = $r[0]['id'];
|
||||||
|
create_tags_from_item($r[0]['id']);
|
||||||
logger('item_store: created item ' . $current_post);
|
logger('item_store: created item ' . $current_post);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1108,6 +1109,7 @@ function item_store($arr,$force_parent = false) {
|
||||||
intval($parent_deleted),
|
intval($parent_deleted),
|
||||||
intval($current_post)
|
intval($current_post)
|
||||||
);
|
);
|
||||||
|
create_tags_from_item($current_post);
|
||||||
|
|
||||||
$arr['id'] = $current_post;
|
$arr['id'] = $current_post;
|
||||||
$arr['parent'] = $parent_id;
|
$arr['parent'] = $parent_id;
|
||||||
|
@ -1825,6 +1827,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
||||||
dbesc(implode(',',$newtags)),
|
dbesc(implode(',',$newtags)),
|
||||||
intval($i[0]['id'])
|
intval($i[0]['id'])
|
||||||
);
|
);
|
||||||
|
create_tags_from_item($i[0]['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1839,6 +1842,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
||||||
dbesc($item['uri']),
|
dbesc($item['uri']),
|
||||||
intval($importer['uid'])
|
intval($importer['uid'])
|
||||||
);
|
);
|
||||||
|
create_tags_from_itemuri($item['uri'], $importer['uid']);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
|
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
|
||||||
|
@ -1849,6 +1853,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
||||||
dbesc($uri),
|
dbesc($uri),
|
||||||
intval($importer['uid'])
|
intval($importer['uid'])
|
||||||
);
|
);
|
||||||
|
create_tags_from_itemuri($uri, $importer['uid']);
|
||||||
if($item['last-child']) {
|
if($item['last-child']) {
|
||||||
// ensure that last-child is set in case the comment that had it just got wiped.
|
// ensure that last-child is set in case the comment that had it just got wiped.
|
||||||
q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
|
q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
|
||||||
|
@ -1962,6 +1967,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
||||||
dbesc($item_id),
|
dbesc($item_id),
|
||||||
intval($importer['uid'])
|
intval($importer['uid'])
|
||||||
);
|
);
|
||||||
|
create_tags_from_itemuri($item_id, $importer['uid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update last-child if it changes
|
// update last-child if it changes
|
||||||
|
@ -2026,6 +2032,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
||||||
dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . $newtag),
|
dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . $newtag),
|
||||||
intval($r[0]['id'])
|
intval($r[0]['id'])
|
||||||
);
|
);
|
||||||
|
create_tags_from_item($r[0]['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2109,6 +2116,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
||||||
dbesc($item_id),
|
dbesc($item_id),
|
||||||
intval($importer['uid'])
|
intval($importer['uid'])
|
||||||
);
|
);
|
||||||
|
create_tags_from_itemuri($item_id, $importer['uid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update last-child if it changes
|
// update last-child if it changes
|
||||||
|
@ -2711,6 +2719,7 @@ function local_delivery($importer,$data) {
|
||||||
dbesc(implode(',',$newtags)),
|
dbesc(implode(',',$newtags)),
|
||||||
intval($i[0]['id'])
|
intval($i[0]['id'])
|
||||||
);
|
);
|
||||||
|
create_tags_from_item($i[0]['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2725,6 +2734,7 @@ function local_delivery($importer,$data) {
|
||||||
dbesc($item['uri']),
|
dbesc($item['uri']),
|
||||||
intval($importer['importer_uid'])
|
intval($importer['importer_uid'])
|
||||||
);
|
);
|
||||||
|
create_tags_from_itemuri($item['uri'], $importer['importer_uid']);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
|
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
|
||||||
|
@ -2735,6 +2745,7 @@ function local_delivery($importer,$data) {
|
||||||
dbesc($uri),
|
dbesc($uri),
|
||||||
intval($importer['importer_uid'])
|
intval($importer['importer_uid'])
|
||||||
);
|
);
|
||||||
|
create_tags_from_itemuri($uri, $importer['importer_uid']);
|
||||||
if($item['last-child']) {
|
if($item['last-child']) {
|
||||||
// ensure that last-child is set in case the comment that had it just got wiped.
|
// ensure that last-child is set in case the comment that had it just got wiped.
|
||||||
q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
|
q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
|
||||||
|
@ -2860,6 +2871,7 @@ function local_delivery($importer,$data) {
|
||||||
dbesc($item_id),
|
dbesc($item_id),
|
||||||
intval($importer['importer_uid'])
|
intval($importer['importer_uid'])
|
||||||
);
|
);
|
||||||
|
create_tags_from_itemuri($item_id, $importer['importer_uid']);
|
||||||
|
|
||||||
proc_run('php',"include/notifier.php","comment-import",$iid);
|
proc_run('php',"include/notifier.php","comment-import",$iid);
|
||||||
|
|
||||||
|
@ -2932,6 +2944,7 @@ function local_delivery($importer,$data) {
|
||||||
intval($tagp[0]['id']),
|
intval($tagp[0]['id']),
|
||||||
dbesc(datetime_convert())
|
dbesc(datetime_convert())
|
||||||
);
|
);
|
||||||
|
create_tags_from_item($tagp[0]['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3032,6 +3045,7 @@ function local_delivery($importer,$data) {
|
||||||
dbesc($item_id),
|
dbesc($item_id),
|
||||||
intval($importer['importer_uid'])
|
intval($importer['importer_uid'])
|
||||||
);
|
);
|
||||||
|
create_tags_from_itemuri($item_id, $importer['importer_uid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update last-child if it changes
|
// update last-child if it changes
|
||||||
|
@ -3092,6 +3106,7 @@ function local_delivery($importer,$data) {
|
||||||
dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $xo->id . ']'. $xo->content . '[/url]'),
|
dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $xo->id . ']'. $xo->content . '[/url]'),
|
||||||
intval($r[0]['id'])
|
intval($r[0]['id'])
|
||||||
);
|
);
|
||||||
|
create_tags_from_item($r[0]['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3206,6 +3221,7 @@ function local_delivery($importer,$data) {
|
||||||
dbesc($item_id),
|
dbesc($item_id),
|
||||||
intval($importer['importer_uid'])
|
intval($importer['importer_uid'])
|
||||||
);
|
);
|
||||||
|
create_tags_from_itemuri($item_id, $importer['importer_uid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update last-child if it changes
|
// update last-child if it changes
|
||||||
|
@ -3897,6 +3913,7 @@ function drop_item($id,$interactive = true) {
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
intval($item['id'])
|
intval($item['id'])
|
||||||
);
|
);
|
||||||
|
create_tags_from_item($item['id']);
|
||||||
|
|
||||||
// clean up categories and tags so they don't end up as orphans
|
// clean up categories and tags so they don't end up as orphans
|
||||||
|
|
||||||
|
@ -3962,6 +3979,7 @@ function drop_item($id,$interactive = true) {
|
||||||
dbesc($item['parent-uri']),
|
dbesc($item['parent-uri']),
|
||||||
intval($item['uid'])
|
intval($item['uid'])
|
||||||
);
|
);
|
||||||
|
create_tags_from_item($item['parent-uri'], $item['uid']);
|
||||||
// ignore the result
|
// ignore the result
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
require_once("boot.php");
|
||||||
|
if(@is_null($a)) {
|
||||||
|
$a = new App;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(is_null($db)) {
|
||||||
|
@include(".htconfig.php");
|
||||||
|
require_once("dba.php");
|
||||||
|
$db = new dba($db_host, $db_user, $db_pass, $db_data);
|
||||||
|
unset($db_host, $db_user, $db_pass, $db_data);
|
||||||
|
};
|
||||||
|
|
||||||
|
$a->set_baseurl(get_config('system','url'));
|
||||||
|
*/
|
||||||
|
|
||||||
|
function create_tags_from_item($itemid) {
|
||||||
|
global $a;
|
||||||
|
|
||||||
|
$searchpath = $a->get_baseurl()."/search?tag=";
|
||||||
|
|
||||||
|
$messages = q("SELECT `uri`, `uid`, `id`, `deleted`, `title`, `body`, `tag` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
|
||||||
|
|
||||||
|
if (!$messages)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$message = $messages[0];
|
||||||
|
|
||||||
|
// Clean up all tags
|
||||||
|
q("DELETE FROM `tag` WHERE `iid` = %d", intval($itemid));
|
||||||
|
|
||||||
|
if ($message["deleted"])
|
||||||
|
return;
|
||||||
|
|
||||||
|
$taglist = explode(",", $message["tag"]);
|
||||||
|
|
||||||
|
$tags = "";
|
||||||
|
foreach ($taglist as $tag)
|
||||||
|
if ((substr(trim($tag), 0, 1) == "#") OR (substr(trim($tag), 0, 1) == "@"))
|
||||||
|
$tags .= " ".trim($tag);
|
||||||
|
else
|
||||||
|
$tags .= " #".trim($tag);
|
||||||
|
|
||||||
|
$data = " ".$message["title"]." ".$message["body"]." ".$tags." ";
|
||||||
|
|
||||||
|
$tags = array();
|
||||||
|
|
||||||
|
$pattern = "/\W\#([^\[].*?)[\s'\".,:;\?!\[\]\/]/ism";
|
||||||
|
if (preg_match_all($pattern, $data, $matches))
|
||||||
|
foreach ($matches[1] as $match)
|
||||||
|
$tags["#".strtolower($match)] = $searchpath.strtolower($match);
|
||||||
|
|
||||||
|
$pattern = "/\W([\#@])\[url\=(.*?)\](.*?)\[\/url\]/ism";
|
||||||
|
if (preg_match_all($pattern, $data, $matches, PREG_SET_ORDER)) {
|
||||||
|
foreach ($matches as $match)
|
||||||
|
$tags[$match[1].strtolower(trim($match[3], ',.:;[]/\"?!'))] = $match[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($tags as $tag=>$link)
|
||||||
|
$r = q("INSERT INTO `tag` (`iid`, `tag`, `link`) VALUES (%d, '%s', '%s')",
|
||||||
|
intval($itemid), dbesc($tag), dbesc($link));
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_tags_from_itemuri($itemuri, $uid) {
|
||||||
|
$messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
|
||||||
|
|
||||||
|
foreach ($messages as $message)
|
||||||
|
create_tags_from_item($message["id"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_items() {
|
||||||
|
$messages = q("SELECT `id` FROM `item` where tag !='' ORDER BY `created` DESC LIMIT 100");
|
||||||
|
|
||||||
|
foreach ($messages as $message)
|
||||||
|
create_tags_from_item($message["id"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//update_items();
|
||||||
|
//create_tags_from_item(265194);
|
||||||
|
//create_tags_from_itemuri("infoagent@diasp.org:cce94abd104c06e8", 2);
|
||||||
|
?>
|
|
@ -148,7 +148,18 @@ class Item extends BaseObject {
|
||||||
$tags=array();
|
$tags=array();
|
||||||
$hashtags = array();
|
$hashtags = array();
|
||||||
$mentions = array();
|
$mentions = array();
|
||||||
foreach(explode(',',$item['tag']) as $tag){
|
|
||||||
|
$taglist = q("select tag,link from tag where iid=%d", intval($item['id']));
|
||||||
|
|
||||||
|
foreach($taglist as $tag) {
|
||||||
|
$tags[] = substr($tag["tag"], 0, 1)."<a href=\"".$tag["link"]."\" target=\"external-link\">".substr($tag["tag"], 1)."</a>";
|
||||||
|
if (substr($tag["tag"], 0, 1) == "#")
|
||||||
|
$hashtags[] = "#<a href=\"".$tag["link"]."\" target=\"external-link\">".substr($tag["tag"], 1)."</a>";
|
||||||
|
elseif (substr($tag["tag"], 0, 1) == "@")
|
||||||
|
$mentions[] = "@<a href=\"".$tag["link"]."\" target=\"external-link\">".substr($tag["tag"], 1)."</a>";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*foreach(explode(',',$item['tag']) as $tag){
|
||||||
$tag = trim($tag);
|
$tag = trim($tag);
|
||||||
if ($tag!="") {
|
if ($tag!="") {
|
||||||
$t = bbcode($tag);
|
$t = bbcode($tag);
|
||||||
|
@ -158,8 +169,7 @@ class Item extends BaseObject {
|
||||||
elseif($t[0] == '@')
|
elseif($t[0] == '@')
|
||||||
$mentions[] = $t;
|
$mentions[] = $t;
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
}
|
|
||||||
|
|
||||||
$like = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : '');
|
$like = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : '');
|
||||||
$dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : '');
|
$dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : '');
|
||||||
|
|
15
update.php
15
update.php
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
define( 'UPDATE_VERSION' , 1157 );
|
define( 'UPDATE_VERSION' , 1158 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -1369,3 +1369,16 @@ ADD INDEX ( `datasize` ) ");
|
||||||
if(!$r) return UPDATE_FAILED;
|
if(!$r) return UPDATE_FAILED;
|
||||||
return UPDATE_SUCCESS;
|
return UPDATE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update_1157() {
|
||||||
|
$r = q("CREATE TABLE IF NOT EXISTS `tag` (
|
||||||
|
`iid` int(11) NOT NULL,
|
||||||
|
`tag` char(255) NOT NULL,
|
||||||
|
`link` char(255) NOT NULL,
|
||||||
|
PRIMARY KEY (`iid`, `tag`),
|
||||||
|
KEY `tag` (`tag`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
|
||||||
|
|
||||||
|
if(!$r) return UPDATE_FAILED;
|
||||||
|
return UPDATE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<div class="profile-edit-side-div"><a class="profile-edit-side-link icon edit" title="$editprofile" href="profiles/$profid" ></a></div>
|
<!-- <div class="profile-edit-side-div"><a class="profile-edit-side-link icon edit" title="$editprofile" href="profiles/$profid" ></a></div> -->
|
||||||
{{ endif }}
|
{{ endif }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1305,16 +1305,16 @@ border-bottom: 1px solid #D2D2D2;
|
||||||
.wall-item-tags {
|
.wall-item-tags {
|
||||||
padding-top: 1px;
|
padding-top: 1px;
|
||||||
padding-bottom: 2px;
|
padding-bottom: 2px;
|
||||||
display: none;
|
/*display: none;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag {
|
.tag {
|
||||||
color: rgb(153,153,153);
|
color: rgb(153,153,153);
|
||||||
padding-left: 3px;
|
/*padding-left: 3px;
|
||||||
font-size: 10px;
|
font-size: 10px;*/
|
||||||
}
|
}
|
||||||
.tag a {
|
.tag a {
|
||||||
padding-right: 8px;
|
/*padding-right: 8px;*/
|
||||||
color: rgb(153,153,153);
|
color: rgb(153,153,153);
|
||||||
}
|
}
|
||||||
.wwto {
|
.wwto {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user