From 0ce4716175fdd4bcc6d1d0eae42491632114d617 Mon Sep 17 00:00:00 2001
From: Thinking Song <123wuming_123@163.com>
Date: Mon, 9 Apr 2012 16:44:54 +0800
Subject: [PATCH 1/3] add form tip you can use form tip like this:
$this->Form->input('name', array('tip'=>'name must be not empty'));
---
View/Helper/BootstrapFormHelper.php | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/View/Helper/BootstrapFormHelper.php b/View/Helper/BootstrapFormHelper.php
index e420621..f898e9b 100644
--- a/View/Helper/BootstrapFormHelper.php
+++ b/View/Helper/BootstrapFormHelper.php
@@ -67,7 +67,13 @@ public function input($fieldName, $params = array()) {
if (!isset($options['after'])) {
$options['after'] = '';
}
+ //$options['after'] .= '';
+ // add form tip
+ if(isset($options['tip'])){
+ $options['after'] .= '
'.$options['tip'].'
';
+ }else{
$options['after'] .= '';
+ }
if (isset($options['label']) && is_string($options['label'])) {
$options['label'] = array(
From 54b8dcebf749200a10857c1f5f4b2c3f02cdf308 Mon Sep 17 00:00:00 2001
From: Thinking Song <123wuming_123@163.com>
Date: Mon, 9 Apr 2012 16:57:03 +0800
Subject: [PATCH 2/3] add BootstrapPaginatorHelper
use paginator with bootstrap style
you can use it like this:
---
View/Helper/BootstrapPaginatorHelper.php | 207 +++++++++++++++++++++++
1 file changed, 207 insertions(+)
create mode 100644 View/Helper/BootstrapPaginatorHelper.php
diff --git a/View/Helper/BootstrapPaginatorHelper.php b/View/Helper/BootstrapPaginatorHelper.php
new file mode 100644
index 0000000..bf7e918
--- /dev/null
+++ b/View/Helper/BootstrapPaginatorHelper.php
@@ -0,0 +1,207 @@
+Paginator->numbers(array('first' => 2, 'last' => 2));`
+ *
+ * Using the first and last options you can create links to the beginning and end of the page set.
+ *
+ * ### Options
+ *
+ * - `before` Content to be inserted before the numbers
+ * - `after` Content to be inserted after the numbers
+ * - `model` Model to create numbers for, defaults to PaginatorHelper::defaultModel()
+ * - `modulus` how many numbers to include on either side of the current page, defaults to 8.
+ * - `separator` Separator content defaults to ' | '
+ * - `tag` The tag to wrap links in, defaults to 'span'
+ * - `first` Whether you want first links generated, set to an integer to define the number of 'first'
+ * links to generate.
+ * - `last` Whether you want last links generated, set to an integer to define the number of 'last'
+ * links to generate.
+ * - `ellipsis` Ellipsis content, defaults to '...'
+ *
+ * @param mixed $options Options for the numbers, (before, after, model, modulus, separator)
+ * @return string numbers string.
+ * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::numbers
+ */
+ public function numbers($options = array()) {
+ if ($options === true) {
+ $options = array(
+ 'before' => ' | ', 'after' => ' | ', 'first' => 'first', 'last' => 'last'
+ );
+ }
+
+ $defaults = array(
+ 'tag' => 'li', 'before' => null, 'after' => null, 'model' => $this->defaultModel(), 'class' => null,
+ 'modulus' => '8', 'separator' => '', 'first' => null, 'last' => null, 'ellipsis' => '...',
+ );
+ $options += $defaults;
+
+ $params = (array)$this->params($options['model']) + array('page' => 1);
+ unset($options['model']);
+
+ if ($params['pageCount'] <= 1) {
+ return false;
+ }
+
+ extract($options);
+ unset($options['tag'], $options['before'], $options['after'], $options['model'],
+ $options['modulus'], $options['separator'], $options['first'], $options['last'],
+ $options['ellipsis'], $options['class']
+ );
+
+ $out = '';
+
+ if ($modulus && $params['pageCount'] > $modulus) {
+ $half = intval($modulus / 2);
+ $end = $params['page'] + $half;
+
+ if ($end > $params['pageCount']) {
+ $end = $params['pageCount'];
+ }
+ $start = $params['page'] - ($modulus - ($end - $params['page']));
+ if ($start <= 1) {
+ $start = 1;
+ $end = $params['page'] + ($modulus - $params['page']) + 1;
+ }
+
+ if ($first && $start > 1) {
+ $offset = ($start <= (int)$first) ? $start - 1 : $first;
+ if ($offset < $start - 1) {
+ $out .= $this->first($offset, compact('tag', 'separator', 'ellipsis', 'class'));
+ } else {
+ $out .= $this->first($offset, compact('tag', 'separator', 'class') + array('after' => $separator));
+ }
+ }
+
+ $out .= $before;
+
+ for ($i = $start; $i < $params['page']; $i++) {
+ $out .= $this->Html->tag($tag, $this->link($i, array('page' => $i), $options), compact('class'))
+ . $separator;
+ }
+
+ $currentClass = 'current';
+ if ($class) {
+ $currentClass .= ' ' . $class;
+ }
+ $out .= $this->Html->tag($tag, $params['page'], array('class' => $currentClass));
+ if ($i != $params['pageCount']) {
+ $out .= $separator;
+ }
+
+ $start = $params['page'] + 1;
+ for ($i = $start; $i < $end; $i++) {
+ $out .= $this->Html->tag($tag, $this->link($i, array('page' => $i), $options), compact('class'))
+ . $separator;
+ }
+
+ if ($end != $params['page']) {
+ $out .= $this->Html->tag($tag, $this->link($i, array('page' => $end), $options), compact('class'));
+ }
+
+ $out .= $after;
+
+ if ($last && $end < $params['pageCount']) {
+ $offset = ($params['pageCount'] < $end + (int)$last) ? $params['pageCount'] - $end : $last;
+ if ($offset <= $last && $params['pageCount'] - $end > $offset) {
+ $out .= $this->last($offset, compact('tag', 'separator', 'ellipsis', 'class'));
+ } else {
+ $out .= $this->last($offset, compact('tag', 'separator', 'class') + array('before' => $separator));
+ }
+ }
+
+ } else {
+ $out .= $before;
+
+ for ($i = 1; $i <= $params['pageCount']; $i++) {
+ if ($i == $params['page']) {
+ $currentClass = 'active';
+ if ($class) {
+ $currentClass .= ' ' . $class;
+ }
+ $out .= $this->Html->tag($tag, $this->link($i, array('page' => $i)), array('class' => $currentClass));
+ } else {
+ $out .= $this->Html->tag($tag, $this->link($i, array('page' => $i), $options), compact('class'));
+ }
+ if ($i != $params['pageCount']) {
+ $out .= $separator;
+ }
+ }
+
+ $out .= $after;
+ }
+
+ return $out;
+ }
+ /**
+ * Protected method for generating prev/next links
+ *
+ * @param string $which
+ * @param string $title
+ * @param array $options
+ * @param string $disabledTitle
+ * @param array $disabledOptions
+ * @return string
+ */
+ protected function _pagingLink($which, $title = null, $options = array(), $disabledTitle = null, $disabledOptions = array()) {
+ $check = 'has' . $which;
+ $_defaults = array(
+ 'url' => array(), 'step' => 1, 'escape' => true,
+ 'model' => null, 'tag' => 'li', 'class' => strtolower($which)
+ );
+ $options = array_merge($_defaults, (array)$options);
+ $paging = $this->params($options['model']);
+ if (empty($disabledOptions)) {
+ $disabledOptions = $options;
+ }
+
+ if (!$this->{$check}($options['model']) && (!empty($disabledTitle) || !empty($disabledOptions))) {
+ if (!empty($disabledTitle) && $disabledTitle !== true) {
+ $title = $disabledTitle;
+ }
+ $options = array_merge($_defaults, (array)$disabledOptions);
+ } elseif (!$this->{$check}($options['model'])) {
+ return null;
+ }
+
+ foreach (array_keys($_defaults) as $key) {
+ ${$key} = $options[$key];
+ unset($options[$key]);
+ }
+ $url = array_merge(array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url);
+
+ if ($this->{$check}($model)) {
+ return $this->Html->tag($tag, $this->link($title, $url, array_merge($options, compact('escape'))), compact('class'));
+ } else {
+ return $this->Html->tag($tag, "$title", array_merge($options, compact('class')));
+ }
+ }
+
+ public function first($first = '<<', $options = array()) {
+ $options = array_merge(array('tag' => 'li'), (array)$options);
+ return parent::first($first, $options);
+ }
+
+ public function last($last = '>>', $options = array()) {
+ $options = array_merge(array('tag' => 'li'), (array)$options);
+ return parent::last($last, $options);
+ }
+
+ public function prev($title = '<', $options = array(), $disabledTitle = null, $disabledOptions = array('class' => 'disabled')) {
+ return parent::prev($title, $options, $disabledTitle, $disabledOptions);
+ }
+
+ public function next($title = '>', $options = array(), $disabledTitle = null, $disabledOptions = array('class' => 'disabled')) {
+ return parent::next($title, $options, $disabledTitle, $disabledOptions);
+ }
+}
\ No newline at end of file
From 2de8a5b58af08daef48c8aa0ba653ee321d9edf1 Mon Sep 17 00:00:00 2001
From: Thinking Song <123wuming_123@163.com>
Date: Wed, 8 Jan 2014 17:04:54 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8Derror=E6=96=B9=E6=B3=95?=
=?UTF-8?q?=E5=8F=82=E6=95=B0=E5=92=8C=E7=88=B6=E7=B1=BB=E5=AE=8C=E5=85=A8?=
=?UTF-8?q?=E4=B8=80=E7=9B=B4=E6=9D=A5=E5=85=BC=E5=AE=B9php5.5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
View/Helper/BootstrapFormHelper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/View/Helper/BootstrapFormHelper.php b/View/Helper/BootstrapFormHelper.php
index f898e9b..52e25bb 100644
--- a/View/Helper/BootstrapFormHelper.php
+++ b/View/Helper/BootstrapFormHelper.php
@@ -97,7 +97,7 @@ public function input($fieldName, $params = array()) {
* Adds the class `help-inline` as its required by bootstrap
*
*/
- public function error($field, $text, $options = array()) {
+ public function error($field, $text=NULL, $options = array()) {
$defaults = array(
'class' => 'help-inline',
);