aboutsummaryrefslogtreecommitdiffstats
path: root/include/taxonomy.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-04-23 19:49:41 -0700
committerfriendica <info@friendica.com>2015-04-23 19:49:41 -0700
commit6679734135fb04f4a7beccb81663bf1e9574f062 (patch)
tree887488543d98b5dd297d917718bdd99844e83ba5 /include/taxonomy.php
parent08b757a22cd2804bfec8ecf682b6987b8c06ca49 (diff)
parentc696860cc53bc25558d83de5eda65d9b583da382 (diff)
downloadvolse-hubzilla-6679734135fb04f4a7beccb81663bf1e9574f062.tar.gz
volse-hubzilla-6679734135fb04f4a7beccb81663bf1e9574f062.tar.bz2
volse-hubzilla-6679734135fb04f4a7beccb81663bf1e9574f062.zip
Merge branch 'master' into tres
Conflicts: include/Contact.php include/ItemObject.php include/api.php include/attach.php include/diaspora.php include/dir_fns.php include/enotify.php include/event.php include/expire.php include/items.php include/notifier.php include/notify.php include/photos.php include/taxonomy.php include/text.php include/widgets.php include/zot.php mod/admin.php mod/channel.php mod/dirsearch.php mod/display.php mod/editwebpage.php mod/events.php mod/home.php mod/item.php mod/manage.php mod/mood.php mod/network.php mod/page.php mod/photos.php mod/ping.php mod/post.php mod/thing.php mod/viewsrc.php view/css/mod_events.css
Diffstat (limited to 'include/taxonomy.php')
-rw-r--r--include/taxonomy.php135
1 files changed, 75 insertions, 60 deletions
diff --git a/include/taxonomy.php b/include/taxonomy.php
index 9be04e16c..ea41369ad 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -38,6 +38,7 @@ function term_query($table,$s,$type = TERM_UNKNOWN) {
function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') {
if(! $term)
return false;
+
$r = q("select * from term
where uid = %d and oid = %d and otype = %d and type = %d
and term = '%s' and url = '%s' ",
@@ -50,6 +51,7 @@ function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') {
);
if($r)
return false;
+
$r = q("insert into term (uid, oid, otype, type, term, url)
values( %d, %d, %d, %d, '%s', '%s') ",
intval($uid),
@@ -59,9 +61,11 @@ function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') {
dbesc($term),
dbesc($url)
);
+
return $r;
}
-
+
+
function get_terms_oftype($arr,$type) {
$ret = array();
if(! (is_array($arr) && count($arr)))
@@ -74,6 +78,7 @@ function get_terms_oftype($arr,$type) {
foreach($arr as $x)
if($x['type'] == $t)
$ret[] = $x;
+
return $ret;
}
@@ -98,7 +103,12 @@ function format_term_for_display($term) {
function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $type = TERM_HASHTAG) {
- $sql_options = '';
+ require_once('include/security.php');
+
+ if(! perm_is_allowed($uid,get_observer_hash(),'view_stream'))
+ return array();
+
+ $sql_options = item_permissions_sql($uid);
$count = intval($count);
if($flags) {
@@ -109,6 +119,7 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $
if($authors) {
if(! is_array($authors))
$authors = array($authors);
+
stringify_array_elms($authors,true);
$sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
}
@@ -128,8 +139,8 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $
if(! $r)
return array();
-
- // Find minimum and maximum log-count.
+
+ // Find minimum and maximum log-count.
$tags = array();
$min = 1e9;
$max = -1e9;
@@ -149,22 +160,23 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $
$range = max(.01, $max - $min) * 1.0001;
for($x = 0; $x < count($tags); $x ++) {
- $tags[$x][2] = 1 + floor(5 * ($tags[$x][1] - $min) / $range);
+ $tags[$x][2] = 1 + floor(9 * ($tags[$x][1] - $min) / $range);
}
return $tags;
}
+
function tags_sort($a,$b) {
- if(strtolower($a[0]) == strtolower($b[0]))
- return 0;
- return((strtolower($a[0]) < strtolower($b[0])) ? -1 : 1);
+ if(strtolower($a[0]) == strtolower($b[0]))
+ return 0;
+
+ return((strtolower($a[0]) < strtolower($b[0])) ? -1 : 1);
}
function dir_tagadelic($count = 0) {
- $sql_options = '';
$count = intval($count);
// Fetch tags
@@ -175,8 +187,8 @@ function dir_tagadelic($count = 0) {
if(! $r)
return array();
-
- // Find minimum and maximum log-count.
+
+ // Find minimum and maximum log-count.
$tags = array();
$min = 1e9;
$max = -1e9;
@@ -196,7 +208,7 @@ function dir_tagadelic($count = 0) {
$range = max(.01, $max - $min) * 1.0001;
for($x = 0; $x < count($tags); $x ++) {
- $tags[$x][2] = 1 + floor(5 * ($tags[$x][1] - $min) / $range);
+ $tags[$x][2] = 1 + floor(9 * ($tags[$x][1] - $min) / $range);
}
return $tags;
@@ -204,65 +216,71 @@ function dir_tagadelic($count = 0) {
function tagblock($link,$uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_HASHTAG) {
- $o = '';
- $tab = 0;
- $r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
-
- if($r) {
- $o = '<div class="tagblock widget"><h3>' . t('Tags') . '</h3><div class="tags" align="center">';
- foreach($r as $rr) {
- $o .= '<span class="tag'.$rr[2].'">#</span><a href="'.$link .'/' . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
+ $o = '';
+
+ $r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
+
+ if($r) {
+ $o = '<div class="tagblock widget"><h3>' . t('Tags') . '</h3><div class="tags" align="center">';
+ foreach($r as $rr) {
+ $o .= '<span class="tag'.$rr[2].'">#</span><a href="'.$link .'/' . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
+ }
+ $o .= '</div></div>';
}
- $o .= '</div></div>';
- }
+
return $o;
}
+
function wtagblock($uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_HASHTAG) {
- $o = '';
- $tab = 0;
- $r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
+ $o = '';
- if($r) {
- $c = q("select channel_address from channel where channel_id = %d limit 1",
- intval($uid)
- );
+ $r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
- $o = '<div class="tagblock widget"><h3>' . t('Tags') . '</h3><div class="tags" align="center">';
- foreach($r as $rr) {
- $o .= '<span class="tag' . $rr[2] . '">#</span><a href="channel/' . $c[0]['channel_address'] . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
+ if($r) {
+ $c = q("select channel_address from channel where channel_id = %d limit 1",
+ intval($uid)
+ );
+
+ $o = '<div class="tagblock widget"><h3>' . t('Tags') . '</h3><div class="tags" align="center">';
+ foreach($r as $rr) {
+ $o .= '<span class="tag' . $rr[2] . '">#</span><a href="channel/' . $c[0]['channel_address'] . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
+ }
+ $o .= '</div></div>';
}
- $o .= '</div></div>';
- }
+
return $o;
}
function catblock($uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_CATEGORY) {
- $o = '';
- $tab = 0;
-
- $r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
+ $o = '';
- if($r) {
- $c = q("select channel_address from channel where channel_id = %d limit 1",
- intval($uid)
- );
+ $r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
- $o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">';
- foreach($r as $rr) {
- $o .= '<a href="channel/' . $c[0]['channel_address']. '?f=&cat=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
+ if($r) {
+ $c = q("select channel_address from channel where channel_id = %d limit 1",
+ intval($uid)
+ );
+
+ $o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">';
+ foreach($r as $rr) {
+ $o .= '<a href="channel/' . $c[0]['channel_address']. '?f=&cat=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
+ }
+ $o .= '</div></div>';
}
- $o .= '</div></div>';
- }
+
return $o;
}
-
function dir_tagblock($link,$r) {
$o = '';
- $tab = 0;
+
+ $observer = get_observer_hash();
+ if(! get_globaldir_setting($observer))
+ return $o;
+
if(! $r)
$r = get_app()->data['directory_keywords'];
@@ -274,14 +292,12 @@ function dir_tagblock($link,$r) {
}
$o .= '</div></div>';
}
+
return $o;
}
-
-
-
/**
* verbs: [0] = first person singular, e.g. "I want", [1] = 3rd person singular, e.g. "Bill wants"
* We use the first person form when creating an activity, but the third person for use in activities
@@ -289,8 +305,6 @@ function dir_tagblock($link,$r) {
* require obj_verbs() to provide full conjugations and specify which form to use in the $_REQUEST params to this module.
*/
-
-
function obj_verbs() {
$verbs = array(
'has' => array( t('have'), t('has')),
@@ -301,26 +315,27 @@ function obj_verbs() {
$arr = array('verbs' => $verbs);
call_hooks('obj_verbs', $arr);
+
return $arr['verbs'];
}
function obj_verb_selector($current = '') {
$verbs = obj_verbs();
- $o .= '<select class="obj-verb-selector" name="verb" >';
+ $o = '<select class="obj-verb-selector" name="verb">';
foreach($verbs as $k => $v) {
$selected = (($k == $current) ? ' selected="selected" ' : '');
$o .= '<option value="' . urlencode($k) . '"' . $selected . '>' . $v[1] . '</option>';
}
$o .= '</select>';
- return $o;
+ return $o;
}
function get_things($profile_hash,$uid) {
$sql_extra = (($profile_hash) ? " and obj_page = '" . $profile_hash . "' " : '');
-
+
$r = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and uid = %d and obj_type = %d $sql_extra order by obj_verb, term",
intval($uid),
intval(TERM_OBJ_THING)
@@ -376,11 +391,11 @@ function get_things($profile_hash,$uid) {
for($x = 0; $x < count($l); $x ++)
$l[$x]['xchan_url'] = zid($l[$x]['xchan_url']);
-
+
if(! $things[$rr['obj_verb']])
$things[$rr['obj_verb']] = array();
- $things[$rr['obj_verb']][] = array('term' => $rr['term'],'url' => $rr['url'],'img' => $rr['imgurl'], 'profile' => $rr['profile_name'],'term_hash' => $rr['term_hash'], 'likes' => $l,'like_count' => count($l),'like_label' => tt('Like','Likes',count($l),'noun'));
+ $things[$rr['obj_verb']][] = array('term' => $rr['term'],'url' => $rr['url'],'img' => $rr['imgurl'], 'profile' => $rr['profile_name'],'term_hash' => $rr['term_hash'], 'likes' => $l,'like_count' => count($l),'like_label' => tt('Like','Likes',count($l),'noun'));
}
$sorted_things = array();
if($things) {
@@ -392,6 +407,6 @@ function get_things($profile_hash,$uid) {
}
}
//logger('things: ' . print_r($sorted_things,true));
- return $sorted_things;
+ return $sorted_things;
} \ No newline at end of file