31use UnexpectedValueException;
47 private array $files = [];
68 parent::__construct( $context, $linkRenderer );
70 $this->stash = $stash;
71 $this->localRepo = $localRepo;
75 if ( !$this->mFieldNames ) {
76 $this->mFieldNames = [
77 'us_timestamp' => $this->
msg(
'uploadstash-header-date' )->text(),
78 'us_key' => $this->
msg(
'uploadstash-header-filekey' )->text(),
79 'thumb' => $this->
msg(
'uploadstash-header-thumb' )->text(),
80 'us_size' => $this->
msg(
'uploadstash-header-dimensions' )->text(),
88 return in_array( $field, [
'us_timestamp',
'us_key' ] );
93 'tables' => [
'uploadstash' ],
101 'conds' => [
'us_user' => $this->
getUser()->getId() ],
108 return [ [
'us_timestamp',
'us_id' ] ];
112 return 'us_timestamp';
126 return htmlspecialchars( $this->
getLanguage()->userTimeAndDate( $value, $this->
getUser() ) );
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]
159 ??
new UploadStashFile( $this->localRepo, $this->mCurrentRow->us_path, $fileKey );
165 private function getEscapedLimitSelectList(): array {
166 $list = $this->getLimitSelectList();
168 foreach ( $list as $key => $value ) {
169 $result[htmlspecialchars( $key )] = $value;
175 $formDescriptor = [];
176 $formDescriptor[
'limit'] = [
179 'label-message' =>
'table_pager_limit_label',
180 'options' => $this->getEscapedLimitSelectList(),
182 'default' => $this->mLimit
185 HTMLForm::factory(
'ooui', $formDescriptor, $this->getContext() )
187 ->setId(
'mw-uploadstash-form' )
189 ->setSubmitTextMsg(
'uploadstash-pager-submit' )
190 ->setWrapperLegendMsg(
'uploadstash' )
196 return parent::getTableClass() .
' uploadstash';
200 return parent::getNavClass() .
' uploadstash_nav';
204 return parent::getSortHeaderClass() .
' uploadstash_sort';
Implements some public methods and some protected utility functions which are required by multiple ch...
Local repository that stores files in the local filesystem and registers them in the wiki's own datab...
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.