Esempio n. 1
0
 /**
  * Render an error page.
  */
 public function render()
 {
     $error = $this->getError();
     $messageBox = new Template('sledgehammer/mvc/templates/httperror.php', $error);
     $messageBox->render();
     foreach ($this->options as $option => $value) {
         switch ((string) $option) {
             case 'notice':
             case 'warning':
                 $function = $option;
                 if (is_array($value)) {
                     call_user_func_array($function, $value);
                 } else {
                     call_user_func($function, $value);
                 }
                 break;
             case 'exception':
                 \Sledgehammer\report_exception($value);
                 break;
             default:
                 \Sledgehammer\notice('Unknown option: "' . $option . '"', array('value' => $value));
                 break;
         }
     }
 }
Esempio n. 2
0
 /**
  * Het document genereren.
  */
 public function render()
 {
     if ($this->headers == null) {
         notice(get_class($this) . '->getHeaders() should be executed before ' . get_class($this) . '->render()');
     }
     $variables = array('charset' => $this->headers['charset'], 'title' => array_value($this->headers, 'title'), 'head' => array(), 'htmlParameters' => \Sledgehammer\implode_xml_parameters($this->headers['htmlParameters']), 'bodyParameters' => \Sledgehammer\implode_xml_parameters($this->headers['bodyParameters']), 'body' => $this->content, 'showStatusbar' => $this->showStatusbar);
     $validHeaders = array('http', 'title', 'charset', 'css', 'meta', 'link', 'javascript', 'htmlParameters', 'bodyParameters');
     foreach ($this->headers as $key => $value) {
         if (!in_array($key, $validHeaders)) {
             notice('Invalid header: "' . $key . '", expecting "' . \Sledgehammer\human_implode('" or "', $validHeaders, '", "') . '"');
         }
     }
     // tags binnen de <head> instellen
     $head = array('meta' => array(), 'link' => array());
     if (isset($this->headers['meta'])) {
         $head['meta'] = $this->headers['meta'];
     }
     if (isset($this->headers['link'])) {
         $head['link'] = $this->headers['link'];
     }
     if (isset($this->headers['css'])) {
         foreach ($this->headers['css'] as $url) {
             $head['link'][] = array('href' => $url, 'type' => 'text/css', 'rel' => 'stylesheet');
         }
     }
     $eot = $this->doctype === 'xhtml' ? ' />' : '>';
     // End of Tag instellen
     foreach ($head as $tag => $tags) {
         foreach ($tags as $parameters) {
             $variables['head'][] = '<' . $tag . \Sledgehammer\implode_xml_parameters($parameters) . $eot;
         }
     }
     if (isset($this->headers['javascript'])) {
         foreach ($this->headers['javascript'] as $identifier => $url) {
             if (is_int($identifier)) {
                 $identifier = $parameters['src'];
             }
             ob_start();
             javascript_once($url, $identifier);
             $variables['head'][] = ob_get_clean();
         }
     }
     $template = new Template('sledgehammer/mvc/templates/doctype/' . $this->doctype . '.php', $variables);
     $template->render();
 }