aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget/Rating.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-03-16 17:11:48 -0700
committerMario Vavti <mario@mariovavti.com>2017-03-29 12:02:09 +0200
commit0bad26e116499d9b656c28f64c81275df4bbecb6 (patch)
treea5a30a33e97db03bb7fdeb156045ba41205546e8 /Zotlabs/Widget/Rating.php
parentcd57483ed9069a26b52ae8d7d74fdc537da89946 (diff)
downloadvolse-hubzilla-0bad26e116499d9b656c28f64c81275df4bbecb6.tar.gz
volse-hubzilla-0bad26e116499d9b656c28f64c81275df4bbecb6.tar.bz2
volse-hubzilla-0bad26e116499d9b656c28f64c81275df4bbecb6.zip
the rest of the standard widgets converted
Diffstat (limited to 'Zotlabs/Widget/Rating.php')
-rw-r--r--Zotlabs/Widget/Rating.php67
1 files changed, 67 insertions, 0 deletions
diff --git a/Zotlabs/Widget/Rating.php b/Zotlabs/Widget/Rating.php
new file mode 100644
index 000000000..5e09f457b
--- /dev/null
+++ b/Zotlabs/Widget/Rating.php
@@ -0,0 +1,67 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+class Rating {
+
+ function widget($arr) {
+
+
+ $rating_enabled = get_config('system','rating_enabled');
+ if(! $rating_enabled) {
+ return;
+ }
+
+ if($arr['target'])
+ $hash = $arr['target'];
+ else
+ $hash = \App::$poi['xchan_hash'];
+
+ if(! $hash)
+ return;
+
+ $url = '';
+ $remote = false;
+
+ if(remote_channel() && ! local_channel()) {
+ $ob = \App::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 = \App::get_channel();
+
+ if($hash == $channel['channel_hash'])
+ $self = true;
+
+ head_add_js('ratings.js');
+ }
+
+
+ $o = '<div class="widget">';
+ $o .= '<h3>' . t('Rating Tools') . '</h3>';
+
+ if((($remote) || (local_channel())) && (! $self)) {
+ if($remote)
+ $o .= '<a class="btn btn-block btn-primary btn-sm" href="' . $url . '"><i class="fa fa-pencil"></i> ' . t('Rate Me') . '</a>';
+ else
+ $o .= '<div class="btn btn-block btn-primary btn-sm" onclick="doRatings(\'' . $hash . '\'); return false;"><i class="fa fa-pencil"></i> ' . t('Rate Me') . '</div>';
+ }
+
+ $o .= '<a class="btn btn-block btn-default btn-sm" href="ratings/' . $hash . '"><i class="fa fa-eye"></i> ' . t('View Ratings') . '</a>';
+ $o .= '</div>';
+
+ return $o;
+
+ }
+}
+