diff options
-rw-r--r-- | EVENTS.txt | 21 | ||||
-rw-r--r-- | lib/htmloutputter.php | 42 | ||||
-rw-r--r-- | plugins/TwitterBridge/TwitterBridgePlugin.php | 7 | ||||
-rwxr-xr-x | plugins/TwitterBridge/daemons/twitterstatusfetcher.php | 18 |
4 files changed, 66 insertions, 22 deletions
diff --git a/EVENTS.txt b/EVENTS.txt index 34a222e8f..f4ec62033 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -574,3 +574,24 @@ EndShortenUrl: After a URL has been shortened - $shortenerName: name of the requested shortener - $shortenedUrl: short version of the url +StartCssLinkElement: Before a <link rel="stylesheet"..> element is written +- $action +- &$src +- &$theme +- &$media + +EndCssLinkElement: After a <link rel="stylesheet"..> element is written +- $action +- $src +- $theme +- $media + +StartScriptElement: Before a <script...> element is written +- $action +- &$src +- &$type + +EndScriptElement: After a <script...> element is written +- $action +- $src +- $type diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 3fabc4037..a0066594f 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -350,14 +350,17 @@ class HTMLOutputter extends XMLOutputter */ function script($src, $type='text/javascript') { - $url = parse_url($src); - if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment)) - { - $src = common_path($src) . '?version=' . STATUSNET_VERSION; + if(Event::handle('StartScriptElement', array($this,&$src,&$type))) { + $url = parse_url($src); + if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment)) + { + $src = common_path($src) . '?version=' . STATUSNET_VERSION; + } + $this->element('script', array('type' => $type, + 'src' => $src), + ' '); + Event::handle('EndScriptElement', array($this,$src,$type)); } - $this->element('script', array('type' => $type, - 'src' => $src), - ' '); } /** @@ -390,19 +393,22 @@ class HTMLOutputter extends XMLOutputter */ function cssLink($src,$theme=null,$media=null) { - $url = parse_url($src); - if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment)) - { - if(file_exists(Theme::file($src,$theme))){ - $src = Theme::path($src, $theme) . '?version=' . STATUSNET_VERSION; - }else{ - $src = common_path($src); + if(Event::handle('StartCssLinkElement', array($this,&$src,&$theme,&$media))) { + $url = parse_url($src); + if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment)) + { + if(file_exists(Theme::file($src,$theme))){ + $src = Theme::path($src, $theme) . '?version=' . STATUSNET_VERSION; + }else{ + $src = common_path($src); + } } + $this->element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => $src, + 'media' => $media)); + Event::handle('EndCssLinkElement', array($this,$src,$theme,$media)); } - $this->element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => $src, - 'media' => $media)); } /** diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php index ad3c2e551..adf9ceda3 100644 --- a/plugins/TwitterBridge/TwitterBridgePlugin.php +++ b/plugins/TwitterBridge/TwitterBridgePlugin.php @@ -127,7 +127,12 @@ class TwitterBridgePlugin extends Plugin */ function onStartEnqueueNotice($notice, &$transports) { - array_push($transports, 'twitter'); + // Avoid a possible loop + + if ($notice->source != 'twitter') { + array_push($transports, 'twitter'); + } + return true; } diff --git a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php index eba1d563b..d8901f47b 100755 --- a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php +++ b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php @@ -209,7 +209,11 @@ class TwitterStatusFetcher extends ParallelizingDaemon continue; } - $this->saveStatus($status, $flink); + $notice = null; + + $notice = $this->saveStatus($status, $flink); + + common_broadcast_notice($notice); } // Okay, record the time we synced with Twitter for posterity @@ -235,12 +239,14 @@ class TwitterStatusFetcher extends ParallelizingDaemon $uri = 'http://twitter.com/' . $status->user->screen_name . '/status/' . $status->id; - $notice = Notice::staticGet('uri', $uri); - // check to see if we've already imported the status + $notice = Notice::staticGet('uri', $uri); + if (empty($notice)) { + // XXX: transaction here? + $notice = new Notice(); $notice->profile_id = $id; @@ -257,6 +263,7 @@ class TwitterStatusFetcher extends ParallelizingDaemon $id = $notice->insert(); Event::handle('EndNoticeSave', array($notice)); } + } if (!Notice_inbox::pkeyGet(array('notice_id' => $notice->id, @@ -270,7 +277,12 @@ class TwitterStatusFetcher extends ParallelizingDaemon $inbox->source = NOTICE_INBOX_SOURCE_GATEWAY; // From a private source $inbox->insert(); + } + + $notice->blowCaches(); + + return $notice; } function ensureProfile($user) |