+ /**
+ * Returns an array of html code of the following checkboxes:
+ * minor and watch
+ *
+ * @param int $tabindex Current tabindex
+ * @param array $checked Array of checkbox => bool, where bool indicates the checked
+ * status of the checkbox
+ *
+ * @return array
+ */
+ public function getCheckboxesOOUI( &$tabindex, $checked ) {
+ $checkboxes = [];
+ $checkboxesDef = $this->getCheckboxesDefinition( $checked );
+
+ $origTabindex = $tabindex;
+
+ foreach ( $checkboxesDef as $name => $options ) {
+ $legacyName = isset( $options['legacy-name'] ) ? $options['legacy-name'] : $name;
+
+ $title = null;
+ $accesskey = null;
+ if ( isset( $options['tooltip'] ) ) {
+ $accesskey = $this->context->msg( "accesskey-{$options['tooltip']}" )->text();
+ $title = Linker::titleAttrib( $options['tooltip'], 'withaccess' );
+ }
+ if ( isset( $options['title-message'] ) ) {
+ $title = $this->context->msg( $options['title-message'] )->text();
+ }
+ if ( isset( $options['label-id'] ) ) {
+ $labelAttribs['id'] = $options['label-id'];
+ }
+
+ $checkboxes[ $legacyName ] = new OOUI\FieldLayout(
+ new OOUI\CheckboxInputWidget( [
+ 'tabIndex' => ++$tabindex,
+ 'accessKey' => $accesskey,
+ 'id' => $options['id'],
+ 'name' => $name,
+ 'selected' => $options['default'],
+ ] ),
+ [
+ 'align' => 'inline',
+ 'label' => new OOUI\HtmlSnippet( $this->context->msg( $options['label-message'] )->parse() ),
+ 'title' => $title,
+ 'id' => isset( $options['label-id'] ) ? $options['label-id'] : null,
+ ]
+ );
+ }
+
+ // Backwards-compatibility hack to run the EditPageBeforeEditChecks hook. It's important,
+ // people have used it for the weirdest things completely unrelated to checkboxes...
+ // And if we're gonna run it, might as well allow its legacy checkboxes to be shown.
+ $legacyCheckboxes = $this->getCheckboxes( $origTabindex, $checked );
+ foreach ( $legacyCheckboxes as $name => $html ) {
+ if ( $html && !isset( $checkboxes[$name] ) ) {
+ $checkboxes[$name] = new OOUI\Widget( [ 'content' => new OOUI\HtmlSnippet( $html ) ] );
+ }
+ }
+
+ return $checkboxes;
+ }
+