21use UnexpectedValueException;
33 private array $files = [];
46 $this->mDefaultDirection = IndexPager::DIR_DESCENDING;
48 parent::__construct( $context, $linkRenderer );
53 if ( !$this->mFieldNames ) {
54 $this->mFieldNames = [
55 'us_timestamp' => $this->
msg(
'uploadstash-header-date' )->text(),
56 'us_key' => $this->
msg(
'uploadstash-header-filekey' )->text(),
57 'thumb' => $this->
msg(
'uploadstash-header-thumb' )->text(),
58 'us_size' => $this->
msg(
'uploadstash-header-dimensions' )->text(),
67 return in_array( $field, [
'us_timestamp',
'us_key' ] );
73 'tables' => [
'uploadstash' ],
84 'conds' => [
'us_user' => $this->
getUser()->getId() ],
92 return [ [
'us_timestamp',
'us_id' ] ];
97 return 'us_timestamp';
111 return htmlspecialchars( $this->
getLanguage()->userTimeAndDate( $value, $this->
getUser() ) );
114 $html = $linkRenderer->makeKnownLink(
118 if ( $this->mCurrentRow->us_status ===
'finished' ) {
119 $html .=
'<br />' . Html::rawElement(
'span', [
'class' =>
'mw-uploadstash-tryagain' ],
120 $this->
msg(
'parentheses' )->rawParams( $linkRenderer->makeKnownLink(
122 $this->msg(
'uploadstash-pager-tryagain' )->text(),
124 [
'wpSourceType' =>
'Stash',
'wpSessionKey' => $value ]
130 $file = $this->getCurrentFile();
131 if ( $file->allowInlineDisplay() ) {
132 $thumbnail = $file->transform( [
137 return $thumbnail->toHtml( [
'loading' =>
'lazy' ] );
140 return $this->
msg(
'uploadstash-nothumb' )->escaped();
142 $file = $this->getCurrentFile();
143 return htmlspecialchars( $file->getDimensionsString() )
144 . $this->
msg(
'word-separator' )->escaped()
145 .
Html::element(
'span', [
'style' =>
'white-space: nowrap;' ],
146 $this->
msg(
'parentheses' )->sizeParams( (
int)$value )->text()
149 throw new UnexpectedValueException(
"Unknown field '$field'" );
153 private function getCurrentFile():
File {
154 $fileKey = $this->mCurrentRow->us_key;
155 return $this->files[$fileKey]
158 $this->mCurrentRow->us_path,
160 $this->mCurrentRow->us_sha1,
161 $this->mCurrentRow->us_mime ??
false
168 private function getEscapedLimitSelectList(): array {
169 $list = $this->getLimitSelectList();
171 foreach ( $list as $key => $value ) {
172 $result[htmlspecialchars( $key )] = $value;
179 $formDescriptor = [];
180 $formDescriptor[
'limit'] = [
183 'label-message' =>
'table_pager_limit_label',
184 'options' => $this->getEscapedLimitSelectList(),
186 'default' => $this->mLimit
189 HTMLForm::factory(
'ooui', $formDescriptor, $this->getContext() )
191 ->setId(
'mw-uploadstash-form' )
192 ->setTitle( $this->getTitle() )
193 ->setSubmitTextMsg(
'uploadstash-pager-submit' )
194 ->setWrapperLegendMsg(
'uploadstash' )
201 return parent::getTableClass() .
' uploadstash';
206 return parent::getNavClass() .
' uploadstash_nav';
211 return parent::getSortHeaderClass() .
' uploadstash_sort';
216class_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.