32 &$query_options, &$join_conds, FormOptions $opts
34 global $wgTranslateRcFilterDefault;
36 if ( $pageName !==
'Recentchanges' || self::isStructuredFilterUiEnabled() ) {
40 $request = RequestContext::getMain()->getRequest();
41 $translations = $request->getVal(
'translations', $wgTranslateRcFilterDefault );
42 $opts->add(
'translations', $wgTranslateRcFilterDefault );
43 $opts->setValue(
'translations', $translations );
45 $dbr = wfGetDB( DB_REPLICA );
47 $namespaces = self::getTranslateNamespaces();
49 if ( $translations ===
'only' ) {
50 $conds[] =
'rc_namespace IN (' . $dbr->makeList( $namespaces ) .
')';
51 $conds[] =
'rc_title like \'%%/%%\'';
52 } elseif ( $translations ===
'filter' ) {
53 $conds[] =
'rc_namespace NOT IN (' . $dbr->makeList( $namespaces ) .
')';
54 } elseif ( $translations ===
'site' ) {
55 $conds[] =
'rc_namespace IN (' . $dbr->makeList( $namespaces ) .
')';
56 $conds[] =
'rc_title not like \'%%/%%\'';
84 if ( self::isStructuredFilterUiEnabled() ) {
88 $opts->consumeValue(
'translations' );
89 $default = $opts->getValue(
'translations' );
92 wfMessage(
'translate-rc-translation-filter' )->text(),
93 'mw-translation-filter'
95 $select =
new XmlSelect(
'translations',
'mw-translation-filter', $default );
97 wfMessage(
'translate-rc-translation-filter-no' )->text(),
100 $select->addOption( wfMessage(
'translate-rc-translation-filter-only' )->text(),
'only' );
102 wfMessage(
'translate-rc-translation-filter-filter' )->text(),
105 $select->addOption( wfMessage(
'translate-rc-translation-filter-site' )->text(),
'site' );
107 $items[
'translations'] = [ $label, $select->getHTML() ];
133 ChangesListSpecialPage $special
135 global $wgTranslateRcFilterDefault;
136 $defaultFilter = $wgTranslateRcFilterDefault !==
'noaction' ?
137 $wgTranslateRcFilterDefault :
138 ChangesListStringOptionsFilterGroup::NONE;
140 $translationsGroup =
new ChangesListStringOptionsFilterGroup(
142 'name' =>
'translations',
143 'title' =>
'translate-rcfilters-translations',
145 'default' => $defaultFilter,
146 'isFullCoverage' =>
true,
150 'label' =>
'translate-rcfilters-translations-only-label',
151 'description' =>
'translate-rcfilters-translations-only-desc',
152 'cssClassSuffix' =>
'only',
153 'isRowApplicableCallable' =>
function ( $ctx, $rc ) {
154 $namespaces = self::getTranslateNamespaces();
156 return in_array( $rc->getAttribute(
'rc_namespace' ), $namespaces ) &&
157 strpos( $rc->getAttribute(
'rc_title' ),
'/' ) !==
false;
162 'label' =>
'translate-rcfilters-translations-site-label',
163 'description' =>
'translate-rcfilters-translations-site-desc',
164 'cssClassSuffix' =>
'site',
165 'isRowApplicableCallable' =>
function ( $ctx, $rc ) {
166 $namespaces = self::getTranslateNamespaces();
168 return in_array( $rc->getAttribute(
'rc_namespace' ), $namespaces ) &&
169 strpos( $rc->getAttribute(
'rc_title' ),
'/' ) ===
false;
174 'label' =>
'translate-rcfilters-translations-filter-label',
175 'description' =>
'translate-rcfilters-translations-filter-desc',
176 'cssClassSuffix' =>
'filter',
177 'isRowApplicableCallable' =>
function ( $ctx, $rc ) {
178 $namespaces = self::getTranslateNamespaces();
180 return !in_array( $rc->getAttribute(
'rc_namespace' ), $namespaces );
184 'queryCallable' =>
function ( $specialClassName, $ctx, $dbr, &$tables,
185 &$fields, &$conds, &$query_options, &$join_conds, $selectedValues
187 $fields = array_merge( $fields, [
'rc_title',
'rc_namespace' ] );
189 $namespaces = self::getTranslateNamespaces();
190 $inNamespaceCond =
'rc_namespace IN (' .
191 $dbr->makeList( $namespaces ) .
')';
192 $notInNamespaceCond =
'rc_namespace NOT IN (' .
193 $dbr->makeList( $namespaces ) .
')';
195 $onlyCond = $dbr->makeList( [
198 $dbr->buildLike( $dbr->anyString(),
'/', $dbr->anyString() )
200 $siteCond = $dbr->makeList( [
203 $dbr->buildLike( $dbr->anyString(),
'/', $dbr->anyString() )
206 if ( count( $selectedValues ) === 3 ) {
211 if ( $selectedValues === [
'filter',
'only' ] ) {
212 $conds[] = $dbr->makeList( [
219 if ( $selectedValues === [
'filter',
'site' ] ) {
220 $conds[] = $dbr->makeList( [
227 if ( $selectedValues === [
'only',
'site' ] ) {
228 $conds[] = $inNamespaceCond;
232 if ( $selectedValues === [
'filter' ] ) {
233 $conds[] = $notInNamespaceCond;
237 if ( $selectedValues === [
'only' ] ) {
238 $conds[] = $onlyCond;
242 if ( $selectedValues === [
'site' ] ) {
243 $conds[] = $siteCond;
249 $special->registerFilterGroup( $translationsGroup );