From e7957e14489ce8eb3b69ebede928dfe441a4924d Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Jul 2012 19:28:02 -0700 Subject: create fetch_tags function, make search work again, change logo --- boot.php | 2 +- include/conversation.php | 15 +-------------- include/items.php | 29 +++++++++++++++++++++++++++++ include/nav.php | 2 +- include/text.php | 11 ++++++----- mod/content.php | 3 ++- mod/network.php | 14 ++------------ mod/profile.php | 3 ++- mod/search.php | 22 ++++++++++++---------- version.inc | 1 + view/theme/quattro/dark/style.css | 4 ++-- view/theme/quattro/quattro.less | 4 ++-- 12 files changed, 61 insertions(+), 49 deletions(-) create mode 100644 version.inc diff --git a/boot.php b/boot.php index 4139abdfd..e50941f8b 100644 --- a/boot.php +++ b/boot.php @@ -10,7 +10,7 @@ require_once('include/nav.php'); require_once('include/cache.php'); 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 ( 'DB_UPDATE_VERSION', 1153 ); diff --git a/include/conversation.php b/include/conversation.php index f81a7e7d2..ce8f5779c 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -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)))) return 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) if($x['id'] == $x['parent']) $parents[] = $x; diff --git a/include/items.php b/include/items.php index 1f90a1d05..d48a04da5 100755 --- a/include/items.php +++ b/include/items.php @@ -3697,3 +3697,32 @@ function store_diaspora_retract_sig($item, $user, $baseurl) { 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; +} diff --git a/include/nav.php b/include/nav.php index a52e4afa3..318512373 100644 --- a/include/nav.php +++ b/include/nav.php @@ -156,7 +156,7 @@ function nav(&$a) { $banner = get_config('system','banner'); if($banner === false) - $banner .= 'logored'; + $banner .= 'logo'; $tpl = get_markup_template('nav.tpl'); diff --git a/include/text.php b/include/text.php index 59ef5a88f..aa377dd68 100644 --- a/include/text.php +++ b/include/text.php @@ -932,8 +932,8 @@ function prepare_body($item,$attach = false) { foreach($terms as $t) { if(strlen($x)) $x .= ','; - $x .= $t['term'] - . ((local_user() == $item['uid']) ? ' ' . t('[remove]') . '' : ''); + $x .= htmlspecialchars($t['term'],ENT_QUOTES,'UTF-8') + . ((local_user() == $item['uid']) ? ' ' . t('[remove]') . '' : ''); } if(strlen($x)) $s .= '
' . t('Categories:') . ' ' . $x . '
'; @@ -947,7 +947,8 @@ function prepare_body($item,$attach = false) { foreach($terms as $t) { if(strlen($x)) $x .= '   '; - $x .= $t['term'] . ' ' . t('[remove]') . ''; + $x .= htmlspecialchars($t['term'],ENT_QUOTES,'UTF-8') + . ' ' . t('[remove]') . ''; } if(strlen($x) && (local_user() == $item['uid'])) $s .= '
' . t('Filed under:') . ' ' . $x . '
'; @@ -1499,8 +1500,8 @@ function format_term_for_display($term) { elseif($term['type'] == TERM_MENTION) $s .= '@'; - if($term['url']) $s .= '' . $term['term'] . ''; - else $s .= $term['term']; + if($term['url']) $s .= '' . htmlspecialchars($term['term']) . ''; + else $s .= htmlspecialchars($term['term']); return $s; } diff --git a/mod/content.php b/mod/content.php index 369f2fce2..7799ee6ad 100644 --- a/mod/content.php +++ b/mod/content.php @@ -290,7 +290,8 @@ function content_content(&$a, $update = 0) { intval(TERM_OBJ_POST) ); - $items = conv_sort($items,$tags,$ordering); + $items = fetch_post_tags($items); + $items = conv_sort($items,$ordering); } else { $items = array(); diff --git a/mod/network.php b/mod/network.php index a136e12d6..21a43f9cb 100644 --- a/mod/network.php +++ b/mod/network.php @@ -664,19 +664,9 @@ function network_content(&$a, $update = 0) { dbesc($parents_str) ); - $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) - ); + $items = fetch_post_tags($items); - $items = conv_sort($items,$tags,$ordering); + $items = conv_sort($items,$ordering); } else { diff --git a/mod/profile.php b/mod/profile.php index b48e035af..c9406c464 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -291,7 +291,8 @@ function profile_content(&$a, $update = 0) { intval(TERM_OBJ_POST) ); - $items = conv_sort($items,$tags,'created'); + $items = fetch_post_tags($items); + $items = conv_sort($items,'created'); } else { $items = array(); diff --git a/mod/search.php b/mod/search.php index 320ffddce..ec7e2ec3a 100644 --- a/mod/search.php +++ b/mod/search.php @@ -108,21 +108,20 @@ function search_content(&$a) { if(! $search) return $o; - if (get_config('system','use_fulltext_engine')) { - if($tag) - $sql_extra = sprintf(" AND MATCH (`item`.`tag`) AGAINST ('".'"%s"'."' in boolean mode) ", '#'.dbesc(protect_sprintf($search))); - else + if($tag) { + $sql_extra = sprintf(" AND `item`.`id` IN (select `oid` from term where otype = %d and type = %d and term = '%s') ", + intval(TERM_OBJ_POST), + 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))); - } else { - if($tag) - $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . protect_sprintf(preg_quote($search)) . '\\[')); else $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); } - - - // Here is the way permissions work in the search module... // Only public posts can be shown // OR your own posts if you are a logged in member @@ -165,6 +164,9 @@ function search_content(&$a) { ); + + + if($tag) $o .= '

Items tagged with: ' . $search . '

'; else diff --git a/version.inc b/version.inc new file mode 100644 index 000000000..9f77d5be5 --- /dev/null +++ b/version.inc @@ -0,0 +1 @@ +2012-07-10.11 diff --git a/view/theme/quattro/dark/style.css b/view/theme/quattro/dark/style.css index 35595c8bc..e1df39452 100644 --- a/view/theme/quattro/dark/style.css +++ b/view/theme/quattro/dark/style.css @@ -1054,7 +1054,7 @@ section { .wall-item-comment-wrapper textarea { height: 1em; width: 100%; - font-size: 10px; + font-size: 12px; color: #999999; border: 1px solid #999999; padding: 0.3em; @@ -1217,7 +1217,7 @@ section { #jot .profile-jot-text { height: 1em; width: 99%; - font-size: 10px; + font-size: 12px; color: #999999; border: 1px solid #999999; padding: 0.3em; diff --git a/view/theme/quattro/quattro.less b/view/theme/quattro/quattro.less index 0dac79bf9..8c123a963 100644 --- a/view/theme/quattro/quattro.less +++ b/view/theme/quattro/quattro.less @@ -521,7 +521,7 @@ section { margin: 1em 2em 1em 60px; .comment-edit-photo { display: none; } textarea { - height: 1em; width: 100%; font-size: 10px; + height: 1em; width: 100%; font-size: 12px; color: @CommentBoxEmptyColor; border: 1px solid @CommentBoxEmptyBorderColor; padding:0.3em; @@ -656,7 +656,7 @@ section { .profile-jot-text { - height: 1em; width: 99%; font-size: 10px; + height: 1em; width: 99%; font-size: 12px; color: @CommentBoxEmptyColor; border: 1px solid @CommentBoxEmptyBorderColor; padding:0.3em; -- cgit v1.2.3