Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php |
— | — | @@ -42,7 +42,9 @@ |
43 | 43 | wfLoadExtensionMessages( 'CentralNotice' ); |
44 | 44 | } |
45 | 45 | |
46 | | - // Handle different types of page requests |
| 46 | + /* |
| 47 | + * Handle different types of page requests. |
| 48 | + */ |
47 | 49 | function execute( $sub ) { |
48 | 50 | global $wgOut, $wgUser, $wgRequest; |
49 | 51 | |
— | — | @@ -141,6 +143,9 @@ |
142 | 144 | $this->showList(); |
143 | 145 | } |
144 | 146 | |
| 147 | + /* |
| 148 | + * Show a list of available templates. Newer templates are shown first. |
| 149 | + */ |
145 | 150 | function showList() { |
146 | 151 | global $wgOut, $wgUser, $wgRequest, $wgLang; |
147 | 152 | |
— | — | @@ -537,7 +542,10 @@ |
538 | 543 | $article->doEdit( $translation, '', EDIT_FORCE_BOT ); |
539 | 544 | } |
540 | 545 | |
541 | | - function queryTemplates($offset, $limit) { |
| 546 | + /* |
| 547 | + * Return an array of templates constrained by offset and limit parameters. |
| 548 | + */ |
| 549 | + function queryTemplates( $offset, $limit ) { |
542 | 550 | $dbr = wfGetDB( DB_SLAVE ); |
543 | 551 | $conds = array(); |
544 | 552 | $options['ORDER BY'] = $this->indexField . ' DESC'; |
— | — | @@ -563,7 +571,6 @@ |
564 | 572 | foreach ( $res as $row ) { |
565 | 573 | array_push( $templates, $row->tmp_name ); |
566 | 574 | } |
567 | | - |
568 | 575 | return $templates; |
569 | 576 | } |
570 | 577 | |
— | — | @@ -770,7 +777,7 @@ |
771 | 778 | function getPagingQueries( $offset, $limit ) { |
772 | 779 | $dbr = wfGetDB( DB_SLAVE ); |
773 | 780 | if ( $offset ) { |
774 | | - // prev |
| 781 | + // Build previous link |
775 | 782 | $templates = array(); |
776 | 783 | $conds = array(); |
777 | 784 | $options['ORDER BY'] = $this->indexField . ' ASC'; |
— | — | @@ -783,14 +790,14 @@ |
784 | 791 | $options |
785 | 792 | ); |
786 | 793 | foreach ( $res as $row ) { |
787 | | - array_push( $templates, $row->tmp_name ); |
| 794 | + array_push( $templates, $row->tmp_id ); |
788 | 795 | } |
789 | 796 | if ( count( $templates ) == $limit + 1 ) { |
790 | 797 | $prev = array( 'offset' => end( $templates ), 'limit' => $limit ); |
791 | 798 | } else { |
792 | 799 | $prev = array( 'offset' => '0', 'limit' => $limit ); |
793 | 800 | } |
794 | | - // next |
| 801 | + // Build next link |
795 | 802 | $templates = array(); |
796 | 803 | $conds = array(); |
797 | 804 | $conds[] = $this->indexField . '<' . $this->mDb->addQuotes( $offset ); |
— | — | @@ -803,7 +810,7 @@ |
804 | 811 | $options |
805 | 812 | ); |
806 | 813 | foreach ( $res as $row ) { |
807 | | - array_push( $templates, $row->tmp_name ); |
| 814 | + array_push( $templates, $row->tmp_id ); |
808 | 815 | } |
809 | 816 | if ( count( $templates ) == $limit + 1 ) { |
810 | 817 | end( $templates ); |
— | — | @@ -812,8 +819,9 @@ |
813 | 820 | $next = false; |
814 | 821 | } |
815 | 822 | } else { |
| 823 | + // No previous link needed |
816 | 824 | $prev = false; |
817 | | - // next |
| 825 | + // Build next link |
818 | 826 | $templates = array(); |
819 | 827 | $options['ORDER BY'] = $this->indexField . ' DESC'; |
820 | 828 | $options['LIMIT'] = intval( $limit ) + 1; |
— | — | @@ -824,7 +832,7 @@ |
825 | 833 | $options |
826 | 834 | ); |
827 | 835 | while ( $row = $dbr->fetchObject( $res ) ) { |
828 | | - array_push( $templates, $row->tmp_name ); |
| 836 | + array_push( $templates, $row->tmp_id ); |
829 | 837 | } |
830 | 838 | if ( count( $templates ) == $limit + 1 ) { |
831 | 839 | end( $templates ); |
— | — | @@ -843,7 +851,7 @@ |
844 | 852 | * of HTML. |
845 | 853 | */ |
846 | 854 | function getPagingLinks( $linkTexts, $offset, $limit, $disabledTexts = array() ) { |
847 | | - $queries = $this->getPagingQueries($offset, $limit); |
| 855 | + $queries = $this->getPagingQueries( $offset, $limit ); |
848 | 856 | $links = array(); |
849 | 857 | foreach ( $queries as $type => $query ) { |
850 | 858 | if ( $query !== false ) { |