diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index 68b255fc7..323b762d0 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -112,7 +112,7 @@ class Controller extends Object { * @var array * @link http://book.cakephp.org/view/1231/Pagination */ - public $paginate = array('limit' => 20, 'page' => 1); + public $paginate = array('limit' => 20, 'page' => 1, 'maxLimit' => 100); /** * The name of the views subfolder containing views for this controller. @@ -1068,8 +1068,8 @@ class Controller extends Object { unset($defaults[0]); } - $options = array_merge(array('page' => 1, 'limit' => 20), $defaults, $options); - $options['limit'] = (int) $options['limit']; + $options = array_merge(array('page' => 1, 'limit' => 20, 'maxLimit' => 100), $defaults, $options); + $options['limit'] = min((int)$options['limit'], $options['maxLimit']); if (empty($options['limit']) || $options['limit'] < 1) { $options['limit'] = 1; } @@ -1108,7 +1108,7 @@ class Controller extends Object { } elseif (intval($page) < 1) { $options['page'] = $page = 1; } - $page = $options['page'] = (integer)$page; + $page = $options['page'] = (int)$page; if (method_exists($object, 'paginate')) { $results = $object->paginate( diff --git a/lib/Cake/Utility/ObjectCollection.php b/lib/Cake/Utility/ObjectCollection.php index b2a6eb443..e9dd53abe 100644 --- a/lib/Cake/Utility/ObjectCollection.php +++ b/lib/Cake/Utility/ObjectCollection.php @@ -1,10 +1,5 @@ _loaded`. Enabled objects are stored in `$this->_enabled`. In addition + * the all support an `enabled` option that controls the enabled/disabled state of the object + * when loaded. + * + * @package cake.libs + * @since CakePHP(tm) v 2.0 + */ abstract class ObjectCollection { /** diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php index 25f62f2be..f9d26e447 100644 --- a/lib/Cake/View/Helper.php +++ b/lib/Cake/View/Helper.php @@ -105,6 +105,30 @@ class Helper extends Object { */ protected $_View; +/** + * Minimized attributes + * + * @var array + */ + protected $_minimizedAttributes = array( + 'compact', 'checked', 'declare', 'readonly', 'disabled', 'selected', + 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize' + ); + +/** + * Format to attribute + * + * @var string + */ + protected $_attributeFormat = '%s="%s"'; + +/** + * Format to attribute + * + * @var string + */ + protected $_minimizedAttributeFormat = '%s="%s"'; + /** * Default Constructor * @@ -358,7 +382,7 @@ class Helper extends Object { foreach ($options as $key => $value) { if (!isset($exclude[$key]) && $value !== false && $value !== null) { - $attributes[] = $this->__formatAttribute($key, $value, $escape); + $attributes[] = $this->_formatAttribute($key, $value, $escape); } } $out = implode(' ', $attributes); @@ -375,30 +399,21 @@ class Helper extends Object { * @param string $key The name of the attribute to create * @param string $value The value of the attribute to create. * @return string The composed attribute. - * @access private */ - function __formatAttribute($key, $value, $escape = true) { + protected function _formatAttribute($key, $value, $escape = true) { $attribute = ''; - $attributeFormat = '%s="%s"'; - static $minimizedAttributes = array(); - if (empty($minimizedAttributes)) { - $minimizedAttributes = array_flip(array( - 'compact', 'checked', 'declare', 'readonly', 'disabled', - 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', - 'multiple', 'noresize' - )); - } - if (is_array($value)) { $value = ''; } - if (isset($minimizedAttributes[$key])) { + if (is_numeric($key)) { + $attribute = sprintf($this->_minimizedAttributeFormat, $value, $value); + } elseif (in_array($key, $this->_minimizedAttributes)) { if ($value === 1 || $value === true || $value === 'true' || $value === '1' || $value == $key) { - $attribute = sprintf($attributeFormat, $key, $key); + $attribute = sprintf($this->_minimizedAttributeFormat, $key, $key); } } else { - $attribute = sprintf($attributeFormat, $key, ($escape ? h($value) : $value)); + $attribute = sprintf($this->_attributeFormat, $key, ($escape ? h($value) : $value)); } return $attribute; } diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 2d23d220d..190deb3cc 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -85,12 +85,12 @@ * Only runs if debug level is greater than zero. * * @param boolean $var Variable to show debug information for. - * @param boolean $showHtml If set to true, the method prints the debug data in a screen-friendly way. + * @param boolean $showHtml If set to true, the method prints the debug data in a browser-friendly way. * @param boolean $showFrom If set to true, the method prints from where the function was called. * @link http://book.cakephp.org/view/1190/Basic-Debugging * @link http://book.cakephp.org/view/1128/debug */ - function debug($var = false, $showHtml = false, $showFrom = true) { + function debug($var = false, $showHtml = null, $showFrom = true) { if (Configure::read('debug') > 0) { $file = ''; $line = ''; @@ -116,10 +116,14 @@ TEXT; $template = $html; if (php_sapi_name() == 'cli') { $template = $text; + } else { + if ($showHtml === null) { + $showHtml = true; + } } $var = print_r($var, true); if ($showHtml) { - $var = str_replace('<', '<', str_replace('>', '>', $var)); + $var = str_replace(array('<', '>'), array('<', '>'), $var); } printf($template, $file, $line, $var); } diff --git a/lib/Cake/tests/cases/basics.test.php b/lib/Cake/tests/cases/basics.test.php index b3b028cd4..7251ab82d 100644 --- a/lib/Cake/tests/cases/basics.test.php +++ b/lib/Cake/tests/cases/basics.test.php @@ -687,12 +687,20 @@ class BasicsTest extends CakeTestCase { $this->assertPattern($pattern, $result); ob_start(); - debug('