MediaWiki REL1_34
OATHAuthOOUIHTMLForm.php
Go to the documentation of this file.
1<?php
2
4
9use OOUI\FieldsetLayout;
10use OOUI\HtmlSnippet;
11use OOUI\Layout;
12use OOUI\PanelLayout;
13use OOUI\Widget;
14use OOUIHTMLForm;
15use Psr\Log\LoggerInterface;
16
17abstract class OATHAuthOOUIHTMLForm extends OOUIHTMLForm implements IManageForm {
21 protected $oathUser;
25 protected $oathRepo;
29 protected $module;
30
34 protected $logger;
35
39 protected $layoutContainer = null;
40
45 protected $panelPadded = true;
46
51 protected $panelFramed = true;
52
61 $this->oathUser = $oathUser;
62 $this->oathRepo = $oathRepo;
63 $this->module = $module;
64 $this->logger = $this->getLogger();
65
66 parent::__construct( $this->getDescriptors(), null, "oathauth" );
67 }
68
72 public function show( $layout = null ) {
73 $this->layoutContainer = $layout;
74 return parent::show();
75 }
76
80 public function displayForm( $submitResult ) {
81 if ( !$this->layoutContainer instanceof Layout ) {
82 return parent::displayForm( $submitResult );
83 }
84
85 $this->layoutContainer->appendContent( new HtmlSnippet(
86 $this->getHTML( $submitResult )
87 ) );
88 }
89
93 protected function getDescriptors() {
94 return [];
95 }
96
100 private function getLogger() {
101 return LoggerFactory::getInstance( 'authentication' );
102 }
103
104 protected function wrapFieldSetSection( $legend, $section, $attributes, $isRoot ) {
105 // to get a user visible effect, wrap the fieldset into a framed panel layout
106 $layout = new PanelLayout( array_merge( [
107 'expanded' => false,
108 'padded' => true,
109 'framed' => false,
110 'infusable' => false,
111 ], [
112 'padded' => $this->panelPadded,
113 'framed' => $this->panelFramed
114 ] ) );
115
116 $layout->appendContent(
117 new FieldsetLayout( [
118 'label' => $legend,
119 'infusable' => false,
120 'items' => [
121 new Widget( [
122 'content' => new HtmlSnippet( $section )
123 ] ),
124 ],
125 ] + $attributes )
126 );
127 return $layout;
128 }
129
134 abstract public function onSubmit( array $formData );
135
136 abstract public function onSuccess();
137}
getHTML( $submitResult)
Returns the raw HTML generated by the form.
wrapFieldSetSection( $legend, $section, $attributes, $isRoot)
Wraps the given $section into an user-visible fieldset.string The fieldset's HtmlOOUI\PanelLayout
__construct(OATHUser $oathUser, OATHUserRepository $oathRepo, IModule $module)
Initialize the form.
displayForm( $submitResult)
Display the form (sending to the context's OutputPage object), with an appropriate error message or s...
Class representing a user from OATH's perspective.
Definition OATHUser.php:28
PSR-3 logger instance factory.
Compact stacked vertical format for forms, implemented using OOUI widgets.