diff options
author | Habeas Codice <habeascodice@federated.social> | 2015-02-05 09:15:39 -0800 |
---|---|---|
committer | Habeas Codice <habeascodice@federated.social> | 2015-02-05 09:15:39 -0800 |
commit | 9ed23f9081b56369349d4e06c51e3856f950804e (patch) | |
tree | b3a1121ec41e04cce02cfa07fc958b95a3fd289b /include/widgets.php | |
parent | 88488fdfbb58aa04b450af1691aba7cea1bce8ab (diff) | |
parent | 646a874390be8f92736866118d7215e8cb80fb8a (diff) | |
download | volse-hubzilla-9ed23f9081b56369349d4e06c51e3856f950804e.tar.gz volse-hubzilla-9ed23f9081b56369349d4e06c51e3856f950804e.tar.bz2 volse-hubzilla-9ed23f9081b56369349d4e06c51e3856f950804e.zip |
Merge branch 'master' of https://github.com/friendica/red
Diffstat (limited to 'include/widgets.php')
-rw-r--r-- | include/widgets.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/include/widgets.php b/include/widgets.php index 523318850..d457db07d 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -903,3 +903,63 @@ function widget_random_block($arr) { return $o; } + + +function widget_rating($arr) { + $a = get_app(); + + $poco_rating = get_config('system','poco_rating_enable'); + if((! $poco_rating) && ($poco_rating !== false)) { + return; + } + + if($arr['target']) + $hash = $arr['target']; + else + $hash = $a->poi['xchan_hash']; + + if(! $hash) + return; + + $url = ''; + $remote = false; + + if(remote_channel() && ! local_channel()) { + $ob = $a->get_observer(); + if($ob && $ob['xchan_url']) { + $p = parse_url($ob['xchan_url']); + if($p) { + $url = $p['scheme'] . '://' . $p['host'] . (($p['port']) ? ':' . $p['port'] : ''); + $url .= '/rate?f=&target=' . urlencode($hash); + } + $remote = true; + } + } + + $self = false; + + if(local_channel()) { + $channel = $a->get_channel(); + + if($hash == $channel['channel_hash']) + $self = true; + + head_add_js('ratings.js'); + + } + + if((($remote) || (local_channel())) && (! $self)) { + $o = '<div class="widget rateme">'; + if($remote) + $o .= '<a class="rateme" href="' . $url . '"><i class="icon-pencil"></i> ' . t('Rate Me') . '</a>'; + else + $o .= '<div class="rateme fakelink" onclick="doRatings(\'' . $hash . '\'); return false;"><i class="icon-pencil"></i> ' . t('Rate Me') . '</div>'; + $o .= '</div>'; + } + + $o .= '<div class="widget rateme"><a class="rateme" href="ratings/' . $hash . '"><i class="icon-eye-open"></i> ' . t('View Ratings') . '</a>'; + $o .= '</div>'; + + return $o; + +}
\ No newline at end of file |