]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
New AjaxWebChannel for returning ajaxy responses to notice input box commands
authorZach Copley <zach@controlyourself.ca>
Tue, 9 Dec 2008 21:06:54 +0000 (16:06 -0500)
committerZach Copley <zach@controlyourself.ca>
Tue, 9 Dec 2008 21:06:54 +0000 (16:06 -0500)
darcs-hash:20081209210654-7b5ce-2ef432aa8cb7bf5cc1a973a71eb70e6b2aae4ab6.gz

actions/newnotice.php
classes/Channel.php

index 932099c605ef2c5265118ccce970fe762da4f767..8ac36320dedc1ccba3007fcc773bd028fd7a2aa4 100644 (file)
@@ -66,7 +66,11 @@ class NewnoticeAction extends Action {
                $cmd = $inter->handle_command($user, $content_shortened);
 
                if ($cmd) {
-                       $cmd->execute(new WebChannel());
+                       if ($this->boolean('ajax')) {
+                               $cmd->execute(new AjaxWebChannel());
+                       } else {
+                               $cmd->execute(new WebChannel());
+                       }
                        return;
                }
 
index 87f02b31679257cc34fb670168c326c1b018e8ba..34735c450dacfe855c3ba43d44bf7a6ea6a8f54d 100644 (file)
@@ -120,6 +120,33 @@ class WebChannel extends Channel {
        }
 }
 
+
+class AjaxWebChannel extends WebChannel {
+
+       function output($user, $text) {
+               common_start_html('text/xml;charset=utf-8', false);
+               common_element_start('head');
+               common_element('title', null, _('Command results'));
+               common_element_end('head');
+               common_element_start('body');
+               common_element('p', array('class' => 'command_results'), $text);
+               common_element_end('body');
+               common_element_end('html');
+       }
+
+       function error($user, $text) {
+               common_start_html('text/xml;charset=utf-8', false);
+               common_element_start('head');
+               common_element('title', null, _('Ajax Error'));
+               common_element_end('head');
+               common_element_start('body');
+               common_element('p', array('class' => 'error'), $text);
+               common_element_end('body');
+               common_element_end('html');
+       }
+}
+
+
 class MailChannel extends Channel {
 
        var $addr = NULL;