Index: trunk/extensions/Deployment/specials/SpecialInstall.php |
— | — | @@ -44,10 +44,17 @@ |
45 | 45 | |
46 | 46 | // If the user is authorized, display the page, if not, show an error. |
47 | 47 | if ( $this->userCanExecute( $wgUser ) ) { |
48 | | - if ( $wgRequest->wasPosted() ) { |
| 48 | + if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
49 | 49 | $this->showCompactSearchOptions(); |
50 | | - // TODO |
51 | | - $this->findExtenions(); |
| 50 | + |
| 51 | + $extensions = $this->findExtenions( $wgRequest->getText( 'filtertype' ), $wgRequest->getText( 'filtervalue' ) ); |
| 52 | + |
| 53 | + if ( count( $extensions ) > 0 ) { |
| 54 | + $this->showExtensionList(); |
| 55 | + } |
| 56 | + else { |
| 57 | + // TODO |
| 58 | + } |
52 | 59 | } |
53 | 60 | else { |
54 | 61 | $this->showFullSearchOptions(); |
— | — | @@ -57,23 +64,97 @@ |
58 | 65 | } |
59 | 66 | } |
60 | 67 | |
| 68 | + /** |
| 69 | + * Created the HTML for the full set of search options controls and adds it to $wgOut. |
| 70 | + * |
| 71 | + * @since 0.1 |
| 72 | + */ |
61 | 73 | protected function showFullSearchOptions() { |
62 | | - // TODO |
| 74 | + global $wgOut, $wgUser, $wgRepositoryLocation; |
| 75 | + |
| 76 | + $wgOut->addWikiMsgArray( 'extensions-description', $wgRepositoryLocation ); |
| 77 | + |
| 78 | + $searchHtml = Html::element( 'h2', array(), wfMsg( 'search-extensions' ) ); |
| 79 | + $searchHtml .= wfMsg( 'search-extensions-long' ); |
| 80 | + |
| 81 | + $searchHtml .= Html::openElement( |
| 82 | + 'form', |
| 83 | + array( |
| 84 | + 'id' => 'searchform', |
| 85 | + 'name' => 'searchform', |
| 86 | + 'method' => 'post', |
| 87 | + 'action' => $this->getTitle()->getLocalURL(), |
| 88 | + ) |
| 89 | + ); |
| 90 | + |
| 91 | + $searchHtml .= Html::rawElement( |
| 92 | + 'select', |
| 93 | + array( |
| 94 | + 'name' => 'filtertype', |
| 95 | + 'id' => 'filtertype' |
| 96 | + ), |
| 97 | + '<option value="term">' . htmlspecialchars( wfMsg( 'search-term' ) ) . '</option>' . |
| 98 | + '<option value="author">' . htmlspecialchars( wfMsg( 'search-author' ) ) . '</option>' . |
| 99 | + '<option value="tag">' . htmlspecialchars( wfMsg( 'search-tag' ) ) . '</option>' |
| 100 | + ); |
| 101 | + |
| 102 | + $searchHtml .= ' '; |
| 103 | + |
| 104 | + $searchHtml .= Html::input( 'filtervalue' ); |
| 105 | + |
| 106 | + $searchHtml .= ' '; |
| 107 | + |
| 108 | + $searchHtml .= Html::input( |
| 109 | + '', |
| 110 | + wfMsg( 'search-extensions-button' ), |
| 111 | + 'submit', |
| 112 | + array( 'id' => 'searchform-button' ) |
| 113 | + ); |
| 114 | + |
| 115 | + $searchHtml .= Html::hidden( 'wpEditToken', $wgUser->editToken() ); |
| 116 | + |
| 117 | + $searchHtml .= Html::closeElement( 'form' ); |
| 118 | + |
| 119 | + $wgOut->addHTML( $searchHtml ); |
| 120 | + |
| 121 | + $tagHtml = Html::element( 'h2', array(), wfMsg( 'popular-extension-tags' ) ); |
| 122 | + $tagHtml .= wfMsg( 'popular-extension-tags-long' ); |
| 123 | + |
| 124 | + $wgOut->addHTML( $tagHtml ); |
63 | 125 | } |
64 | 126 | |
| 127 | + /** |
| 128 | + * Created the HTML for the compact search options and adds it to $wgOut. |
| 129 | + * |
| 130 | + * @since 0.1 |
| 131 | + */ |
65 | 132 | protected function showCompactSearchOptions() { |
| 133 | + global $wgOut; |
66 | 134 | // TODO |
67 | 135 | } |
68 | 136 | |
| 137 | + /** |
| 138 | + * Queries the repository for a list of extensions matching the search criteria |
| 139 | + * and returns these. |
| 140 | + * |
| 141 | + * @since 0.1 |
| 142 | + * |
| 143 | + * @param $filterType String |
| 144 | + * @param $filterValue String |
| 145 | + * |
| 146 | + * @return arrau |
| 147 | + */ |
69 | 148 | protected function findExtenions( $filterType, $filterValue ) { |
70 | 149 | $repository = wfGetRepository(); |
71 | 150 | |
72 | | - $repository->findExtenions( $filterType, $filterValue ); |
| 151 | + return $repository->findExtenions( $filterType, $filterValue ); |
73 | 152 | } |
74 | 153 | |
75 | 154 | /** |
76 | 155 | * Show the extensions that where found in a list. |
77 | 156 | * |
| 157 | + * @since 0.1 |
| 158 | + * |
78 | 159 | * @param $extensions Array |
79 | 160 | */ |
80 | 161 | protected function showExtensionList( array $extensions ) { |
Index: trunk/extensions/Deployment/Deployment.i18n.php |
— | — | @@ -45,6 +45,10 @@ |
46 | 46 | 'extensions-description' => 'Extensions extend and expand the functionality of MediaWiki. You can browse and search extensions that are in the [$1 MediaWiki Extension Repository] to install via this page.', |
47 | 47 | 'search-extensions' => 'Search', |
48 | 48 | 'search-extensions-long' => 'Search for extensions by keyword, author, or tag.', |
| 49 | + 'search-term' => 'Term', |
| 50 | + 'search-author' => 'Author', |
| 51 | + 'search-tag' => 'Tag', |
| 52 | + 'search-extensions-button' => 'Search extensions', |
49 | 53 | 'popular-extension-tags' => 'Popular tags', |
50 | 54 | 'popular-extension-tags-long' => 'You may also browse based on the most popular tags in the Extension Repository:', |
51 | 55 | |
Index: trunk/extensions/Deployment/includes/DistributionRepository.php |
— | — | @@ -57,7 +57,14 @@ |
58 | 58 | array( 'sslVerifyHost' => true, 'sslVerifyCert' => true ) |
59 | 59 | ); |
60 | 60 | |
61 | | - // TODO: parse and return result |
| 61 | + $extensions = array(); |
| 62 | + |
| 63 | + if ( $response !== false ) { |
| 64 | + $extensions = FormatJson::decode( $response ); |
| 65 | + } |
| 66 | + // TODO |
| 67 | + var_dump($extensions);exit; |
| 68 | + return $extensions; |
62 | 69 | } |
63 | 70 | |
64 | 71 | } |
\ No newline at end of file |