Mainframe98 has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/405369 )
Change subject: Implement Special:UnusedVideos
......................................................................
Implement Special:UnusedVideos
Bug: T184902
Change-Id: I4304a022eda96e14820dd9351e2bc09918e7dcb7
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M includes/Video.alias.php
M includes/Video.hooks.php
A includes/specials/SpecialUnusedVideos.php
6 files changed, 140 insertions(+), 37 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Video
refs/changes/69/405369/1
diff --git a/extension.json b/extension.json
index 5ca8bf9..4855cbb 100644
--- a/extension.json
+++ b/extension.json
@@ -1,10 +1,11 @@
{
"name": "Video",
- "version": "1.7.2",
+ "version": "1.8.2",
"author": [
"David Pean",
"Jack Phoenix",
- "John Du Hart"
+ "John Du Hart",
+ "Mainframe98"
],
"license-name": "GPL-2.0+",
"url": "https://www.mediawiki.org/wiki/Extension:Video",
@@ -13,7 +14,8 @@
"SpecialPages": {
"AddVideo": "AddVideo",
"NewVideos": "NewVideos",
- "Undelete": "SpecialUndeleteWithVideoSupport"
+ "Undelete": "SpecialUndeleteWithVideoSupport",
+ "UnusedVideos": "SpecialUnusedVideos"
},
"MessagesDirs": {
"Video": [
@@ -68,7 +70,8 @@
"NewVideos": "includes/specials/SpecialNewVideos.php",
"SpecialUndeleteWithVideoSupport":
"includes/specials/SpecialUndeleteWithVideoSupport.php",
"VideoHooks": "includes/Video.hooks.php",
- "NewVideosPager": "includes/specials/pagers/NewVideosPager.php"
+ "NewVideosPager": "includes/specials/pagers/NewVideosPager.php",
+ "SpecialUnusedVideos":
"includes/specials/SpecialUnusedVideos.php"
},
"Hooks": {
"ArticleFromTitle": [
@@ -105,6 +108,9 @@
],
"CanonicalNamespaces": [
"VideoHooks::onCanonicalNamespaces"
+ ],
+ "wgQueryPages": [
+ "VideoHooks::onwgQueryPages"
]
},
"ResourceFileModulePaths": {
diff --git a/i18n/en.json b/i18n/en.json
index a3d13d4..f165bc1 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -8,6 +8,7 @@
"video-desc": "Allows new Video namespace for embeddable media on
supported sites",
"addvideo": "Add video",
"newvideos": "New videos",
+ "unusedvideos": "Unused videos",
"video-upload-new-version": "Upload a new version of this video",
"video-newvideos-showfrom": "Show new videos starting from $2, $1",
"video-newvideos-list-text": "Below is a list of <strong>$1</strong>
{{PLURAL:$1|video|videos}}.",
@@ -45,5 +46,6 @@
"video-showhidebots": "($1 bots)",
"action-addvideo": "add videos from external services into the site",
"right-addvideo": "Add videos from external services into the site",
- "video-hidebots": "Hide uploads by bots"
+ "video-hidebots": "Hide uploads by bots",
+ "unusedvideos-summary": "The following videos have been added to the
wiki but are not used on any pages. Please note that other web sites may link
to a file with a direct URL, and so may still be listed here despite being in
active use."
}
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 139fdd9..d6f1ccb 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -47,5 +47,6 @@
"video-showhidebots": "This is shown on the special page
[[Special:NewVideos]]. The format is
\"{{int:video-showhidebots|[[MediaWiki:Hide/{{SUBPAGENAME}}|{{int:hide}}]]}}\"
or
\"{{int:showhidebots|[[MediaWiki:Show/{{SUBPAGENAME}}|{{int:show}}]]}}\"\n\n{{Identical|$1
bots}}",
"action-addvideo": "{{doc-action|addvideo}}",
"right-addvideo": "{{doc-right|addvideo}}",
- "video-hidebots": "Used as label for a checkbox. When unchecked,
[[Special:NewVideos]] will also display uploads by users in the bots group."
+ "video-hidebots": "Used as label for a checkbox. When unchecked,
[[Special:NewVideos]] will also display uploads by users in the bots group.",
+ "unusedvideos-summary": "Header message of [[Special:UnusedVideos]]"
}
diff --git a/includes/Video.alias.php b/includes/Video.alias.php
index 2967215..ea954ae 100644
--- a/includes/Video.alias.php
+++ b/includes/Video.alias.php
@@ -6,28 +6,30 @@
* @ingroup Extensions
*/
-$specialPageAliases = array();
+$specialPageAliases = [];
/** English */
-$specialPageAliases['en'] = array(
- 'AddVideo' => array( 'AddVideo' ),
- 'NewVideos' => array( 'NewVideos' ),
-);
+$specialPageAliases['en'] = [
+ 'AddVideo' => [ 'AddVideo' ],
+ 'NewVideos' => [ 'NewVideos' ],
+ 'UnusedVideos' => [ 'UnusedVideos' ],
+];
/** Finnish (Suomi) */
-$specialPageAliases['fi'] = array(
- 'AddVideo' => array( 'Lisää video' ),
- 'NewVideos' => array( 'Uudet videot' ),
-);
+$specialPageAliases['fi'] = [
+ 'AddVideo' => [ 'Lisää video' ],
+ 'NewVideos' => [ 'Uudet videot' ],
+];
/** French (Français) */
-$specialPageAliases['fr'] = array(
- 'AddVideo' => array( 'Ajouter vidéo', 'Ajouter video', 'AjouterVidéo',
'AjouterVideo' ),
- 'NewVideos' => array( 'Nouvelles vidéos', 'Nouvelles videos',
'NouvellesVidéos', 'NouvellesVideos' ),
-);
+$specialPageAliases['fr'] = [
+ 'AddVideo' => [ 'Ajouter vidéo', 'Ajouter video', 'AjouterVidéo',
'AjouterVideo' ],
+ 'NewVideos' => [ 'Nouvelles vidéos', 'Nouvelles videos',
'NouvellesVidéos', 'NouvellesVideos' ],
+];
/** Dutch (Nederlands) */
-$specialPageAliases['nl'] = array(
- 'AddVideo' => array( 'VideoToevoegen', 'Video toevoegen' ),
- 'NewVideos' => array( "NieuweVideos", "NieuweVideo's", 'NieuweVideo’s',
"Nieuwe video's", 'Nieuwe video’s' ),
-);
+$specialPageAliases['nl'] = [
+ 'AddVideo' => [ 'VideoToevoegen', 'Video toevoegen' ],
+ 'NewVideos' => [ 'NieuweVideos', "NieuweVideo's", 'NieuweVideo’s',
"Nieuwe video's", 'Nieuwe video’s' ],
+ 'UnusedVideos' => [ 'OngebruikteVideos', "OngebruikteVideo's",
'OngebruikteVideo’s', "Ongebruiktevideo's", 'Ongebruikte video’s' ],
+];
diff --git a/includes/Video.hooks.php b/includes/Video.hooks.php
index 8a19fc3..f709aa1 100644
--- a/includes/Video.hooks.php
+++ b/includes/Video.hooks.php
@@ -63,8 +63,7 @@
if ( !empty( $align ) ) {
$alignTag = " align=\"{$align}\"";
}
- $output = "<video
name=\"{$video->getName()}\"{$widthTag}{$alignTag} />";
- return $output;
+ return "<video
name=\"{$video->getName()}\"{$widthTag}{$alignTag} />";
}
return $matches[0];
}
@@ -81,8 +80,8 @@
public static function videoFromTitle( &$title, &$article ) {
global $wgRequest;
- if ( $title->getNamespace() == NS_VIDEO ) {
- if ( $wgRequest->getVal( 'action' ) == 'edit' ) {
+ if ( $title->getNamespace() === NS_VIDEO ) {
+ if ( $wgRequest->getVal( 'action' ) === 'edit' ) {
$addTitle = SpecialPage::getTitleFor(
'AddVideo' );
$video = Video::newFromName( $title->getText(),
RequestContext::getMain() );
if ( !$video->exists() ) {
@@ -126,7 +125,7 @@
$width = $width_max = 425;
$height = $height_max = 350;
- $validAlign = array( 'LEFT', 'CENTER', 'RIGHT' );
+ $validAlign = [ 'LEFT', 'CENTER', 'RIGHT' ];
if ( !empty( $argv['width'] ) && ( $width_max >= $argv['width']
) ) {
$width = $argv['width'];
@@ -171,7 +170,7 @@
$article = new Article( $cat->mTitle );
$article->view();
- if ( $cat->mTitle->getNamespace() == NS_CATEGORY ) {
+ if ( $cat->mTitle->getNamespace() === NS_CATEGORY ) {
global $wgOut, $wgRequest;
$from = $wgRequest->getVal( 'from' );
// @todo CHECKME/FIXME: is this correct? I just added
something
@@ -196,16 +195,16 @@
* @return bool
*/
public static function onVideoDelete( &$articleObj, &$user, &$reason,
&$error ) {
- if ( $articleObj->getTitle()->getNamespace() == NS_VIDEO ) {
+ if ( $articleObj->getTitle()->getNamespace() === NS_VIDEO ) {
global $wgRequest;
$context = ( is_callable( $articleObj, 'getContext' ) ?
$articleObj->getContext() : RequestContext::getMain() );
$videoObj = new Video( $articleObj->getTitle(),
$context );
$videoName = $videoObj->getName();
$oldVideo = $wgRequest->getVal( 'wpOldVideo', false );
- $where = array(
+ $where = [
'video_name' => $videoName
- );
+ ];
/*
BEWARE! THIS DOES NOT WORK HOW YOU WOULD THINK IT
DOES...
IT GENERATES INVALID SQL LIKE video_name =
\'(Ayumi_Hamasaki_-_Ladies_Night) OR (Video:Ayumi Hamasaki - Ladies Night)\'
@@ -230,7 +229,7 @@
$dbw->insertSelect(
'oldvideo',
'video',
- array(
+ [
'ov_name' => 'video_name',
'ov_archive_name' =>
$dbw->addQuotes( $archiveName ),
'ov_url' => 'video_url',
@@ -238,7 +237,7 @@
'ov_user_id' => 'video_user_id',
'ov_user_name' =>
'video_user_name',
'ov_timestamp' =>
'video_timestamp'
- ),
+ ],
$where,
__METHOD__
);
@@ -280,7 +279,7 @@
* @return bool
*/
public static function specialUndeleteSwitchArchive( $archive, $title )
{
- if ( $title->getNamespace() == NS_VIDEO ) {
+ if ( $title->getNamespace() === NS_VIDEO ) {
$archive = new VideoPageArchive( $title );
}
return true;
@@ -307,8 +306,8 @@
* @return bool
*/
public static function onUserRename( $renameUserSQL ) {
- $renameUserSQL->tables['oldvideo'] = array( 'ov_user_name',
'ov_user_id' );
- $renameUserSQL->tables['video'] = array( 'video_user_name',
'video_user_id' );
+ $renameUserSQL->tables['oldvideo'] = [ 'ov_user_name',
'ov_user_id' ];
+ $renameUserSQL->tables['video'] = [ 'video_user_name',
'video_user_id' ];
return true;
}
@@ -324,4 +323,17 @@
$list[NS_VIDEO_TALK] = 'Video_talk';
return true;
}
+
+ /**
+ * Hook to add Special:UnusedVideos to the list generated by
QueryPage::getPages.
+ * Used by the maintenance script updateSpecialPages.
+ *
+ * @param array $wgQueryPages
+ * @return bool
+ */
+ public static function onwgQueryPages( &$wgQueryPages ) {
+ $wgQueryPages[] = [ 'SpecialUnusedVideos', 'UnusedVideos' ];
+
+ return true;
+ }
}
diff --git a/includes/specials/SpecialUnusedVideos.php
b/includes/specials/SpecialUnusedVideos.php
new file mode 100644
index 0000000..d74a233
--- /dev/null
+++ b/includes/specials/SpecialUnusedVideos.php
@@ -0,0 +1,80 @@
+<?php
+
+use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IDatabase;
+
+/**
+ * Special:Un usedVideos - a special page for unused videos
+ *
+ * @file
+ * @ingroup Extensions
+ */
+class SpecialUnusedVideos extends QueryPage {
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ parent::__construct( 'UnusedVideos' );
+ }
+
+ /**
+ * Format and output report results using the given information plus
+ * OutputPage
+ *
+ * @param OutputPage $out OutputPage to print to
+ * @param Skin $skin User skin to use [unused]
+ * @param IDatabase $dbr (read) connection to use
+ * @param ResultWrapper $res Result pointer
+ * @param int $num Number of available result rows
+ * @param int $offset Paging offset
+ */
+ protected function outputResults( $out, $skin, $dbr, $res, $num,
$offset ) {
+ if ( $num > 0 ) {
+ $gallery = new VideoGallery();
+
+ # $res might contain the whole 1,000 rows, so we read
up to
+ # $num [should update this to use a Pager]
+ $i = 0;
+ foreach ( $res as $row ) {
+ $i++;
+ $title = Title::makeTitle( NS_VIDEO,
$row->title );
+ $video = new Video( $title, $this->getContext()
);
+
+ $gallery->add( $video);
+ if ( $i === $num ) {
+ break;
+ }
+ }
+
+ $out->addHTML( $gallery->toHTML() );
+ }
+ }
+
+ public function getQueryInfo() {
+ return [
+ 'tables' => [ 'video', 'pagelinks' ],
+ 'fields' => [
+ 'namespace' => NS_VIDEO,
+ 'title' => 'video_name'
+ ],
+ 'conds' => [ 'pl_title IS NULL' ],
+ 'join_conds' => [ 'pagelinks' => [ 'LEFT JOIN',
'pl_title = video_name' ] ]
+ ];
+ }
+
+ // Gotta override this since it's abstract
+ public function formatResult( $skin, $result ) {
+ }
+
+ public function isExpensive() {
+ return true;
+ }
+
+ public function getOrderFields() {
+ return [ 'title' ];
+ }
+
+ protected function getGroupName() {
+ return 'maintenance';
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/405369
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4304a022eda96e14820dd9351e2bc09918e7dcb7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Video
Gerrit-Branch: master
Gerrit-Owner: Mainframe98 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits