transmit, receive, and parse bookmarks
This commit is contained in:
parent
c4d0884596
commit
876f5d4de0
@ -822,7 +822,7 @@ function encode_item_xchan($xchan) {
|
|||||||
function encode_item_terms($terms) {
|
function encode_item_terms($terms) {
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
|
||||||
$allowed_export_terms = array( TERM_UNKNOWN, TERM_HASHTAG, TERM_MENTION, TERM_CATEGORY );
|
$allowed_export_terms = array( TERM_UNKNOWN, TERM_HASHTAG, TERM_MENTION, TERM_CATEGORY, TERM_BOOKMARK );
|
||||||
|
|
||||||
if($terms) {
|
if($terms) {
|
||||||
foreach($terms as $term) {
|
foreach($terms as $term) {
|
||||||
@ -834,7 +834,7 @@ function encode_item_terms($terms) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function termtype($t) {
|
function termtype($t) {
|
||||||
$types = array('unknown','hashtag','mention','category','private_category','file','search');
|
$types = array('unknown','hashtag','mention','category','private_category','file','search','thing','bookmark');
|
||||||
return(($types[$t]) ? $types[$t] : 'unknown');
|
return(($types[$t]) ? $types[$t] : 'unknown');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -865,6 +865,12 @@ function decode_tags($t) {
|
|||||||
case 'search':
|
case 'search':
|
||||||
$tag['type'] = TERM_SEARCH;
|
$tag['type'] = TERM_SEARCH;
|
||||||
break;
|
break;
|
||||||
|
case 'thing':
|
||||||
|
$tag['type'] = TERM_THING;
|
||||||
|
break;
|
||||||
|
case 'bookmark':
|
||||||
|
$tag['type'] = TERM_BOOKMARK;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
case 'unknown':
|
case 'unknown':
|
||||||
$tag['type'] = TERM_UNKNOWN;
|
$tag['type'] = TERM_UNKNOWN;
|
||||||
|
@ -593,7 +593,7 @@ function get_tags($s) {
|
|||||||
if(substr($mtch,-1,1) === '.')
|
if(substr($mtch,-1,1) === '.')
|
||||||
$mtch = substr($mtch,0,-1);
|
$mtch = substr($mtch,0,-1);
|
||||||
// ignore strictly numeric tags like #1
|
// ignore strictly numeric tags like #1
|
||||||
if((strpos($mtch,'#') === 0) && ctype_digit(substr($mtch,1)))
|
if((strpos($mtch,'#') === 0) && ( ctype_digit(substr($mtch,1)) || substr($mtch,1,1) === '^'))
|
||||||
continue;
|
continue;
|
||||||
// try not to catch url fragments
|
// try not to catch url fragments
|
||||||
if(strpos($s,$mtch) && preg_match('/[a-zA-z0-9\/]/',substr($s,strpos($s,$mtch)-1,1)))
|
if(strpos($s,$mtch) && preg_match('/[a-zA-z0-9\/]/',substr($s,strpos($s,$mtch)-1,1)))
|
||||||
@ -601,6 +601,18 @@ function get_tags($s) {
|
|||||||
$ret[] = $mtch;
|
$ret[] = $mtch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bookmarks
|
||||||
|
|
||||||
|
if(preg_match_all('/#\^\[(url|zrl)=(.*?)\](.*?)\[\/(url|zrl)\]/',$s,$match,PREG_SET_ORDER)) {
|
||||||
|
foreach($match as $mtch) {
|
||||||
|
$ret[] = $mtch[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// logger('get_tags: ' . print_r($ret,true));
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
21
mod/item.php
21
mod/item.php
@ -887,13 +887,24 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
|
|||||||
$replaced = false;
|
$replaced = false;
|
||||||
$r = null;
|
$r = null;
|
||||||
|
|
||||||
$termtype = ((strpos($tag,'#') === 0) ? TERM_HASHTAG : TERM_UNKNOWN);
|
|
||||||
$termtype = ((strpos($tag,'@') === 0) ? TERM_MENTION : $termtype);
|
$termtype = ((strpos($tag,'#') === 0) ? TERM_HASHTAG : TERM_UNKNOWN);
|
||||||
|
$termtype = ((strpos($tag,'@') === 0) ? TERM_MENTION : $termtype);
|
||||||
|
$termtype = ((strpos($tag,'#^[') === 0) ? TERM_BOOKMARK : $termtype);
|
||||||
|
|
||||||
|
|
||||||
//is it a hash tag?
|
//is it a hash tag?
|
||||||
if(strpos($tag,'#') === 0) {
|
if(strpos($tag,'#') === 0) {
|
||||||
// if the tag is replaced...
|
if(strpos($tag,'#^[') === 0) {
|
||||||
if(strpos($tag,'[zrl=')) {
|
if(preg_match('/#\^\[(url|zrl)=(.*?)\](.*?)\[\/(url|zrl)\]/',$tag,$match)) {
|
||||||
|
$basetag = $match[3];
|
||||||
|
$url = $match[2];
|
||||||
|
$replaced = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if the tag is already replaced...
|
||||||
|
elseif(strpos($tag,'[zrl=')) {
|
||||||
//...do nothing
|
//...do nothing
|
||||||
return $replaced;
|
return $replaced;
|
||||||
}
|
}
|
||||||
@ -904,7 +915,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
|
|||||||
$body = str_replace($tag,$newtag,$body);
|
$body = str_replace($tag,$newtag,$body);
|
||||||
$replaced = true;
|
$replaced = true;
|
||||||
}
|
}
|
||||||
else {
|
if(! $replaced) {
|
||||||
//base tag has the tags name only
|
//base tag has the tags name only
|
||||||
$basetag = str_replace('_',' ',substr($tag,1));
|
$basetag = str_replace('_',' ',substr($tag,1));
|
||||||
//create text for link
|
//create text for link
|
||||||
|
@ -38,7 +38,7 @@ function page_content(&$a) {
|
|||||||
|
|
||||||
$channel_address = argv(1);
|
$channel_address = argv(1);
|
||||||
$page_id = argv(2);
|
$page_id = argv(2);
|
||||||
dbg(1);
|
|
||||||
$u = q("select channel_id from channel where channel_address = '%s' limit 1",
|
$u = q("select channel_id from channel where channel_address = '%s' limit 1",
|
||||||
dbesc($channel_address)
|
dbesc($channel_address)
|
||||||
);
|
);
|
||||||
@ -63,7 +63,7 @@ dbg(1);
|
|||||||
dbesc($page_id),
|
dbesc($page_id),
|
||||||
intval(ITEM_WEBPAGE)
|
intval(ITEM_WEBPAGE)
|
||||||
);
|
);
|
||||||
dbg(0);
|
|
||||||
if(! $r) {
|
if(! $r) {
|
||||||
|
|
||||||
// Check again with no permissions clause to see if it is a permissions issue
|
// Check again with no permissions clause to see if it is a permissions issue
|
||||||
|
Reference in New Issue
Block a user