@@ -39,8 +39,7 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | if(isset($arr['status']) && $type==2){ |
| 41 | 41 | $ret=$arr; |
| 42 | - } |
|
| 43 | - else{ |
|
| 42 | + } else{ |
|
| 44 | 43 | $ret['status'] = $type; |
| 45 | 44 | $ret['data'] = $arr; |
| 46 | 45 | } |
@@ -157,7 +156,7 @@ discard block |
||
| 157 | 156 | // 重新生成id |
| 158 | 157 | session_regenerate_id(); |
| 159 | 158 | } |
| 160 | - }else { |
|
| 159 | + } else { |
|
| 161 | 160 | if (strpos($name, '.')) { |
| 162 | 161 | list($name1, $name2) = explode('.', $name); |
| 163 | 162 | return isset($_SESSION[$name1][$name2]) ? $_SESSION[$name1][$name2] : null; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | /** |
| 96 | 96 | * session管理函数 |
| 97 | - * @param string|array $name session名称 如果为数组则表示进行session设置 |
|
| 97 | + * @param string $name session名称 如果为数组则表示进行session设置 |
|
| 98 | 98 | * @param mixed $value session值 |
| 99 | 99 | * @return mixed |
| 100 | 100 | */ |
@@ -407,6 +407,11 @@ discard block |
||
| 407 | 407 | $value .= ' '; |
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | +/** |
|
| 411 | + * @param string $name |
|
| 412 | + * |
|
| 413 | + * @return string|null |
|
| 414 | + */ |
|
| 410 | 415 | function config($name=null,$value=null,$default=null){ |
| 411 | 416 | $config=\puck\Conf::load(); |
| 412 | 417 | if ($name===null){ |
@@ -28,6 +28,10 @@ |
||
| 28 | 28 | $function = new \Twig_SimpleFunction('I','I'); |
| 29 | 29 | $this->twig->addFunction($function); |
| 30 | 30 | } |
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @param string $name |
|
| 34 | + */ |
|
| 31 | 35 | protected function assign($name, $value = '') |
| 32 | 36 | { |
| 33 | 37 | if (is_array($name)) { |
@@ -62,6 +62,10 @@ |
||
| 62 | 62 | self::param(); |
| 63 | 63 | self::exec($class,ACTION_NAME); |
| 64 | 64 | } |
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @param string $function |
|
| 68 | + */ |
|
| 65 | 69 | static public function exec($class,$function){ |
| 66 | 70 | $method = new \ReflectionMethod($class, $function); |
| 67 | 71 | if ($method->isPublic() && !$method->isStatic()) { |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | self::init(); |
| 21 | 21 | if($path==''){ |
| 22 | 22 | $path=array(); |
| 23 | - }else{ |
|
| 23 | + } else{ |
|
| 24 | 24 | $path=str_replace('-','_',$path); |
| 25 | 25 | $path = explode('/',$path); |
| 26 | 26 | } |
@@ -28,8 +28,7 @@ discard block |
||
| 28 | 28 | if(count($path)==0){ |
| 29 | 29 | array_push($path,'home'); |
| 30 | 30 | array_push($path,'index'); |
| 31 | - } |
|
| 32 | - elseif (count($path)==1){ |
|
| 31 | + } elseif (count($path)==1){ |
|
| 33 | 32 | array_push($path,'index'); |
| 34 | 33 | } |
| 35 | 34 | if(!empty($path)){ |
@@ -46,8 +46,8 @@ |
||
| 46 | 46 | * |
| 47 | 47 | * pass values when class is istantiated |
| 48 | 48 | * |
| 49 | - * @param numeric $_perPage sets the number of iteems per page |
|
| 50 | - * @param numeric $_instance sets the instance for the GET parameter |
|
| 49 | + * @param numeric $perPage sets the number of iteems per page |
|
| 50 | + * @param numeric $instance sets the instance for the GET parameter |
|
| 51 | 51 | */ |
| 52 | 52 | public function __construct($perPage,$instance){ |
| 53 | 53 | $this->_instance = $instance; |
@@ -133,71 +133,74 @@ |
||
| 133 | 133 | $ext=$this->getParam(); |
| 134 | 134 | } |
| 135 | 135 | $pagination .= "<ul class='pager'>"; |
| 136 | - if ($this->_page > 1) |
|
| 137 | - $pagination.= "<li class='previous'><a href='".$path."$this->_instance=$prev"."$ext'><<</a></li>"; |
|
| 138 | - else |
|
| 139 | - $pagination.= "<li class='disabled previous'><span class='disabled'><<</span></li>"; |
|
| 136 | + if ($this->_page > 1) { |
|
| 137 | + $pagination.= "<li class='previous'><a href='".$path."$this->_instance=$prev"."$ext'><<</a></li>"; |
|
| 138 | + } else { |
|
| 139 | + $pagination.= "<li class='disabled previous'><span class='disabled'><<</span></li>"; |
|
| 140 | + } |
|
| 140 | 141 | |
| 141 | 142 | if ($lastpage < 7 + ($adjacents * 2)) |
| 142 | 143 | { |
| 143 | 144 | for ($counter = 1; $counter <= $lastpage; $counter++) |
| 144 | 145 | { |
| 145 | - if ($counter == $this->_page) |
|
| 146 | - $pagination.= "<li class='current'><span>$counter</span></li>"; |
|
| 147 | - else |
|
| 148 | - $pagination.= "<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>"; |
|
| 146 | + if ($counter == $this->_page) { |
|
| 147 | + $pagination.= "<li class='current'><span>$counter</span></li>"; |
|
| 148 | + } else { |
|
| 149 | + $pagination.= "<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>"; |
|
| 150 | + } |
|
| 149 | 151 | } |
| 150 | - } |
|
| 151 | - elseif($lastpage > 5 + ($adjacents * 2)) |
|
| 152 | + } elseif($lastpage > 5 + ($adjacents * 2)) |
|
| 152 | 153 | { |
| 153 | 154 | if($this->_page < 1 + ($adjacents * 2)) |
| 154 | 155 | { |
| 155 | 156 | for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) |
| 156 | 157 | { |
| 157 | - if ($counter == $this->_page) |
|
| 158 | - $pagination.= "<li class='current'><span>$counter</span></li>"; |
|
| 159 | - else |
|
| 160 | - $pagination.= "<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>"; |
|
| 158 | + if ($counter == $this->_page) { |
|
| 159 | + $pagination.= "<li class='current'><span>$counter</span></li>"; |
|
| 160 | + } else { |
|
| 161 | + $pagination.= "<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>"; |
|
| 162 | + } |
|
| 161 | 163 | } |
| 162 | 164 | $pagination.= "..."; |
| 163 | 165 | $pagination.= "<li><a href='".$path."$this->_instance=$lpm1"."$ext'>$lpm1</a></li>"; |
| 164 | 166 | $pagination.= "<li><a href='".$path."$this->_instance=$lastpage"."$ext'>$lastpage</a></li>"; |
| 165 | - } |
|
| 166 | - elseif($lastpage - ($adjacents * 2) > $this->_page && $this->_page > ($adjacents * 2)) |
|
| 167 | + } elseif($lastpage - ($adjacents * 2) > $this->_page && $this->_page > ($adjacents * 2)) |
|
| 167 | 168 | { |
| 168 | 169 | $pagination.= "<li><a href='".$path."$this->_instance=1"."$ext'>1</a></li>"; |
| 169 | 170 | $pagination.= "<li><a href='".$path."$this->_instance=2"."$ext'>2</a></li>"; |
| 170 | 171 | $pagination.= "..."; |
| 171 | 172 | for ($counter = $this->_page - $adjacents; $counter <= $this->_page + $adjacents; $counter++) |
| 172 | 173 | { |
| 173 | - if ($counter == $this->_page) |
|
| 174 | - $pagination.= "<li class='current'><span>$counter</span></li>"; |
|
| 175 | - else |
|
| 176 | - $pagination.= "<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>"; |
|
| 174 | + if ($counter == $this->_page) { |
|
| 175 | + $pagination.= "<li class='current'><span>$counter</span></li>"; |
|
| 176 | + } else { |
|
| 177 | + $pagination.= "<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>"; |
|
| 178 | + } |
|
| 177 | 179 | } |
| 178 | 180 | $pagination.= ".."; |
| 179 | 181 | $pagination.= "<li><a href='".$path."$this->_instance=$lpm1"."$ext'>$lpm1</a></li>"; |
| 180 | 182 | $pagination.= "<li><a href='".$path."$this->_instance=$lastpage"."$ext'>$lastpage</a></li>"; |
| 181 | - } |
|
| 182 | - else |
|
| 183 | + } else |
|
| 183 | 184 | { |
| 184 | 185 | $pagination.= "<li><a href='".$path."$this->_instance=1"."$ext'>1</a></li>"; |
| 185 | 186 | $pagination.= "<li><a href='".$path."$this->_instance=2"."$ext'>2</a></li>"; |
| 186 | 187 | $pagination.= ".."; |
| 187 | 188 | for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) |
| 188 | 189 | { |
| 189 | - if ($counter == $this->_page) |
|
| 190 | - $pagination.= "<li class='current'><span>$counter</span></li>"; |
|
| 191 | - else |
|
| 192 | - $pagination.= "<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>"; |
|
| 190 | + if ($counter == $this->_page) { |
|
| 191 | + $pagination.= "<li class='current'><span>$counter</span></li>"; |
|
| 192 | + } else { |
|
| 193 | + $pagination.= "<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>"; |
|
| 194 | + } |
|
| 193 | 195 | } |
| 194 | 196 | } |
| 195 | 197 | } |
| 196 | 198 | |
| 197 | - if ($this->_page < $counter - 1) |
|
| 198 | - $pagination.= "<li class='next'><a href='".$path."$this->_instance=$next"."$ext'>>></a></li>"; |
|
| 199 | - else |
|
| 200 | - $pagination.= "<li class='next disabled'><span class='disabled'>>></span></li>"; |
|
| 199 | + if ($this->_page < $counter - 1) { |
|
| 200 | + $pagination.= "<li class='next'><a href='".$path."$this->_instance=$next"."$ext'>>></a></li>"; |
|
| 201 | + } else { |
|
| 202 | + $pagination.= "<li class='next disabled'><span class='disabled'>>></span></li>"; |
|
| 203 | + } |
|
| 201 | 204 | $pagination.= "</ul>\n"; |
| 202 | 205 | } |
| 203 | 206 | |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | * @access protected |
| 1099 | 1099 | * @param string $value 字段值 |
| 1100 | 1100 | * @param mixed $rule 验证规则 |
| 1101 | - * @return mixed |
|
| 1101 | + * @return boolean |
|
| 1102 | 1102 | */ |
| 1103 | 1103 | protected function allowIp($value, $rule) |
| 1104 | 1104 | { |
@@ -1110,7 +1110,7 @@ discard block |
||
| 1110 | 1110 | * @access protected |
| 1111 | 1111 | * @param string $value 字段值 |
| 1112 | 1112 | * @param mixed $rule 验证规则 |
| 1113 | - * @return mixed |
|
| 1113 | + * @return boolean |
|
| 1114 | 1114 | */ |
| 1115 | 1115 | protected function denyIp($value, $rule) |
| 1116 | 1116 | { |
@@ -1121,8 +1121,8 @@ discard block |
||
| 1121 | 1121 | * 使用正则验证数据 |
| 1122 | 1122 | * @access protected |
| 1123 | 1123 | * @param mixed $value 字段值 |
| 1124 | - * @param mixed $rule 验证规则 正则规则或者预定义正则名 |
|
| 1125 | - * @return mixed |
|
| 1124 | + * @param string $rule 验证规则 正则规则或者预定义正则名 |
|
| 1125 | + * @return boolean |
|
| 1126 | 1126 | */ |
| 1127 | 1127 | protected function regex($value, $rule) |
| 1128 | 1128 | { |
@@ -1140,7 +1140,7 @@ discard block |
||
| 1140 | 1140 | * 验证表单令牌 |
| 1141 | 1141 | * @access protected |
| 1142 | 1142 | * @param mixed $value 字段值 |
| 1143 | - * @param mixed $rule 验证规则 |
|
| 1143 | + * @param string $rule 验证规则 |
|
| 1144 | 1144 | * @param array $data 数据 |
| 1145 | 1145 | * @return bool |
| 1146 | 1146 | */ |
@@ -58,6 +58,10 @@ |
||
| 58 | 58 | public function update($data){ |
| 59 | 59 | return $this->db->update($this->table,$data); |
| 60 | 60 | } |
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @param string $field |
|
| 64 | + */ |
|
| 61 | 65 | public function field($field){ |
| 62 | 66 | $this->field=$field; |
| 63 | 67 | return $this; |