X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FRealtime%2FRealtimePlugin.php;h=181927968648a132f2ef9754725502f3b8d4b5af;hb=1ccfb5d9d34128005bc10d89e3ed56ff0e643969;hp=0f3e3107148f6931910172551d2d1cc696d5b9ce;hpb=480eeb1b800b77cf48111d0fa984721a171f981b;p=quix0rs-gnu-social.git diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 0f3e310714..1819279686 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -76,6 +76,13 @@ class RealtimePlugin extends Plugin return true; } + $base = $action->selfUrl(); + if (mb_strstr($base, '?')) { + $url = $base . '&realtime=1'; + } else { + $url = $base . '?realtime=1'; + } + $scripts = $this->_getScripts(); foreach ($scripts as $script) { @@ -90,12 +97,20 @@ class RealtimePlugin extends Plugin $user_id = 0; } + if ($action->boolean('realtime')) { + $realtimeUI = ' RealtimeUpdate.initPopupWindow();'; + } + else { + $iconurl = common_path('plugins/Realtime/icon_external.gif'); + $realtimeUI = ' RealtimeUpdate.addPopup("'.$url.'", "'.$timeline.'", "'. $iconurl .'");'; + } + $action->elementStart('script', array('type' => 'text/javascript')); $script = ' $(document).ready(function() { '. + $realtimeUI. $this->_updateInitialize($timeline, $user_id). '}); '; - $action->raw($script); $action->elementEnd('script'); @@ -189,28 +204,6 @@ class RealtimePlugin extends Plugin return true; } - function onStartShowPageNotice($action) - { - $timeline = $this->_getTimeline($action); - if (!empty($timeline)) { - $base = $action->selfUrl(); - if (mb_strstr($url, '?')) { - $url = $base . '&realtime=1'; - } else { - $url = $base . '?realtime=1'; - } - $title = $action->title(); - $code = "window.open('$url', '$title', 'toolbar=no,resizable=yes,scrollbars=yes,status=yes,height=640,width=575');"; - $action->element('a', array('href' => $base, - 'onclick' => $code, - 'id' => 'realtime_timeline', - 'title' => _('Pop up')), - 'Pop up'); - - } - return true; - } - function onStartShowBody($action) { $realtime = $action->boolean('realtime'); @@ -222,10 +215,22 @@ class RealtimePlugin extends Plugin (common_current_user()) ? array('id' => $action->trimmed('action'), 'class' => 'user_in') : array('id' => $action->trimmed('action'))); + + // XXX hack to deal with JS that tries to get the + // root url from page output + + $action->elementStart('address'); + $action->element('a', array('class' => 'url', + 'href' => common_local_url('public')), + ''); + $action->elementEnd('address'); + if (common_logged_in()) { $action->showNoticeForm(); } - $action->showContent(); + + $action->showContentBlock(); + $action->showScripts(); $action->elementEnd('body'); return false; // No default processing }