CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 1.2 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 1.2
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Classes

  • AclBase
  • AclBehavior
  • AclComponent
  • AclNode
  • AclShell
  • Aco
  • AcoAction
  • AjaxHelper
  • ApcEngine
  • ApiShell
  • App
  • AppController
  • AppHelper
  • AppModel
  • Aro
  • AuthComponent
  • BakeShell
  • BehaviorCollection
  • Cache
  • CacheEngine
  • CacheHelper
  • CakeErrorController
  • CakeLog
  • CakeSchema
  • CakeSession
  • CakeSocket
  • ClassRegistry
  • Component
  • Configure
  • ConnectionManager
  • ConsoleShell
  • ContainableBehavior
  • Controller
  • ControllerTask
  • CookieComponent
  • DataSource
  • DbAcl
  • DbAclSchema
  • DbConfigTask
  • DboAdodb
  • DboDb2
  • DboFirebird
  • DboMssql
  • DboMysql
  • DboMysqlBase
  • DboMysqli
  • DboOdbc
  • DboOracle
  • DboPostgres
  • DboSource
  • DboSqlite
  • DboSybase
  • Debugger
  • EmailComponent
  • ErrorHandler
  • ExtractTask
  • File
  • FileEngine
  • Flay
  • Folder
  • FormHelper
  • Helper
  • HtmlHelper
  • HttpSocket
  • I18n
  • I18nModel
  • i18nSchema
  • I18nShell
  • Inflector
  • IniAcl
  • JavascriptHelper
  • JsHelper
  • JsHelperObject
  • L10n
  • MagicDb
  • MagicFileResource
  • MediaView
  • MemcacheEngine
  • Model
  • ModelBehavior
  • ModelTask
  • Multibyte
  • NumberHelper
  • Object
  • Overloadable
  • Overloadable2
  • PagesController
  • PaginatorHelper
  • Permission
  • PluginTask
  • ProjectTask
  • RequestHandlerComponent
  • Router
  • RssHelper
  • Sanitize
  • Scaffold
  • ScaffoldView
  • SchemaShell
  • Security
  • SecurityComponent
  • SessionComponent
  • SessionHelper
  • SessionsSchema
  • Set
  • Shell
  • String
  • TestSuiteShell
  • TestTask
  • TextHelper
  • ThemeView
  • TimeHelper
  • TranslateBehavior
  • TreeBehavior
  • Validation
  • View
  • ViewTask
  • XcacheEngine
  • Xml
  • XmlElement
  • XmlHelper
  • XmlManager
  • XmlNode
  • XmlTextNode

Functions

  • __enclose
  • make_clean_css
  • mb_encode_mimeheader
  • mb_stripos
  • mb_stristr
  • mb_strlen
  • mb_strpos
  • mb_strrchr
  • mb_strrichr
  • mb_strripos
  • mb_strrpos
  • mb_strstr
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count
  • write_css_cache
  1: <?php
  2: /* SVN FILE: $Id$ */
  3: /**
  4:  * Error handler
  5:  *
  6:  * Provides Error Capturing for Framework errors.
  7:  *
  8:  * PHP versions 4 and 5
  9:  *
 10:  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 11:  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 12:  *
 13:  * Licensed under The MIT License
 14:  * Redistributions of files must retain the above copyright notice.
 15:  *
 16:  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 17:  * @link          http://cakephp.org CakePHP(tm) Project
 18:  * @package       cake
 19:  * @subpackage    cake.cake.libs
 20:  * @since         CakePHP(tm) v 0.10.5.1732
 21:  * @version       $Revision$
 22:  * @modifiedby    $LastChangedBy$
 23:  * @lastmodified  $Date$
 24:  * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 25:  */
 26: App::import('Controller', 'App');
 27: /**
 28:  * Error Handling Controller
 29:  *
 30:  * Controller used by ErrorHandler to render error views.
 31:  *
 32:  * @package       cake
 33:  * @subpackage    cake.cake.libs
 34:  */
 35: class CakeErrorController extends AppController {
 36:     var $name = 'CakeError';
 37: /**
 38:  * Uses Property
 39:  *
 40:  * @var array
 41:  */
 42:     var $uses = array();
 43: /**
 44:  * __construct
 45:  *
 46:  * @access public
 47:  * @return void
 48:  */
 49:     function __construct() {
 50:         parent::__construct();
 51:         $this->_set(Router::getPaths());
 52:         $this->params = Router::getParams();
 53:         $this->constructClasses();
 54:         $this->Component->initialize($this);
 55:         $this->_set(array('cacheAction' => false, 'viewPath' => 'errors'));
 56:     }
 57: }
 58: /**
 59:  * Error Handler.
 60:  *
 61:  * Captures and handles all cakeError() calls.
 62:  * Displays helpful framework errors when debug > 1.
 63:  * When debug < 1 cakeError() will render 404 or 500 errors.
 64:  *
 65:  * @package       cake
 66:  * @subpackage    cake.cake.libs
 67:  */
 68: class ErrorHandler extends Object {
 69: /**
 70:  * Controller instance.
 71:  *
 72:  * @var Controller
 73:  * @access public
 74:  */
 75:     var $controller = null;
 76: /**
 77:  * Class constructor.
 78:  *
 79:  * @param string $method Method producing the error
 80:  * @param array $messages Error messages
 81:  */
 82:     function __construct($method, $messages) {
 83:         App::import('Core', 'Sanitize');
 84:         static $__previousError = null;
 85: 
 86:         if ($__previousError != array($method, $messages)) {
 87:             $__previousError = array($method, $messages);
 88:             $this->controller =& new CakeErrorController();
 89:         } else {
 90:             $this->controller =& new Controller();
 91:             $this->controller->viewPath = 'errors';
 92:         }
 93: 
 94:         $options = array('escape' => false);
 95:         $messages = Sanitize::clean($messages, $options);
 96: 
 97:         if (!isset($messages[0])) {
 98:             $messages = array($messages);
 99:         }
100: 
101:         if (method_exists($this->controller, 'apperror')) {
102:             return $this->controller->appError($method, $messages);
103:         }
104: 
105:         if (!in_array(strtolower($method), array_map('strtolower', get_class_methods($this)))) {
106:             $method = 'error';
107:         }
108: 
109:         if ($method !== 'error') {
110:             if (Configure::read() == 0) {
111:                 $method = 'error404';
112:                 if (isset($code) && $code == 500) {
113:                     $method = 'error500';
114:                 }
115:             }
116:         }
117:         $this->dispatchMethod($method, $messages);
118:         $this->_stop();
119:     }
120: /**
121:  * Displays an error page (e.g. 404 Not found).
122:  *
123:  * @param array $params Parameters for controller
124:  * @access public
125:  */
126:     function error($params) {
127:         extract($params, EXTR_OVERWRITE);
128:         $this->controller->set(array(
129:             'code' => $code,
130:             'name' => $name,
131:             'message' => $message,
132:             'title' => $code . ' ' . $name
133:         ));
134:         $this->_outputMessage('error404');
135:     }
136: /**
137:  * Convenience method to display a 404 page.
138:  *
139:  * @param array $params Parameters for controller
140:  * @access public
141:  */
142:     function error404($params) {
143:         extract($params, EXTR_OVERWRITE);
144: 
145:         if (!isset($url)) {
146:             $url = $this->controller->here;
147:         }
148:         $url = Router::normalize($url);
149:         header("HTTP/1.0 404 Not Found");
150:         $this->controller->set(array(
151:             'code' => '404',
152:             'name' => __('Not Found', true),
153:             'message' => h($url),
154:             'base' => $this->controller->base
155:         ));
156:         $this->_outputMessage('error404');
157:     }
158: /**
159:  * Renders the Missing Controller web page.
160:  *
161:  * @param array $params Parameters for controller
162:  * @access public
163:  */
164:     function missingController($params) {
165:         extract($params, EXTR_OVERWRITE);
166: 
167:         $controllerName = str_replace('Controller', '', $className);
168:         $this->controller->set(array(
169:             'controller' => $className,
170:             'controllerName' => $controllerName,
171:             'title' => __('Missing Controller', true)
172:         ));
173:         $this->_outputMessage('missingController');
174:     }
175: /**
176:  * Renders the Missing Action web page.
177:  *
178:  * @param array $params Parameters for controller
179:  * @access public
180:  */
181:     function missingAction($params) {
182:         extract($params, EXTR_OVERWRITE);
183: 
184:         $controllerName = str_replace('Controller', '', $className);
185:         $this->controller->set(array(
186:             'controller' => $className,
187:             'controllerName' => $controllerName,
188:             'action' => $action,
189:             'title' => __('Missing Method in Controller', true)
190:         ));
191:         $this->_outputMessage('missingAction');
192:     }
193: /**
194:  * Renders the Private Action web page.
195:  *
196:  * @param array $params Parameters for controller
197:  * @access public
198:  */
199:     function privateAction($params) {
200:         extract($params, EXTR_OVERWRITE);
201: 
202:         $this->controller->set(array(
203:             'controller' => $className,
204:             'action' => $action,
205:             'title' => __('Trying to access private method in class', true)
206:         ));
207:         $this->_outputMessage('privateAction');
208:     }
209: /**
210:  * Renders the Missing Table web page.
211:  *
212:  * @param array $params Parameters for controller
213:  * @access public
214:  */
215:     function missingTable($params) {
216:         extract($params, EXTR_OVERWRITE);
217: 
218:         $this->controller->set(array(
219:             'model' => $className,
220:             'table' => $table,
221:             'title' => __('Missing Database Table', true)
222:         ));
223:         $this->_outputMessage('missingTable');
224:     }
225: /**
226:  * Renders the Missing Database web page.
227:  *
228:  * @param array $params Parameters for controller
229:  * @access public
230:  */
231:     function missingDatabase($params = array()) {
232:         $this->controller->set(array(
233:             'title' => __('Scaffold Missing Database Connection', true)
234:         ));
235:         $this->_outputMessage('missingScaffolddb');
236:     }
237: /**
238:  * Renders the Missing View web page.
239:  *
240:  * @param array $params Parameters for controller
241:  * @access public
242:  */
243:     function missingView($params) {
244:         extract($params, EXTR_OVERWRITE);
245: 
246:         $this->controller->set(array(
247:             'controller' => $className,
248:             'action' => $action,
249:             'file' => $file,
250:             'title' => __('Missing View', true)
251:         ));
252:         $this->_outputMessage('missingView');
253:     }
254: /**
255:  * Renders the Missing Layout web page.
256:  *
257:  * @param array $params Parameters for controller
258:  * @access public
259:  */
260:     function missingLayout($params) {
261:         extract($params, EXTR_OVERWRITE);
262: 
263:         $this->controller->layout = 'default';
264:         $this->controller->set(array(
265:             'file' => $file,
266:             'title' => __('Missing Layout', true)
267:         ));
268:         $this->_outputMessage('missingLayout');
269:     }
270: /**
271:  * Renders the Database Connection web page.
272:  *
273:  * @param array $params Parameters for controller
274:  * @access public
275:  */
276:     function missingConnection($params) {
277:         extract($params, EXTR_OVERWRITE);
278: 
279:         $this->controller->set(array(
280:             'model' => $className,
281:             'title' => __('Missing Database Connection', true)
282:         ));
283:         $this->_outputMessage('missingConnection');
284:     }
285: /**
286:  * Renders the Missing Helper file web page.
287:  *
288:  * @param array $params Parameters for controller
289:  * @access public
290:  */
291:     function missingHelperFile($params) {
292:         extract($params, EXTR_OVERWRITE);
293: 
294:         $this->controller->set(array(
295:             'helperClass' => Inflector::camelize($helper) . "Helper",
296:             'file' => $file,
297:             'title' => __('Missing Helper File', true)
298:         ));
299:         $this->_outputMessage('missingHelperFile');
300:     }
301: /**
302:  * Renders the Missing Helper class web page.
303:  *
304:  * @param array $params Parameters for controller
305:  * @access public
306:  */
307:     function missingHelperClass($params) {
308:         extract($params, EXTR_OVERWRITE);
309: 
310:         $this->controller->set(array(
311:             'helperClass' => Inflector::camelize($helper) . "Helper",
312:             'file' => $file,
313:             'title' => __('Missing Helper Class', true)
314:         ));
315:         $this->_outputMessage('missingHelperClass');
316:     }
317: /**
318:  * Renders the Missing Component file web page.
319:  *
320:  * @param array $params Parameters for controller
321:  * @access public
322:  */
323:     function missingComponentFile($params) {
324:         extract($params, EXTR_OVERWRITE);
325: 
326:         $this->controller->set(array(
327:             'controller' => $className,
328:             'component' => $component,
329:             'file' => $file,
330:             'title' => __('Missing Component File', true)
331:         ));
332:         $this->_outputMessage('missingComponentFile');
333:     }
334: /**
335:  * Renders the Missing Component class web page.
336:  *
337:  * @param array $params Parameters for controller
338:  * @access public
339:  */
340:     function missingComponentClass($params) {
341:         extract($params, EXTR_OVERWRITE);
342: 
343:         $this->controller->set(array(
344:             'controller' => $className,
345:             'component' => $component,
346:             'file' => $file,
347:             'title' => __('Missing Component Class', true)
348:         ));
349:         $this->_outputMessage('missingComponentClass');
350:     }
351: /**
352:  * Renders the Missing Model class web page.
353:  *
354:  * @param unknown_type $params Parameters for controller
355:  * @access public
356:  */
357:     function missingModel($params) {
358:         extract($params, EXTR_OVERWRITE);
359: 
360:         $this->controller->set(array(
361:             'model' => $className,
362:             'title' => __('Missing Model', true)
363:         ));
364:         $this->_outputMessage('missingModel');
365:     }
366: /**
367:  * Output message
368:  *
369:  * @access protected
370:  */
371:     function _outputMessage($template) {
372:         $this->controller->render($template);
373:         $this->controller->afterFilter();
374:         echo $this->controller->output;
375:     }
376: }
377: ?>
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs