31use UnexpectedValueException;
47 private array $files = [];
61 parent::__construct( $context, $linkRenderer );
63 $this->stash = $stash;
64 $this->localRepo = $localRepo;
68 if ( !$this->mFieldNames ) {
69 $this->mFieldNames = [
70 'us_timestamp' => $this->
msg(
'uploadstash-header-date' )->text(),
71 'us_key' => $this->
msg(
'uploadstash-header-filekey' )->text(),
72 'thumb' => $this->
msg(
'uploadstash-header-thumb' )->text(),
73 'us_size' => $this->
msg(
'uploadstash-header-dimensions' )->text(),
81 return in_array( $field, [
'us_timestamp',
'us_key' ] );
86 'tables' => [
'uploadstash' ],
96 'conds' => [
'us_user' => $this->
getUser()->getId() ],
103 return [ [
'us_timestamp',
'us_id' ] ];
107 return 'us_timestamp';
121 return htmlspecialchars( $this->
getLanguage()->userTimeAndDate( $value, $this->
getUser() ) );
128 $file = $this->getCurrentFile();
129 if ( $file->allowInlineDisplay() ) {
130 $thumbnail = $file->transform( [
135 return $thumbnail->toHtml( [
'loading' =>
'lazy' ] );
138 return $this->
msg(
'uploadstash-nothumb' )->escaped();
140 $file = $this->getCurrentFile();
141 return htmlspecialchars( $file->getDimensionsString() )
142 . $this->
msg(
'word-separator' )->escaped()
143 .
Html::element(
'span', [
'style' =>
'white-space: nowrap;' ],
144 $this->
msg(
'parentheses' )->sizeParams( (
int)$value )->text()
147 throw new UnexpectedValueException(
"Unknown field '$field'" );
151 private function getCurrentFile():
File {
152 $fileKey = $this->mCurrentRow->us_key;
153 return $this->files[$fileKey]
156 $this->mCurrentRow->us_path,
158 $this->mCurrentRow->us_sha1,
159 $this->mCurrentRow->us_mime ??
false
166 private function getEscapedLimitSelectList(): array {
167 $list = $this->getLimitSelectList();
169 foreach ( $list as $key => $value ) {
170 $result[htmlspecialchars( $key )] = $value;
176 $formDescriptor = [];
177 $formDescriptor[
'limit'] = [
180 'label-message' =>
'table_pager_limit_label',
181 'options' => $this->getEscapedLimitSelectList(),
183 'default' => $this->mLimit
186 HTMLForm::factory(
'ooui', $formDescriptor, $this->getContext() )
188 ->setId(
'mw-uploadstash-form' )
190 ->setSubmitTextMsg(
'uploadstash-pager-submit' )
191 ->setWrapperLegendMsg(
'uploadstash' )
197 return parent::getTableClass() .
' uploadstash';
201 return parent::getNavClass() .
' uploadstash_nav';
205 return parent::getSortHeaderClass() .
' uploadstash_sort';
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,...
UploadStash is intended to accomplish a few things:
Interface for objects which can provide a MediaWiki context on request.