Searching for tags has been enabled in all places. The tag detection has been improved for imports with missing line feeds.
This commit is contained in:
parent
b9afb38f4d
commit
5501dd0759
6 changed files with 112 additions and 51 deletions
|
@ -523,7 +523,26 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
|
|||
$tags=array();
|
||||
$hashtags = array();
|
||||
$mentions = array();
|
||||
foreach(explode(',',$item['tag']) as $tag){
|
||||
|
||||
$taglist = q("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d)",
|
||||
intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION));
|
||||
|
||||
foreach($taglist as $tag) {
|
||||
|
||||
if ($tag["url"] == "")
|
||||
$tag["url"] = $searchpath.strtolower($tag["term"]);
|
||||
|
||||
if ($tag["type"] == TERM_HASHTAG) {
|
||||
$hashtags[] = "#<a href=\"".$tag["url"]."\" target=\"external-link\">".$tag["term"]."</a>";
|
||||
$prefix = "#";
|
||||
} elseif ($tag["type"] == TERM_MENTION) {
|
||||
$mentions[] = "@<a href=\"".$tag["url"]."\" target=\"external-link\">".$tag["term"]."</a>";
|
||||
$prefix = "@";
|
||||
}
|
||||
$tags[] = $prefix."<a href=\"".$tag["url"]."\" target=\"external-link\">".$tag["term"]."</a>";
|
||||
}
|
||||
|
||||
/*foreach(explode(',',$item['tag']) as $tag){
|
||||
$tag = trim($tag);
|
||||
if ($tag!="") {
|
||||
$t = bbcode($tag);
|
||||
|
@ -533,7 +552,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
|
|||
elseif($t[0] == '@')
|
||||
$mentions[] = $t;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
$sp = false;
|
||||
$profile_link = best_link_url($item,$sp);
|
||||
|
|
|
@ -89,7 +89,7 @@ class dba {
|
|||
if(x($a->config,'system') && x($a->config['system'],'db_log')) {
|
||||
$stamp2 = microtime(true);
|
||||
$duration = round($stamp2-$stamp1, 3);
|
||||
if ($duration > $a->config["system"]["db_loglimit"]) {
|
||||
if (($duration > $a->config["system"]["db_loglimit"])) {
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
@file_put_contents($a->config["system"]["db_log"], $duration."\t".
|
||||
basename($backtrace[1]["file"])."\t".
|
||||
|
|
|
@ -918,7 +918,7 @@ function fix_contact_ssl_policy(&$contact,$new_policy) {
|
|||
* Return: The parsed XML in an array form. Use print_r() to see the resulting array structure.
|
||||
* Examples: $array = xml2array(file_get_contents('feed.xml'));
|
||||
* $array = xml2array(file_get_contents('feed.xml', true, 1, 'attribute'));
|
||||
*/
|
||||
*/
|
||||
|
||||
function xml2array($contents, $namespaces = true, $get_attributes=1, $priority = 'attribute') {
|
||||
if(!$contents) return array();
|
||||
|
@ -976,7 +976,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
|
|||
|
||||
$result = array();
|
||||
$attributes_data = array();
|
||||
|
||||
|
||||
if(isset($value)) {
|
||||
if($priority == 'tag') $result = $value;
|
||||
else $result['value'] = $value; // Put the value in a assoc array if we are in the 'Attribute' mode
|
||||
|
@ -992,7 +992,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
|
|||
|
||||
// See tag status and do the needed.
|
||||
if($namespaces && strpos($tag,':')) {
|
||||
$namespc = substr($tag,0,strrpos($tag,':'));
|
||||
$namespc = substr($tag,0,strrpos($tag,':'));
|
||||
$tag = strtolower(substr($tag,strlen($namespc)+1));
|
||||
$result['@namespace'] = $namespc;
|
||||
}
|
||||
|
@ -1015,7 +1015,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
|
|||
} else { // This section will make the value an array if multiple tags with the same name appear together
|
||||
$current[$tag] = array($current[$tag],$result); // This will combine the existing item and the new item together to make an array
|
||||
$repeated_tag_index[$tag.'_'.$level] = 2;
|
||||
|
||||
|
||||
if(isset($current[$tag.'_attr'])) { // The attribute of the last(0th) tag must be moved as well
|
||||
$current[$tag]['0_attr'] = $current[$tag.'_attr'];
|
||||
unset($current[$tag.'_attr']);
|
||||
|
@ -1038,7 +1038,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
|
|||
|
||||
// ...push the new element into that array.
|
||||
$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
|
||||
|
||||
|
||||
if($priority == 'tag' and $get_attributes and $attributes_data) {
|
||||
$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
|
||||
}
|
||||
|
@ -1049,11 +1049,11 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
|
|||
$repeated_tag_index[$tag.'_'.$level] = 1;
|
||||
if($priority == 'tag' and $get_attributes) {
|
||||
if(isset($current[$tag.'_attr'])) { // The attribute of the last(0th) tag must be moved as well
|
||||
|
||||
|
||||
$current[$tag]['0_attr'] = $current[$tag.'_attr'];
|
||||
unset($current[$tag.'_attr']);
|
||||
}
|
||||
|
||||
|
||||
if($attributes_data) {
|
||||
$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
|
||||
}
|
||||
|
@ -1066,6 +1066,6 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
|
|||
$current = &$parent[$level-1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return($xml_array);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -562,11 +562,12 @@ function get_tags($s) {
|
|||
$ret = array();
|
||||
|
||||
// ignore anything in a code block
|
||||
|
||||
$s = preg_replace('/\[code\](.*?)\[\/code\]/sm','',$s);
|
||||
|
||||
// ignore anything in a bbtag
|
||||
// Force line feeds at bbtags
|
||||
$s = str_replace(array("[", "]"), array("\n[", "]\n"), $s);
|
||||
|
||||
// ignore anything in a bbtag
|
||||
$s = preg_replace('/\[(.*?)\]/sm','',$s);
|
||||
|
||||
// Match full names against @tags including the space between first and last
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue