MyController.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. App::uses('Controller', 'Controller');
  3. /**
  4. * DRY Controller stuff
  5. */
  6. class MyController extends Controller {
  7. /**
  8. * @var array
  9. * @link https://github.com/cakephp/cakephp/pull/857
  10. */
  11. public $paginate = array();
  12. /**
  13. * Fix for asset compress to not run into fatal error loops
  14. */
  15. public function __construct($request = null, $response = null) {
  16. parent::__construct($request, $response);
  17. if ($this->request !== null && (strpos($this->request->here, '/js/cjs/') === 0 || strpos($this->request->here, '/css/ccss/') === 0)) {
  18. unset($this->request->params['ext']);
  19. }
  20. }
  21. /**
  22. * Add headers for IE8 etc to fix caching issues in those stupid browsers
  23. *
  24. * @overwrite to fix IE cacheing issues
  25. * @return void
  26. */
  27. public function disableCache() {
  28. $this->response->header(array(
  29. 'Pragma' => 'no-cache',
  30. ));
  31. return parent::disableCache();
  32. }
  33. /**
  34. * Handles automatic pagination of model records.
  35. *
  36. * @overwrite to support defaults like limit, querystring settings
  37. * @param Model|string $object Model to paginate (e.g: model instance, or 'Model', or 'Model.InnerModel')
  38. * @param string|array $scope Conditions to use while paginating
  39. * @param array $whitelist List of allowed options for paging
  40. * @return array Model query results
  41. */
  42. public function paginate($object = null, $scope = array(), $whitelist = array()) {
  43. if ($defaultSettings = (array)Configure::read('Paginator')) {
  44. $this->paginate += $defaultSettings;
  45. }
  46. return parent::paginate($object, $scope, $whitelist);
  47. }
  48. }