aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-12-28 17:04:23 -0800
committerfriendica <info@friendica.com>2013-12-28 17:04:23 -0800
commit22f614feba8502a5fd040cc34dab2baa3087da3c (patch)
tree65dc8bd6ed84f2fb7a745c85ddf299aae234254f
parentaacd3164fa9efdb4dc3f835f67a61dfc14dc8d11 (diff)
downloadvolse-hubzilla-22f614feba8502a5fd040cc34dab2baa3087da3c.tar.gz
volse-hubzilla-22f614feba8502a5fd040cc34dab2baa3087da3c.tar.bz2
volse-hubzilla-22f614feba8502a5fd040cc34dab2baa3087da3c.zip
a bit more backend work on things
-rw-r--r--include/identity.php35
-rw-r--r--include/taxonomy.php68
-rw-r--r--view/tpl/list_things.tpl13
3 files changed, 84 insertions, 32 deletions
diff --git a/include/identity.php b/include/identity.php
index 63b05f4bb..5e25244e6 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -966,44 +966,15 @@ function advanced_profile(&$a) {
if($txt = prepare_text($a->profile['education'])) $profile['education'] = array( t('School/education:'), $txt );
- $r = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and obj_page = '%s' and uid = %d and obj_type = %d
- order by obj_verb, term",
- dbesc($a->profile['profile_guid']),
- intval($a->profile['profile_uid']),
- intval(TERM_OBJ_THING)
- );
-
- $things = null;
-
- if($r) {
- $things = array();
- // Use the system obj_verbs array as a sort key, since we don't really
- // want an alphabetic sort. To change the order, use a plugin to
- // alter the obj_verbs() array or alter it in code. Unknown verbs come
- // after the known ones - in no particular order.
-
- $v = obj_verbs();
- foreach($v as $k => $foo)
- $things[$k] = null;
- foreach($r as $rr) {
- if(! $things[$rr['obj_verb']])
- $things[$rr['obj_verb']] = array();
- $things[$rr['obj_verb']][] = array('term' => $rr['term'],'url' => $rr['url'],'img' => $rr['imgurl']);
- }
- $sorted_things = array();
- if($things)
- foreach($things as $k => $v)
- if(is_array($things[$k]))
- $sorted_things[$k] = $v;
- }
+ $things = get_things($a->profile['profile_guid'],$a->profile['profile_uid']);
- logger('mod_profile: things: ' . print_r($sorted_things,true), LOGGER_DATA);
+ logger('mod_profile: things: ' . print_r($things,true), LOGGER_DATA);
return replace_macros($tpl, array(
'$title' => t('Profile'),
'$profile' => $profile,
- '$things' => $sorted_things
+ '$things' => $things
));
}
diff --git a/include/taxonomy.php b/include/taxonomy.php
index 7887f7687..065f904fc 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -270,4 +270,72 @@ function obj_verb_selector() {
$o .= '</select>';
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)
+ );
+
+
+ $things = $sorted_things = null;
+
+ $profile_hashes = array();
+
+ if($r) {
+
+ // if no profile_hash was specified (display on profile page mode), match each of the things to a profile name
+ // (list all my things mode). This is harder than it sounds.
+
+ foreach($r as $rr) {
+ $rr['profile_name'] = '';
+ if(! in_array($rr['term_hash'],$profile_hashes))
+ $profile_hashes[] = $rr['term_hash'];
+ }
+ stringify_array_elms($profile_hashes);
+ if(! $profile_hash) {
+ $exp = explode(',',$profile_hashes);
+ $p = q("select profile_guid as hash, profile_name as name from profile where profile_guid in ( $exp ) ");
+ if($p) {
+ foreach($r as $rr) {
+ foreach($p as $pp) {
+ if($rr['obj_page'] == $pp['hash']) {
+ $rr['profile_name'] == $pp['name'];
+ }
+ }
+ }
+ }
+ }
+
+ $things = array();
+
+ // Use the system obj_verbs array as a sort key, since we don't really
+ // want an alphabetic sort. To change the order, use a plugin to
+ // alter the obj_verbs() array or alter it in code. Unknown verbs come
+ // after the known ones - in no particular order.
+
+ $v = obj_verbs();
+ foreach($v as $k => $foo)
+ $things[$k] = null;
+ foreach($r as $rr) {
+ 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']);
+ }
+ $sorted_things = array();
+ if($things) {
+ foreach($things as $k => $v) {
+ if(is_array($things[$k])) {
+ $sorted_things[$k] = $v;
+ }
+ }
+ }
+ }
+
+ return $sorted_things;
+
} \ No newline at end of file
diff --git a/view/tpl/list_things.tpl b/view/tpl/list_things.tpl
new file mode 100644
index 000000000..fb8935d82
--- /dev/null
+++ b/view/tpl/list_things.tpl
@@ -0,0 +1,13 @@
+{{if $things}}
+{{foreach $things as $key => $items}}
+<b>{{$items.profile}} {{$key}}</b>
+<ul class="profile-thing-list">
+{{foreach $items as $item}}
+<li>{{if $item.img}}<img src="{{$item.img}}" width="100" height="100" alt="{{$item.term}}" />{{/if}}
+<a href="{{$item.url}}" >{{$item.term}}</a>
+</li>
+{{/foreach}}
+</ul>
+<div class="clear"></div>
+{{/foreach}}
+{{/if}}