@@ -30,15 +30,17 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | public function getDbFile() |
| 32 | 32 | { |
| 33 | - if($this->_dbFile===null) |
|
| 34 | - $this->_dbFile=Prado::getPathOfNamespace(self::DEFAULT_DB_FILE,self::DB_FILE_EXT); |
|
| 33 | + if($this->_dbFile===null) { |
|
| 34 | + $this->_dbFile=Prado::getPathOfNamespace(self::DEFAULT_DB_FILE,self::DB_FILE_EXT); |
|
| 35 | + } |
|
| 35 | 36 | return $this->_dbFile; |
| 36 | 37 | } |
| 37 | 38 | |
| 38 | 39 | public function setDbFile($value) |
| 39 | 40 | { |
| 40 | - if(($this->_dbFile=Prado::getPathOfNamespace($value,self::DB_FILE_EXT))===null) |
|
| 41 | - throw new BlogException(500,'blogdatamodule_dbfile_invalid',$value); |
|
| 41 | + if(($this->_dbFile=Prado::getPathOfNamespace($value,self::DB_FILE_EXT))===null) { |
|
| 42 | + throw new BlogException(500,'blogdatamodule_dbfile_invalid',$value); |
|
| 43 | + } |
|
| 42 | 44 | } |
| 43 | 45 | |
| 44 | 46 | protected function createDatabase() |
@@ -52,8 +54,7 @@ discard block |
||
| 52 | 54 | try { |
| 53 | 55 | $command=$this->_db->createCommand($statement); |
| 54 | 56 | $command->execute(); |
| 55 | - } |
|
| 56 | - catch(TDbException $e) |
|
| 57 | + } catch(TDbException $e) |
|
| 57 | 58 | { |
| 58 | 59 | throw new BlogException(500,'blogdatamodule_createdatabase_failed',$e->getErrorMessage(),$statement); |
| 59 | 60 | } |
@@ -69,25 +70,28 @@ discard block |
||
| 69 | 70 | try { |
| 70 | 71 | $this->_db=new TDbConnection("sqlite:".$dbFile); |
| 71 | 72 | $this->_db->Active=true; |
| 72 | - } |
|
| 73 | - catch(TDbException $e) |
|
| 73 | + } catch(TDbException $e) |
|
| 74 | 74 | { |
| 75 | 75 | throw new BlogException(500,'blogdatamodule_dbconnect_failed',$e->getErrorMessage()); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if($newDb) |
|
| 79 | - $this->createDatabase(); |
|
| 78 | + if($newDb) { |
|
| 79 | + $this->createDatabase(); |
|
| 80 | + } |
|
| 80 | 81 | } |
| 81 | 82 | |
| 82 | 83 | protected function generateModifier($filter,$orderBy,$limit) |
| 83 | 84 | { |
| 84 | 85 | $modifier=''; |
| 85 | - if($filter!=='') |
|
| 86 | - $modifier=' WHERE '.$filter; |
|
| 87 | - if($orderBy!=='') |
|
| 88 | - $modifier.=' ORDER BY '.$orderBy; |
|
| 89 | - if($limit!=='') |
|
| 90 | - $modifier.=' LIMIT '.$limit; |
|
| 86 | + if($filter!=='') { |
|
| 87 | + $modifier=' WHERE '.$filter; |
|
| 88 | + } |
|
| 89 | + if($orderBy!=='') { |
|
| 90 | + $modifier.=' ORDER BY '.$orderBy; |
|
| 91 | + } |
|
| 92 | + if($limit!=='') { |
|
| 93 | + $modifier.=' LIMIT '.$limit; |
|
| 94 | + } |
|
| 91 | 95 | return $modifier; |
| 92 | 96 | } |
| 93 | 97 | |
@@ -96,8 +100,7 @@ discard block |
||
| 96 | 100 | try { |
| 97 | 101 | $command=$this->_db->createCommand($sql); |
| 98 | 102 | return $command->query(); |
| 99 | - } |
|
| 100 | - catch(TDbException $e) |
|
| 103 | + } catch(TDbException $e) |
|
| 101 | 104 | { |
| 102 | 105 | throw new BlogException(500,'blogdatamodule_query_failed',$e->getErrorMessage(),$sql); |
| 103 | 106 | } |
@@ -121,36 +124,41 @@ discard block |
||
| 121 | 124 | |
| 122 | 125 | public function queryUsers($filter='',$orderBy='',$limit='') |
| 123 | 126 | { |
| 124 | - if($filter!=='') |
|
| 125 | - $filter='WHERE '.$filter; |
|
| 127 | + if($filter!=='') { |
|
| 128 | + $filter='WHERE '.$filter; |
|
| 129 | + } |
|
| 126 | 130 | $sql="SELECT * FROM tblUsers $filter $orderBy $limit"; |
| 127 | 131 | $rows=$this->query($sql); |
| 128 | 132 | $users=array(); |
| 129 | - foreach($rows as $row) |
|
| 130 | - $users[]=$this->populateUserRecord($row); |
|
| 133 | + foreach($rows as $row) { |
|
| 134 | + $users[]=$this->populateUserRecord($row); |
|
| 135 | + } |
|
| 131 | 136 | return $users; |
| 132 | 137 | } |
| 133 | 138 | |
| 134 | 139 | public function queryUserCount($filter) |
| 135 | 140 | { |
| 136 | - if($filter!=='') |
|
| 137 | - $filter='WHERE '.$filter; |
|
| 141 | + if($filter!=='') { |
|
| 142 | + $filter='WHERE '.$filter; |
|
| 143 | + } |
|
| 138 | 144 | $sql="SELECT COUNT(id) AS user_count FROM tblUsers $filter"; |
| 139 | 145 | $result=$this->query($sql); |
| 140 | - if(($row=$result->read())!==false) |
|
| 141 | - return $row['user_count']; |
|
| 142 | - else |
|
| 143 | - return 0; |
|
| 146 | + if(($row=$result->read())!==false) { |
|
| 147 | + return $row['user_count']; |
|
| 148 | + } else { |
|
| 149 | + return 0; |
|
| 150 | + } |
|
| 144 | 151 | } |
| 145 | 152 | |
| 146 | 153 | public function queryUserByID($id) |
| 147 | 154 | { |
| 148 | 155 | $sql="SELECT * FROM tblUsers WHERE id=$id"; |
| 149 | 156 | $result=$this->query($sql); |
| 150 | - if(($row=$result->read())!==false) |
|
| 151 | - return $this->populateUserRecord($row); |
|
| 152 | - else |
|
| 153 | - return null; |
|
| 157 | + if(($row=$result->read())!==false) { |
|
| 158 | + return $this->populateUserRecord($row); |
|
| 159 | + } else { |
|
| 160 | + return null; |
|
| 161 | + } |
|
| 154 | 162 | } |
| 155 | 163 | |
| 156 | 164 | public function queryUserByName($name) |
@@ -160,10 +168,11 @@ discard block |
||
| 160 | 168 | |
| 161 | 169 | $result=$command->query(); |
| 162 | 170 | |
| 163 | - if(($row=$result->read())!==false) |
|
| 164 | - return $this->populateUserRecord($row); |
|
| 165 | - else |
|
| 166 | - return null; |
|
| 171 | + if(($row=$result->read())!==false) { |
|
| 172 | + return $this->populateUserRecord($row); |
|
| 173 | + } else { |
|
| 174 | + return null; |
|
| 175 | + } |
|
| 167 | 176 | } |
| 168 | 177 | |
| 169 | 178 | public function insertUser($user) |
@@ -220,10 +229,11 @@ discard block |
||
| 220 | 229 | $postRecord=new PostRecord; |
| 221 | 230 | $postRecord->ID=(integer)$row['id']; |
| 222 | 231 | $postRecord->AuthorID=(integer)$row['author_id']; |
| 223 | - if($row['author_full_name']!=='') |
|
| 224 | - $postRecord->AuthorName=$row['author_full_name']; |
|
| 225 | - else |
|
| 226 | - $postRecord->AuthorName=$row['author_name']; |
|
| 232 | + if($row['author_full_name']!=='') { |
|
| 233 | + $postRecord->AuthorName=$row['author_full_name']; |
|
| 234 | + } else { |
|
| 235 | + $postRecord->AuthorName=$row['author_name']; |
|
| 236 | + } |
|
| 227 | 237 | $postRecord->CreateTime=(integer)$row['create_time']; |
| 228 | 238 | $postRecord->ModifyTime=(integer)$row['modify_time']; |
| 229 | 239 | $postRecord->Title=$row['title']; |
@@ -237,10 +247,12 @@ discard block |
||
| 237 | 247 | { |
| 238 | 248 | //FIXME this is insecure by design since it misses proper escaping |
| 239 | 249 | $filter=''; |
| 240 | - if($postFilter!=='') |
|
| 241 | - $filter.=" AND $postFilter"; |
|
| 242 | - if($categoryFilter!=='') |
|
| 243 | - $filter.=" AND a.id IN (SELECT post_id AS id FROM tblPost2Category WHERE $categoryFilter)"; |
|
| 250 | + if($postFilter!=='') { |
|
| 251 | + $filter.=" AND $postFilter"; |
|
| 252 | + } |
|
| 253 | + if($categoryFilter!=='') { |
|
| 254 | + $filter.=" AND a.id IN (SELECT post_id AS id FROM tblPost2Category WHERE $categoryFilter)"; |
|
| 255 | + } |
|
| 244 | 256 | $sql="SELECT a.id AS id, |
| 245 | 257 | a.author_id AS author_id, |
| 246 | 258 | b.name AS author_name, |
@@ -255,8 +267,9 @@ discard block |
||
| 255 | 267 | WHERE a.author_id=b.id $filter $orderBy $limit"; |
| 256 | 268 | $rows=$this->query($sql); |
| 257 | 269 | $posts=array(); |
| 258 | - foreach($rows as $row) |
|
| 259 | - $posts[]=$this->populatePostRecord($row); |
|
| 270 | + foreach($rows as $row) { |
|
| 271 | + $posts[]=$this->populatePostRecord($row); |
|
| 272 | + } |
|
| 260 | 273 | return $posts; |
| 261 | 274 | } |
| 262 | 275 | |
@@ -275,8 +288,9 @@ discard block |
||
| 275 | 288 | FROM tblPosts a, tblUsers b |
| 276 | 289 | WHERE a.author_id=b.id AND a.status=0"; |
| 277 | 290 | |
| 278 | - foreach($keywords as $keyword) |
|
| 279 | - $sql.=" AND (content LIKE ? OR title LIKE ?)"; |
|
| 291 | + foreach($keywords as $keyword) { |
|
| 292 | + $sql.=" AND (content LIKE ? OR title LIKE ?)"; |
|
| 293 | + } |
|
| 280 | 294 | |
| 281 | 295 | $sql.=" $orderBy $limit"; |
| 282 | 296 | |
@@ -292,8 +306,9 @@ discard block |
||
| 292 | 306 | $rows=$command->query(); |
| 293 | 307 | |
| 294 | 308 | $posts=array(); |
| 295 | - foreach($rows as $row) |
|
| 296 | - $posts[]=$this->populatePostRecord($row); |
|
| 309 | + foreach($rows as $row) { |
|
| 310 | + $posts[]=$this->populatePostRecord($row); |
|
| 311 | + } |
|
| 297 | 312 | return $posts; |
| 298 | 313 | |
| 299 | 314 | } |
@@ -302,18 +317,21 @@ discard block |
||
| 302 | 317 | { |
| 303 | 318 | //FIXME this is insecure by design since it misses proper escaping |
| 304 | 319 | $filter=''; |
| 305 | - if($postFilter!=='') |
|
| 306 | - $filter.=" AND $postFilter"; |
|
| 307 | - if($categoryFilter!=='') |
|
| 308 | - $filter.=" AND a.id IN (SELECT post_id AS id FROM tblPost2Category WHERE $categoryFilter)"; |
|
| 320 | + if($postFilter!=='') { |
|
| 321 | + $filter.=" AND $postFilter"; |
|
| 322 | + } |
|
| 323 | + if($categoryFilter!=='') { |
|
| 324 | + $filter.=" AND a.id IN (SELECT post_id AS id FROM tblPost2Category WHERE $categoryFilter)"; |
|
| 325 | + } |
|
| 309 | 326 | $sql="SELECT COUNT(a.id) AS post_count |
| 310 | 327 | FROM tblPosts a, tblUsers b |
| 311 | 328 | WHERE a.author_id=b.id $filter"; |
| 312 | 329 | $result=$this->query($sql); |
| 313 | - if(($row=$result->read())!==false) |
|
| 314 | - return $row['post_count']; |
|
| 315 | - else |
|
| 316 | - return 0; |
|
| 330 | + if(($row=$result->read())!==false) { |
|
| 331 | + return $row['post_count']; |
|
| 332 | + } else { |
|
| 333 | + return 0; |
|
| 334 | + } |
|
| 317 | 335 | } |
| 318 | 336 | |
| 319 | 337 | public function queryPostByID($id) |
@@ -336,10 +354,11 @@ discard block |
||
| 336 | 354 | |
| 337 | 355 | $result=$command->query(); |
| 338 | 356 | |
| 339 | - if(($row=$result->read())!==false) |
|
| 340 | - return $this->populatePostRecord($row); |
|
| 341 | - else |
|
| 342 | - return null; |
|
| 357 | + if(($row=$result->read())!==false) { |
|
| 358 | + return $this->populatePostRecord($row); |
|
| 359 | + } else { |
|
| 360 | + return null; |
|
| 361 | + } |
|
| 343 | 362 | } |
| 344 | 363 | |
| 345 | 364 | public function insertPost($post,$catIDs) |
@@ -356,8 +375,9 @@ discard block |
||
| 356 | 375 | |
| 357 | 376 | $command->execute(); |
| 358 | 377 | $post->ID=$this->_db->getLastInsertID(); |
| 359 | - foreach($catIDs as $catID) |
|
| 360 | - $this->insertPostCategory($post->ID,$catID); |
|
| 378 | + foreach($catIDs as $catID) { |
|
| 379 | + $this->insertPostCategory($post->ID,$catID); |
|
| 380 | + } |
|
| 361 | 381 | } |
| 362 | 382 | |
| 363 | 383 | public function updatePost($post,$newCatIDs=null) |
@@ -366,14 +386,17 @@ discard block |
||
| 366 | 386 | { |
| 367 | 387 | $cats=$this->queryCategoriesByPostID($post->ID); |
| 368 | 388 | $catIDs=array(); |
| 369 | - foreach($cats as $cat) |
|
| 370 | - $catIDs[]=$cat->ID; |
|
| 389 | + foreach($cats as $cat) { |
|
| 390 | + $catIDs[]=$cat->ID; |
|
| 391 | + } |
|
| 371 | 392 | $deleteIDs=array_diff($catIDs,$newCatIDs); |
| 372 | - foreach($deleteIDs as $id) |
|
| 373 | - $this->deletePostCategory($post->ID,$id); |
|
| 393 | + foreach($deleteIDs as $id) { |
|
| 394 | + $this->deletePostCategory($post->ID,$id); |
|
| 395 | + } |
|
| 374 | 396 | $insertIDs=array_diff($newCatIDs,$catIDs); |
| 375 | - foreach($insertIDs as $id) |
|
| 376 | - $this->insertPostCategory($post->ID,$id); |
|
| 397 | + foreach($insertIDs as $id) { |
|
| 398 | + $this->insertPostCategory($post->ID,$id); |
|
| 399 | + } |
|
| 377 | 400 | } |
| 378 | 401 | |
| 379 | 402 | $command=$this->_db->createCommand("UPDATE tblPosts SET |
@@ -394,8 +417,9 @@ discard block |
||
| 394 | 417 | public function deletePost($id) |
| 395 | 418 | { |
| 396 | 419 | $cats=$this->queryCategoriesByPostID($id); |
| 397 | - foreach($cats as $cat) |
|
| 398 | - $this->deletePostCategory($id,$cat->ID); |
|
| 420 | + foreach($cats as $cat) { |
|
| 421 | + $this->deletePostCategory($id,$cat->ID); |
|
| 422 | + } |
|
| 399 | 423 | |
| 400 | 424 | $command=$this->_db->createCommand("DELETE FROM tblComments WHERE post_id=?"); |
| 401 | 425 | $command->bindValue(1, $id); |
@@ -424,13 +448,15 @@ discard block |
||
| 424 | 448 | public function queryComments($filter,$orderBy,$limit) |
| 425 | 449 | { |
| 426 | 450 | //FIXME this is insecure by design since it misses proper escaping |
| 427 | - if($filter!=='') |
|
| 428 | - $filter='WHERE '.$filter; |
|
| 451 | + if($filter!=='') { |
|
| 452 | + $filter='WHERE '.$filter; |
|
| 453 | + } |
|
| 429 | 454 | $sql="SELECT * FROM tblComments $filter $orderBy $limit"; |
| 430 | 455 | $rows=$this->query($sql); |
| 431 | 456 | $comments=array(); |
| 432 | - foreach($rows as $row) |
|
| 433 | - $comments[]=$this->populateCommentRecord($row); |
|
| 457 | + foreach($rows as $row) { |
|
| 458 | + $comments[]=$this->populateCommentRecord($row); |
|
| 459 | + } |
|
| 434 | 460 | return $comments; |
| 435 | 461 | } |
| 436 | 462 | |
@@ -443,8 +469,9 @@ discard block |
||
| 443 | 469 | $rows=$command->query(); |
| 444 | 470 | |
| 445 | 471 | $comments=array(); |
| 446 | - foreach($rows as $row) |
|
| 447 | - $comments[]=$this->populateCommentRecord($row); |
|
| 472 | + foreach($rows as $row) { |
|
| 473 | + $comments[]=$this->populateCommentRecord($row); |
|
| 474 | + } |
|
| 448 | 475 | return $comments; |
| 449 | 476 | } |
| 450 | 477 | |
@@ -512,8 +539,9 @@ discard block |
||
| 512 | 539 | $sql="SELECT * FROM tblCategories ORDER BY name ASC"; |
| 513 | 540 | $rows=$this->query($sql); |
| 514 | 541 | $cats=array(); |
| 515 | - foreach($rows as $row) |
|
| 516 | - $cats[]=$this->populateCategoryRecord($row); |
|
| 542 | + foreach($rows as $row) { |
|
| 543 | + $cats[]=$this->populateCategoryRecord($row); |
|
| 544 | + } |
|
| 517 | 545 | return $cats; |
| 518 | 546 | } |
| 519 | 547 | |
@@ -531,8 +559,9 @@ discard block |
||
| 531 | 559 | $rows=$command->query(); |
| 532 | 560 | |
| 533 | 561 | $cats=array(); |
| 534 | - foreach($rows as $row) |
|
| 535 | - $cats[]=$this->populateCategoryRecord($row); |
|
| 562 | + foreach($rows as $row) { |
|
| 563 | + $cats[]=$this->populateCategoryRecord($row); |
|
| 564 | + } |
|
| 536 | 565 | return $cats; |
| 537 | 566 | } |
| 538 | 567 | |
@@ -544,10 +573,11 @@ discard block |
||
| 544 | 573 | $command->bindValue(1, $id); |
| 545 | 574 | $result=$command->query(); |
| 546 | 575 | |
| 547 | - if(($row=$result->read())!==false) |
|
| 548 | - return $this->populateCategoryRecord($row); |
|
| 549 | - else |
|
| 550 | - return null; |
|
| 576 | + if(($row=$result->read())!==false) { |
|
| 577 | + return $this->populateCategoryRecord($row); |
|
| 578 | + } else { |
|
| 579 | + return null; |
|
| 580 | + } |
|
| 551 | 581 | } |
| 552 | 582 | |
| 553 | 583 | public function queryCategoryByName($name) |
@@ -558,10 +588,11 @@ discard block |
||
| 558 | 588 | $command->bindValue(1, $name); |
| 559 | 589 | $result=$command->query(); |
| 560 | 590 | |
| 561 | - if(($row=$result->read())!==false) |
|
| 562 | - return $this->populateCategoryRecord($row); |
|
| 563 | - else |
|
| 564 | - return null; |
|
| 591 | + if(($row=$result->read())!==false) { |
|
| 592 | + return $this->populateCategoryRecord($row); |
|
| 593 | + } else { |
|
| 594 | + return null; |
|
| 595 | + } |
|
| 565 | 596 | } |
| 566 | 597 | |
| 567 | 598 | public function insertCategory($category) |
@@ -640,10 +671,11 @@ discard block |
||
| 640 | 671 | { |
| 641 | 672 | $sql="SELECT MIN(create_time) AS create_time FROM tblPosts"; |
| 642 | 673 | $result=$this->query($sql); |
| 643 | - if(($row=$result->read())!==false) |
|
| 644 | - return $row['create_time']; |
|
| 645 | - else |
|
| 646 | - return time(); |
|
| 674 | + if(($row=$result->read())!==false) { |
|
| 675 | + return $row['create_time']; |
|
| 676 | + } else { |
|
| 677 | + return time(); |
|
| 678 | + } |
|
| 647 | 679 | } |
| 648 | 680 | } |
| 649 | 681 | |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function getUser($username=null) |
| 35 | 35 | { |
| 36 | - if($username===null) |
|
| 37 | - return new BlogUser($this); |
|
| 38 | - else |
|
| 36 | + if($username===null) { |
|
| 37 | + return new BlogUser($this); |
|
| 38 | + } else |
|
| 39 | 39 | { |
| 40 | 40 | $username=strtolower($username); |
| 41 | 41 | $db=$this->Application->getModule('data'); |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | $user->setIsGuest(false); |
| 48 | 48 | $user->setRoles($userRecord->Role===UserRecord::ROLE_USER?'user':'admin'); |
| 49 | 49 | return $user; |
| 50 | + } else { |
|
| 51 | + return null; |
|
| 50 | 52 | } |
| 51 | - else |
|
| 52 | - return null; |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
@@ -62,10 +62,11 @@ discard block |
||
| 62 | 62 | public function validateUser($username,$password) |
| 63 | 63 | { |
| 64 | 64 | $db=$this->Application->getModule('data'); |
| 65 | - if(($userRecord=$db->queryUserByName($username))!==null) |
|
| 66 | - return $userRecord->Password===md5($password) && $userRecord->Status===UserRecord::STATUS_NORMAL; |
|
| 67 | - else |
|
| 68 | - return false; |
|
| 65 | + if(($userRecord=$db->queryUserByName($username))!==null) { |
|
| 66 | + return $userRecord->Password===md5($password) && $userRecord->Status===UserRecord::STATUS_NORMAL; |
|
| 67 | + } else { |
|
| 68 | + return false; |
|
| 69 | + } |
|
| 69 | 70 | } |
| 70 | 71 | |
| 71 | 72 | /** |
@@ -42,8 +42,9 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | public function addParsedObject($object) |
| 44 | 44 | { |
| 45 | - if($object instanceof XListMenuItem) |
|
| 46 | - parent::addParsedObject($object); |
|
| 45 | + if($object instanceof XListMenuItem) { |
|
| 46 | + parent::addParsedObject($object); |
|
| 47 | + } |
|
| 47 | 48 | } |
| 48 | 49 | |
| 49 | 50 | public function getActiveCssClass() |
@@ -68,10 +69,12 @@ discard block |
||
| 68 | 69 | |
| 69 | 70 | public function render($writer) |
| 70 | 71 | { |
| 71 | - if(($activeClass=$this->getActiveCssClass())!=='') |
|
| 72 | - $activeClass=' class="'.$activeClass.'"'; |
|
| 73 | - if(($inactiveClass=$this->getInactiveCssClass())!=='') |
|
| 74 | - $inactiveClass=' class="'.$inactiveClass.'"'; |
|
| 72 | + if(($activeClass=$this->getActiveCssClass())!=='') { |
|
| 73 | + $activeClass=' class="'.$activeClass.'"'; |
|
| 74 | + } |
|
| 75 | + if(($inactiveClass=$this->getInactiveCssClass())!=='') { |
|
| 76 | + $inactiveClass=' class="'.$inactiveClass.'"'; |
|
| 77 | + } |
|
| 75 | 78 | $currentPagePath=$this->getPage()->getPagePath(); |
| 76 | 79 | $writer->write("<ul>\n"); |
| 77 | 80 | foreach($this->getItems() as $item) |
@@ -80,20 +83,22 @@ discard block |
||
| 80 | 83 | //if(strpos($currentPagePath.'.',$pagePath.'.')===0) |
| 81 | 84 | if($pagePath[strlen($pagePath)-1]==='*') |
| 82 | 85 | { |
| 83 | - if(strpos($currentPagePath.'.',rtrim($pagePath,'*'))===0) |
|
| 84 | - $cssClass=$activeClass; |
|
| 85 | - else |
|
| 86 | - $cssClass=$inactiveClass; |
|
| 87 | - } |
|
| 88 | - else |
|
| 86 | + if(strpos($currentPagePath.'.',rtrim($pagePath,'*'))===0) { |
|
| 87 | + $cssClass=$activeClass; |
|
| 88 | + } else { |
|
| 89 | + $cssClass=$inactiveClass; |
|
| 90 | + } |
|
| 91 | + } else |
|
| 89 | 92 | { |
| 90 | - if($pagePath===$currentPagePath) |
|
| 91 | - $cssClass=$activeClass; |
|
| 92 | - else |
|
| 93 | - $cssClass=$inactiveClass; |
|
| 93 | + if($pagePath===$currentPagePath) { |
|
| 94 | + $cssClass=$activeClass; |
|
| 95 | + } else { |
|
| 96 | + $cssClass=$inactiveClass; |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + if(($url=$item->getNavigateUrl())==='') { |
|
| 100 | + $url=$this->getService()->constructUrl($pagePath); |
|
| 94 | 101 | } |
| 95 | - if(($url=$item->getNavigateUrl())==='') |
|
| 96 | - $url=$this->getService()->constructUrl($pagePath); |
|
| 97 | 102 | $writer->write("<li><a href=\"$url\"$cssClass>".$item->getText()."</a></li>\n"); |
| 98 | 103 | } |
| 99 | 104 | $writer->write("</ul>"); |
@@ -6,12 +6,15 @@ |
||
| 6 | 6 | $runtimePath=$basePath.'/protected/runtime'; |
| 7 | 7 | $dataPath=$basePath.'/protected/Data'; |
| 8 | 8 | |
| 9 | -if(!is_writable($assetsPath)) |
|
| 9 | +if(!is_writable($assetsPath)) { |
|
| 10 | 10 | die("Please make sure that the directory $assetsPath is writable by Web server process."); |
| 11 | -if(!is_writable($runtimePath)) |
|
| 11 | +} |
|
| 12 | +if(!is_writable($runtimePath)) { |
|
| 12 | 13 | die("Please make sure that the directory $runtimePath is writable by Web server process."); |
| 13 | -if(!is_writable($dataPath)) |
|
| 14 | +} |
|
| 15 | +if(!is_writable($dataPath)) { |
|
| 14 | 16 | die("Please make sure that the directory $dataPath is writable by Web server process."); |
| 17 | +} |
|
| 15 | 18 | |
| 16 | 19 | require_once($frameworkPath); |
| 17 | 20 | $application=new TApplication('protected',false,TApplication::CONFIG_TYPE_PHP); |
@@ -4,8 +4,9 @@ |
||
| 4 | 4 | { |
| 5 | 5 | public function __construct() |
| 6 | 6 | { |
| 7 | - if(isset($this->Request['notheme'])) |
|
| 8 | - $this->Service->RequestedPage->EnableTheming=false; |
|
| 7 | + if(isset($this->Request['notheme'])) { |
|
| 8 | + $this->Service->RequestedPage->EnableTheming=false; |
|
| 9 | + } |
|
| 9 | 10 | parent::__construct(); |
| 10 | 11 | } |
| 11 | 12 | } |
@@ -22,8 +22,9 @@ |
||
| 22 | 22 | { |
| 23 | 23 | $classFile='class-'.array_pop($paths).'.html'; |
| 24 | 24 | $this->setNavigateUrl(self::BASE_URL . '/' . $classFile); |
| 25 | - if($this->getText() === '') |
|
| 26 | - $this->setText('API Manual'); |
|
| 25 | + if($this->getText() === '') { |
|
| 26 | + $this->setText('API Manual'); |
|
| 27 | + } |
|
| 27 | 28 | } |
| 28 | 29 | } |
| 29 | 30 | } |
@@ -23,8 +23,9 @@ |
||
| 23 | 23 | public function onInit($param) |
| 24 | 24 | { |
| 25 | 25 | parent::onInit($param); |
| 26 | - if(strlen($q = $this->Page->Request['q']) > 0) |
|
| 27 | - $this->search->setText($q); |
|
| 26 | + if(strlen($q = $this->Page->Request['q']) > 0) { |
|
| 27 | + $this->search->setText($q); |
|
| 28 | + } |
|
| 28 | 29 | } |
| 29 | 30 | |
| 30 | 31 | public function doSearch($sender, $param) |
@@ -4,8 +4,9 @@ discard block |
||
| 4 | 4 | { |
| 5 | 5 | public function __construct() |
| 6 | 6 | { |
| 7 | - if(isset($this->Request['notheme'])) |
|
| 8 | - $this->Service->RequestedPage->EnableTheming=false; |
|
| 7 | + if(isset($this->Request['notheme'])) { |
|
| 8 | + $this->Service->RequestedPage->EnableTheming=false; |
|
| 9 | + } |
|
| 9 | 10 | parent::__construct(); |
| 10 | 11 | } |
| 11 | 12 | |
@@ -13,10 +14,11 @@ discard block |
||
| 13 | 14 | { |
| 14 | 15 | parent::onLoad($param); |
| 15 | 16 | $url=$this->Request->RequestUri; |
| 16 | - if(strpos($url,'?')===false) |
|
| 17 | - $url.='?notheme=true'; |
|
| 18 | - else |
|
| 19 | - $url.='&notheme=true'; |
|
| 17 | + if(strpos($url,'?')===false) { |
|
| 18 | + $url.='?notheme=true'; |
|
| 19 | + } else { |
|
| 20 | + $url.='&notheme=true'; |
|
| 21 | + } |
|
| 20 | 22 | $this->PrinterLink->NavigateUrl=$url; |
| 21 | 23 | |
| 22 | 24 | if(isset($this->Request['notheme'])) |
@@ -40,8 +42,9 @@ discard block |
||
| 40 | 42 | unset($params[$this->Request->ServiceID]); |
| 41 | 43 | $url = $this->Service->ConstructUrl($this->Service->RequestedPagePath, $params); |
| 42 | 44 | $item->link->NavigateUrl = $url; |
| 43 | - if($this->Application->Globalization->Culture == $params['lang']) |
|
| 44 | - $item->link->CssClass="active"; |
|
| 45 | + if($this->Application->Globalization->Culture == $params['lang']) { |
|
| 46 | + $item->link->CssClass="active"; |
|
| 47 | + } |
|
| 45 | 48 | } |
| 46 | 49 | } |
| 47 | 50 | } |
@@ -37,8 +37,9 @@ discard block |
||
| 37 | 37 | $data = $this->getCommentData(); |
| 38 | 38 | foreach($data as $r) |
| 39 | 39 | { |
| 40 | - if(!isset($count[$r->block_id])) |
|
| 41 | - $count[$r->block_id]=0; |
|
| 40 | + if(!isset($count[$r->block_id])) { |
|
| 41 | + $count[$r->block_id]=0; |
|
| 42 | + } |
|
| 42 | 43 | $count[$r->block_id]++; |
| 43 | 44 | } |
| 44 | 45 | $js = "var comment_count = ".TJavascript::encode($count).";\n"; |
@@ -55,8 +56,9 @@ discard block |
||
| 55 | 56 | |
| 56 | 57 | function add_comment($sender, $param) |
| 57 | 58 | { |
| 58 | - if(!$this->Page->IsValid) |
|
| 59 | - return; |
|
| 59 | + if(!$this->Page->IsValid) { |
|
| 60 | + return; |
|
| 61 | + } |
|
| 60 | 62 | $record = new CommentRecord; |
| 61 | 63 | $record->username = $this->username->Text; |
| 62 | 64 | $record->date_added = date('Y-m-d h:i:s'); |