X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2FRealtime%2FRealtimePlugin.php;h=2b3cb35f1d370dcc8b3b6c5421b3129956bcd032;hb=04c4facba9230f40726c5891dcac21d928fbb2ab;hp=b737e442a02cfba6132e2d838b29546c3eb09f8b;hpb=42da45d3bc3cd0caa34f8d9f34c5617fedbb755e;p=quix0rs-gnu-social.git diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index b737e442a0..2b3cb35f1d 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -59,6 +59,7 @@ class RealtimePlugin extends Plugin { $this->replyurl = common_local_url('newnotice'); $this->favorurl = common_local_url('favor'); + $this->repeaturl = common_local_url('repeat'); // FIXME: need to find a better way to pass this pattern in $this->deleteurl = common_local_url('deletenotice', array('notice' => '0000000000')); @@ -105,22 +106,18 @@ class RealtimePlugin extends Plugin $realtimeUI = ' RealtimeUpdate.initActions("'.$url.'", "'.$timeline.'", "'. $pluginPath .'");'; } - $action->elementStart('script', array('type' => 'text/javascript')); - $script = ' $(document).ready(function() { '. $realtimeUI. $this->_updateInitialize($timeline, $user_id). '}); '; - $action->raw($script); - - $action->elementEnd('script'); + $action->inlineScript($script); return true; } function onEndShowStatusNetStyles($action) { - $action->cssLink(common_path('plugins/Realtime/realtimeupdate.css'), + $action->cssLink(common_path('plugins/Realtime/realtimeupdate.css'), null, 'screen, projection, tv'); return true; } @@ -157,14 +154,11 @@ class RealtimePlugin extends Plugin // Add to inbox timelines // XXX: do a join - $inbox = new Notice_inbox(); - $inbox->notice_id = $notice->id; + $ni = $notice->whoGets(); - if ($inbox->find()) { - while ($inbox->fetch()) { - $user = User::staticGet('id', $inbox->user_id); - $paths[] = array('all', $user->nickname); - } + foreach (array_keys($ni) as $user_id) { + $user = User::staticGet('id', $user_id); + $paths[] = array('all', $user->nickname); } // Add to the replies timeline @@ -220,8 +214,9 @@ class RealtimePlugin extends Plugin $action->elementStart('body', (common_current_user()) ? array('id' => $action->trimmed('action'), - 'class' => 'user_in') - : array('id' => $action->trimmed('action'))); + 'class' => 'user_in realtime-popup') + : array('id' => $action->trimmed('action'), + 'class'=> 'realtime-popup')); // XXX hack to deal with JS that tries to get the // root url from page output @@ -249,8 +244,6 @@ class RealtimePlugin extends Plugin // of refactoring from within a plugin, so I'm just abusing // the ApiAction method. Don't do this unless you're me! - require_once(INSTALLDIR.'/lib/api.php'); - $act = new ApiAction('/dev/null'); $arr = $act->twitterStatusArray($notice, true); @@ -269,6 +262,24 @@ class RealtimePlugin extends Plugin $profile = $notice->getProfile(); $arr['user']['profile_url'] = $profile->profileurl; + // Add needed repeat data + + if (!empty($notice->repeat_of)) { + $original = Notice::staticGet('id', $notice->repeat_of); + if (!empty($original)) { + $arr['retweeted_status']['url'] = $original->bestUrl(); + $arr['retweeted_status']['html'] = htmlspecialchars($original->rendered); + $arr['retweeted_status']['source'] = htmlspecialchars($original->source); + $originalProfile = $original->getProfile(); + $arr['retweeted_status']['user']['profile_url'] = $originalProfile->profileurl; + if (!empty($original->reply_to)) { + $originalReply = Notice::staticGet('id', $original->reply_to); + $arr['retweeted_status']['in_reply_to_status_url'] = $originalReply->bestUrl(); + } + } + $original = null; + } + return $arr; } @@ -292,22 +303,14 @@ class RealtimePlugin extends Plugin return $tags; } - // Push this up to Plugin - - function log($level, $msg) - { - common_log($level, get_class($this) . ': '.$msg); - } - function _getScripts() { - return array('plugins/Realtime/realtimeupdate.js', - 'plugins/Realtime/json2.js'); + return array(common_path('plugins/Realtime/realtimeupdate.js')); } function _updateInitialize($timeline, $user_id) { - return "RealtimeUpdate.init($user_id, \"$this->replyurl\", \"$this->favorurl\", \"$this->deleteurl\"); "; + return "RealtimeUpdate.init($user_id, \"$this->replyurl\", \"$this->favorurl\", \"$this->repeaturl\", \"$this->deleteurl\"); "; } function _connect()