20use UnexpectedValueException;
34 private array $files = [];
48 parent::__construct( $context, $linkRenderer );
50 $this->stash = $stash;
51 $this->localRepo = $localRepo;
56 if ( !$this->mFieldNames ) {
57 $this->mFieldNames = [
58 'us_timestamp' => $this->
msg(
'uploadstash-header-date' )->text(),
59 'us_key' => $this->
msg(
'uploadstash-header-filekey' )->text(),
60 'thumb' => $this->
msg(
'uploadstash-header-thumb' )->text(),
61 'us_size' => $this->
msg(
'uploadstash-header-dimensions' )->text(),
70 return in_array( $field, [
'us_timestamp',
'us_key' ] );
76 'tables' => [
'uploadstash' ],
87 'conds' => [
'us_user' => $this->
getUser()->getId() ],
95 return [ [
'us_timestamp',
'us_id' ] ];
100 return 'us_timestamp';
114 return htmlspecialchars( $this->
getLanguage()->userTimeAndDate( $value, $this->
getUser() ) );
117 $html = $linkRenderer->makeKnownLink(
121 if ( $this->mCurrentRow->us_status ===
'finished' ) {
122 $html .=
'<br />' . Html::rawElement(
'span', [
'class' =>
'mw-uploadstash-tryagain' ],
123 $this->
msg(
'parentheses' )->rawParams( $linkRenderer->makeKnownLink(
125 $this->msg(
'uploadstash-pager-tryagain' )->text(),
127 [
'wpSourceType' =>
'Stash',
'wpSessionKey' => $value ]
133 $file = $this->getCurrentFile();
134 if ( $file->allowInlineDisplay() ) {
135 $thumbnail = $file->transform( [
140 return $thumbnail->toHtml( [
'loading' =>
'lazy' ] );
143 return $this->
msg(
'uploadstash-nothumb' )->escaped();
145 $file = $this->getCurrentFile();
146 return htmlspecialchars( $file->getDimensionsString() )
147 . $this->
msg(
'word-separator' )->escaped()
148 .
Html::element(
'span', [
'style' =>
'white-space: nowrap;' ],
149 $this->
msg(
'parentheses' )->sizeParams( (
int)$value )->text()
152 throw new UnexpectedValueException(
"Unknown field '$field'" );
156 private function getCurrentFile():
File {
157 $fileKey = $this->mCurrentRow->us_key;
158 return $this->files[$fileKey]
161 $this->mCurrentRow->us_path,
163 $this->mCurrentRow->us_sha1,
164 $this->mCurrentRow->us_mime ??
false
171 private function getEscapedLimitSelectList(): array {
172 $list = $this->getLimitSelectList();
174 foreach ( $list as $key => $value ) {
175 $result[htmlspecialchars( $key )] = $value;
182 $formDescriptor = [];
183 $formDescriptor[
'limit'] = [
186 'label-message' =>
'table_pager_limit_label',
187 'options' => $this->getEscapedLimitSelectList(),
189 'default' => $this->mLimit
192 HTMLForm::factory(
'ooui', $formDescriptor, $this->getContext() )
194 ->setId(
'mw-uploadstash-form' )
195 ->setTitle( $this->getTitle() )
196 ->setSubmitTextMsg(
'uploadstash-pager-submit' )
197 ->setWrapperLegendMsg(
'uploadstash' )
204 return parent::getTableClass() .
' uploadstash';
209 return parent::getNavClass() .
' uploadstash_nav';
214 return parent::getSortHeaderClass() .
' uploadstash_sort';
219class_alias( UploadStashPager::class,
'MediaWiki\\Pager\\UploadStashPager' );
setContext(IContextSource $context)
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Parent class for all special pages.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Interface for objects which can provide a MediaWiki context on request.