/** * Render an HTML error page from an exception. * * @param Exception $exception * @param Mad_Controller_Request_Http $request * @param Mad_Controller_Response_Http $response */ public function render($exception, $request, $response) { // If there is anything leftover in the output buffer, such // as interrupted template rendering, destroy it. while (ob_get_level()) { ob_get_clean(); } // title if ($exception instanceof Mad_Support_Exception) { $title = $exception->getTitle(); } else { $title = get_class($exception); } // message if (!strlen($message = $exception->getMessage())) { $message = "<no message>"; } // assignments $this->_view->title = $title; $this->_view->message = $message; $this->_view->exception = $exception; $this->_view->trace = $this->formatTrace($exception); $this->_view->request = $request; $this->_view->response = $response; $this->_view->extraction = $this->extractSource($exception); // render the error page contents $this->_view->contents = $this->_view->render('diagnostics'); // render the error layout $html = $this->_view->render('layout'); return $html; }
/** * Generate mailer class stubs */ private function _generateMailerStubs() { $name = !empty($this->_args) ? array_shift($this->_args) : null; if (!$name) { $this->_exit("You did not specify the name of the Mailer to generate"); } $name = str_replace('Mailer', '', $name); $mailerName = Mad_Support_Inflector::camelize($name) . 'Mailer'; $this->_tpl->mailerName = $mailerName; $content = $this->_tpl->render('mailer.php'); $this->_createFile(MAD_ROOT . "/app/models/{$mailerName}.php", $content); // CREATE DIRECTORIES $this->_createDir(MAD_ROOT . '/app/views/' . $mailerName); }
/** * Parse options to build message body string * * @param string * @return string */ protected function _parseMessageBody($methodName) { // template for body - copy instance variables $view = new Mad_View_Base(); foreach ($this->body as $key => $value) { $view->{$key} = $value; } $template = get_class($this) . "/{$methodName}.html"; $content = $view->render($template); $body = "This is a message in MIME format. If you see this,\r\n" . "your mail reader does not support the MIME format.\r\n\r\n"; // Text body $body .= "--{$this->_mimeBoundary}\r\n"; $body .= "Content-Type: text/plain; charset=\"{$this->charset}\"\r\n"; $body .= "Content-Disposition: inline\r\n"; $body .= "Content-Transfer-Encoding: 8bit\r\n"; $body .= "{$content}\r\n\r\n"; // Attachments (important to keep the double newlines) foreach ($this->_attachments as $filename => $options) { $encoded = base64_encode($options['body']); $chunked = chunk_split($encoded, 76, "\r\n"); $body .= "--{$this->_mimeBoundary}\r\n"; $body .= "Content-Type: " . $options["contentType"] . "; charset=\"{$this->charset}\"\r\n"; $body .= "Content-Disposition: attachment; filename=\"{$filename}\"\r\n"; $body .= "Content-Transfer-Encoding: " . $options['transferEncoding'] . "\r\n\r\n"; $body .= $chunked . "\r\n"; } $body .= "--{$this->_mimeBoundary}--\r\n\r\n"; return $this->_body = $body; }