/* First, determine the type of view we are asking for */
$view = empty($args['gallery_view']) ? 'Mini' : $args['gallery_view'];
-
- require_once ANSEL_BASE . '/lib/Views/EmbeddedRenderers/' . basename($view) . '.php';
$class = 'Ansel_View_EmbeddedRenderer_' . basename($view);
if (!class_exists($class)) {
- return '';
+ throw new Horde_Exception(sprintf("Class definition for %s not found.", $class));
}
-
- $view = call_user_func(array($class, 'makeView'), $args);
-
+ $view = new $class($args);
header('Content-Type: script/javascript');
return $view->html();
}
$params['view'] = $view;
$trail = array();
$return = array();
-
- if (is_callable(array($classname, 'makeView'))) {
- $view = call_user_func_array(array($classname, 'makeView'), array($params));
- if (is_a($view, 'PEAR_Error')) {
- $return['html'] = $view->getMessage();
- $return['crumbs'] = array();
- return $return;
- }
-
- $return['html'] = $view->html();
- if ($params['view'] == 'Gallery' || $params['view'] == 'Image') {
- $trail = $view->getGalleryCrumbData();
- }
- $return['crumbs'] = $trail;
-
+ try {
+ $view = new $classname($params);
+ } catch (Horde_Exception $e) {
+ $return['html'] = $e->getMessage();
+ $return['crumbs'] = array();
return $return;
- } else {
- return PEAR::raiseError(sprintf(
- _("Unable to load the definition of %s."), $view));
}
+ $return['html'] = $view->html();
+ if ($params['view'] == 'Gallery' || $params['view'] == 'Image') {
+ $trail = $view->getGalleryCrumbData();
+ }
+ $return['crumbs'] = $trail;
+
+ return $return;
+
}
$viewname = basename(Horde_Util::getFormData('view', 'Gallery'));
$view = 'Ansel_View_' . $viewname;
-if (!$view || !class_exists($view)) {
+if (!class_exists($view)) {
throw new Horde_Exception(sprintf("Could not load class definition of %s", $view));
}