create fetch_tags function, make search work again, change logo

This commit is contained in:
friendica 2012-07-10 19:28:02 -07:00
parent 94fabe3a29
commit e7957e1448
12 changed files with 61 additions and 49 deletions

View File

@ -10,7 +10,7 @@ require_once('include/nav.php');
require_once('include/cache.php'); require_once('include/cache.php');
define ( 'FRIENDICA_PLATFORM', 'Red'); define ( 'FRIENDICA_PLATFORM', 'Red');
define ( 'FRIENDICA_VERSION', '0.0.0001' ); define ( 'FRIENDICA_VERSION', trim(file_get_contents('version.inc')));
define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1153 ); define ( 'DB_UPDATE_VERSION', 1153 );

View File

@ -1102,26 +1102,13 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
} }
function conv_sort($arr,$tags,$order) { function conv_sort($arr,$order) {
if((!(is_array($arr) && count($arr)))) if((!(is_array($arr) && count($arr))))
return array(); return array();
$parents = array(); $parents = array();
for($x = 0; $x < count($arr); $x ++) {
if(count($tags)) {
foreach($tags as $t) {
if($t['oid'] == $arr[$x]['item_id']) {
if(! is_array($arr[$x]['term']))
$arr[$x]['term'] = array();
$arr[$x]['term'][] = $t;
}
}
}
}
foreach($arr as $x) foreach($arr as $x)
if($x['id'] == $x['parent']) if($x['id'] == $x['parent'])
$parents[] = $x; $parents[] = $x;

View File

@ -3697,3 +3697,32 @@ function store_diaspora_retract_sig($item, $user, $baseurl) {
return; return;
} }
function fetch_post_tags($items) {
$tag_finder = array();
if(count($items))
foreach($items as $item)
if(! in_array($item['item_id'],$tag_finder))
$tag_finder[] = $item['item_id'];
$tag_finder_str = implode(', ', $tag_finder);
$tags = q("select * from term where oid in ( %s ) and otype = %d",
dbesc($tag_finder_str),
intval(TERM_OBJ_POST)
);
for($x = 0; $x < count($items); $x ++) {
if(count($tags)) {
foreach($tags as $t) {
if($t['oid'] == $items[$x]['item_id']) {
if(! is_array($items[$x]['term']))
$items[$x]['term'] = array();
$items[$x]['term'][] = $t;
}
}
}
}
return $items;
}

View File

@ -156,7 +156,7 @@ function nav(&$a) {
$banner = get_config('system','banner'); $banner = get_config('system','banner');
if($banner === false) if($banner === false)
$banner .= '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">red</a></span>'; $banner .= '<a href="http://friendica.com"><img id="logo-img" src="images/fred-32.png" alt="logo" /></a>';
$tpl = get_markup_template('nav.tpl'); $tpl = get_markup_template('nav.tpl');

View File

@ -932,8 +932,8 @@ function prepare_body($item,$attach = false) {
foreach($terms as $t) { foreach($terms as $t) {
if(strlen($x)) if(strlen($x))
$x .= ','; $x .= ',';
$x .= $t['term'] $x .= htmlspecialchars($t['term'],ENT_QUOTES,'UTF-8')
. ((local_user() == $item['uid']) ? ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&cat=' . $t['term'] . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>' : ''); . ((local_user() == $item['uid']) ? ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&cat=' . urlencode($t['term']) . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>' : '');
} }
if(strlen($x)) if(strlen($x))
$s .= '<div class="categorytags"><span>' . t('Categories:') . ' </span>' . $x . '</div>'; $s .= '<div class="categorytags"><span>' . t('Categories:') . ' </span>' . $x . '</div>';
@ -947,7 +947,8 @@ function prepare_body($item,$attach = false) {
foreach($terms as $t) { foreach($terms as $t) {
if(strlen($x)) if(strlen($x))
$x .= '&nbsp;&nbsp;&nbsp;'; $x .= '&nbsp;&nbsp;&nbsp;';
$x .= $t['term'] . ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&term=' . $t['term'] . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>'; $x .= htmlspecialchars($t['term'],ENT_QUOTES,'UTF-8')
. ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&term=' . urlencode($t['term']) . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>';
} }
if(strlen($x) && (local_user() == $item['uid'])) if(strlen($x) && (local_user() == $item['uid']))
$s .= '<div class="filesavetags"><span>' . t('Filed under:') . ' </span>' . $x . '</div>'; $s .= '<div class="filesavetags"><span>' . t('Filed under:') . ' </span>' . $x . '</div>';
@ -1499,8 +1500,8 @@ function format_term_for_display($term) {
elseif($term['type'] == TERM_MENTION) elseif($term['type'] == TERM_MENTION)
$s .= '@'; $s .= '@';
if($term['url']) $s .= '<a target="extlink" href="' . $term['url'] . '">' . $term['term'] . '</a>'; if($term['url']) $s .= '<a target="extlink" href="' . $term['url'] . '">' . htmlspecialchars($term['term']) . '</a>';
else $s .= $term['term']; else $s .= htmlspecialchars($term['term']);
return $s; return $s;
} }

View File

@ -290,7 +290,8 @@ function content_content(&$a, $update = 0) {
intval(TERM_OBJ_POST) intval(TERM_OBJ_POST)
); );
$items = conv_sort($items,$tags,$ordering); $items = fetch_post_tags($items);
$items = conv_sort($items,$ordering);
} else { } else {
$items = array(); $items = array();

View File

@ -664,19 +664,9 @@ function network_content(&$a, $update = 0) {
dbesc($parents_str) dbesc($parents_str)
); );
$tag_finder = array(); $items = fetch_post_tags($items);
if(count($items))
foreach($items as $item)
if(! in_array($item['item_id'],$tag_finder))
$tag_finder[] = $item['item_id'];
$tag_finder_str = implode(', ', $tag_finder);
$tags = q("select * from term where oid in ( %s ) and otype = %d", $items = conv_sort($items,$ordering);
dbesc($tag_finder_str),
intval(TERM_OBJ_POST)
);
$items = conv_sort($items,$tags,$ordering);
} else { } else {

View File

@ -291,7 +291,8 @@ function profile_content(&$a, $update = 0) {
intval(TERM_OBJ_POST) intval(TERM_OBJ_POST)
); );
$items = conv_sort($items,$tags,'created'); $items = fetch_post_tags($items);
$items = conv_sort($items,'created');
} else { } else {
$items = array(); $items = array();

View File

@ -108,21 +108,20 @@ function search_content(&$a) {
if(! $search) if(! $search)
return $o; return $o;
if (get_config('system','use_fulltext_engine')) { if($tag) {
if($tag) $sql_extra = sprintf(" AND `item`.`id` IN (select `oid` from term where otype = %d and type = %d and term = '%s') ",
$sql_extra = sprintf(" AND MATCH (`item`.`tag`) AGAINST ('".'"%s"'."' in boolean mode) ", '#'.dbesc(protect_sprintf($search))); intval(TERM_OBJ_POST),
else intval(TERM_HASHTAG),
dbesc(protect_sprintf($search))
);
}
else {
if (get_config('system','use_fulltext_engine'))
$sql_extra = sprintf(" AND MATCH (`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) ", dbesc(protect_sprintf($search))); $sql_extra = sprintf(" AND MATCH (`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) ", dbesc(protect_sprintf($search)));
} else {
if($tag)
$sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . protect_sprintf(preg_quote($search)) . '\\['));
else else
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
} }
// Here is the way permissions work in the search module... // Here is the way permissions work in the search module...
// Only public posts can be shown // Only public posts can be shown
// OR your own posts if you are a logged in member // OR your own posts if you are a logged in member
@ -165,6 +164,9 @@ function search_content(&$a) {
); );
if($tag) if($tag)
$o .= '<h2>Items tagged with: ' . $search . '</h2>'; $o .= '<h2>Items tagged with: ' . $search . '</h2>';
else else

1
version.inc Normal file
View File

@ -0,0 +1 @@
2012-07-10.11

View File

@ -1054,7 +1054,7 @@ section {
.wall-item-comment-wrapper textarea { .wall-item-comment-wrapper textarea {
height: 1em; height: 1em;
width: 100%; width: 100%;
font-size: 10px; font-size: 12px;
color: #999999; color: #999999;
border: 1px solid #999999; border: 1px solid #999999;
padding: 0.3em; padding: 0.3em;
@ -1217,7 +1217,7 @@ section {
#jot .profile-jot-text { #jot .profile-jot-text {
height: 1em; height: 1em;
width: 99%; width: 99%;
font-size: 10px; font-size: 12px;
color: #999999; color: #999999;
border: 1px solid #999999; border: 1px solid #999999;
padding: 0.3em; padding: 0.3em;

View File

@ -521,7 +521,7 @@ section {
margin: 1em 2em 1em 60px; margin: 1em 2em 1em 60px;
.comment-edit-photo { display: none; } .comment-edit-photo { display: none; }
textarea { textarea {
height: 1em; width: 100%; font-size: 10px; height: 1em; width: 100%; font-size: 12px;
color: @CommentBoxEmptyColor; color: @CommentBoxEmptyColor;
border: 1px solid @CommentBoxEmptyBorderColor; border: 1px solid @CommentBoxEmptyBorderColor;
padding:0.3em; padding:0.3em;
@ -656,7 +656,7 @@ section {
.profile-jot-text { .profile-jot-text {
height: 1em; width: 99%; font-size: 10px; height: 1em; width: 99%; font-size: 12px;
color: @CommentBoxEmptyColor; color: @CommentBoxEmptyColor;
border: 1px solid @CommentBoxEmptyBorderColor; border: 1px solid @CommentBoxEmptyBorderColor;
padding:0.3em; padding:0.3em;