1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace ICanBoogie\Exception;
13
14 use ICanBoogie\Exception;
15 use ICanBoogie\Module;
16
17 class Config extends Exception
18 {
19 public function __construct($message, array $params=array(), $code=500)
20 {
21 global $core;
22
23 if (is_string($message) && isset($core->modules->descriptors[$message]))
24 {
25 $message = $core->modules[$message];
26 }
27
28 if ($message instanceof Module)
29 {
30 $params += array
31 (
32 ':module_id' => (string) $message,
33 '!title' => (string) $message
34 );
35
36 $message = 'You need to <a href="' . $core->site->path . '/admin/:module_id/config">configure the <q>!title</q> module</a>.';
37 }
38
39 parent::__construct($message, $params, $code);
40 }
41
42 public function __toString()
43 {
44 parent::__toString();
45
46 if ($this->code && !headers_sent())
47 {
48 header('HTTP/1.0 ' . $this->code . ' ' . $this->title);
49 }
50
51 $rc = '<code class="exception">';
52 $rc .= '<strong>' . $this->title . ', with the following message:</strong><br /><br />';
53 $rc .= $this->getMessage() . '<br />';
54 $rc .= '</code>';
55
56 return $rc;
57 }
58 }