Changing comments layout preparing for generated documentation with Phpdocumentor
[lhc/web/wiklou.git] / includes / SpecialImagelist.php
1 <?php
2 /**
3 *
4 */
5
6 /**
7 *
8 */
9 function wfSpecialImagelist() {
10 global $wgUser, $wgOut, $wgLang, $wgRequest;
11
12 $sort = $wgRequest->getVal( 'sort' );
13 $wpIlMatch = $wgRequest->getText( 'wpIlMatch' );
14 $dbr =& wfGetDB( DB_SLAVE );
15 $image = $dbr->tableName( 'image' );
16 $sql = "SELECT img_size,img_name,img_user,img_user_text," .
17 "img_description,img_timestamp FROM $image";
18
19 $byname = wfMsg( "byname" );
20 $bydate = wfMsg( "bydate" );
21 $bysize = wfMsg( "bysize" );
22
23 if ( !empty( $wpIlMatch ) ) {
24 $nt = Title::newFromUrl( $wpIlMatch );
25 if($nt ) {
26 $m = $dbr->strencode( strtolower( $nt->getDBkey() ) );
27 $m = str_replace( "%", "\\%", $m );
28 $m = str_replace( "_", "\\_", $m );
29 $sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'";
30 }
31 }
32 if ( "bysize" == $sort ) {
33 $sql .= " ORDER BY img_size DESC";
34 $st = $bysize;
35 } else if ( "byname" == $sort ) {
36 $sql .= " ORDER BY img_name";
37 $st = $byname;
38 } else {
39 $sort = "bydate";
40 $sql .= " ORDER BY img_timestamp DESC";
41 $st = $bydate;
42 }
43 list( $limit, $offset ) = wfCheckLimits( 50 );
44 if ( 0 == $limit ) {
45 $lt = wfMsg( "all" );
46 } else {
47 $lt = $wgLang->formatNum( "${limit}" );
48 $sql .= " LIMIT {$limit}";
49 }
50 $wgOut->addHTML( "<p>" . wfMsg( "imglegend" ) . "</p>\n" );
51
52 $text = wfMsg( "imagelisttext",
53 "<strong>{$lt}</strong>", "<strong>{$st}</strong>" );
54 $wgOut->addHTML( "<p>{$text}\n</p>" );
55
56 $sk = $wgUser->getSkin();
57 $cap = wfMsg( "ilshowmatch" );
58 $sub = wfMsg( "ilsubmit" );
59 $titleObj = Title::makeTitle( NS_SPECIAL, "Imagelist" );
60 $action = $titleObj->escapeLocalURL( "sort={$sort}&limit={$limit}" );
61
62 $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
63 "{$action}\">" .
64 "{$cap}: <input type='text' size='8' name=\"wpIlMatch\" value=\"" .
65 htmlspecialchars( $wpIlMatch ) . "\" /> " .
66 "<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>" );
67 $nums = array( 50, 100, 250, 500 );
68 $here = $wgLang->specialPage( "Imagelist" );
69
70 $fill = "";
71 $first = true;
72 foreach ( $nums as $num ) {
73 if ( ! $first ) { $fill .= " | "; }
74 $first = false;
75
76 $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
77 "sort=byname&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
78 }
79 $text = wfMsg( "showlast", $fill, $byname );
80 $wgOut->addHTML( "<p>{$text}<br />\n" );
81
82 $fill = "";
83 $first = true;
84 foreach ( $nums as $num ) {
85 if ( ! $first ) { $fill .= " | "; }
86 $first = false;
87
88 $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
89 "sort=bysize&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
90 }
91 $text = wfMsg( "showlast", $fill, $bysize );
92 $wgOut->addHTML( "{$text}<br />\n" );
93
94 $fill = "";
95 $first = true;
96 foreach ( $nums as $num ) {
97 if ( ! $first ) { $fill .= " | "; }
98 $first = false;
99
100 $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
101 "sort=bydate&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
102 }
103 $text = wfMsg( "showlast", $fill, $bydate );
104 $wgOut->addHTML( "{$text}</p>\n<p>" );
105
106 $res = $dbr->query( $sql, "wfSpecialImagelist" );
107 while ( $s = $dbr->fetchObject( $res ) ) {
108 $name = $s->img_name;
109 $ut = $s->img_user_text;
110 if ( 0 == $s->img_user ) { $ul = $ut; }
111 else { $ul = $sk->makeLink( $wgLang->getNsText(
112 Namespace::getUser() ) . ":{$ut}", $ut ); }
113
114 $ilink = "<a href=\"" . Image::wfImageUrl( $name ) .
115 "\">{$name}</a>";
116
117 $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size ) );
118 $l = "(" .
119 $sk->makeKnownLink( $wgLang->getNsText(
120 Namespace::getImage() ) . ":{$name}", wfMsg( "imgdesc" ) ) .
121 ") {$ilink} . . {$nb} . . {$ul} . . " .
122 $wgLang->timeanddate( $s->img_timestamp, true );
123
124 if ( "" != $s->img_description ) {
125 $l .= " <em>({$s->img_description})</em>";
126 }
127 $wgOut->addHTML( "{$l}<br />\n" );
128 }
129 $wgOut->addHTML( "</p>" );
130 $dbr->freeResult( $res );
131 }
132
133 ?>