MediaWiki  1.23.12
SpecialNewimages.php
Go to the documentation of this file.
1 <?php
25  public function __construct() {
26  parent::__construct( 'Newimages' );
27  }
28 
29  public function execute( $par ) {
30  $this->setHeaders();
31  $this->outputHeader();
32 
33  $pager = new NewFilesPager( $this->getContext(), $par );
34 
35  if ( !$this->including() ) {
36  $form = $pager->getForm();
37  $form->prepareForm();
38  $form->displayForm( '' );
39  }
40 
41  $this->getOutput()->addHTML( $pager->getBody() );
42  if ( !$this->including() ) {
43  $this->getOutput()->addHTML( $pager->getNavigationBar() );
44  }
45  }
46 
47  protected function getGroupName() {
48  return 'changes';
49  }
50 }
51 
59  var $gallery;
60 
61  function __construct( IContextSource $context, $par = null ) {
62  $this->like = $context->getRequest()->getText( 'like' );
63  $this->showbots = $context->getRequest()->getBool( 'showbots', 0 );
64  if ( is_numeric( $par ) ) {
65  $this->setLimit( $par );
66  }
67 
68  parent::__construct( $context );
69  }
70 
71  function getQueryInfo() {
72  global $wgMiserMode;
73  $conds = $jconds = array();
74  $tables = array( 'image' );
75 
76  if ( !$this->showbots ) {
77  $groupsWithBotPermission = User::getGroupsWithPermission( 'bot' );
78 
79  if ( count( $groupsWithBotPermission ) ) {
80  $tables[] = 'user_groups';
81  $conds[] = 'ug_group IS NULL';
82  $jconds['user_groups'] = array(
83  'LEFT JOIN',
84  array(
85  'ug_group' => $groupsWithBotPermission,
86  'ug_user = img_user'
87  )
88  );
89  }
90  }
91 
92  if ( !$wgMiserMode && $this->like !== null ) {
93  $dbr = wfGetDB( DB_SLAVE );
94  $likeObj = Title::newFromURL( $this->like );
95  if ( $likeObj instanceof Title ) {
96  $like = $dbr->buildLike(
97  $dbr->anyString(),
98  strtolower( $likeObj->getDBkey() ),
99  $dbr->anyString()
100  );
101  $conds[] = "LOWER(img_name) $like";
102  }
103  }
104 
105  $query = array(
106  'tables' => $tables,
107  'fields' => '*',
108  'join_conds' => $jconds,
109  'conds' => $conds
110  );
111 
112  return $query;
113  }
114 
115  function getIndexField() {
116  return 'img_timestamp';
117  }
118 
119  function getStartBody() {
120  if ( !$this->gallery ) {
121  // Note that null for mode is taken to mean use default.
122  $mode = $this->getRequest()->getVal( 'gallerymode', null );
123  try {
124  $this->gallery = ImageGalleryBase::factory( $mode );
125  } catch ( MWException $e ) {
126  // User specified something invalid, fallback to default.
127  $this->gallery = ImageGalleryBase::factory();
128  }
129  $this->gallery->setContext( $this->getContext() );
130  }
131 
132  return '';
133  }
134 
135  function getEndBody() {
136  return $this->gallery->toHTML();
137  }
138 
139  function formatRow( $row ) {
140  $name = $row->img_name;
141  $user = User::newFromId( $row->img_user );
142 
144  $ul = Linker::link( $user->getUserpage(), $user->getName() );
145  $time = $this->getLanguage()->userTimeAndDate( $row->img_timestamp, $this->getUser() );
146 
147  $this->gallery->add(
148  $title,
149  "$ul<br />\n<i>"
150  . htmlspecialchars( $time )
151  . "</i><br />\n"
152  );
153  }
154 
155  function getForm() {
156  global $wgMiserMode;
157 
158  $fields = array(
159  'like' => array(
160  'type' => 'text',
161  'label-message' => 'newimages-label',
162  'name' => 'like',
163  ),
164  'showbots' => array(
165  'type' => 'check',
166  'label' => $this->msg( 'showhidebots', $this->msg( 'show' )->plain() )->escaped(),
167  'name' => 'showbots',
168  ),
169  'limit' => array(
170  'type' => 'hidden',
171  'default' => $this->mLimit,
172  'name' => 'limit',
173  ),
174  'offset' => array(
175  'type' => 'hidden',
176  'default' => $this->getRequest()->getText( 'offset' ),
177  'name' => 'offset',
178  ),
179  );
180 
181  if ( $wgMiserMode ) {
182  unset( $fields['like'] );
183  }
184 
185  $context = new DerivativeContext( $this->getContext() );
186  $context->setTitle( $this->getTitle() ); // Remove subpage
187  $form = new HTMLForm( $fields, $context );
188  $form->setSubmitTextMsg( 'ilsubmit' );
189  $form->setMethod( 'get' );
190  $form->setWrapperLegendMsg( 'newimages-legend' );
191 
192  return $form;
193  }
194 }
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:33
Title\makeTitle
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:398
User\newFromId
static newFromId( $id)
Static factory method for creation from a given user ID.
Definition: User.php:412
ContextSource\getContext
getContext()
Get the RequestContext object.
Definition: ContextSource.php:40
NewFilesPager\getForm
getForm()
Definition: SpecialNewimages.php:154
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
ContextSource\msg
msg()
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:175
$tables
namespace and then decline to actually register it RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
Definition: hooks.txt:815
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:535
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3706
$form
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead $form
Definition: hooks.txt:2578
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1358
NewFilesPager\$gallery
ImageGallery $gallery
Definition: SpecialNewimages.php:58
NS_FILE
const NS_FILE
Definition: Defines.php:85
ImageGalleryBase\factory
static factory( $mode=false)
Get a new image gallery.
Definition: ImageGalleryBase.php:66
SpecialNewFiles
Definition: SpecialNewimages.php:24
IncludableSpecialPage
Shortcut to construct an includable special page.
Definition: IncludableSpecialPage.php:29
ContextSource\getRequest
getRequest()
Get the WebRequest object.
Definition: ContextSource.php:77
ContextSource\getTitle
getTitle()
Get the Title object.
Definition: ContextSource.php:87
$dbr
$dbr
Definition: testCompression.php:48
Linker\link
static link( $target, $html=null, $customAttribs=array(), $query=array(), $options=array())
This function returns an HTML link to the given target.
Definition: Linker.php:192
NewFilesPager\formatRow
formatRow( $row)
Abstract formatting function.
Definition: SpecialNewimages.php:138
ContextSource\getLanguage
getLanguage()
Get the Language object.
Definition: ContextSource.php:154
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:32
MWException
MediaWiki exception.
Definition: MWException.php:26
IndexPager\setLimit
setLimit( $limit)
Set the limit from an other source than the request.
Definition: Pager.php:259
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:352
NewFilesPager\getStartBody
getStartBody()
Hook into getBody(), allows text to be inserted at the start.
Definition: SpecialNewimages.php:118
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:508
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
$ul
$ul
Definition: upgradeLogging.php:173
Title\newFromURL
static newFromURL( $url)
THIS IS NOT THE FUNCTION YOU WANT.
Definition: Title.php:241
SpecialNewFiles\__construct
__construct()
Definition: SpecialNewimages.php:25
SpecialNewFiles\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialNewimages.php:47
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
IContextSource
Interface for objects which can provide a context on request.
Definition: IContextSource.php:29
NewFilesPager\getQueryInfo
getQueryInfo()
This function should be overridden to provide all parameters needed for the main paged query.
Definition: SpecialNewimages.php:70
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:55
Title
Represents a title within MediaWiki.
Definition: Title.php:35
like
For a write use something like
Definition: database.txt:26
NewFilesPager\getEndBody
getEndBody()
Hook into getBody() for the end of the list.
Definition: SpecialNewimages.php:134
IContextSource\getRequest
getRequest()
Get the WebRequest object.
NewFilesPager\getIndexField
getIndexField()
This function should be overridden to return the name of the index fi- eld.
Definition: SpecialNewimages.php:114
ReverseChronologicalPager
IndexPager with a formatted navigation bar.
Definition: Pager.php:829
SpecialNewFiles\execute
execute( $par)
Default execute method Checks user permissions, calls the function given in mFunction.
Definition: SpecialNewimages.php:29
$query
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1105
NewFilesPager\__construct
__construct(IContextSource $context, $par=null)
Definition: SpecialNewimages.php:60
ImageGallery
Backwards compatibility.
Definition: TraditionalImageGallery.php:333
NewFilesPager
Definition: SpecialNewimages.php:55
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:443
SpecialPage\including
including( $x=null)
Whether the special page is being evaluated via transclusion.
Definition: SpecialPage.php:207
User\getGroupsWithPermission
static getGroupsWithPermission( $role)
Get all the groups who have a given permission.
Definition: User.php:4124
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:1632
HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms.
Definition: HTMLForm.php:100