]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/action.php
Remove Google References
[quix0rs-gnu-social.git] / lib / action.php
index 7f3aea9c1a74115d2bbaccf4787faff1ad1ac4fc..284f160e676da39b52247af353d1b90297cd6636 100644 (file)
@@ -95,9 +95,22 @@ class Action extends HTMLOutputter // lawsuit
         return $this->msg;
     }
 
+    public function handleError($e)
+    {
+        if ($e instanceof ClientException) {
+            $this->clientError($e->getMessage(), $e->getCode());
+        } elseif ($e instanceof ServerException) {
+            $this->serverError($e->getMessage(), $e->getCode());
+        } else {
+            // If it wasn't specified more closely which kind of exception it was
+            $this->serverError($e->getMessage(), 500);
+        }
+    }
+
     static public function run(array $args=array(), $output='php://output', $indent=null) {
         $class = get_called_class();
         $action = new $class($output, $indent);
+        set_exception_handler(array($action, 'handleError'));
         $action->execute($args);
         return $action;
     }
@@ -381,8 +394,7 @@ class Action extends HTMLOutputter // lawsuit
     {
         $theme = new Theme($mainTheme);
 
-        // Some themes may have external stylesheets, such as using the
-        // Google Font APIs to load webfonts.
+        // Some themes may have external stylesheets
         foreach ($theme->getExternals() as $url) {
             $this->cssLink($url, $mainTheme, $media);
         }
@@ -416,7 +428,6 @@ class Action extends HTMLOutputter // lawsuit
                 $this->script('extlib/jquery.form.js');
                 $this->script('extlib/jquery-ui/jquery-ui.js');
                 $this->script('extlib/jquery.cookie.js');
-                $this->inlineScript('if (typeof window.JSON !== "object") { $.getScript("'.common_path('js/extlib/json2.js', GNUsocial::isHTTPS()).'"); }');
 
                 Event::handle('EndShowJQueryScripts', array($this));
             }
@@ -460,6 +471,7 @@ class Action extends HTMLOutputter // lawsuit
 
             // TRANS: Localized tooltip for '...' expansion button on overlong remote messages.
             $messages['showmore_tooltip'] = _m('TOOLTIP', 'Show more');
+            $messages['popup_close_button'] = _m('TOOLTIP', 'Close popup');
 
             $messages = array_merge($messages, $this->getScriptMessages());
 
@@ -1153,7 +1165,7 @@ class Action extends HTMLOutputter // lawsuit
                         $url = $sslimage;
                     } else if (preg_match('#^http://i.creativecommons.org/#', $image)) {
                         // CC support HTTPS on their images
-                        $url = preg_replace('/^http/', 'https', $image);
+                        $url = preg_replace('/^http/', 'https', $image, 1);
                     } else {
                         // Better to show mixed content than no content
                         $url = $image;
@@ -1442,7 +1454,9 @@ class Action extends HTMLOutputter // lawsuit
             $this->endDocument('json');
             break;
         default:
-            throw new ServerException($msg, $code);
+            common_log(LOG_ERR, 'Handled serverError ('._ve($code).') but cannot output into desired format ('._ve($this->format).'): '._ve($msg));
+            $action = new ServerErrorAction($msg, $code);
+            $action->execute();
         }
 
         exit((int)$code);
@@ -1470,7 +1484,7 @@ class Action extends HTMLOutputter // lawsuit
         if (!array_key_exists($code, ClientErrorAction::$status)) {
             $code = 400;
         }
-        
+
         $status_string = ClientErrorAction::$status[$code];
 
         switch ($format) {
@@ -1489,7 +1503,7 @@ class Action extends HTMLOutputter // lawsuit
             }
             $this->initDocument('json');
             $error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
-            $this->text(json_encode($error_array));
+            print(json_encode($error_array));
             $this->endDocument('json');
             break;
         case 'text':
@@ -1498,7 +1512,9 @@ class Action extends HTMLOutputter // lawsuit
             echo $msg;
             break;
         default:
-            throw new ClientException($msg, $code);
+            common_log(LOG_ERR, 'Handled clientError ('._ve($code).') but cannot output into desired format ('._ve($this->format).'): '._ve($msg));
+            $action = new ClientErrorAction($msg, $code);
+            $action->execute();
         }
         exit((int)$code);
     }