MediaWiki
REL1_19
|
00001 <?php 00023 class SpecialNewFiles extends IncludableSpecialPage { 00024 00025 public function __construct(){ 00026 parent::__construct( 'Newimages' ); 00027 } 00028 00029 public function execute( $par ){ 00030 $this->setHeaders(); 00031 $this->outputHeader(); 00032 00033 $pager = new NewFilesPager( $this->getContext(), $par ); 00034 00035 if ( !$this->including() ) { 00036 $form = $pager->getForm(); 00037 $form->prepareForm(); 00038 $form->displayForm( '' ); 00039 } 00040 $this->getOutput()->addHTML( $pager->getBody() ); 00041 if ( !$this->including() ) { 00042 $this->getOutput()->addHTML( $pager->getNavigationBar() ); 00043 } 00044 } 00045 } 00046 00047 00051 class NewFilesPager extends ReverseChronologicalPager { 00052 00056 var $gallery; 00057 00058 function __construct( IContextSource $context, $par = null ) { 00059 $this->like = $context->getRequest()->getText( 'like' ); 00060 $this->showbots = $context->getRequest()->getBool( 'showbots' , 0 ); 00061 00062 parent::__construct( $context ); 00063 } 00064 00065 function getQueryInfo() { 00066 global $wgMiserMode; 00067 $conds = $jconds = array(); 00068 $tables = array( 'image' ); 00069 00070 if( !$this->showbots ) { 00071 $tables[] = 'user_groups'; 00072 $conds[] = 'ug_group IS NULL'; 00073 $jconds['user_groups'] = array( 00074 'LEFT JOIN', 00075 array( 00076 'ug_group' => User::getGroupsWithPermission( 'bot' ), 00077 'ug_user = img_user' 00078 ) 00079 ); 00080 } 00081 00082 if( !$wgMiserMode && $this->like !== null ){ 00083 $dbr = wfGetDB( DB_SLAVE ); 00084 $likeObj = Title::newFromURL( $this->like ); 00085 if( $likeObj instanceof Title ){ 00086 $like = $dbr->buildLike( $dbr->anyString(), strtolower( $likeObj->getDBkey() ), $dbr->anyString() ); 00087 $conds[] = "LOWER(img_name) $like"; 00088 } 00089 } 00090 00091 $query = array( 00092 'tables' => $tables, 00093 'fields' => '*', 00094 'join_conds' => $jconds, 00095 'conds' => $conds 00096 ); 00097 00098 return $query; 00099 } 00100 00101 function getIndexField(){ 00102 return 'img_timestamp'; 00103 } 00104 00105 function getStartBody(){ 00106 if ( !$this->gallery ) { 00107 $this->gallery = new ImageGallery(); 00108 } 00109 return ''; 00110 } 00111 00112 function getEndBody(){ 00113 return $this->gallery->toHTML(); 00114 } 00115 00116 function formatRow( $row ) { 00117 $name = $row->img_name; 00118 $user = User::newFromId( $row->img_user ); 00119 00120 $title = Title::makeTitle( NS_FILE, $name ); 00121 $ul = Linker::link( $user->getUserpage(), $user->getName() ); 00122 00123 $this->gallery->add( 00124 $title, 00125 "$ul<br />\n<i>" 00126 . htmlspecialchars( $this->getLanguage()->timeanddate( $row->img_timestamp, true ) ) 00127 . "</i><br />\n" 00128 ); 00129 } 00130 00131 function getForm() { 00132 global $wgMiserMode; 00133 00134 $fields = array( 00135 'like' => array( 00136 'type' => 'text', 00137 'label-message' => 'newimages-label', 00138 'name' => 'like', 00139 ), 00140 'showbots' => array( 00141 'type' => 'check', 00142 'label' => wfMessage( 'showhidebots', wfMsg( 'show' ) ), 00143 'name' => 'showbots', 00144 # 'default' => $this->getRequest()->getBool( 'showbots', 0 ), 00145 ), 00146 'limit' => array( 00147 'type' => 'hidden', 00148 'default' => $this->getRequest()->getText( 'limit' ), 00149 'name' => 'limit', 00150 ), 00151 'offset' => array( 00152 'type' => 'hidden', 00153 'default' => $this->getRequest()->getText( 'offset' ), 00154 'name' => 'offset', 00155 ), 00156 ); 00157 00158 if( $wgMiserMode ){ 00159 unset( $fields['like'] ); 00160 } 00161 00162 $form = new HTMLForm( $fields, $this->getContext() ); 00163 $form->setTitle( $this->getTitle() ); 00164 $form->setSubmitText( wfMsg( 'ilsubmit' ) ); 00165 $form->setMethod( 'get' ); 00166 $form->setWrapperLegend( wfMsg( 'newimages-legend' ) ); 00167 00168 return $form; 00169 } 00170 }