Catch exceptions.
authorJan Schneider <jan@horde.org>
Thu, 4 Feb 2010 21:53:55 +0000 (22:53 +0100)
committerJan Schneider <jan@horde.org>
Thu, 4 Feb 2010 22:27:24 +0000 (23:27 +0100)
framework/Block/lib/Horde/Block/Layout/View.php

index 540806b..f897db7 100644 (file)
@@ -69,37 +69,39 @@ class Horde_Block_Layout_View extends Horde_Block_Layout
                 }
                 if (is_array($item)) {
                     $this->_applications[$item['app']] = $item['app'];
-                    $block = Horde_Block_Collection::getBlock($item['app'], $item['params']['type'], $item['params']['params'], $row_num, $col_num);
-                    $rowspan = $item['height'];
-                    $colspan = $item['width'];
-                    for ($i = 0; $i < $item['height']; $i++) {
-                        if (!isset($covered[$row_num + $i])) {
-                            $covered[$row_num + $i] = array();
+                    try {
+                        $block = Horde_Block_Collection::getBlock($item['app'], $item['params']['type'], $item['params']['params'], $row_num, $col_num);
+                        $rowspan = $item['height'];
+                        $colspan = $item['width'];
+                        for ($i = 0; $i < $item['height']; $i++) {
+                            if (!isset($covered[$row_num + $i])) {
+                                $covered[$row_num + $i] = array();
+                            }
+                            for ($j = 0; $j < $item['width']; $j++) {
+                                $covered[$row_num + $i][$col_num + $j] = true;
+                            }
                         }
-                        for ($j = 0; $j < $item['width']; $j++) {
-                            $covered[$row_num + $i][$col_num + $j] = true;
+                        if ($block instanceof Horde_Block) {
+                            $header = $block->getTitle();
+                            $content = $block->getContent();
+                            if ($content instanceof PEAR_Error) {
+                                $content = $content->getMessage();
+                            }
+                            if ($browser->hasFeature('xmlhttpreq')) {
+                                $refresh_time = isset($item['params']['params']['_refresh_time']) ? $item['params']['params']['_refresh_time'] : $interval;
+                            }
+                            ob_start();
+                            include $tplDir . '/portal/block.inc';
+                            $html .= ob_get_clean();
+                        } else {
+                            $html .= '<td width="' . ($width * $colspan) . '%">&nbsp;</td>';
                         }
-                    }
-                    if ($block instanceof PEAR_Error) {
+                    } catch (Horde_Exception $e) {
                         $header = _("Error");
-                        $content = $block->getMessage();
-                        ob_start();
-                        include $tplDir . '/portal/block.inc';
-                        $html .= ob_get_clean();
-                    } elseif ($block instanceof Horde_Block) {
-                        $header = $block->getTitle();
-                        $content = $block->getContent();
-                        if ($content instanceof PEAR_Error) {
-                            $content = $content->getMessage();
-                        }
-                        if ($browser->hasFeature('xmlhttpreq')) {
-                            $refresh_time = isset($item['params']['params']['_refresh_time']) ? $item['params']['params']['_refresh_time'] : $interval;
-                        }
+                        $content = $e->getMessage();
                         ob_start();
                         include $tplDir . '/portal/block.inc';
                         $html .= ob_get_clean();
-                    } else {
-                        $html .= '<td width="' . ($width * $colspan) . '%">&nbsp;</td>';
                     }
                 } else {
                     $html .= '<td width="' . ($width) . '%">&nbsp;</td>';