00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 App::import('Core', array('Component', 'View'));
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 class Controller extends Object {
00044
00045
00046
00047
00048
00049
00050 var $name = null;
00051
00052
00053
00054
00055
00056
00057 var $here = null;
00058
00059
00060
00061
00062
00063
00064 var $webroot = null;
00065
00066
00067
00068
00069
00070
00071 var $action = null;
00072
00073
00074
00075
00076
00077
00078
00079
00080 var $uses = false;
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 var $helpers = array('Html', 'Form');
00091
00092
00093
00094
00095
00096
00097
00098 var $params = array();
00099
00100
00101
00102
00103
00104
00105
00106 var $data = array();
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 var $paginate = array('limit' => 20, 'page' => 1);
00126
00127
00128
00129
00130
00131
00132 var $viewPath = null;
00133
00134
00135
00136
00137
00138
00139 var $layoutPath = null;
00140
00141
00142
00143
00144
00145
00146 var $viewVars = array();
00147
00148
00149
00150
00151
00152
00153
00154 var $pageTitle = false;
00155
00156
00157
00158
00159
00160
00161 var $modelNames = array();
00162
00163
00164
00165
00166
00167
00168 var $base = null;
00169
00170
00171
00172
00173
00174
00175
00176
00177 var $layout = 'default';
00178
00179
00180
00181
00182
00183
00184
00185 var $autoRender = true;
00186
00187
00188
00189
00190
00191
00192 var $autoLayout = true;
00193
00194
00195
00196
00197
00198
00199 var $Component = null;
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 var $components = array();
00210
00211
00212
00213
00214
00215
00216 var $view = 'View';
00217
00218
00219
00220
00221
00222
00223 var $ext = '.ctp';
00224
00225
00226
00227
00228
00229
00230
00231
00232 var $output = null;
00233
00234
00235
00236
00237
00238
00239 var $plugin = null;
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256 var $cacheAction = false;
00257
00258
00259
00260
00261
00262
00263
00264
00265 var $persistModel = false;
00266
00267
00268
00269
00270
00271
00272 var $passedArgs = array();
00273
00274
00275
00276
00277 function __construct() {
00278 if ($this->name === null) {
00279 $r = null;
00280 if (!preg_match('/(.*)Controller/i', get_class($this), $r)) {
00281 die (__("Controller::__construct() : Can not get or parse my own class name, exiting."));
00282 }
00283 $this->name = $r[1];
00284 }
00285
00286 if ($this->viewPath == null) {
00287 $this->viewPath = Inflector::underscore($this->name);
00288 }
00289 $this->modelClass = Inflector::classify($this->name);
00290 $this->modelKey = Inflector::underscore($this->modelClass);
00291 $this->Component =& new Component();
00292 parent::__construct();
00293 }
00294
00295
00296
00297
00298
00299
00300 function _initComponents() {
00301 trigger_error(__('Controller::_initComponents(); deprecated, use $this->Component->init($this);', true), E_USER_WARNING);
00302 $this->Component->init($this);
00303 }
00304
00305
00306
00307
00308
00309 function __mergeVars() {
00310 $pluginName = Inflector::camelize($this->plugin);
00311 $pluginController = $pluginName . 'AppController';
00312
00313 if (is_subclass_of($this, 'AppController') || is_subclass_of($this, $pluginController)) {
00314 $appVars = get_class_vars('AppController');
00315 $uses = $appVars['uses'];
00316 $merge = array('components', 'helpers');
00317 $plugin = null;
00318
00319 if (!empty($this->plugin)) {
00320 $plugin = $pluginName . '.';
00321 if (!is_subclass_of($this, $pluginController)) {
00322 $pluginController = null;
00323 }
00324 } else {
00325 $pluginController = null;
00326 }
00327
00328 if ($uses == $this->uses && !empty($this->uses)) {
00329 if (!in_array($plugin . $this->modelClass, $this->uses)) {
00330 array_unshift($this->uses, $plugin . $this->modelClass);
00331 } elseif ($this->uses[0] !== $plugin . $this->modelClass) {
00332 $this->uses = array_flip($this->uses);
00333 unset($this->uses[$plugin . $this->modelClass]);
00334 $this->uses = array_flip($this->uses);
00335 array_unshift($this->uses, $plugin . $this->modelClass);
00336 }
00337 } elseif ($this->uses !== null || $this->uses !== false) {
00338 $merge[] = 'uses';
00339 }
00340
00341 foreach ($merge as $var) {
00342 if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
00343 if ($var == 'components') {
00344 $normal = Set::normalize($this->{$var});
00345 $app = Set::normalize($appVars[$var]);
00346 $this->{$var} = Set::merge($normal, $app);
00347 } else {
00348 $this->{$var} = Set::merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
00349 }
00350 }
00351 }
00352 }
00353
00354 if ($pluginController) {
00355 $appVars = get_class_vars($pluginController);
00356 $uses = $appVars['uses'];
00357 $merge = array('components', 'helpers');
00358
00359 if ($this->uses !== null || $this->uses !== false) {
00360 $merge[] = 'uses';
00361 }
00362
00363 foreach ($merge as $var) {
00364 if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
00365 if ($var == 'components') {
00366 $normal = Set::normalize($this->{$var});
00367 $app = Set::normalize($appVars[$var]);
00368 $this->{$var} = Set::merge($normal, array_diff_assoc($app, $normal));
00369 } else {
00370 $this->{$var} = Set::merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
00371 }
00372 }
00373 }
00374 }
00375 }
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385 function constructClasses() {
00386 $this->__mergeVars();
00387 $this->Component->init($this);
00388
00389 if ($this->uses !== null || ($this->uses !== array())) {
00390 if (empty($this->passedArgs) || !isset($this->passedArgs['0'])) {
00391 $id = false;
00392 } else {
00393 $id = $this->passedArgs['0'];
00394 }
00395
00396 if ($this->uses === false) {
00397 $this->loadModel($this->modelClass, $id);
00398 } elseif ($this->uses) {
00399 $uses = is_array($this->uses) ? $this->uses : array($this->uses);
00400 $this->modelClass = $uses[0];
00401 foreach ($uses as $modelClass) {
00402 $this->loadModel($modelClass);
00403 }
00404 }
00405 }
00406 return true;
00407 }
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418 function loadModel($modelClass = null, $id = null) {
00419 if ($modelClass === null) {
00420 $modelClass = $this->modelClass;
00421 }
00422 $cached = false;
00423 $object = null;
00424 $plugin = null;
00425 if ($this->uses === false) {
00426 if ($this->plugin) {
00427 $plugin = $this->plugin . '.';
00428 }
00429 }
00430
00431 if (strpos($modelClass, '.') !== false) {
00432 list($plugin, $modelClass) = explode('.', $modelClass);
00433 $plugin = $plugin . '.';
00434 }
00435
00436 if ($this->persistModel === true) {
00437 $cached = $this->_persist($modelClass, null, $object);
00438 }
00439
00440 if (($cached === false)) {
00441 $this->modelNames[] = $modelClass;
00442
00443 if (!PHP5) {
00444 $this->{$modelClass} =& ClassRegistry::init(array('class' => $plugin . $modelClass, 'alias' => $modelClass, 'id' => $id));
00445 } else {
00446 $this->{$modelClass} = ClassRegistry::init(array('class' => $plugin . $modelClass, 'alias' => $modelClass, 'id' => $id));
00447 }
00448
00449 if (!$this->{$modelClass}) {
00450 return $this->cakeError('missingModel', array(array('className' => $modelClass, 'webroot' => '', 'base' => $this->base)));
00451 }
00452
00453 if ($this->persistModel === true) {
00454 $this->_persist($modelClass, true, $this->{$modelClass});
00455 $registry = ClassRegistry::getInstance();
00456 $this->_persist($modelClass . 'registry', true, $registry->__objects, 'registry');
00457 }
00458 } else {
00459 $this->_persist($modelClass . 'registry', true, $object, 'registry');
00460 $this->_persist($modelClass, true, $object);
00461 $this->modelNames[] = $modelClass;
00462 }
00463 }
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474 function redirect($url, $status = null, $exit = true) {
00475 $this->autoRender = false;
00476
00477 if (is_array($status)) {
00478 extract($status, EXTR_OVERWRITE);
00479 }
00480 $response = $this->Component->beforeRedirect($this, $url, $status, $exit);
00481
00482 if ($response === false) {
00483 return;
00484 }
00485 if (is_array($response)) {
00486 foreach ($response as $resp) {
00487 if (is_array($resp) && isset($resp['url'])) {
00488 extract($resp, EXTR_OVERWRITE);
00489 } elseif ($resp !== null) {
00490 $url = $resp;
00491 }
00492 }
00493 }
00494
00495 if (function_exists('session_write_close')) {
00496 session_write_close();
00497 }
00498
00499 if (!empty($status)) {
00500 $codes = array(
00501 100 => "Continue",
00502 101 => "Switching Protocols",
00503 200 => "OK",
00504 201 => "Created",
00505 202 => "Accepted",
00506 203 => "Non-Authoritative Information",
00507 204 => "No Content",
00508 205 => "Reset Content",
00509 206 => "Partial Content",
00510 300 => "Multiple Choices",
00511 301 => "Moved Permanently",
00512 302 => "Found",
00513 303 => "See Other",
00514 304 => "Not Modified",
00515 305 => "Use Proxy",
00516 307 => "Temporary Redirect",
00517 400 => "Bad Request",
00518 401 => "Unauthorized",
00519 402 => "Payment Required",
00520 403 => "Forbidden",
00521 404 => "Not Found",
00522 405 => "Method Not Allowed",
00523 406 => "Not Acceptable",
00524 407 => "Proxy Authentication Required",
00525 408 => "Request Time-out",
00526 409 => "Conflict",
00527 410 => "Gone",
00528 411 => "Length Required",
00529 412 => "Precondition Failed",
00530 413 => "Request Entity Too Large",
00531 414 => "Request-URI Too Large",
00532 415 => "Unsupported Media Type",
00533 416 => "Requested range not satisfiable",
00534 417 => "Expectation Failed",
00535 500 => "Internal Server Error",
00536 501 => "Not Implemented",
00537 502 => "Bad Gateway",
00538 503 => "Service Unavailable",
00539 504 => "Gateway Time-out"
00540 );
00541 if (is_string($status)) {
00542 $codes = array_combine(array_values($codes), array_keys($codes));
00543 }
00544
00545 if (isset($codes[$status])) {
00546 $code = ife(is_numeric($status), $status, $codes[$status]);
00547 $msg = ife(is_string($status), $status, $codes[$status]);
00548 $status = "HTTP/1.1 {$code} {$msg}";
00549 } else {
00550 $status = null;
00551 }
00552 }
00553
00554 if (!empty($status)) {
00555 $this->header($status);
00556 }
00557 if ($url !== null) {
00558 $this->header('Location: ' . Router::url($url, true));
00559 }
00560
00561 if (!empty($status) && ($status >= 300 && $status < 400)) {
00562 $this->header($status);
00563 }
00564
00565 if ($exit) {
00566 $this->_stop();
00567 }
00568 }
00569
00570
00571
00572
00573
00574
00575
00576 function header($status) {
00577 header($status);
00578 }
00579
00580
00581
00582
00583
00584
00585
00586
00587 function set($one, $two = null) {
00588 $data = array();
00589
00590 if (is_array($one)) {
00591 if (is_array($two)) {
00592 $data = array_combine($one, $two);
00593 } else {
00594 $data = $one;
00595 }
00596 } else {
00597 $data = array($one => $two);
00598 }
00599
00600 foreach ($data as $name => $value) {
00601 if ($name == 'title') {
00602 $this->pageTitle = $value;
00603 } else {
00604 if ($two === null && is_array($one)) {
00605 $this->viewVars[Inflector::variable($name)] = $value;
00606 } else {
00607 $this->viewVars[$name] = $value;
00608 }
00609 }
00610 }
00611 }
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624 function setAction($action) {
00625 $this->action = $action;
00626 $args = func_get_args();
00627 unset($args[0]);
00628 return call_user_func_array(array(&$this, $action), $args);
00629 }
00630
00631
00632
00633
00634
00635
00636 function isAuthorized() {
00637 trigger_error(sprintf(__('%s::isAuthorized() is not defined.', true), $this->name), E_USER_WARNING);
00638 return false;
00639 }
00640
00641
00642
00643
00644
00645
00646 function validate() {
00647 $args = func_get_args();
00648 $errors = call_user_func_array(array(&$this, 'validateErrors'), $args);
00649
00650 if ($errors === false) {
00651 return 0;
00652 }
00653 return count($errors);
00654 }
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664 function validateErrors() {
00665 $objects = func_get_args();
00666
00667 if (!count($objects)) {
00668 return false;
00669 }
00670
00671 $errors = array();
00672 foreach ($objects as $object) {
00673 $this->{$object->alias}->set($object->data);
00674 $errors = array_merge($errors, $this->{$object->alias}->invalidFields());
00675 }
00676
00677 return $this->validationErrors = (count($errors) ? $errors : false);
00678 }
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689 function render($action = null, $layout = null, $file = null) {
00690 $this->beforeRender();
00691
00692 $viewClass = $this->view;
00693 if ($this->view != 'View') {
00694 if (strpos($viewClass, '.') !== false) {
00695 list($plugin, $viewClass) = explode('.', $viewClass);
00696 }
00697 $viewClass = $viewClass . 'View';
00698 App::import('View', $this->view);
00699 }
00700
00701 $this->Component->beforeRender($this);
00702
00703 $this->params['models'] = $this->modelNames;
00704
00705 if (Configure::read() > 2) {
00706 $this->set('cakeDebug', $this);
00707 }
00708
00709 $View =& new $viewClass($this);
00710
00711 if (!empty($this->modelNames)) {
00712 $models = array();
00713 foreach ($this->modelNames as $currentModel) {
00714 if (isset($this->$currentModel) && is_a($this->$currentModel, 'Model')) {
00715 $models[] = Inflector::underscore($currentModel);
00716 }
00717 if (isset($this->$currentModel) && is_a($this->$currentModel, 'Model') && !empty($this->$currentModel->validationErrors)) {
00718 $View->validationErrors[Inflector::camelize($currentModel)] =& $this->$currentModel->validationErrors;
00719 }
00720 }
00721 $models = array_diff(ClassRegistry::keys(), $models);
00722 foreach ($models as $currentModel) {
00723 if (ClassRegistry::isKeySet($currentModel)) {
00724 $currentObject =& ClassRegistry::getObject($currentModel);
00725 if (is_a($currentObject, 'Model') && !empty($currentObject->validationErrors)) {
00726 $View->validationErrors[Inflector::camelize($currentModel)] =& $currentObject->validationErrors;
00727 }
00728 }
00729 }
00730 }
00731
00732 $this->autoRender = false;
00733 $this->output .= $View->render($action, $layout, $file);
00734
00735 return $this->output;
00736 }
00737
00738
00739
00740
00741
00742
00743
00744
00745 function referer($default = null, $local = false) {
00746 $ref = env('HTTP_REFERER');
00747 if (!empty($ref) && defined('FULL_BASE_URL')) {
00748 $base = FULL_BASE_URL . $this->webroot;
00749 if (strpos($ref, $base) === 0) {
00750 $return = substr($ref, strlen($base));
00751 if ($return[0] != '/') {
00752 $return = '/'.$return;
00753 }
00754 return $return;
00755 } elseif (!$local) {
00756 return $ref;
00757 }
00758 }
00759
00760 if ($default != null) {
00761 return $default;
00762 } else {
00763 return '/';
00764 }
00765 }
00766
00767
00768
00769
00770
00771 function disableCache() {
00772 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
00773 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
00774 header("Cache-Control: no-store, no-cache, must-revalidate");
00775 header("Cache-Control: post-check=0, pre-check=0", false);
00776 header("Pragma: no-cache");
00777 }
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787 function flash($message, $url, $pause = 1) {
00788 $this->autoRender = false;
00789 $this->set('url', Router::url($url));
00790 $this->set('message', $message);
00791 $this->set('pause', $pause);
00792 $this->set('page_title', $message);
00793 $this->render(false, 'flash');
00794 }
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806 function postConditions($data = array(), $op = null, $bool = 'AND', $exclusive = false) {
00807 if (!is_array($data) || empty($data)) {
00808 if (!empty($this->data)) {
00809 $data = $this->data;
00810 } else {
00811 return null;
00812 }
00813 }
00814 $cond = array();
00815
00816 if ($op === null) {
00817 $op = '';
00818 }
00819
00820 foreach ($data as $model => $fields) {
00821 foreach ($fields as $field => $value) {
00822 $key = $model.'.'.$field;
00823 $fieldOp = $op;
00824 if (is_array($op) && array_key_exists($key, $op)) {
00825 $fieldOp = $op[$key];
00826 } elseif (is_array($op) && array_key_exists($field, $op)) {
00827 $fieldOp = $op[$field];
00828 } elseif (is_array($op)) {
00829 $fieldOp = false;
00830 }
00831 if ($exclusive && $fieldOp === false) {
00832 continue;
00833 }
00834 $fieldOp = strtoupper(trim($fieldOp));
00835 if ($fieldOp == 'LIKE') {
00836 $key = $key.' LIKE';
00837 $value = '%'.$value.'%';
00838 } elseif ($fieldOp && $fieldOp != '=') {
00839 $key = $key.' '.$fieldOp;
00840 }
00841 $cond[$key] = $value;
00842 }
00843 }
00844 if ($bool != null && strtoupper($bool) != 'AND') {
00845 $cond = array($bool => $cond);
00846 }
00847 return $cond;
00848 }
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858 function paginate($object = null, $scope = array(), $whitelist = array()) {
00859 if (is_array($object)) {
00860 $whitelist = $scope;
00861 $scope = $object;
00862 $object = null;
00863 }
00864 $assoc = null;
00865
00866 if (is_string($object)) {
00867 $assoc = null;
00868
00869 if (strpos($object, '.') !== false) {
00870 list($object, $assoc) = explode('.', $object);
00871 }
00872
00873 if ($assoc && isset($this->{$object}->{$assoc})) {
00874 $object = $this->{$object}->{$assoc};
00875 } elseif ($assoc && isset($this->{$this->modelClass}) && isset($this->{$this->modelClass}->{$assoc})) {
00876 $object = $this->{$this->modelClass}->{$assoc};
00877 } elseif (isset($this->{$object})) {
00878 $object = $this->{$object};
00879 } elseif (isset($this->{$this->modelClass}) && isset($this->{$this->modelClass}->{$object})) {
00880 $object = $this->{$this->modelClass}->{$object};
00881 }
00882 } elseif (empty($object) || $object == null) {
00883 if (isset($this->{$this->modelClass})) {
00884 $object = $this->{$this->modelClass};
00885 } else {
00886 $className = null;
00887 $name = $this->uses[0];
00888 if (strpos($this->uses[0], '.') !== false) {
00889 list($name, $className) = explode('.', $this->uses[0]);
00890 }
00891 if ($className) {
00892 $object = $this->{$className};
00893 } else {
00894 $object = $this->{$name};
00895 }
00896 }
00897 }
00898
00899 if (!is_object($object)) {
00900 trigger_error(sprintf(__('Controller::paginate() - can\'t find model %1$s in controller %2$sController', true), $object, $this->name), E_USER_WARNING);
00901 return array();
00902 }
00903 $options = array_merge($this->params, $this->params['url'], $this->passedArgs);
00904
00905 if (isset($this->paginate[$object->alias])) {
00906 $defaults = $this->paginate[$object->alias];
00907 } else {
00908 $defaults = $this->paginate;
00909 }
00910
00911 if (isset($options['show'])) {
00912 $options['limit'] = $options['show'];
00913 }
00914
00915 if (isset($options['sort']) && isset($options['direction'])) {
00916 $options['order'] = array($options['sort'] => $options['direction']);
00917 } elseif (isset($options['sort'])) {
00918 $options['order'] = array($options['sort'] => 'asc');
00919 }
00920
00921 if (!empty($options['order']) && is_array($options['order'])) {
00922 $alias = $object->alias ;
00923 $key = $field = key($options['order']);
00924
00925 if (strpos($key, '.') !== false) {
00926 list($alias, $field) = explode('.', $key);
00927 }
00928 $value = $options['order'][$key];
00929 unset($options['order'][$key]);
00930
00931 if (isset($object->{$alias}) && $object->{$alias}->hasField($field)) {
00932 $options['order'][$alias . '.' . $field] = $value;
00933 } elseif ($object->hasField($field)) {
00934 $options['order'][$alias . '.' . $field] = $value;
00935 }
00936 }
00937 $vars = array('fields', 'order', 'limit', 'page', 'recursive');
00938 $keys = array_keys($options);
00939 $count = count($keys);
00940
00941 for ($i = 0; $i < $count; $i++) {
00942 if (!in_array($keys[$i], $vars)) {
00943 unset($options[$keys[$i]]);
00944 }
00945 if (empty($whitelist) && ($keys[$i] == 'fields' || $keys[$i] == 'recursive')) {
00946 unset($options[$keys[$i]]);
00947 } elseif (!empty($whitelist) && !in_array($keys[$i], $whitelist)) {
00948 unset($options[$keys[$i]]);
00949 }
00950 }
00951 $conditions = $fields = $order = $limit = $page = $recursive = null;
00952
00953 if (!isset($defaults['conditions'])) {
00954 $defaults['conditions'] = array();
00955 }
00956 extract($options = array_merge(array('page' => 1, 'limit' => 20), $defaults, $options));
00957
00958 if (is_array($scope) && !empty($scope)) {
00959 $conditions = array_merge($conditions, $scope);
00960 } elseif (is_string($scope)) {
00961 $conditions = array($conditions, $scope);
00962 }
00963 if ($recursive === null) {
00964 $recursive = $object->recursive;
00965 }
00966 $type = 'all';
00967
00968 if (isset($defaults[0])) {
00969 $type = array_shift($defaults);
00970 }
00971 $extra = array_diff_key($defaults, compact('conditions', 'fields', 'order', 'limit', 'page', 'recursive'));
00972
00973 if (method_exists($object, 'paginateCount')) {
00974 $count = $object->paginateCount($conditions, $recursive);
00975 } else {
00976 $parameters = compact('conditions');
00977 if ($recursive != $object->recursive) {
00978 $parameters['recursive'] = $recursive;
00979 }
00980 $count = $object->find('count', array_merge($parameters, $extra));
00981 }
00982 $pageCount = intval(ceil($count / $limit));
00983
00984 if ($page == 'last' || $page >= $pageCount) {
00985 $options['page'] = $page = $pageCount;
00986 } elseif (intval($page) < 1) {
00987 $options['page'] = $page = 1;
00988 }
00989
00990 if (method_exists($object, 'paginate')) {
00991 $results = $object->paginate($conditions, $fields, $order, $limit, $page, $recursive);
00992 } else {
00993 $parameters = compact('conditions', 'fields', 'order', 'limit', 'page');
00994 if ($recursive != $object->recursive) {
00995 $parameters['recursive'] = $recursive;
00996 }
00997 $results = $object->find($type, array_merge($parameters, $extra));
00998 }
00999 $paging = array(
01000 'page' => $page,
01001 'current' => count($results),
01002 'count' => $count,
01003 'prevPage' => ($page > 1),
01004 'nextPage' => ($count > ($page * $limit)),
01005 'pageCount' => $pageCount,
01006 'defaults' => array_merge(array('limit' => 20, 'step' => 1), $defaults),
01007 'options' => $options
01008 );
01009 $this->params['paging'][$object->alias] = $paging;
01010
01011 if (!in_array('Paginator', $this->helpers) && !array_key_exists('Paginator', $this->helpers)) {
01012 $this->helpers[] = 'Paginator';
01013 }
01014 return $results;
01015 }
01016
01017
01018
01019
01020
01021 function beforeFilter() {
01022 }
01023
01024
01025
01026
01027
01028 function beforeRender() {
01029 }
01030
01031
01032
01033
01034
01035 function afterFilter() {
01036 }
01037
01038
01039
01040
01041
01042
01043
01044 function _beforeScaffold($method) {
01045 return true;
01046 }
01047
01048
01049
01050
01051
01052
01053
01054 function _afterScaffoldSave($method) {
01055 return true;
01056 }
01057
01058
01059
01060
01061
01062
01063
01064 function _afterScaffoldSaveError($method) {
01065 return true;
01066 }
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076 function _scaffoldError($method) {
01077 return false;
01078 }
01079 }
01080 ?>