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) {
$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');
{
$paths = array();
- // XXX: Add other timelines; this is just for the public one
+ // Add to the author's timeline
+
+ $user = User::staticGet('id', $notice->profile_id);
+
+ if (!empty($user)) {
+ $paths[] = array('showstream', $user->nickname);
+ }
+
+ // Add to the public timeline
if ($notice->is_local ||
($notice->is_local == 0 && !common_config('public', 'localonly'))) {
$paths[] = array('public');
}
+ // Add to the tags timeline
+
$tags = $this->getNoticeTags($notice);
if (!empty($tags)) {
}
}
+ // Add to inbox timelines
+ // XXX: do a join
+
+ $inbox = new Notice_inbox();
+ $inbox->notice_id = $notice->id;
+
+ if ($inbox->find()) {
+ while ($inbox->fetch()) {
+ $user = User::staticGet('id', $inbox->user_id);
+ $paths[] = array('all', $user->nickname);
+ }
+ }
+
+ // Add to the replies timeline
+
+ $reply = new Reply();
+ $reply->notice_id = $notice->id;
+
+ if ($reply->find()) {
+ while ($reply->fetch()) {
+ $user = User::staticGet('id', $reply->profile_id);
+ if (!empty($user)) {
+ $paths[] = array('replies', $user->nickname);
+ }
+ }
+ }
+
+ // Add to the group timeline
+ // XXX: join
+
+ $gi = new Group_inbox();
+ $gi->notice_id = $notice->id;
+
+ if ($gi->find()) {
+ while ($gi->fetch()) {
+ $ug = User_group::staticGet('id', $gi->group_id);
+ $paths[] = array('showgroup', $ug->nickname);
+ }
+ }
+
if (count($paths) > 0) {
$json = $this->noticeAsJson($notice);
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');
(common_current_user()) ? array('id' => $action->trimmed('action'),
'class' => 'user_in')
: array('id' => $action->trimmed('action')));
+
+ $action->elementStart('div', array('id' => 'header'));
+
+ // 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->elementEnd('div');
+
+ $action->showContentBlock();
$action->elementEnd('body');
return false; // No default processing
}
$path = null;
$timeline = null;
- switch ($action->trimmed('action')) {
+ $action_name = $action->trimmed('action');
+
+ switch ($action_name) {
case 'public':
$path = array('public');
break;
$path = array('tag', $tag);
}
break;
+ case 'showstream':
+ case 'all':
+ case 'replies':
+ case 'showgroup':
+ $nickname = common_canonical_nickname($action->trimmed('nickname'));
+ if (!empty($nickname)) {
+ $path = array($action_name, $nickname);
+ }
+ break;
default:
break;
}
- if (!is_null($path)) {
+ if (!empty($path)) {
$timeline = $this->_pathToChannel($path);
}