Linux multi-monitor fullscreen support
[ryzomcore.git] / web / public_php / webtt / cake / console / error.php
blobe837d1b8dc1b1f8611e82f75fdab25b6732e2234
1 <?php
2 /**
3 * ErrorHandler for Console Shells
5 * PHP versions 4 and 5
7 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
8 * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
10 * Licensed under The MIT License
11 * Redistributions of files must retain the above copyright notice.
13 * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
14 * @link http://cakephp.org CakePHP(tm) Project
15 * @package cake
16 * @subpackage cake.cake.console
17 * @since CakePHP(tm) v 1.2.0.5074
18 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
21 /**
22 * Error Handler for Cake console.
24 * @package cake
25 * @subpackage cake.cake.console
27 class ErrorHandler extends Object {
29 /**
30 * Standard output stream.
32 * @var filehandle
33 * @access public
35 var $stdout;
37 /**
38 * Standard error stream.
40 * @var filehandle
41 * @access public
43 var $stderr;
45 /**
46 * Class constructor.
48 * @param string $method Method dispatching an error
49 * @param array $messages Error messages
51 function __construct($method, $messages) {
52 $this->stdout = fopen('php://stdout', 'w');
53 $this->stderr = fopen('php://stderr', 'w');
54 call_user_func_array(array(&$this, $method), $messages);
57 /**
58 * Displays an error page (e.g. 404 Not found).
60 * @param array $params Parameters (code, name, and message)
61 * @access public
63 function error($params) {
64 extract($params, EXTR_OVERWRITE);
65 $this->stderr($code . $name . $message."\n");
66 $this->_stop(1);
69 /**
70 * Convenience method to display a 404 page.
72 * @param array $params Parameters (url, message)
73 * @access public
75 function error404($params) {
76 extract($params, EXTR_OVERWRITE);
77 $this->error(array(
78 'code' => '404',
79 'name' => 'Not found',
80 'message' => sprintf(__("The requested address %s was not found on this server.", true), $url, $message)
81 ));
82 $this->_stop(1);
85 /**
86 * Renders the Missing Controller web page.
88 * @param array $params Parameters (className)
89 * @access public
91 function missingController($params) {
92 extract($params, EXTR_OVERWRITE);
93 $controllerName = str_replace('Controller', '', $className);
94 $this->stderr(sprintf(__("Missing Controller '%s'", true), $controllerName));
95 $this->_stop(1);
98 /**
99 * Renders the Missing Action web page.
101 * @param array $params Parameters (action, className)
102 * @access public
104 function missingAction($params) {
105 extract($params, EXTR_OVERWRITE);
106 $this->stderr(sprintf(__("Missing Method '%s' in '%s'", true), $action, $className));
107 $this->_stop(1);
111 * Renders the Private Action web page.
113 * @param array $params Parameters (action, className)
114 * @access public
116 function privateAction($params) {
117 extract($params, EXTR_OVERWRITE);
118 $this->stderr(sprintf(__("Trying to access private method '%s' in '%s'", true), $action, $className));
119 $this->_stop(1);
123 * Renders the Missing Table web page.
125 * @param array $params Parameters (table, className)
126 * @access public
128 function missingTable($params) {
129 extract($params, EXTR_OVERWRITE);
130 $this->stderr(sprintf(__("Missing database table '%s' for model '%s'", true), $table, $className));
131 $this->_stop(1);
135 * Renders the Missing Database web page.
137 * @param array $params Parameters
138 * @access public
140 function missingDatabase($params = array()) {
141 $this->stderr(__("Missing Database", true));
142 $this->_stop(1);
146 * Renders the Missing View web page.
148 * @param array $params Parameters (file, action, className)
149 * @access public
151 function missingView($params) {
152 extract($params, EXTR_OVERWRITE);
153 $this->stderr(sprintf(__("Missing View '%s' for '%s' in '%s'", true), $file, $action, $className));
154 $this->_stop(1);
158 * Renders the Missing Layout web page.
160 * @param array $params Parameters (file)
161 * @access public
163 function missingLayout($params) {
164 extract($params, EXTR_OVERWRITE);
165 $this->stderr(sprintf(__("Missing Layout '%s'", true), $file));
166 $this->_stop(1);
170 * Renders the Database Connection web page.
172 * @param array $params Parameters
173 * @access public
175 function missingConnection($params) {
176 extract($params, EXTR_OVERWRITE);
177 $this->stderr(__("Missing Database Connection. Try 'cake bake'", true));
178 $this->_stop(1);
182 * Renders the Missing Helper file web page.
184 * @param array $params Parameters (file, helper)
185 * @access public
187 function missingHelperFile($params) {
188 extract($params, EXTR_OVERWRITE);
189 $this->stderr(sprintf(__("Missing Helper file '%s' for '%s'", true), $file, Inflector::camelize($helper)));
190 $this->_stop(1);
194 * Renders the Missing Helper class web page.
196 * @param array $params Parameters (file, helper)
197 * @access public
199 function missingHelperClass($params) {
200 extract($params, EXTR_OVERWRITE);
201 $this->stderr(sprintf(__("Missing Helper class '%s' in '%s'", true), Inflector::camelize($helper), $file));
202 $this->_stop(1);
206 * Renders the Missing Component file web page.
208 * @param array $params Parameters (file, component)
209 * @access public
211 function missingComponentFile($params) {
212 extract($params, EXTR_OVERWRITE);
213 $this->stderr(sprintf(__("Missing Component file '%s' for '%s'", true), $file, Inflector::camelize($component)));
214 $this->_stop(1);
218 * Renders the Missing Component class web page.
220 * @param array $params Parameters (file, component)
221 * @access public
223 function missingComponentClass($params) {
224 extract($params, EXTR_OVERWRITE);
225 $this->stderr(sprintf(__("Missing Component class '%s' in '%s'", true), Inflector::camelize($component), $file));
226 $this->_stop(1);
230 * Renders the Missing Model class web page.
232 * @param array $params Parameters (className)
233 * @access public
235 function missingModel($params) {
236 extract($params, EXTR_OVERWRITE);
237 $this->stderr(sprintf(__("Missing model '%s'", true), $className));
238 $this->_stop(1);
242 * Outputs to the stdout filehandle.
244 * @param string $string String to output.
245 * @param boolean $newline If true, the outputs gets an added newline.
246 * @access public
248 function stdout($string, $newline = true) {
249 if ($newline) {
250 fwrite($this->stdout, $string . "\n");
251 } else {
252 fwrite($this->stdout, $string);
257 * Outputs to the stderr filehandle.
259 * @param string $string Error text to output.
260 * @access public
262 function stderr($string) {
263 fwrite($this->stderr, "Error: ". $string . "\n");