/** * Dumps anything you need to see * * @param mixed $mixed - What to debug * @param string $element - Where to render it * @return string */ public static function debug($mixed, $element = '#content') { //TODO: RESTful debug $trace = debug_backtrace(); $view = new View(); $view->setModuleName('krn'); $view->loadTemplate('debug'); $view->setVariable('element', $element); $view->setVariable('trace', $trace); $view->setVariable('mixed', $mixed); $result = $view->render(); !Core::isAjax() || ($result = Html::ReplaceHtml($result, $element)); return $result; }
/** * @covers \Plugin\View::dispatch * @covers \Plugin\View::renderTemplate * @depends testCreateView */ public function testSetAndGetValue() { $testValue = 'test value'; $view = new View('Plugin/testTemplate'); $view->setVariable('test', $testValue); $result = $view->dispatch(); $this->assertTrue(is_string($result) && strpos($result, $testValue) !== false); }
/** * Display the Dataset in a grid */ public function dbGrid() { $view = new View(); $view->setVariable('id', $this->id); $view->setVariable('showTitles', $this->dbGridShowHeader); $view->setVariable('rowAction', $this->gridRowLink['action']); $view->setVariable('rowFieldId', $this->gridRowLink['fieldId']); if ($this->dbGridAutoHeader) { $this->dbGridColumns = array(); foreach ($this->getRow(0) as $field => $value) { $this->addGridColumn(ucwords(String::decamelize($field)), $field); } } $view->setVariable('head', $this->dbGridColumns); $view->setVariable('gridClass', $this->gridClass); $view->setVariable('content', $this->dataset); $view->loadTemplate($this->dbGridTemplate); return $view->render(); }
/** * Show error page after non-recoverable error * * @param string $error * @param int $code * @param string $trace * @return void */ public static function showError($error, $code, $trace = '') { if ($code != self::ERROR_404) { $code = self::ERROR_500; } $view = new View('Plugin/' . 'error_' . $code); $view->setLayout('error'); $view->setVariable('error', $error); $view->setVariable('trace', $trace); $view->setTerminal(\Request\Service::isTerminalRequest()); echo $view->dispatch(); }
/** * Returns the error page * * The page is rendered using the * view template handler * * It also includes the trace of * the current execution * * This page can be edited in * the file tpl/krn/exception.tpl * * @param $error - The error trace ( an array('message' => 'The Error Message', 'file' => 'The File Name', 'Class' => 'The Class Name') ) * @return string - The rendered error page */ private static function throwException(array $error) { $trace = debug_backtrace(); $view = new View(); $view->setModuleName('krn'); $view->loadTemplate('exception'); $view->setVariable('error', $error); $view->setVariable('trace', $trace); return $view->render(false); }