Index: trunk/extensions/Deployment/specials/SpecialExtensions.php |
— | — | @@ -57,24 +57,79 @@ |
58 | 58 | |
59 | 59 | // If the user is authorized, display the page, if not, show an error. |
60 | 60 | if ( $this->userCanExecute( $wgUser ) ) { |
61 | | - $wgOut->addHTML( |
62 | | - Html::element( |
63 | | - 'button', |
64 | | - array( |
65 | | - 'type' => 'button', |
66 | | - 'onclick' => 'window.location="' . Xml::escapeJsString( SpecialPage::getTitleFor( 'install' )->getFullURL() ) . '"' |
67 | | - ), |
68 | | - wfMsg( 'add-new-extensions' ) |
69 | | - ) |
70 | | - ); |
71 | | - |
72 | | - $wgOut->addWikiText( $this->getExtensionList() ); |
| 61 | + $this->displayPage(); |
73 | 62 | } else { |
74 | 63 | $this->displayRestrictionError(); |
75 | 64 | } |
76 | 65 | } |
77 | 66 | |
78 | 67 | /** |
| 68 | + * Creates and outputs the page contents. |
| 69 | + * |
| 70 | + * @since 0.1 |
| 71 | + */ |
| 72 | + protected function displayPage() { |
| 73 | + global $wgOut; |
| 74 | + |
| 75 | + // Shows an "add new" button linking to the Special:Install page. |
| 76 | + $wgOut->addHTML( |
| 77 | + Html::element( |
| 78 | + 'button', |
| 79 | + array( |
| 80 | + 'type' => 'button', |
| 81 | + 'onclick' => 'window.location="' . Xml::escapeJsString( SpecialPage::getTitleFor( 'install' )->getFullURL() ) . '"' |
| 82 | + ), |
| 83 | + wfMsg( 'add-new-extensions' ) |
| 84 | + ) |
| 85 | + ); |
| 86 | + |
| 87 | + $wgOut->addWikiText( |
| 88 | + Xml::element( 'h2', array( 'id' => 'mw-version-ext' ), wfMsg( 'version-extensions' ) ) |
| 89 | + ); |
| 90 | + |
| 91 | + $this->displayFilterControl(); |
| 92 | + |
| 93 | + $this->displayBulkActions(); |
| 94 | + |
| 95 | + $wgOut->addWikiText( $this->getExtensionList() ); |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * Creates and outputs the filter control. |
| 100 | + * |
| 101 | + * @since 0.1 |
| 102 | + */ |
| 103 | + protected function displayFilterControl() { |
| 104 | + global $wgOut, $wgExtensionCredits; |
| 105 | + |
| 106 | + $extensionAmount = 0; |
| 107 | + $filterSegments = array(); |
| 108 | + |
| 109 | + // TODO: links |
| 110 | + |
| 111 | + foreach ( $wgExtensionCredits as $type => $extensions ) { |
| 112 | + $amount = count( $extensions ); |
| 113 | + $name = SpecialVersion::getExtensionTypeName( $type ); |
| 114 | + |
| 115 | + $filterSegments[] = "$name ($amount)"; |
| 116 | + $extensionAmount += $amount; |
| 117 | + } |
| 118 | + |
| 119 | + $filterSegments = array_merge( array( "All ($extensionAmount)" ), $filterSegments ); |
| 120 | + |
| 121 | + $wgOut->addHTML( implode( ' | ', $filterSegments ) ); |
| 122 | + } |
| 123 | + |
| 124 | + /** |
| 125 | + * Creates and outputs the bilk actions control. |
| 126 | + * |
| 127 | + * @since 0.1 |
| 128 | + */ |
| 129 | + protected function displayBulkActions() { |
| 130 | + // TODO |
| 131 | + } |
| 132 | + |
| 133 | + /** |
79 | 134 | * Creates and returns the HTML for the extension list. |
80 | 135 | * |
81 | 136 | * @since 0.1 |
— | — | @@ -84,8 +139,7 @@ |
85 | 140 | protected function getExtensionList() { |
86 | 141 | global $wgExtensionCredits; |
87 | 142 | |
88 | | - $out = Xml::element( 'h2', array( 'id' => 'mw-version-ext' ), wfMsg( 'version-extensions' ) ); |
89 | | - $out .= Xml::openElement( 'table', array( 'class' => 'wikitable', 'id' => 'sv-ext' ) ); |
| 143 | + $out = Xml::openElement( 'table', array( 'class' => 'wikitable', 'id' => 'sv-ext' ) ); |
90 | 144 | |
91 | 145 | $extensionTypes = SpecialVersion::getExtensionTypes(); |
92 | 146 | |