Index: trunk/extensions/Reviews/includes/ReviewsDBObject.php |
— | — | @@ -451,19 +451,13 @@ |
452 | 452 | return new static( $data, $loadDefaults ); |
453 | 453 | } |
454 | 454 | |
455 | | - // |
456 | | - // |
457 | | - // All below methods ought to be static, but can't be since this would require LSB introduced in PHP 5.3. |
458 | | - // |
459 | | - // |
460 | | - |
461 | 455 | /** |
462 | 456 | * Get the database type used for read operations. |
463 | 457 | * |
464 | 458 | * @since 0.2 |
465 | 459 | * @return integer DB_ enum |
466 | 460 | */ |
467 | | - public function getReadDb() { |
| 461 | + public static function getReadDb() { |
468 | 462 | return self::$readDb; |
469 | 463 | } |
470 | 464 | |
— | — | @@ -474,7 +468,7 @@ |
475 | 469 | * |
476 | 470 | * @since 0.2 |
477 | 471 | */ |
478 | | - public function setReadDb( $db ) { |
| 472 | + public static function setReadDb( $db ) { |
479 | 473 | self::$readDb = $db; |
480 | 474 | } |
481 | 475 | |
— | — | @@ -487,8 +481,8 @@ |
488 | 482 | * |
489 | 483 | * @return boolean |
490 | 484 | */ |
491 | | - public function canHasField( $name ) { |
492 | | - return array_key_exists( $name, $this->getFieldTypes() ); |
| 485 | + public static function canHasField( $name ) { |
| 486 | + return array_key_exists( $name, static::getFieldTypes() ); |
493 | 487 | } |
494 | 488 | |
495 | 489 | /** |
— | — | @@ -501,11 +495,11 @@ |
502 | 496 | * |
503 | 497 | * @return array |
504 | 498 | */ |
505 | | - public function getPrefixedFields( $fields ) { |
| 499 | + public static function getPrefixedFields( $fields ) { |
506 | 500 | $fields = (array)$fields; |
507 | 501 | |
508 | 502 | foreach ( $fields as &$field ) { |
509 | | - $field = $this->getFieldPrefix() . $field; |
| 503 | + $field = static::getFieldPrefix() . $field; |
510 | 504 | } |
511 | 505 | |
512 | 506 | return $fields; |
— | — | @@ -520,8 +514,8 @@ |
521 | 515 | * |
522 | 516 | * @return string |
523 | 517 | */ |
524 | | - public function getPrefixedField( $field ) { |
525 | | - return $this->getFieldPrefix() . $field; |
| 518 | + public static function getPrefixedField( $field ) { |
| 519 | + return static::getFieldPrefix() . $field; |
526 | 520 | } |
527 | 521 | |
528 | 522 | /** |
— | — | @@ -535,11 +529,11 @@ |
536 | 530 | * |
537 | 531 | * @return array |
538 | 532 | */ |
539 | | - public function getPrefixedValues( array $values ) { |
| 533 | + public static function getPrefixedValues( array $values ) { |
540 | 534 | $prefixedValues = array(); |
541 | 535 | |
542 | 536 | foreach ( $values as $field => $value ) { |
543 | | - $prefixedValues[$this->getFieldPrefix() . $field] = $value; |
| 537 | + $prefixedValues[static::getFieldPrefix() . $field] = $value; |
544 | 538 | } |
545 | 539 | |
546 | 540 | return $prefixedValues; |
— | — | @@ -556,10 +550,10 @@ |
557 | 551 | * |
558 | 552 | * @return array |
559 | 553 | */ |
560 | | - protected function getFieldsFromDBResult( $result ) { |
| 554 | + protected static function getFieldsFromDBResult( $result ) { |
561 | 555 | $result = (array)$result; |
562 | 556 | $data = array(); |
563 | | - $idFieldLength = strlen( $this->getFieldPrefix() ); |
| 557 | + $idFieldLength = strlen( static::getFieldPrefix() ); |
564 | 558 | |
565 | 559 | foreach ( $result as $name => $value ) { |
566 | 560 | $data[substr( $name, $idFieldLength )] = $value; |
— | — | @@ -577,8 +571,8 @@ |
578 | 572 | * |
579 | 573 | * @return ReviewDBObject |
580 | 574 | */ |
581 | | - public function newFromDBResult( $result ) { |
582 | | - return $this->newFromArray( $this->getFieldsFromDBResult( $result ) ); |
| 575 | + public static function newFromDBResult( $result ) { |
| 576 | + return static::newFromArray( static::getFieldsFromDBResult( $result ) ); |
583 | 577 | } |
584 | 578 | |
585 | 579 | /** |
— | — | @@ -590,10 +584,10 @@ |
591 | 585 | * |
592 | 586 | * @return boolean Success indicator |
593 | 587 | */ |
594 | | - public function delete( array $conditions ) { |
| 588 | + public static function delete( array $conditions ) { |
595 | 589 | return wfGetDB( DB_MASTER )->delete( |
596 | | - $this->getDBTable(), |
597 | | - $this->getPrefixedValues( $conditions ) |
| 590 | + static::getDBTable(), |
| 591 | + static::getPrefixedValues( $conditions ) |
598 | 592 | ); |
599 | 593 | } |
600 | 594 | |
— | — | @@ -607,12 +601,12 @@ |
608 | 602 | * |
609 | 603 | * @return boolean Success indicator |
610 | 604 | */ |
611 | | - public function addToField( $field, $amount ) { |
| 605 | + public static function addToField( $field, $amount ) { |
612 | 606 | if ( $amount == 0 ) { |
613 | 607 | return true; |
614 | 608 | } |
615 | 609 | |
616 | | - if ( !$this->hasIdField() ) { |
| 610 | + if ( !static::hasIdField() ) { |
617 | 611 | return false; |
618 | 612 | } |
619 | 613 | |
— | — | @@ -621,17 +615,17 @@ |
622 | 616 | |
623 | 617 | $dbw = wfGetDB( DB_MASTER ); |
624 | 618 | |
625 | | - $fullField = $this->getPrefixedField( $field ); |
| 619 | + $fullField = static::getPrefixedField( $field ); |
626 | 620 | |
627 | 621 | $success = $dbw->update( |
628 | | - $this->getDBTable(), |
| 622 | + static::getDBTable(), |
629 | 623 | array( "$fullField=$fullField" . ( $isNegative ? '-' : '+' ) . $absoluteAmount ), |
630 | | - array( $this->getPrefixedField( 'id' ) => $this->getId() ), |
| 624 | + array( static::getPrefixedField( 'id' ) => static::getId() ), |
631 | 625 | __METHOD__ |
632 | 626 | ); |
633 | 627 | |
634 | | - if ( $success && $this->hasField( $field ) ) { |
635 | | - $this->setField( $field, $this->getField( $field ) + $amount ); |
| 628 | + if ( $success && static::hasField( $field ) ) { |
| 629 | + static::setField( $field, static::getField( $field ) + $amount ); |
636 | 630 | } |
637 | 631 | |
638 | 632 | return $success; |
— | — | @@ -649,21 +643,21 @@ |
650 | 644 | * |
651 | 645 | * @return array of self |
652 | 646 | */ |
653 | | - public function select( $fields = null, array $conditions = array(), array $options = array() ) { |
| 647 | + public static function select( $fields = null, array $conditions = array(), array $options = array() ) { |
654 | 648 | if ( is_null( $fields ) ) { |
655 | | - $fields = array_keys( $this->getFieldTypes() ); |
| 649 | + $fields = array_keys( static::getFieldTypes() ); |
656 | 650 | } |
657 | 651 | |
658 | | - $result = $this->rawSelect( |
659 | | - $this->getPrefixedFields( $fields ), |
660 | | - $this->getPrefixedValues( $conditions ), |
| 652 | + $result = static::rawSelect( |
| 653 | + static::getPrefixedFields( $fields ), |
| 654 | + static::getPrefixedValues( $conditions ), |
661 | 655 | $options |
662 | 656 | ); |
663 | 657 | |
664 | 658 | $objects = array(); |
665 | 659 | |
666 | 660 | foreach ( $result as $record ) { |
667 | | - $objects[] = $this->newFromDBResult( $record ); |
| 661 | + $objects[] = static::newFromDBResult( $record ); |
668 | 662 | } |
669 | 663 | |
670 | 664 | return $objects; |
— | — | @@ -681,10 +675,10 @@ |
682 | 676 | * |
683 | 677 | * @return self|false |
684 | 678 | */ |
685 | | - public function selectRow( $fields = null, array $conditions = array(), array $options = array() ) { |
| 679 | + public static function selectRow( $fields = null, array $conditions = array(), array $options = array() ) { |
686 | 680 | $options['LIMIT'] = 1; |
687 | 681 | |
688 | | - $objects = $this->select( $fields, $conditions, $options ); |
| 682 | + $objects = static::select( $fields, $conditions, $options ); |
689 | 683 | |
690 | 684 | return count( $objects ) > 0 ? $objects[0] : false; |
691 | 685 | } |
— | — | @@ -699,8 +693,8 @@ |
700 | 694 | * |
701 | 695 | * @return boolean |
702 | 696 | */ |
703 | | - public function has( array $conditions = array() ) { |
704 | | - return $this->selectRow( array( 'id' ), $conditions ) !== false; |
| 697 | + public static function has( array $conditions = array() ) { |
| 698 | + return static::selectRow( array( 'id' ), $conditions ) !== false; |
705 | 699 | } |
706 | 700 | |
707 | 701 | /** |
— | — | @@ -714,10 +708,10 @@ |
715 | 709 | * |
716 | 710 | * @return integer |
717 | 711 | */ |
718 | | - public function count( array $conditions = array(), array $options = array() ) { |
719 | | - $res = $this->rawSelect( |
| 712 | + public static function count( array $conditions = array(), array $options = array() ) { |
| 713 | + $res = static::rawSelect( |
720 | 714 | array( 'COUNT(*) AS rowcount' ), |
721 | | - $this->getPrefixedValues( $conditions ), |
| 715 | + static::getPrefixedValues( $conditions ), |
722 | 716 | $options |
723 | 717 | )->fetchObject(); |
724 | 718 | |
— | — | @@ -736,11 +730,11 @@ |
737 | 731 | * |
738 | 732 | * @return ResultWrapper |
739 | 733 | */ |
740 | | - public function rawSelect( $fields = null, array $conditions = array(), array $options = array() ) { |
741 | | - $dbr = wfGetDB( $this->getReadDb() ); |
| 734 | + public static function rawSelect( $fields = null, array $conditions = array(), array $options = array() ) { |
| 735 | + $dbr = wfGetDB( static::getReadDb() ); |
742 | 736 | |
743 | 737 | return $dbr->select( |
744 | | - $this->getDBTable(), |
| 738 | + static::getDBTable(), |
745 | 739 | $fields, |
746 | 740 | count( $conditions ) == 0 ? '' : $conditions, |
747 | 741 | __METHOD__, |
— | — | @@ -760,13 +754,13 @@ |
761 | 755 | * |
762 | 756 | * @return boolean Success indicator |
763 | 757 | */ |
764 | | - public function update( array $values, array $conditions = array() ) { |
| 758 | + public static function update( array $values, array $conditions = array() ) { |
765 | 759 | $dbw = wfGetDB( DB_MASTER ); |
766 | 760 | |
767 | 761 | return $dbw->update( |
768 | | - $this->getDBTable(), |
769 | | - $this->getPrefixedValues( $values ), |
770 | | - $this->getPrefixedValues( $conditions ), |
| 762 | + static::getDBTable(), |
| 763 | + static::getPrefixedValues( $values ), |
| 764 | + static::getPrefixedValues( $conditions ), |
771 | 765 | __METHOD__ |
772 | 766 | ); |
773 | 767 | } |
— | — | @@ -778,8 +772,8 @@ |
779 | 773 | * |
780 | 774 | * @return array |
781 | 775 | */ |
782 | | - public function getFieldNames() { |
783 | | - return array_keys( $this->getFieldTypes() ); |
| 776 | + public static function getFieldNames() { |
| 777 | + return array_keys( static::getFieldTypes() ); |
784 | 778 | } |
785 | 779 | |
786 | 780 | /** |
— | — | @@ -791,7 +785,7 @@ |
792 | 786 | * |
793 | 787 | * @return array |
794 | 788 | */ |
795 | | - public function getFieldDescriptions() { |
| 789 | + public static function getFieldDescriptions() { |
796 | 790 | return array(); |
797 | 791 | } |
798 | 792 | |
— | — | @@ -805,7 +799,7 @@ |
806 | 800 | * |
807 | 801 | * @return array |
808 | 802 | */ |
809 | | - public function getAPIParams( $requireParams = false, $setDefaults = false ) { |
| 803 | + public static function getAPIParams( $requireParams = false, $setDefaults = false ) { |
810 | 804 | $typeMap = array( |
811 | 805 | 'id' => 'integer', |
812 | 806 | 'int' => 'integer', |
— | — | @@ -816,9 +810,9 @@ |
817 | 811 | ); |
818 | 812 | |
819 | 813 | $params = array(); |
820 | | - $defaults = $this->getDefaults(); |
| 814 | + $defaults = static::getDefaults(); |
821 | 815 | |
822 | | - foreach ( $this->getFieldTypes() as $field => $type ) { |
| 816 | + foreach ( static::getFieldTypes() as $field => $type ) { |
823 | 817 | if ( $field == 'id' ) { |
824 | 818 | continue; |
825 | 819 | } |
Index: trunk/extensions/Reviews/Reviews.settings.php |
— | — | @@ -28,6 +28,7 @@ |
29 | 29 | */ |
30 | 30 | protected static function getDefaultSettings() { |
31 | 31 | return array( |
| 32 | + 'enableTopLink' => true, |
32 | 33 | ); |
33 | 34 | } |
34 | 35 | |
Index: trunk/extensions/Reviews/Reviews.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | die( '<b>Error:</b> Reviews requires MediaWiki 1.18 or above.' ); |
30 | 30 | } |
31 | 31 | |
32 | | -define( 'REVIEWS_VERSION', '0.2 alpha' ); |
| 32 | +define( 'REVIEWS_VERSION', '0.1 alpha' ); |
33 | 33 | |
34 | 34 | $wgExtensionCredits['other'][] = array( |
35 | 35 | 'path' => __FILE__, |
— | — | @@ -95,3 +95,6 @@ |
96 | 96 | unset( $moduleTemplate ); |
97 | 97 | |
98 | 98 | $egReviewsSettings = array(); |
| 99 | + |
| 100 | +# The default value for the user preference to display a top link to the my reviews special page. |
| 101 | +$wgDefaultUserOptions['reviews_showtoplink'] = false; |