2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2010-06-21 12:59:04 +00:00
|
|
|
/**
|
2010-08-15 07:16:58 +00:00
|
|
|
* Implements Special:Unusedimages
|
2010-06-21 12:59:04 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2010-06-21 13:16:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-06-21 12:59:04 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-15 07:16:58 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup SpecialPage
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2010-08-15 07:16:58 +00:00
|
|
|
* A special page that lists unused images
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup SpecialPage
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2007-03-28 21:01:58 +00:00
|
|
|
class UnusedimagesPage extends ImageQueryPage {
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-12-02 16:17:30 +00:00
|
|
|
function isExpensive() { return true; }
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2004-09-19 21:36:55 +00:00
|
|
|
function getName() {
|
|
|
|
|
return 'Unusedimages';
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2004-09-19 21:36:55 +00:00
|
|
|
function sortDescending() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2004-11-13 20:40:28 +00:00
|
|
|
function isSyndicated() { return false; }
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-19 21:36:55 +00:00
|
|
|
function getSQL() {
|
2010-11-24 15:40:25 +00:00
|
|
|
global $wgCountCategorizedImagesAsUsed;
|
|
|
|
|
|
2007-01-22 23:50:42 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2010-11-25 09:38:04 +00:00
|
|
|
$epoch = $dbr->unixTimestamp( 'img_timestamp' );
|
2009-02-21 17:30:59 +00:00
|
|
|
|
2005-04-15 21:49:21 +00:00
|
|
|
if ( $wgCountCategorizedImagesAsUsed ) {
|
Changing lines like this: "extract( $dbw->tableNames( 'page', 'archive' ) );" to be like this: "list ($page, $archive) = $dbw->tableNamesN( 'page', 'archive' );".
Three reasons for this:
1) It's better for analysis tools [which want explicit variable declaration]
2) It's easier for a human to read, as it's completely explicit where the variables came from [which is something you don't get with extract() ]
3) It makes it easier to find everywhere where a variable is used with search/grep [which you can't currently do with $tbl_page variables from things like: "extract($db->tableNames( 'page', 'revision'), EXTR_PREFIX_ALL, 'tbl');"].
Otherwise, from a functionality/efficiency perspective the two forms should be identical.
By doing this have been able run static analysis over the usages of these variables, thus eliminating 5 unneeded table names from calls, plus removing 3 unused calls entirely, and it just feels subjectively slightly nicer to me.
2006-11-27 08:36:57 +00:00
|
|
|
list( $page, $image, $imagelinks, $categorylinks ) = $dbr->tableNamesN( 'page', 'image', 'imagelinks', 'categorylinks' );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2009-02-21 17:30:59 +00:00
|
|
|
return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value,
|
2007-12-02 16:17:30 +00:00
|
|
|
img_user, img_user_text, img_description
|
|
|
|
|
FROM ((($page AS I LEFT JOIN $categorylinks AS L ON I.page_id = L.cl_from)
|
|
|
|
|
LEFT JOIN $imagelinks AS P ON I.page_title = P.il_to)
|
|
|
|
|
INNER JOIN $image AS G ON I.page_title = G.img_name)
|
2008-12-01 17:14:30 +00:00
|
|
|
WHERE I.page_namespace = ".NS_FILE." AND L.cl_from IS NULL AND P.il_to IS NULL";
|
2005-04-15 21:49:21 +00:00
|
|
|
} else {
|
Changing lines like this: "extract( $dbw->tableNames( 'page', 'archive' ) );" to be like this: "list ($page, $archive) = $dbw->tableNamesN( 'page', 'archive' );".
Three reasons for this:
1) It's better for analysis tools [which want explicit variable declaration]
2) It's easier for a human to read, as it's completely explicit where the variables came from [which is something you don't get with extract() ]
3) It makes it easier to find everywhere where a variable is used with search/grep [which you can't currently do with $tbl_page variables from things like: "extract($db->tableNames( 'page', 'revision'), EXTR_PREFIX_ALL, 'tbl');"].
Otherwise, from a functionality/efficiency perspective the two forms should be identical.
By doing this have been able run static analysis over the usages of these variables, thus eliminating 5 unneeded table names from calls, plus removing 3 unused calls entirely, and it just feels subjectively slightly nicer to me.
2006-11-27 08:36:57 +00:00
|
|
|
list( $image, $imagelinks ) = $dbr->tableNamesN( 'image','imagelinks' );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2009-02-21 17:30:59 +00:00
|
|
|
return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value,
|
2007-12-02 16:17:30 +00:00
|
|
|
img_user, img_user_text, img_description
|
|
|
|
|
FROM $image LEFT JOIN $imagelinks ON img_name=il_to WHERE il_to IS NULL ";
|
2005-04-15 21:49:21 +00:00
|
|
|
}
|
2004-09-19 21:36:55 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2004-09-19 21:36:55 +00:00
|
|
|
function getPageHeader() {
|
2009-02-21 17:30:59 +00:00
|
|
|
return wfMsgExt( 'unusedimagestext', array( 'parse' ) );
|
2004-09-19 21:36:55 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-19 21:36:55 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-19 21:36:55 +00:00
|
|
|
/**
|
|
|
|
|
* Entry point
|
|
|
|
|
*/
|
|
|
|
|
function wfSpecialUnusedimages() {
|
|
|
|
|
list( $limit, $offset ) = wfCheckLimits();
|
|
|
|
|
$uip = new UnusedimagesPage();
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-19 21:36:55 +00:00
|
|
|
return $uip->doQuery( $offset, $limit );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|