/** * When a view is rendered, check for plugins which are adding tabs to the view. If any exist, then * wrap the current view output in the first tab of a jQuery tabs implementation and add links to the plugin output * for the other tabs. */ public function render($print = FALSE, $renderer = FALSE) { $output = parent::render($print, $renderer); $tabs = $this->get_tabs(); // If only one tab, that is the current view, so don't bother tabifying it. if (count($tabs) > 1) { $js = "<script type=\"text/javascript\">\njQuery(document).ready(function() {\n var t=\$('#tabs').tabs();\n var initTab='" . (array_key_exists('tab', $_GET) ? $_GET['tab'] : '') . "';\n if (initTab!='') {\n t.tabs('select', '#' + initTab);\n }\n});\n</script>"; $prefix = "<div id=\"tabs\"><ul>\n"; $suffix = "</div>\n"; $args = $this->get_args(); foreach ($tabs as $tab => $controller) { if ($controller == $this->viewname) { // this is the default page $path = "#main"; } else { // a plugin page $path = url::site() . "{$controller}{$args}"; } $prefix .= '<li><a href="' . $path . '" title="' . $tab . '"><span>' . $tab . "</span></a></li>\n"; $suffix .= '<div id="' . str_replace(' ', '_', $tab) . '"></div>'; } $prefix .= "</ul>\n<div id=\"main\">"; $suffix .= "</div>\n"; $output = "{$js}{$prefix}{$output}{$suffix}"; } return $output; }
/** * Override View_Core::render so that we trap errors stemming from bad PHP includes and show a * visible stack trace to help developers. * * @see View_Core::render */ public function render($print=false, $renderer=false) { try { return parent::render($print, $renderer); } catch (Exception $e) { Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString()); return ""; } }
/** * Renders a view. * * Add an additional filter to modify view data * * @param boolean set to TRUE to echo the output instead of returning it * @param callback special renderer to pass the output through * @return string if print is FALSE * @return void if print is TRUE */ public function render($print = FALSE, $renderer = FALSE) { // Run view_pre_render filter to allow plugins/themes to add extra data to a view Event::run('ushahidi_filter.view_pre_render', $this->kohana_local_data); // View specific hook pre render hook ie. ushahidi_filter.view_pre_render.reports_main Event::run('ushahidi_filter.view_pre_render.' . str_replace('/', '_', $this->name), $this->kohana_local_data); return parent::render($print, $renderer); }
/** * Override View_Core::render so that we trap errors stemming from bad PHP includes and show a * visible stack trace to help developers. * * @see View_Core::render */ public function render($print = false, $renderer = false, $modifier = false) { try { $this->kohana_local_data = array_merge(View::$global_data, $this->kohana_local_data); return parent::render($print, $renderer, $modifier); } catch (Exception $e) { Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString()); return ""; } }
public function template($print = FALSE, $renderer = FALSE) { $output = (string) parent::render(FALSE, $renderer); $output = json_encode($output); $output = str_replace(array('\\n', ' '), '', $output); if ($print === TRUE) { echo $output; return; } return $output; }
/** * Override View_Core::render so that we trap errors stemming from bad PHP includes and show a * visible stack trace to help developers. * * @see View_Core::render */ public function render($print = false, $renderer = false) { try { return parent::render($print, $renderer); } catch (Exception $e) { if (!IN_PRODUCTION) { print $e->getTraceAsString(); return $e->getMessage(); } Kohana::Log('error', $e->getTraceAsString()); Kohana::Log('debug', $e->getMessage()); return ""; } }