jenkins-bot has submitted this change and it was merged.

Change subject: Massive modernization, bugfixes, etc.
......................................................................


Massive modernization, bugfixes, etc.

Still has a long way to go before this is even remotely stable &
feature-complete, but at least it's not horribly broken anymore. Right now
a patch (see the patches/ directory) is required to make Special:Undelete
function properly. In the future proper hooks will be added to core and
this extension shall use those.

Change-Id: I5fd606c575fe94f20e1c06e4fdf795c3c9c0dd80
---
A ArchivedVideo.php
M RevertVideoAction.php
M SpecialAddVideo.php
M SpecialNewVideos.php
D Video.i18n.php
M Video.namespaces.php
M Video.php
M VideoClass.php
M VideoGallery.php
M VideoGalleryPopulate.php
M VideoHooks.php
M VideoPage.php
M VideoPageArchive.php
M i18n/en.json
M i18n/fi.json
A patches/MW-1.23-SpecialUndelete.patch
M providers/BaseVideoProvider.php
M providers/YouTubeVideo.php
18 files changed, 924 insertions(+), 377 deletions(-)

Approvals:
  Jack Phoenix: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/ArchivedVideo.php b/ArchivedVideo.php
new file mode 100644
index 0000000..ab31c7b
--- /dev/null
+++ b/ArchivedVideo.php
@@ -0,0 +1,425 @@
+<?php
+/**
+ * Deleted video in the 'oldvideo' table.
+ *
+ * Based on MW 1.23's ArchivedFile.php.
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup FileAbstraction
+ * @date 22 September 2014
+ */
+
+/**
+ * Class representing a row of the 'oldvideo' table
+ *
+ * @ingroup FileAbstraction
+ */
+class ArchivedVideo extends ArchivedFile {
+       /** @var int filearchive row ID */
+       private $id;
+
+       /** @var string Video name */
+       private $name;
+
+       /** @var string FileStore storage group */
+       private $group;
+
+       /** @var string FileStore SHA-1 key */
+       private $key;
+
+       /** @var int File size in bytes */
+       private $size;
+
+       /** @var int size in bytes */
+       private $bits;
+
+       /** @var int Width */
+       private $width;
+
+       /** @var int Height */
+       private $height;
+
+       /** @var string Metadata string */
+       private $metadata;
+
+       /** @var string MIME type */
+       private $mime;
+
+       /** @var string Media type */
+       private $media_type;
+
+       /** @var string Upload description */
+       private $description;
+
+       /** @var int User ID of uploader */
+       private $user;
+
+       /** @var string User name of uploader */
+       private $user_text;
+
+       /** @var string Time of upload */
+       private $timestamp;
+
+       /** @var bool Whether or not all this has been loaded from the database 
(loadFromXxx) */
+       private $dataLoaded;
+
+       /** @var int Bitfield akin to rev_deleted */
+       private $deleted;
+
+       /** @var string SHA-1 hash of file content */
+       private $sha1;
+
+       /** @var string Number of pages of a multipage document, or false for
+        * documents which aren't multipage documents
+        */
+       private $pageCount;
+
+       /** @var string Original base filename */
+       private $archive_name;
+
+       /** @var MediaHandler */
+       protected $handler;
+
+       /** @var Title */
+       protected $title; # video title
+
+       /** @var string Video URL */
+       protected $url;
+
+       /**
+        * @throws MWException
+        * @param Title $title
+        * @param int $id
+        * @param string $key
+        */
+       function __construct( $title, $id = 0, $key = '' ) {
+               $this->id = -1;
+               $this->title = false;
+               $this->name = false;
+               $this->group = 'deleted'; // needed for direct use of 
constructor
+               $this->key = '';
+               $this->size = 0;
+               $this->bits = 0;
+               $this->width = 0;
+               $this->height = 0;
+               $this->metadata = '';
+               $this->mime = 'unknown/unknown';
+               $this->media_type = '';
+               $this->description = '';
+               $this->user = 0;
+               $this->user_text = '';
+               $this->timestamp = null;
+               $this->deleted = 0;
+               $this->dataLoaded = false;
+               $this->exists = false;
+               $this->sha1 = '';
+               $this->url = '';
+
+               if ( $title instanceof Title ) {
+                       $this->title = Title::makeTitleSafe( NS_VIDEO, 
$title->getDBkey() );
+                       $this->name = $title->getDBkey();
+               } else {
+                       // Convert strings to Title objects
+                       $this->title = Title::makeTitleSafe( NS_FILE, 
(string)$title );
+                       $this->name = $title->getDBkey();
+               }
+
+               /*
+               if ( $id ) {
+                       $this->id = $id;
+               }
+
+               if ( $key ) {
+                       $this->key = $key;
+               }
+               */
+
+               if ( !$id && !$key && !( $title instanceof Title ) ) {
+                       throw new MWException( 'No specifications provided to 
ArchivedVideo constructor.' );
+               }
+       }
+
+       /**
+        * Loads a video object from the oldvideo table
+        * @throws MWException
+        * @return bool|null True on success or null
+        */
+       public function load() {
+               if ( $this->dataLoaded ) {
+                       return true;
+               }
+               $conds = array();
+
+               /**
+               if ( $this->id > 0 ) {
+                       $conds['fa_id'] = $this->id;
+               }
+               if ( $this->key ) {
+                       $conds['fa_storage_group'] = $this->group;
+                       $conds['fa_storage_key'] = $this->key;
+               }
+               **/
+               if ( $this->title ) {
+                       $conds['ov_name'] = $this->title->getDBkey();
+               }
+
+               if ( !count( $conds ) ) {
+                       throw new MWException( 'No specific information for 
retrieving archived video' );
+               }
+
+               if ( !$this->title || $this->title->getNamespace() == NS_VIDEO 
) {
+                       $this->dataLoaded = true; // set it here, to have also 
true on miss
+                       $dbr = wfGetDB( DB_SLAVE );
+                       $row = $dbr->selectRow(
+                               'oldvideo',
+                               self::selectFields(),
+                               $conds,
+                               __METHOD__,
+                               array( 'ORDER BY' => 'ov_timestamp DESC' )
+                       );
+                       if ( !$row ) {
+                               // this revision does not exist?
+                               return null;
+                       }
+
+                       // initialize fields for filestore video object
+                       $this->loadFromRow( $row );
+               } else {
+                       throw new MWException( 'This title does not correspond 
to a video page.' );
+               }
+               $this->exists = true;
+
+               return true;
+       }
+
+       /**
+        * Loads a video object from the oldvideo table
+        *
+        * @param stdClass $row
+        * @return ArchivedFile
+        */
+       public static function newFromRow( $row ) {
+               $video = new ArchivedVideo( Title::makeTitle( NS_VIDEO, 
$row->ov_name ) );
+               $video->loadFromRow( $row );
+
+               return $video;
+       }
+
+       /**
+        * Fields in the oldvideo table
+        * @return array
+        */
+       static function selectFields() {
+               return array(
+                       'ov_name',
+                       'ov_archive_name',
+                       'ov_url',
+                       'ov_type',
+                       'ov_user_id',
+                       'ov_user_name',
+                       'ov_timestamp'
+               );
+       }
+
+       /**
+        * Load ArchivedVideo object fields from a DB row.
+        *
+        * @param stdClass $row Object database row
+        */
+       public function loadFromRow( $row ) {
+               //$this->id = intval( $row->fa_id );
+               $this->name = $row->ov_name;
+               $this->archive_name = $row->ov_archive_name;
+               /**
+               $this->group = $row->fa_storage_group;
+               $this->key = $row->fa_storage_key;
+               $this->size = $row->fa_size;
+               $this->bits = $row->fa_bits;
+               $this->width = $row->fa_width;
+               $this->height = $row->fa_height;
+               $this->metadata = $row->fa_metadata;
+               **/
+               $this->mime = 'video/x-flv'; // @todo FIXME/CHECKME: is 
hard-coding the minor MIME type like this OK?
+               $this->media_type = 'VIDEO';
+               //$this->description = $row->fa_description;
+               $this->user = $row->ov_user_id;
+               $this->user_text = $row->ov_user_name;
+               $this->timestamp = $row->ov_timestamp;
+               $this->url = $row->ov_url;
+               /**
+               $this->deleted = $row->fa_deleted;
+               if ( isset( $row->fa_sha1 ) ) {
+                       $this->sha1 = $row->fa_sha1;
+               } else {
+                       // old row, populate from key
+                       $this->sha1 = LocalRepo::getHashFromKey( $this->key );
+               }
+               **/
+       }
+
+       /**
+        * Return the video URL
+        * This is a custom method
+        * @return string
+        */
+       public function getURL() {
+               $this->load();
+
+               return $this->url;
+       }
+
+       // WHY ARE THESE TWO NOT PROPERLY INHERITED AND HAVE TO BE DUPLICATED 
HERE?
+       /**
+        * Return the user ID of the uploader.
+        *
+        * @return int
+        */
+       public function getRawUser() {
+               $this->load();
+
+               return $this->user;
+       }
+
+       /**
+        * Return the user name of the uploader.
+        *
+        * @return string
+        */
+       public function getRawUserText() {
+               $this->load();
+
+               return $this->user_text;
+       }
+
+       /** Getters mostly inherited from the parent class **/
+
+       /**
+        * Return the FileStore key
+        * @return string
+        */
+       public function getKey() {
+               $this->load();
+
+               return $this->key;
+       }
+
+       /**
+        * Return the FileStore key (overriding base File class)
+        * @return string
+        */
+       public function getStorageKey() {
+               return $this->getKey();
+       }
+
+       /**
+        * Return the FileStore storage group
+        * @return string
+        */
+       public function getGroup() {
+               return $this->group;
+       }
+
+       /**
+        * Return the width of the image
+        * @return int
+        */
+       public function getWidth() {
+               $this->load();
+
+               return $this->width;
+       }
+
+       /**
+        * Return the height of the image
+        * @return int
+        */
+       public function getHeight() {
+               $this->load();
+
+               return $this->height;
+       }
+
+       /**
+        * Get handler-specific metadata
+        * @return string
+        */
+       public function getMetadata() {
+               $this->load();
+
+               return $this->metadata;
+       }
+
+       /**
+        * Return the size of the image file, in bytes
+        * @return int
+        */
+       public function getSize() {
+               $this->load();
+
+               return $this->size;
+       }
+
+       /**
+        * Return the bits of the image file, in bytes
+        * @return int
+        */
+       public function getBits() {
+               $this->load();
+
+               return $this->bits;
+       }
+
+       /**
+        * Returns the mime type of the file.
+        * @return string
+        */
+       public function getMimeType() {
+               $this->load();
+
+               return $this->mime;
+       }
+
+       /**
+        * @return bool False for documents which aren't multipage documents
+        */
+       function pageCount() {
+               return false;
+       }
+
+       /**
+        * Return the type of the media in the file.
+        * Use the value returned by this function with the MEDIATYPE_xxx 
constants.
+        * @return string
+        */
+       public function getMediaType() {
+               $this->load();
+
+               return 'VIDEO';
+       }
+
+       /**
+        * Get the SHA-1 base 36 hash of the file
+        *
+        * @return string
+        */
+       function getSha1() {
+               $this->load();
+
+               return $this->sha1;
+       }
+}
diff --git a/RevertVideoAction.php b/RevertVideoAction.php
index 31eeaad..a065472 100644
--- a/RevertVideoAction.php
+++ b/RevertVideoAction.php
@@ -40,7 +40,7 @@
                        throw new ErrorPageError( 'internalerror', 
'unexpected', array( 'oldvideo', $oldvideo ) );
                }
 
-               $dbr = wfGetDB( DB_READ );
+               $dbr = wfGetDB( DB_SLAVE );
                $row = $dbr->selectRow(
                        'oldvideo',
                        array( 'ov_url', 'ov_type', 'ov_timestamp', 'ov_url', 
'ov_name' ),
@@ -54,14 +54,14 @@
        }
 
        protected function alterForm( HTMLForm $form ) {
-               $form->setWrapperLegend( wfMsgHtml( 'video-revert-legend' ) );
-               $form->setSubmitText( wfMsg( 'filerevert-submit' ) );
+               $form->setWrapperLegend( wfMessage( 'video-revert-legend' 
)->escaped() );
+               $form->setSubmitText( wfMessage( 'filerevert-submit' 
)->escaped() );
                $form->addHiddenField( 'oldvideo', 
$this->getRequest()->getText( 'oldvideo' ) );
        }
 
        /**
         * Get an HTMLForm descriptor array
-        * @return Array
+        * @return array
         */
        protected function getFormFields() {
                $timestamp = $this->oldvideo->ov_timestamp;
@@ -71,19 +71,19 @@
                                'type' => 'info',
                                'vertical-label' => true,
                                'raw' => true,
-                               'default' => wfMsgExt( 'video-revert-intro', 
'parse', $this->getTitle()->getText(),
+                               'default' => wfMessage( 'video-revert-intro', 
$this->getTitle()->getText(),
                                        $this->getLang()->date( $timestamp, 
true ), $this->getLang()->time( $timestamp, true ),
-                                       $this->oldvideo->ov_url )
+                                       $this->oldvideo->ov_url )->parse()
                        ),
                );
        }
 
        /**
-        * Process the form on POST submission.  If you return false from 
getFormFields(),
-        * this will obviously never be reached.  If you don't want to do 
anything with the
+        * Process the form on POST submission. If you return false from 
getFormFields(),
+        * this will obviously never be reached. If you don't want to do 
anything with the
         * form, just return false here
-        * @param  $data Array
-        * @return Bool|Array true for success, false for didn't-try, array of 
errors on failure
+        * @param array $data
+        * @return bool|array True for success, false for didn't-try, array of 
errors on failure
         */
        public function onSubmit( $data ) {
                // Record upload and update metadata cache
@@ -94,28 +94,27 @@
        }
 
        /**
-        * Do something exciting on successful processing of the form.  This 
might be to show
-        * a confirmation message (watch, rollback, etc) or to redirect 
somewhere else (edit,
-        * protect, etc).
+        * Do something exciting on successful processing of the form.
+        * This might be to show a confirmation message (watch, rollback, etc.) 
or
+        * to redirect somewhere else (edit, protect, etc).
         */
        public function onSuccess() {
                $out = $this->getOutput();
-               $out->setPageTitle( wfMsgHtml( 'actioncomplete' ) );
+               $out->setPageTitle( wfMessage( 'actioncomplete' )->escaped() );
                $out->setRobotPolicy( 'noindex,nofollow' );
-               $out->addHTML( wfMsg( 'video-revert-success' ) );
+               $out->addHTML( wfMessage( 'video-revert-success' )->escaped() );
 
                $descTitle = $this->video->getTitle();
                $out->returnToMain( null, $descTitle->getPrefixedText() );
        }
 
        protected function getPageTitle() {
-               return wfMsg( 'filerevert', $this->getTitle()->getText() );
+               return wfMessage( 'filerevert', $this->getTitle()->getText() 
)->escaped();
        }
 
        protected function getDescription() {
                $this->getOutput()->addBacklinkSubtitle( $this->getTitle() );
                return '';
        }
-
 
 }
diff --git a/SpecialAddVideo.php b/SpecialAddVideo.php
index e7220fd..888b839 100644
--- a/SpecialAddVideo.php
+++ b/SpecialAddVideo.php
@@ -23,24 +23,24 @@
        }
 
        /**
+        * Group this special page under the correct header in 
Special:SpecialPages.
+        *
+        * @return string
+        */
+       function getGroupName() {
+               return 'media';
+       }
+
+       /**
         * Show the special page
         *
-        * @param $par Mixed: parameter passed to the page or null
-        * @return bool|null
+        * @param mixed|null $par Parameter passed to the page or null
         */
        public function execute( $par ) {
-               global $wgExtensionAssetsPath;
-
                $out = $this->getOutput();
-               // Add CSS
-               if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) {
-                       $out->addModuleStyles( 'ext.video' );
-               } else {
-                       $out->addExtensionStyle( $wgExtensionAssetsPath . 
'/Video/Video.css' );
-               }
 
                // If the user doesn't have the required 'addvideo' permission, 
display an error
-               if( !$this->userCanExecute( $this->getUser() ) ) {
+               if ( !$this->userCanExecute( $this->getUser() ) ) {
                        $this->displayRestrictionError();
                        return;
                }
@@ -51,16 +51,19 @@
                }
 
                // If user is blocked, s/he doesn't need to access this page
-               if( $this->getUser()->isBlocked() ) {
+               if ( $this->getUser()->isBlocked() ) {
                        throw new UserBlockedError( $this->getUser()->mBlock );
                }
+
+               // Add CSS
+               $out->addModuleStyles( 'ext.video' );
 
                $this->setHeaders();
 
                $form = new HTMLForm( $this->getFormFields(), 
$this->getContext() );
-               $form->setIntro( wfMsgExt( 'video-addvideo-instructions', 
'parse' ) );
-               $form->setWrapperLegend( wfMsg( 'video-addvideo-title' ) );
-               $form->setSubmitText( wfMsg( 'video-addvideo-button' ) );
+               $form->setIntro( $this->msg( 'video-addvideo-instructions' 
)->parse() );
+               $form->setWrapperLegend( $this->msg( 'video-addvideo-title' 
)->plain() );
+               $form->setSubmitText( $this->msg( 'video-addvideo-button' 
)->plain() );
                $form->setSubmitCallback( array( $this, 'submit' ) );
 
                if ( $this->getRequest()->getCheck( 'forReUpload' ) ) {
@@ -73,7 +76,7 @@
        /**
         * Extracts the URL and provider type from a raw string
         *
-        * @param string $value Value form the Video input
+        * @param string $value Value from the Video input
         * @return array Element 0 is the URL, 1 is the provider
         */
        protected function getUrlAndProvider( $value ) {
@@ -91,15 +94,15 @@
         * Checks to see if the string given is a valid URL and corresponds
         * to a supported provider.
         *
-        * @param $value Array
-        * @param $allData Array
-        * @return bool|String
+        * @param array $value
+        * @param array $allData
+        * @return bool|string
         */
        public function validateVideoField( $value, $allData ) {
                list( , $provider ) = $this->getUrlAndProvider( $value );
 
                if ( $provider == 'unknown' ) {
-                       return wfMsg( 'video-addvideo-invalidcode' );
+                       return $this->msg( 'video-addvideo-invalidcode' 
)->plain();
                }
 
                return true;
@@ -119,12 +122,12 @@
                $video = Video::newFromName( $value, $this->getContext() );
 
                if ( $video === null || !( $video instanceof Video ) ) {
-                       return wfMsg( 'badtitle' );
+                       return $this->msg( 'badtitle' )->plain();
                }
 
                // TODO: Check to see if this is a new version
                if ( $video->exists() && !$this->getRequest()->getCheck( 
'forReUpload' ) ) {
-                       return wfMsgHtml( 'video-addvideo-exists' );
+                       return $this->msg( 'video-addvideo-exists' )->escaped();
                }
 
                $this->video = $video;
@@ -135,7 +138,7 @@
        /**
         * Actually inserts the Video into the DB if validation passes
         *
-        * @param $data Array
+        * @param array $data
         * @return bool
         */
        public function submit( array $data ) {
diff --git a/SpecialNewVideos.php b/SpecialNewVideos.php
index 8c85818..8d7dc07 100644
--- a/SpecialNewVideos.php
+++ b/SpecialNewVideos.php
@@ -17,9 +17,18 @@
        }
 
        /**
+        * Group this special page under the correct header in 
Special:SpecialPages.
+        *
+        * @return string
+        */
+       function getGroupName() {
+               return 'changes';
+       }
+
+       /**
         * Show the special page
         *
-        * @param $par Mixed: parameter passed to the page or null
+        * @param mixed|null $par Parameter passed to the page or null
         */
        public function execute( $par ) {
                global $wgGroupPermissions;
@@ -28,7 +37,7 @@
                $request = $this->getRequest();
                $lang = $this->getLanguage();
 
-               $out->setPageTitle( wfMsgHtml( 'newvideos' ) );
+               $out->setPageTitle( $this->msg( 'newvideos' ) );
 
                $wpIlMatch = $request->getText( 'wpIlMatch' );
                $dbr = wfGetDB( DB_SLAVE );
@@ -36,20 +45,20 @@
                $hidebots = $request->getBool( 'hidebots', 1 );
 
                $hidebotsql = '';
-               if( $hidebots ) {
+               if ( $hidebots ) {
                        /*
                         * Make a list of group names which have the 'bot' flag
                         * set.
                         */
                        $botconds = array();
-                       foreach( $wgGroupPermissions as $groupname => $perms ) {
-                               if( array_key_exists( 'bot', $perms ) && 
$perms['bot'] ) {
+                       foreach ( $wgGroupPermissions as $groupname => $perms ) 
{
+                               if ( array_key_exists( 'bot', $perms ) && 
$perms['bot'] ) {
                                        $botconds[] = "ug_group='$groupname'";
                                }
                        }
 
                        /* If not bot groups, do not set $hidebotsql */
-                       if( $botconds ) {
+                       if ( $botconds ) {
                                $isbotmember = $dbr->makeList( $botconds, 
LIST_OR );
 
                                /*
@@ -66,13 +75,13 @@
                $video = $dbr->tableName( 'video' );
 
                $sql = "SELECT video_timestamp FROM $video";
-               if( $hidebotsql ) {
+               if ( $hidebotsql ) {
                        $sql .= "$hidebotsql WHERE ug_group IS NULL";
                }
-               $sql.= ' ORDER BY video_timestamp DESC LIMIT 1';
+               $sql .= ' ORDER BY video_timestamp DESC LIMIT 1';
                $res = $dbr->query( $sql, __METHOD__ );
                $row = $dbr->fetchRow( $res );
-               if( $row !== false ) {
+               if ( $row !== false ) {
                        $ts = $row[0];
                } else {
                        $ts = false;
@@ -85,7 +94,8 @@
                /** Hardcode this for now. */
                $limit = 48;
 
-               if ( $parval = intval( $par ) ) {
+               $parval = intval( $par );
+               if ( $parval ) {
                        if ( $parval <= $limit && $parval > 0 ) {
                                $limit = $parval;
                        }
@@ -95,7 +105,7 @@
                $searchpar = array();
                if ( $wpIlMatch != '' ) {
                        $nt = Title::newFromUrl( $wpIlMatch );
-                       if( $nt ) {
+                       if ( $nt ) {
                                $m = $dbr->strencode( strtolower( 
$nt->getDBkey() ) );
                                $m = str_replace( '%', "\\%", $m );
                                $m = str_replace( '_', "\\_", $m );
@@ -115,11 +125,11 @@
                $sql = 'SELECT video_name, video_url, video_user_name, 
video_user_id, '.
                                " video_timestamp FROM $video";
 
-               if( $hidebotsql ) {
+               if ( $hidebotsql ) {
                        $sql .= $hidebotsql;
                        $where[] = 'ug_group IS NULL';
                }
-               if( count( $where ) ) {
+               if ( count( $where ) ) {
                        $sql.= ' WHERE ' . $dbr->makeList( $where, LIST_AND );
                }
                $sql.= ' ORDER BY video_timestamp '. ( $invertSort ? '' : ' 
DESC' );
@@ -128,8 +138,8 @@
 
                // We have to flip things around to get the last N after a 
certain date
                $videos = array();
-               foreach( $res as $s ) {
-                       if( $invertSort ) {
+               foreach ( $res as $s ) {
+                       if ( $invertSort ) {
                                array_unshift( $videos, $s );
                        } else {
                                array_push( $videos, $s );
@@ -140,8 +150,8 @@
                $firstTimestamp = null;
                $lastTimestamp = null;
                $shownVideos = 0;
-               foreach( $videos as $s ) {
-                       if( ++$shownVideos > $limit ) {
+               foreach ( $videos as $s ) {
+                       if ( ++$shownVideos > $limit ) {
                                // One extra just to test for whether to show a 
page link;
                                // don't actually show it.
                                break;
@@ -152,7 +162,7 @@
 
                        $nt = Title::newFromText( $name, NS_VIDEO );
                        $vid = new Video( $nt, $this->getContext() );
-                       $ul = Linker::makeLinkObj( Title::makeTitle( NS_USER, 
$ut ), $ut );
+                       $ul = Linker::linkKnown( Title::makeTitle( NS_USER, $ut 
), $ut );
 
                        $gallery->add(
                                $vid,
@@ -162,20 +172,20 @@
                        );
 
                        $timestamp = wfTimestamp( TS_MW, $s->video_timestamp );
-                       if( empty( $firstTimestamp ) ) {
+                       if ( empty( $firstTimestamp ) ) {
                                $firstTimestamp = $timestamp;
                        }
                        $lastTimestamp = $timestamp;
                }
 
-               $bydate = wfMsg( 'bydate' );
+               $bydate = $this->msg( 'bydate' )->escaped();
                $lt = $lang->formatNum( min( $shownVideos, $limit ) );
-               if( $shownav ) {
-                       $text = wfMsgExt( 'imagelisttext', 'parse', $lt, 
$bydate );
+               if ( $shownav ) {
+                       $text = $this->msg( 'imagelisttext', $lt, $bydate 
)->parse();
                        $out->addHTML( $text . "\n" );
                }
 
-               $sub = wfMsg( 'ilsubmit' );
+               $sub = $this->msg( 'ilsubmit' )->escaped();
                $titleObj = SpecialPage::getTitleFor( 'NewVideos' );
                $action = htmlspecialchars( $titleObj->getLocalURL( $hidebots ? 
'' : 'hidebots=0' ) );
                if( $shownav ) {
@@ -190,7 +200,7 @@
                // Paging controls...
 
                # If we change bot visibility, this needs to be carried along.
-               if( !$hidebots ) {
+               if ( !$hidebots ) {
                        $botpar = array( 'hidebots' => 0 );
                } else {
                        $botpar = array();
@@ -206,7 +216,7 @@
 
                $dateLink = Linker::linkKnown(
                        $titleObj,
-                       htmlspecialchars( wfMsgHtml( 'sp-newimages-showfrom', 
$date, $time ) ),
+                       htmlspecialchars( $this->msg( 'sp-newimages-showfrom', 
$date, $time )->escaped() ),
                        array(),
                        $query
                );
@@ -216,18 +226,17 @@
                        $searchpar
                );
 
-               $showhide = $hidebots ? wfMsg( 'show' ) : wfMsg( 'hide' );
+               $showhide = $hidebots ? $this->msg( 'show' )->escaped() : 
$this->msg( 'hide' )->escaped();
 
                $botLink = Linker::linkKnown(
                        $titleObj,
-                       htmlspecialchars( wfMsg( 'video-showhidebots', 
$showhide ) ),
+                       htmlspecialchars( $this->msg( 'video-showhidebots', 
$showhide )->escaped() ),
                        array(),
                        $query
                );
 
-               $opts = array( 'parsemag', 'escapenoentities' );
-               $prevLink = wfMsgExt( 'pager-newer-n', $opts, $lang->formatNum( 
$limit ) );
-               if( $firstTimestamp && $firstTimestamp != $latestTimestamp ) {
+               $prevLink = $this->msg( 'pager-newer-n', $lang->formatNum( 
$limit ) )->parse();
+               if ( $firstTimestamp && $firstTimestamp != $latestTimestamp ) {
                        $query = array_merge(
                                array( 'from' => $firstTimestamp ),
                                $botpar,
@@ -241,8 +250,8 @@
                        );
                }
 
-               $nextLink = wfMsgExt( 'pager-older-n', $opts, $lang->formatNum( 
$limit ) );
-               if( $shownVideos > $limit && $lastTimestamp ) {
+               $nextLink = $this->msg( 'pager-older-n', $lang->formatNum( 
$limit ) )->parse();
+               if ( $shownVideos > $limit && $lastTimestamp ) {
                        $query = array_merge(
                                array( 'until' => $lastTimestamp ),
                                $botpar,
@@ -258,16 +267,16 @@
                }
 
                $prevnext = '<p>' . $botLink . ' ' .
-                       wfMsgHtml( 'viewprevnext', $prevLink, $nextLink, 
$dateLink ) .
+                       $this->msg( 'viewprevnext', $prevLink, $nextLink, 
$dateLink )->text() .
                        '</p>';
 
-               if( $shownav ) {
+               if ( $shownav ) {
                        $out->addHTML( $prevnext );
                }
 
-               if( count( $videos ) ) {
+               if ( count( $videos ) ) {
                        $out->addHTML( $gallery->toHTML() );
-                       if( $shownav ) {
+                       if ( $shownav ) {
                                $out->addHTML( $prevnext );
                        }
                } else {
diff --git a/Video.i18n.php b/Video.i18n.php
deleted file mode 100644
index 2ea9dbc..0000000
--- a/Video.i18n.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * This is a backwards-compatibility shim, generated by:
- * 
https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php
- *
- * Beginning with MediaWiki 1.23, translation strings are stored in json files,
- * and the EXTENSION.i18n.php file only exists to provide compatibility with
- * older releases of MediaWiki. For more information about this migration, see:
- * https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format
- *
- * This shim maintains compatibility back to MediaWiki 1.17.
- */
-$messages = array();
-if ( !function_exists( 'wfJsonI18nShim8dd8aa43ceb81964' ) ) {
-       function wfJsonI18nShim8dd8aa43ceb81964( $cache, $code, &$cachedData ) {
-               $codeSequence = array_merge( array( $code ), 
$cachedData['fallbackSequence'] );
-               foreach ( $codeSequence as $csCode ) {
-                       $fileName = dirname( __FILE__ ) . "/i18n/$csCode.json";
-                       if ( is_readable( $fileName ) ) {
-                               $data = FormatJson::decode( file_get_contents( 
$fileName ), true );
-                               foreach ( array_keys( $data ) as $key ) {
-                                       if ( $key === '' || $key[0] === '@' ) {
-                                               unset( $data[$key] );
-                                       }
-                               }
-                               $cachedData['messages'] = array_merge( $data, 
$cachedData['messages'] );
-                       }
-
-                       $cachedData['deps'][] = new FileDependency( $fileName );
-               }
-               return true;
-       }
-
-       $GLOBALS['wgHooks']['LocalisationCacheRecache'][] = 
'wfJsonI18nShim8dd8aa43ceb81964';
-}
diff --git a/Video.namespaces.php b/Video.namespaces.php
index d658f30..e31ac40 100644
--- a/Video.namespaces.php
+++ b/Video.namespaces.php
@@ -8,11 +8,11 @@
 $namespaceNames = array();
 
 // For wikis where the Video extension is not installed.
-if( !defined( 'NS_VIDEO' ) ) {
+if ( !defined( 'NS_VIDEO' ) ) {
        define( 'NS_VIDEO', 400 );
 }
 
-if( !defined( 'NS_VIDEO_TALK' ) ) {
+if ( !defined( 'NS_VIDEO_TALK' ) ) {
        define( 'NS_VIDEO_TALK', 401 );
 }
 
diff --git a/Video.php b/Video.php
index 1329548..3f85311 100644
--- a/Video.php
+++ b/Video.php
@@ -7,9 +7,9 @@
  * @author David Pean <[email protected]> - original code/ideas
  * @author Jack Phoenix <[email protected]>
  * @copyright Copyright © 2007 David Pean, Wikia Inc.
- * @copyright Copyright © 2008-2011 Jack Phoenix
+ * @copyright Copyright © 2008-2014 Jack Phoenix
  * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 
2.0 or later
- * @link http://www.mediawiki.org/wiki/Extension:Video Documentation
+ * @link https://www.mediawiki.org/wiki/Extension:Video Documentation
  */
 
 // Bail out if we're not inside MediaWiki
@@ -29,16 +29,16 @@
 // ResourceLoader support for MediaWiki 1.17+
 $wgResourceModules['ext.video'] = array(
        'styles' => 'Video.css',
-       'localBasePath' => dirname( __FILE__ ),
+       'localBasePath' => __DIR__,
        'remoteExtPath' => 'Video'
 );
 
 // Global video namespace reference
-if( !defined( 'NS_VIDEO' ) ) {
+if ( !defined( 'NS_VIDEO' ) ) {
        define( 'NS_VIDEO', 400 );
 }
 
-if( !defined( 'NS_VIDEO_TALK' ) ) {
+if ( !defined( 'NS_VIDEO_TALK' ) ) {
        define( 'NS_VIDEO_TALK', 401 );
 }
 
@@ -48,62 +48,58 @@
 $wgGroupPermissions['user']['addvideo'] = true;
 
 // Set up i18n and autoload the gazillion different classes we have
-$dir = dirname( __FILE__ ) . '/';
 $wgMessagesDirs['Video'] = __DIR__ . '/i18n';
-$wgExtensionMessagesFiles['Video'] = $dir . 'Video.i18n.php';
-$wgExtensionMessagesFiles['VideoAlias'] = $dir . 'Video.alias.php';
+$wgExtensionMessagesFiles['VideoAlias'] = __DIR__ . '/Video.alias.php';
 // Namespace translations
-$wgExtensionMessagesFiles['VideoNamespaces'] = $dir . 'Video.namespaces.php';
+$wgExtensionMessagesFiles['VideoNamespaces'] = __DIR__ . 
'/Video.namespaces.php';
 
 // Base Video class
-$wgAutoloadClasses['Video'] = $dir . 'VideoClass.php';
+$wgAutoloadClasses['Video'] = __DIR__ . '/VideoClass.php';
 
 // ...and the dozen different provider classes
-$wgAutoloadClasses['ArchiveOrgVideoProvider'] = $dir . 
'providers/ArchiveOrgVideo.php';
-$wgAutoloadClasses['BlipTVVideoProvider'] = $dir . 'providers/BlipTVVideo.php';
-$wgAutoloadClasses['DailyMotionVideoProvider'] = $dir . 
'providers/DailyMotionVideo.php';
-$wgAutoloadClasses['BaseVideoProvider'] = $dir . 
'providers/BaseVideoProvider.php';
-$wgAutoloadClasses['GametrailersVideoProvider'] = $dir . 
'providers/GametrailersVideo.php';
-$wgAutoloadClasses['GamevideosVideoProvider'] = $dir . 
'providers/GamevideosVideo.php';
-$wgAutoloadClasses['GoGreenTubeVideoProvider'] = $dir . 
'providers/GoGreenTubeVideo.php';
-$wgAutoloadClasses['GoogleVideoProvider'] = $dir . 'providers/GoogleVideo.php';
-$wgAutoloadClasses['HuluVideoProvider'] = $dir . 'providers/HuluVideo.php';
-$wgAutoloadClasses['MetaCafeVideoProvider'] = $dir . 
'providers/MetaCafeVideo.php';
-$wgAutoloadClasses['MySpaceVideoProvider'] = $dir . 
'providers/MySpaceVideo.php';
-$wgAutoloadClasses['MovieClipsVideoProvider'] = $dir . 
'providers/MovieClipsVideo.php';
-$wgAutoloadClasses['MTVNetworksVideoProvider'] = $dir . 
'providers/MTVNetworksVideo.php';
-$wgAutoloadClasses['MyVideoVideoProvider'] = $dir . 
'providers/MyVideoVideo.php';
-$wgAutoloadClasses['NewsRoomVideoProvider'] = $dir . 
'providers/NewsRoomVideo.php';
-$wgAutoloadClasses['SevenloadVideoProvider'] = $dir . 
'providers/SevenloadVideo.php';
-$wgAutoloadClasses['SouthParkStudiosVideoProvider'] = $dir . 
'providers/SouthParkStudiosVideo.php';
-$wgAutoloadClasses['ViddlerVideoProvider'] = $dir . 
'providers/ViddlerVideo.php';
-$wgAutoloadClasses['VimeoVideoProvider'] = $dir . 'providers/VimeoVideo.php';
-$wgAutoloadClasses['WeGameVideoProvider'] = $dir . 'providers/WeGameVideo.php';
-$wgAutoloadClasses['YouTubeVideoProvider'] = $dir . 
'providers/YouTubeVideo.php';
+$wgAutoloadClasses['ArchiveOrgVideoProvider'] = __DIR__ . 
'/providers/ArchiveOrgVideo.php';
+$wgAutoloadClasses['BlipTVVideoProvider'] = __DIR__ . 
'/providers/BlipTVVideo.php';
+$wgAutoloadClasses['DailyMotionVideoProvider'] = __DIR__ . 
'/providers/DailyMotionVideo.php';
+$wgAutoloadClasses['BaseVideoProvider'] = __DIR__ . 
'/providers/BaseVideoProvider.php';
+$wgAutoloadClasses['GametrailersVideoProvider'] = __DIR__ . 
'/providers/GametrailersVideo.php';
+$wgAutoloadClasses['GamevideosVideoProvider'] = __DIR__ . 
'/providers/GamevideosVideo.php';
+$wgAutoloadClasses['GoGreenTubeVideoProvider'] = __DIR__ . 
'/providers/GoGreenTubeVideo.php';
+$wgAutoloadClasses['GoogleVideoProvider'] = __DIR__ . 
'/providers/GoogleVideo.php';
+$wgAutoloadClasses['HuluVideoProvider'] = __DIR__ . '/providers/HuluVideo.php';
+$wgAutoloadClasses['MetaCafeVideoProvider'] = __DIR__ . 
'/providers/MetaCafeVideo.php';
+$wgAutoloadClasses['MySpaceVideoProvider'] = __DIR__ . 
'/providers/MySpaceVideo.php';
+$wgAutoloadClasses['MovieClipsVideoProvider'] = __DIR__ . 
'/providers/MovieClipsVideo.php';
+$wgAutoloadClasses['MTVNetworksVideoProvider'] = __DIR__ . 
'/providers/MTVNetworksVideo.php';
+$wgAutoloadClasses['MyVideoVideoProvider'] = __DIR__ . 
'/providers/MyVideoVideo.php';
+$wgAutoloadClasses['NewsRoomVideoProvider'] = __DIR__ . 
'/providers/NewsRoomVideo.php';
+$wgAutoloadClasses['SevenloadVideoProvider'] = __DIR__ . 
'/providers/SevenloadVideo.php';
+$wgAutoloadClasses['SouthParkStudiosVideoProvider'] = __DIR__ . 
'/providers/SouthParkStudiosVideo.php';
+$wgAutoloadClasses['ViddlerVideoProvider'] = __DIR__ . 
'/providers/ViddlerVideo.php';
+$wgAutoloadClasses['VimeoVideoProvider'] = __DIR__ . 
'/providers/VimeoVideo.php';
+$wgAutoloadClasses['WeGameVideoProvider'] = __DIR__ . 
'/providers/WeGameVideo.php';
+$wgAutoloadClasses['YouTubeVideoProvider'] = __DIR__ . 
'/providers/YouTubeVideo.php';
 
 // User Interface stuff
-$wgAutoloadClasses['VideoPage'] = $dir . 'VideoPage.php';
-$wgAutoloadClasses['WikiVideoPage'] = $dir . 'WikiVideoPage.php';
-$wgAutoloadClasses['RevertVideoAction'] = $dir . 'RevertVideoAction.php';
-$wgAutoloadClasses['VideoHistoryList'] = $dir . 'VideoPage.php';
-$wgAutoloadClasses['CategoryWithVideoViewer'] = $dir . 'VideoPage.php';
+$wgAutoloadClasses['VideoPage'] = __DIR__ . '/VideoPage.php';
+$wgAutoloadClasses['WikiVideoPage'] = __DIR__ . '/WikiVideoPage.php';
+$wgAutoloadClasses['RevertVideoAction'] = __DIR__ . '/RevertVideoAction.php';
+$wgAutoloadClasses['VideoHistoryList'] = __DIR__ . '/VideoPage.php';
+$wgAutoloadClasses['CategoryWithVideoViewer'] = __DIR__ . '/VideoPage.php';
 
-$wgAutoloadClasses['VideoGallery'] = $dir . 'VideoGallery.php';
+$wgAutoloadClasses['VideoGallery'] = __DIR__ . '/VideoGallery.php';
 
 // Class for undeleting previously deleted videos
-$wgAutoloadClasses['VideoPageArchive'] = $dir . 'VideoPageArchive.php';
+$wgAutoloadClasses['VideoPageArchive'] = __DIR__ . '/VideoPageArchive.php';
+$wgAutoloadClasses['ArchivedVideo'] = __DIR__ . '/ArchivedVideo.php';
 
 // New special pages
-$wgAutoloadClasses['AddVideo'] = $dir . 'SpecialAddVideo.php';
-$wgAutoloadClasses['NewVideos'] = $dir . 'SpecialNewVideos.php';
+$wgAutoloadClasses['AddVideo'] = __DIR__ . '/SpecialAddVideo.php';
+$wgAutoloadClasses['NewVideos'] = __DIR__ . '/SpecialNewVideos.php';
 $wgSpecialPages['AddVideo'] = 'AddVideo';
 $wgSpecialPages['NewVideos'] = 'NewVideos';
-// Special page groups for MW 1.13+
-$wgSpecialPageGroups['AddVideo'] = 'media';
-$wgSpecialPageGroups['NewVideos'] = 'changes';
 
 // Hook things up
-$wgAutoloadClasses['VideoHooks'] = $dir . 'VideoHooks.php';
+$wgAutoloadClasses['VideoHooks'] = __DIR__ . '/VideoHooks.php';
 
 $wgHooks['ArticleFromTitle'][] = 'VideoHooks::videoFromTitle';
 $wgHooks['CategoryPageView'][] = 'VideoHooks::categoryPageWithVideo';
diff --git a/VideoClass.php b/VideoClass.php
index b8e6f2c..8386088 100644
--- a/VideoClass.php
+++ b/VideoClass.php
@@ -5,7 +5,7 @@
        /**
         * @var String: database key of the video
         */
-       public  $name;
+       public $name;
 
        /**
         * @var Title: Title object associated with the current Video
@@ -117,7 +117,7 @@
         * @param IContextSource $context Nearest context object
         */
        public function __construct( $title, IContextSource $context ) {
-               if( !is_object( $title ) ) {
+               if ( !is_object( $title ) ) {
                        throw new MWException( 'Video constructor given bogus 
title.' );
                }
                $this->title =& $title;
@@ -132,9 +132,9 @@
        /**
         * Create a Video object from a video name
         *
-        * @param $name Mixed: name of the video, used to create a title object 
using Title::makeTitleSafe
-        * @param $context IContextSource nearest context object
-        * @return Video|null returns a Video object on success, null if the 
title is invalid
+        * @param mixed $name Name of the video, used to create a title object 
using Title::makeTitleSafe
+        * @param IContextSource $context Nearest context object
+        * @return Video|null A Video object on success, null if the title is 
invalid
         */
        public static function newFromName( $name, IContextSource $context ) {
                $title = Title::makeTitleSafe( NS_VIDEO, $name );
@@ -148,10 +148,10 @@
        /**
         * Add the video into the database
         *
-        * @param $url String: URL to the video on the provider service
-        * @param $type String: (internal) provider name in lowercase
-        * @param $categories String: pipe-separated list of categories
-        * @param $watch Boolean: add the new video page to the user's 
watchlist?
+        * @param string $url URL to the video on the provider service
+        * @param string $type (internal) provider name in lowercase
+        * @param string $categories Pipe-separated list of categories
+        * @param bool $watch Add the new video page to the user's watchlist?
         */
        public function addVideo( $url, $type, $categories, $watch = false ) {
                $user = $this->context->getUser();
@@ -159,10 +159,10 @@
 
                $now = $dbw->timestamp();
 
-               $desc = wfMsgForContent(
+               $desc = wfMessage(
                        'video-log-added-entry',
                        Title::makeTitle( NS_VIDEO, $this->getName() 
)->getPrefixedText()
-               );
+               )->inContentLanguage()->text();
                // Test to see if the row exists using INSERT IGNORE
                // This avoids race conditions by locking the row until the 
commit, and also
                // doesn't deadlock. SELECT FOR UPDATE causes a deadlock for 
every race condition.
@@ -182,11 +182,11 @@
 
                $categoryWikiText = '';
 
-               if( $dbw->affectedRows() == 0 ) {
-                       $desc = wfMsgForContent(
+               if ( $dbw->affectedRows() == 0 ) {
+                       $desc = wfMessage(
                                'video-log-updated-entry',
                                Title::makeTitle( NS_VIDEO, $this->getName() 
)->getPrefixedText()
-                       );
+                       )->inContentLanguage()->text();
 
                        // Clear cache
                        global $wgMemc;
@@ -232,30 +232,30 @@
                $watch = $watch || $user->isWatched( $descTitle );
 
                // Get the localized category name
-               $videoCategoryName = wfMsgForContent( 'video-category-name' );
+               $videoCategoryName = wfMessage( 'video-category-name' 
)->inContentLanguage()->text();
 
-               if( $categories ) {
+               if ( $categories ) {
                        $categories .= "|$videoCategoryName";
                } else {
-                       $categories = "$videoCategoryName";
+                       $categories = $videoCategoryName;
                }
 
                // Loop through category variable and individually build 
Category Tab for Wiki text
-               if( $categories ) {
+               if ( $categories ) {
                        $categories_array = explode( '|', $categories );
-                       foreach( $categories_array as $ctg ) {
+                       foreach ( $categories_array as $ctg ) {
                                $ctg = trim( $ctg );
-                               if( $ctg ) {
+                               if ( $ctg ) {
                                        $catName = 
$this->context->getLanguage()->getNsText( NS_CATEGORY );
                                        $tag = "[[{$catName}:{$ctg}]]";
-                                       if( strpos( $categoryWikiText, $tag ) 
=== false ) {
+                                       if ( strpos( $categoryWikiText, $tag ) 
=== false ) {
                                                $categoryWikiText .= "\n{$tag}";
                                        }
                                }
                        }
                }
 
-               if( $descTitle->exists() ) {
+               if ( $descTitle->exists() ) {
                        # Invalidate the cache for the description page
                        $descTitle->invalidateCache();
                        $descTitle->purgeSquid();
@@ -265,7 +265,7 @@
                        $article->doEdit( $categoryWikiText, $desc, 
EDIT_SUPPRESS_RC );
                }
 
-               if( $watch ) {
+               if ( $watch ) {
                        $user->addWatch( $descTitle );
                }
 
@@ -280,7 +280,8 @@
 
        /**
         * Try to load video metadata from memcached.
-        * @return Boolean: true on success.
+        *
+        * @return bool True on success.
         */
        private function loadFromCache() {
                global $wgMemc;
@@ -291,7 +292,7 @@
                $key = $this->getCacheKey();
                $data = $wgMemc->get( $key );
 
-               if( !empty( $data ) && is_array( $data ) ) {
+               if ( !empty( $data ) && is_array( $data ) ) {
                        $this->url = $data['url'];
                        $this->type = $data['type'];
                        $this->submitter_user_id = $data['user_id'];
@@ -421,7 +422,7 @@
        }
 
        /**
-        * @return Boolean: true if the Video exists
+        * @return bool True if the Video exists
         */
        public function exists() {
                $this->load();
@@ -431,7 +432,7 @@
        /**
         * Get the embed code for this Video
         *
-        * @return String: video embed code
+        * @return string Video embed code
         */
        public function getEmbedCode() {
                if ( !isset( self::$providers[$this->type] ) ) {
@@ -447,7 +448,7 @@
        /**
         * Is the supplied value a URL?
         *
-        * @return Boolean: true if it is, otherwise false
+        * @return bool True if it is, otherwise false
         */
        public static function isURL( $code ) {
                return preg_match( '%^(?:http|https|ftp)://(?:www\.)?.*$%i', 
$code ) ? true : false;
@@ -457,8 +458,8 @@
         * Try to figure out the video's URL from the embed code that the 
provider
         * allows users to copy & paste on their own sites.
         *
-        * @param $code String: the video's HTML embedding code
-        * @return String: URL of the video
+        * @param string $code The video's HTML embedding code
+        * @return string URL of the video
         */
        public static function getURLfromEmbedCode( $code ) {
                preg_match(
@@ -468,16 +469,16 @@
                );
 
                $embedCode = '';
-               if( isset( $matches[2] ) ) {
+               if ( isset( $matches[2] ) ) {
                        $embedCode = $matches[2];
                }
 
                // Some providers (such as MySpace) have flashvars='' in the 
embed
                // code, and the base URL in the src='' so we need to grab the
                // flashvars and append it to get the real URL
-               if( isset( $matches[6] ) ) {
+               if ( isset( $matches[6] ) ) {
                        $flash_vars = $matches[6];
-                       if( strpos( '?', $flash_vars ) !== false ) {
+                       if ( strpos( '?', $flash_vars ) !== false ) {
                                $embedCode .= '&';
                        } else {
                                $embedCode .= '?';
@@ -510,8 +511,8 @@
        /**
         * Returns if $haystack ends with $needle
         *
-        * @param $haystack String
-        * @param $needle String
+        * @param string $haystack
+        * @param string $needle
         * @return bool
         */
        protected static function endsWith( $haystack, $needle ) {
@@ -521,8 +522,8 @@
        /**
         * Figure out the provider's name (lowercased) from a given URL.
         *
-        * @param $url String: URL to check
-        * @return String: provider name or 'unknown' if we were unable to 
figure
+        * @param string $url URL to check
+        * @return string Provider name or 'unknown' if we were unable to figure
         *                 it out
         */
        public static function getProviderByURL( $url ) {
@@ -540,13 +541,13 @@
        }
 
        public function setWidth( $width ) {
-               if( is_numeric( $width ) ) {
+               if ( is_numeric( $width ) ) {
                        $this->width = $width;
                }
        }
 
        public function setHeight( $height ) {
-               if( is_numeric( $height ) ) {
+               if ( is_numeric( $height ) ) {
                        $this->height = $height;
                }
        }
@@ -563,7 +564,7 @@
        /**
         * Get the code for embedding the current video on a wiki page.
         *
-        * @return String: wikitext to insert on a wiki page
+        * @return string Wikitext to insert on a wiki page
         */
        public function getEmbedThisCode() {
                $videoName = htmlspecialchars( $this->getName(), ENT_QUOTES );
@@ -583,11 +584,13 @@
                $dbr = wfGetDB( DB_SLAVE );
 
                if ( empty( $this->historyLine ) ) { // called for the first 
time, return line from cur
-                       $this->historyRes = $dbr->select( 'video',
+                       $this->historyRes = $dbr->select(
+                               'video',
                                array(
                                        'video_url',
                                        'video_type',
-                                       'video_user_id','video_user_name',
+                                       'video_user_id',
+                                       'video_user_name',
                                        'video_timestamp',
                                        "'' AS ov_archive_name"
                                ),
diff --git a/VideoGallery.php b/VideoGallery.php
index a71c3db..6f6e746 100644
--- a/VideoGallery.php
+++ b/VideoGallery.php
@@ -23,13 +23,13 @@
        $vg->setShowFilename( true );
        $vg->setParsing();
 
-       if( isset( $argv['perrow'] ) ) {
+       if ( isset( $argv['perrow'] ) ) {
                $vg->setPerRow( $argv['perrow'] );
        }
-       if( isset( $params['widths'] ) ) {
+       if ( isset( $params['widths'] ) ) {
                $vg->setWidths( $argv['widths'] );
        }
-       if( isset( $params['heights'] ) ) {
+       if ( isset( $params['heights'] ) ) {
                $vg->setHeights( $argv['heights'] );
        }
 
@@ -40,6 +40,7 @@
                // Video:Some video name|This is some video
                $matches = array();
                preg_match( "/^([^|]+)(\\|(.*))?$/", $line, $matches );
+
                // Skip empty lines
                if ( count( $matches ) == 0 ) {
                        continue;
@@ -47,10 +48,11 @@
 
                $tp = Title::newFromText( $matches[1] );
                $nt =& $tp;
-               if( is_null( $nt ) ) {
+               if ( is_null( $nt ) ) {
                        // Bogus title. Ignore these so we don't bomb out later.
                        continue;
                }
+
                if ( isset( $matches[3] ) ) {
                        $label = $matches[3];
                } else {
@@ -92,7 +94,7 @@
        private $mWidths = 200, $mHeights = 200; // How wide/tall each 
thumbnail should be
 
        /**
-        * Create a new image gallery object.
+        * Create a new video gallery object.
         */
        function __construct() {
                $this->mVideos = array();
@@ -117,7 +119,7 @@
        /**
         * Set the caption (as plain text)
         *
-        * @param $caption Caption
+        * @param string $caption Caption
         */
        function setCaption( $caption ) {
                $this->mCaption = htmlspecialchars( $caption );
@@ -126,41 +128,41 @@
        /**
         * Set the caption (as HTML)
         *
-        * @param $caption Caption
+        * @param string $caption Caption
         */
        public function setCaptionHtml( $caption ) {
                $this->mCaption = $caption;
        }
 
        /**
-        * Set how many images will be displayed per row.
+        * Set how many videos will be displayed per row.
         *
         * @param int $num > 0; invalid numbers will be rejected
         */
        public function setPerRow( $num ) {
-               if( $num > 0 ) {
+               if ( $num > 0 ) {
                        $this->mPerRow = (int)$num;
                }
        }
 
        /**
-        * Set how wide each image will be, in pixels.
+        * Set how wide each video will be, in pixels.
         *
         * @param int $num > 0; invalid numbers will be ignored
         */
        public function setWidths( $num ) {
-               if( $num > 0 ) {
+               if ( $num > 0 ) {
                        $this->mWidths = (int)$num;
                }
        }
 
        /**
-        * Set how high each image will be, in pixels.
+        * Set how high each video will be, in pixels.
         *
         * @param int $num > 0; invalid numbers will be ignored
         */
        public function setHeights( $num ) {
-               if( $num > 0 ) {
+               if ( $num > 0 ) {
                        $this->mHeights = (int)$num;
                }
        }
@@ -169,7 +171,7 @@
         * Add a video to the gallery.
         *
         * @param $video Video object that is added to the gallery
-        * @param $html String: additional HTML text to be shown. The name and 
size of the image are always shown.
+        * @param $html String: additional HTML text to be shown. The name and 
size of the video are always shown.
         */
        function add( $video, $html = '' ) {
                $this->mVideos[] = array( &$video, $html );
@@ -177,27 +179,27 @@
        }
 
        /**
-       * Add an image at the beginning of the gallery.
-       *
-       * @param $image Image object that is added to the gallery
-       * @param $html String: Additional HTML text to be shown. The name and 
size of the image are always shown.
-       */
+        * Add a video at the beginning of the gallery.
+        *
+        * @param $video Video object that is added to the gallery
+        * @param $html String: Additional HTML text to be shown. The name and 
size of the video are always shown.
+        */
        function insert( $video, $html = '' ) {
                array_unshift( $this->mVideos, array( &$video, $html ) );
        }
 
        /**
-        * @return true if the gallery contains no videos
+        * @return bool True if the gallery contains no videos
         */
        function isEmpty() {
                return empty( $this->mVideos );
        }
 
        /**
-        * Enable/Disable showing of the filename of an image in the gallery.
+        * Enable/Disable showing of the filename of a video in the gallery.
         * Enabled by default.
         *
-        * @param $f Boolean: set to false to disable.
+        * @param bool $f Set to false to disable.
         */
        function setShowFilename( $f ) {
                $this->mShowFilename = ( $f == true );
@@ -216,8 +218,9 @@
                global $wgLang;
 
                $s = '<table class="gallery" cellspacing="0" cellpadding="0">';
-               if( $this->getCaption() )
+               if ( $this->getCaption() ) {
                        $s .= "\n\t<caption>{$this->mCaption}</caption>";
+               }
 
                $i = 0;
                foreach ( $this->mVideos as $pair ) {
@@ -226,14 +229,15 @@
 
                        $nt = $video->getTitle();
 
-                       if( $nt->getNamespace() != NS_VIDEO ) {
+                       if ( $nt->getNamespace() != NS_VIDEO ) {
                                # We're dealing with a non-video, spit out the 
name and be done with it.
                                $thumbhtml = "\n\t\t\t" . '<div style="height: 
' . ( $this->mHeights * 1.25 + 2 ) . 'px;">'
                                        . htmlspecialchars( $nt->getText() ) . 
'</div>';
                        } else {
+                               $video->load(); // Just in case to ensure that 
all the fields we need are populated, etc.
                                $video->setWidth( $this->mWidths );
                                $video->setHeight( $this->mHeights );
-                               $vpad = floor( ( 1.25*  $this->mHeights - 
$this->mWidths ) / 2 ) - 2;
+                               $vpad = floor( ( 1.25 * $this->mHeights - 
$this->mWidths ) / 2 ) - 2;
                                $thumbhtml = "\n\t\t\t" . '<div class="thumb" 
style="padding: ' . $vpad . 'px 0; width: ' . ( $this->mWidths + 30 ) . 'px;">'
                                        . $video->getEmbedCode() . '</div>';
                        }
@@ -241,7 +245,7 @@
                        $nb = '';
 
                        $textlink = $this->mShowFilename ?
-                               Linker::makeKnownLinkObj( $nt, 
htmlspecialchars( $wgLang->truncate( $nt->getText(), 30, '...' ) ) ) . "<br 
/>\n" :
+                               Linker::linkKnown( $nt, htmlspecialchars( 
$wgLang->truncate( $nt->getText(), 30, '...' ) ) ) . "<br />\n" :
                                '';
 
                        # ATTENTION: The newline after <div 
class="gallerytext"> is needed to accommodate htmltidy which
@@ -263,7 +267,7 @@
                        }
                        ++$i;
                }
-               if( $i % $this->mPerRow != 0 ) {
+               if ( $i % $this->mPerRow != 0 ) {
                        $s .= "\n\t</tr>";
                }
                $s .= "\n</table>";
diff --git a/VideoGalleryPopulate.php b/VideoGalleryPopulate.php
index 11dce76..c0bd2e3 100644
--- a/VideoGalleryPopulate.php
+++ b/VideoGalleryPopulate.php
@@ -24,7 +24,7 @@
        $category = ( isset( $args['category'] ) ) ? $args['category'] : '';
        $limit = ( isset( $args['limit'] ) ) ? intval( $args['limit'] ) : 10;
 
-       if( empty( $category ) ) {
+       if ( empty( $category ) ) {
                return '';
        }
 
@@ -36,18 +36,18 @@
                $category = $newParser->preprocess( $category, 
$parser->getTitle(), $parser->getOptions() );
        }
        $category_title = Title::newFromText( $category );
-       if( !( $category_title instanceof Title ) ) {
+       if ( !( $category_title instanceof Title ) ) {
                return '';
        }
 
        // @todo FIXME: not overly i18n-friendly here...
        $category_title_secondary = Title::newFromText( $category . ' Videos' );
-       if( !( $category_title_secondary instanceof Title ) ) {
+       if ( !( $category_title_secondary instanceof Title ) ) {
                return '';
        }
 
        $params['ORDER BY'] = 'page_id';
-       if( $limit ) {
+       if ( $limit ) {
                $params['LIMIT'] = $limit;
        }
 
diff --git a/VideoHooks.php b/VideoHooks.php
index 2aec312..16f2dbf 100644
--- a/VideoHooks.php
+++ b/VideoHooks.php
@@ -12,8 +12,8 @@
         * Convert [[Video:Video Name]] tags to <video/> hook; calls
         * VideoHooks::renderVideo to do that.
         *
-        * @param $parser Object: instance of Parser
-        * @param $text String: input text to search for [[Video:]] tags
+        * @param Parser $parser
+        * @param string $text Input text to search for [[Video:]] tags
         * @param $strip_state [unused]
         * @return Boolean: true
         */
@@ -41,11 +41,11 @@
                $video = Video::newFromName( $video_name, 
RequestContext::getMain() );
                $x = 1;
 
-               foreach( $params as $param ) {
-                       if( $x > 1 ) {
+               foreach ( $params as $param ) {
+                       if ( $x > 1 ) {
                                $width_check = preg_match( '/px/i', $param );
 
-                               if( $width_check ) {
+                               if ( $width_check ) {
                                        $width = preg_replace( '/px/i', '', 
$param );
                                } else {
                                        $align = $param;
@@ -55,7 +55,7 @@
                }
 
                if ( is_object( $video ) ) {
-                       if( $video->exists() ) {
+                       if ( $video->exists() ) {
                                $widthTag = $alignTag = '';
                                if ( !empty( $width ) ) {
                                        $widthTag = " width=\"{$width}\"";
@@ -74,18 +74,18 @@
         * Calls VideoPage instead of standard Article for pages in the NS_VIDEO
         * namespace.
         *
-        * @param $title Object: Title object for the current page
-        * @param $article Object: Article object for the current page
-        * @return Boolean: true
+        * @param Title $title Title object for the current page
+        * @param Article $article Article object for the current page
+        * @return bool
         */
        public static function videoFromTitle( &$title, &$article ) {
                global $wgRequest;
 
                if ( $title->getNamespace() == NS_VIDEO ) {
-                       if( $wgRequest->getVal( 'action' ) == 'edit' ) {
+                       if ( $wgRequest->getVal( 'action' ) == 'edit' ) {
                                $addTitle = SpecialPage::getTitleFor( 
'AddVideo' );
                                $video = Video::newFromName( $title->getText(), 
RequestContext::getMain() );
-                               if( !$video->exists() ) {
+                               if ( !$video->exists() ) {
                                        global $wgOut;
                                        $wgOut->redirect(
                                                $addTitle->getFullURL( 
'wpTitle=' . $video->getName() )
@@ -101,8 +101,8 @@
        /**
         * Register the new <video> hook with MediaWiki's parser.
         *
-        * @param $parser Object: instance of Parser
-        * @return Boolean: true
+        * @param Parser $parser
+        * @return bool
         */
        public static function registerVideoHook( &$parser ) {
                $parser->setHook( 'video', 'VideoHooks::videoEmbed' );
@@ -112,15 +112,15 @@
        /**
         * Callback function for VideoHooks::registerVideoHook.
         *
-        * @param $input [unused]
-        * @param $argv Array: array or user-supplied arguments; name must be 
present.
+        * @param string $input [unused]
+        * @param array $argv Array of user-supplied arguments; name must be 
present.
         *                     Optional args include width, height and align.
-        * @param $parser Object: instance of parser
-        * @return String
+        * @param Parser $parser
+        * @return string Video HTML code suitable for outputting
         */
-       public static function videoEmbed( $input, $argv, $parser ) {
+       public static function videoEmbed( $input, $argv, Parser $parser ) {
                $video_name = $argv['name'];
-               if( !$video_name ) {
+               if ( !$video_name ) {
                        return '';
                }
 
@@ -128,24 +128,24 @@
                $height = $height_max = 350;
                $validAlign = array( 'LEFT', 'CENTER', 'RIGHT' );
 
-               if( !empty( $argv['width'] ) && ( $width_max >= $argv['width'] 
) ) {
+               if ( !empty( $argv['width'] ) && ( $width_max >= $argv['width'] 
) ) {
                        $width = $argv['width'];
                }
 
-               if( !empty( $argv['height'] ) && ( $height_max >= 
$argv['height'] ) ) {
+               if ( !empty( $argv['height'] ) && ( $height_max >= 
$argv['height'] ) ) {
                        $height = $argv['height'];
                }
 
                $align = isset( $argv['align'] ) ? $argv['align'] : 'left';
                $alignTag = '';
 
-               if( in_array( strtoupper( $align ), $validAlign ) ) {
+               if ( in_array( strtoupper( $align ), $validAlign ) ) {
                        $alignTag = " class=\"float{$align}\" ";
                }
 
                $output = '';
                $video = Video::newFromName( $video_name, 
RequestContext::getMain() );
-               if( $video->exists() ) {
+               if ( $video->exists() ) {
                        $video->setWidth( $width );
                        $video->setHeight( $height );
 
@@ -160,8 +160,8 @@
        /**
         * Injects Video Gallery into Category pages
         *
-        * @param $cat CategoryPage object
-        * @return Boolean: false
+        * @param CategoryPage $cat
+        * @return bool
         */
        public static function categoryPageWithVideo( &$cat ) {
                $article = new Article( $cat->mTitle );
@@ -185,17 +185,18 @@
         * Called on video deletion; this is the main logic for deleting videos.
         * There is no logic related to video deletion on the VideoPage class.
         *
-        * @param $articleObj Article: instance of Article or its subclass
-        * @param $user Object: current User object ($wgUser)
-        * @param $reason String: reason for the deletion [unused]
-        * @param $error String: error message, if any [unused]
-        * @return Boolean: true
+        * @param Article $articleObj Instance of Article or its subclass
+        * @param User $user Current User object ($wgUser)
+        * @param string $reason Reason for the deletion [unused]
+        * @param string $error Error message, if any [unused]
+        * @return bool
         */
        public static function onVideoDelete( &$articleObj, &$user, &$reason, 
&$error ) {
                if ( $articleObj->getTitle()->getNamespace() == NS_VIDEO ) {
                        global $wgRequest;
 
-                       $videoObj = new Video( $articleObj->getTitle(), 
$articleObj->getContext() );
+                       $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(
@@ -267,10 +268,10 @@
         * Standard PageArchive allows only to restore the wiki page, not the
         * associated video.
         *
-        * @param $archive Object: PageArchive object or a child class
-        * @param $title Object: Title object for the current page that we're 
about
-        *                       to undelete or view
-        * @return Boolean: true
+        * @param PageArchive|VideoPageArchive $archive PageArchive object or a 
child class
+        * @param Title $title Title for the current page that we're about to
+        *                     undelete or view
+        * @return bool
         */
        public static function specialUndeleteSwitchArchive( $archive, $title ) 
{
                if ( $title->getNamespace() == NS_VIDEO ) {
@@ -282,28 +283,22 @@
        /**
         * Applies the schema changes when the user runs maintenance/update.php.
         *
-        * @param $updater
-        * @return Boolean: true
+        * @param DatabaseUpdater $updater
+        * @return bool
         */
-       public static function addTables( $updater = null ) {
-               $dir = dirname( __FILE__ );
+       public static function addTables( $updater ) {
+               $dir = __DIR__;
                $file = "$dir/video.sql";
-               if ( $updater === null ) {
-                       global $wgExtNewTables;
-                       $wgExtNewTables[] = array( 'video', $file );
-                       $wgExtNewTables[] = array( 'oldvideo', $file );
-               } else {
-                       $updater->addExtensionUpdate( array( 'addTable', 
'video', $file, true ) );
-                       $updater->addExtensionUpdate( array( 'addTable', 
'oldvideo', $file, true ) );
-               }
+               $updater->addExtensionUpdate( array( 'addTable', 'video', 
$file, true ) );
+               $updater->addExtensionUpdate( array( 'addTable', 'oldvideo', 
$file, true ) );
                return true;
        }
 
        /**
         * For the Renameuser extension.
         *
-        * @param $renameUserSQL
-        * @return Boolean: true
+        * @param RenameuserSQL $renameUserSQL
+        * @return bool
         */
        public static function onUserRename( $renameUserSQL ) {
                $renameUserSQL->tables['oldvideo'] = array( 'ov_user_name', 
'ov_user_id' );
@@ -314,9 +309,9 @@
        /**
         * Register the canonical names for our namespace and its talkspace.
         *
-        * @param $list Array: array of namespace numbers with corresponding
+        * @param array $list Array of namespace numbers with corresponding
         *                     canonical names
-        * @return Boolean: true
+        * @return bool
         */
        public static function onCanonicalNamespaces( &$list ) {
                $list[NS_VIDEO] = 'Video';
diff --git a/VideoPage.php b/VideoPage.php
index 3e8effd..83ac332 100644
--- a/VideoPage.php
+++ b/VideoPage.php
@@ -39,7 +39,7 @@
                        $out->setPageTitle( $this->mTitle->getPrefixedText() );
                }
 
-               if( $this->video->exists() ) {
+               if ( $this->video->exists() ) {
                        // Display flash video
                        $out->addHTML( $this->video->getEmbedCode() );
 
@@ -53,11 +53,11 @@
                        $title = SpecialPage::getTitleFor( 'AddVideo' );
                        $link = Linker::linkKnown(
                                $title,
-                               wfMsgHtml( 'video-novideo-linktext' ),
+                               $this->msg( 'video-novideo-linktext' )->plain(),
                                array(),
                                array( 'wpTitle' => $this->video->getName() )
                        );
-                       $out->addHTML( wfMsgWikiHtml( 'video-novideo', $link ) 
);
+                       $out->addHTML( $this->msg( 'video-novideo', $link 
)->text() );
 
                        //$wgOut->addHTML( $videoLinksHTML );
                        //$this->videoLinks();
@@ -75,7 +75,7 @@
         *              parser hooks, like <video name="Foo" />...how to fix 
this?
         */
        function videoLinks() {
-               global $wgOut;
+               $out = $this->getContext()->getOutput();
 
                $limit = 100;
 
@@ -99,15 +99,15 @@
                $count = $dbr->numRows( $res );
 
                if ( $count == 0 ) {
-                       $wgOut->addHTML( '<div 
id="mw-imagepage-nolinkstoimage">' . "\n" );
-                       $wgOut->addWikiMsg( 'video-no-links-to-video' );
-                       $wgOut->addHTML( "</div>\n" );
+                       $out->addHTML( '<div id="mw-imagepage-nolinkstoimage">' 
. "\n" );
+                       $out->addWikiMsg( 'video-no-links-to-video' );
+                       $out->addHTML( "</div>\n" );
                        return;
                }
 
-               $wgOut->addHTML( '<div id="mw-imagepage-section-linkstoimage">' 
. "\n" );
-               $wgOut->addWikiMsg( 'video-links-to-video', $count );
-               $wgOut->addHTML( '<ul class="mw-imagepage-linktoimage">' . "\n" 
);
+               $out->addHTML( '<div id="mw-imagepage-section-linkstoimage">' . 
"\n" );
+               $out->addWikiMsg( 'video-links-to-video', $count );
+               $out->addHTML( '<ul class="mw-imagepage-linktoimage">' . "\n" );
 
                $count = 0;
                while ( $s = $res->fetchObject() ) {
@@ -117,15 +117,15 @@
                                // more to fetch
                                $name = Title::makeTitle( $s->page_namespace, 
$s->page_title );
                                $link = Linker::linkKnown( $name );
-                               $wgOut->addHTML( "<li>{$link}</li>\n" );
+                               $out->addHTML( "<li>{$link}</li>\n" );
                        }
                }
-               $wgOut->addHTML( "</ul></div>\n" );
+               $out->addHTML( "</ul></div>\n" );
                $res->free();
 
                // Add a link to [[Special:WhatLinksHere]]
                if ( $count > $limit ) {
-                       $wgOut->addWikiMsg(
+                       $out->addWikiMsg(
                                'video-more-links-to-video',
                                $this->mTitle->getPrefixedDBkey()
                        );
@@ -141,7 +141,7 @@
         * Get the HTML table that contains the code for embedding the current
         * video on a wiki page.
         *
-        * @return String: HTML
+        * @return string HTML
         */
        public function getEmbedThisTag() {
                $code = $this->video->getEmbedThisCode();
@@ -151,7 +151,7 @@
                <table cellpadding="0" cellspacing="2" border="0">
                        <tr>
                                <td>
-                                       <b>' . wfMsg( 'video-embed' ) . '</b>
+                                       <b>' . wfMessage( 'video-embed' 
)->plain() . '</b>
                                </td>
                                <td>
                                <form name="embed_video" action="">
@@ -167,8 +167,6 @@
         * we follow it with an upload history of the video and its usage.
         */
        function videoHistory() {
-               global $wgOut;
-
                $line = $this->video->nextHistoryLine();
 
                if ( $line ) {
@@ -196,11 +194,11 @@
                } else {
                        $s = '';
                }
-               $wgOut->addHTML( $s );
+               $this->getContext()->getOutput()->addHTML( $s );
 
                // Exist check because we don't want to show this on pages 
where a video
                // doesn't exist along with the novideo message, that would 
suck.
-               if( $this->video->exists() ) {
+               if ( $this->video->exists() ) {
                        $this->uploadLinksBox();
                }
        }
@@ -210,12 +208,11 @@
         * users.
         */
        function uploadLinksBox() {
-               global $wgUser, $wgOut;
-
-               $wgOut->addHTML( '<br /><ul>' );
+               $out = $this->getContext()->getOutput();
+               $out->addHTML( '<br /><ul>' );
 
                // "Upload a new version of this video" link
-               if( $wgUser->isAllowed( 'reupload' ) ) {
+               if ( $this->getContext()->getUser()->isAllowed( 'reupload' ) ) {
                        $ulink = Linker::link(
                                SpecialPage::getTitleFor( 'AddVideo' ),
                                wfMsg( 'uploadnewversion-linktext' ),
@@ -225,10 +222,10 @@
                                        'forReUpload' => 1,
                                )
                        );
-                       $wgOut->addHTML( "<li>{$ulink}</li>" );
+                       $out->addHTML( "<li>{$ulink}</li>" );
                }
 
-               $wgOut->addHTML( '</ul>' );
+               $out->addHTML( '</ul>' );
        }
 }
 
@@ -238,8 +235,8 @@
 class VideoHistoryList {
        function beginVideoHistoryList() {
                $s = "\n" .
-                       Xml::element( 'h2', array( 'id' => 'filehistory' ), 
wfMsgHtml( 'video-history' ) ) .
-                       "\n<p>" . wfMsg( 'video-histlegend' ) . "</p>\n" . '<ul 
class="special">';
+                       Xml::element( 'h2', array( 'id' => 'filehistory' ), 
wfMessage( 'video-history' )->plain() ) .
+                       "\n<p>" . wfMessage( 'video-histlegend' )->parse() . 
"</p>\n" . '<ul class="special">';
                return $s;
        }
 
@@ -248,26 +245,27 @@
                return $s;
        }
 
-       function videoHistoryLine( $iscur, $timestamp, $video, $user_id, 
$user_name, $url, $type, $title ) {
+       function videoHistoryLine( $isCur, $timestamp, $video, $user_id, 
$user_name, $url, $type, $title ) {
                global $wgUser, $wgLang;
 
                $datetime = $wgLang->timeanddate( $timestamp, true );
-               $cur = wfMsgHtml( 'cur' );
+               $cur = wfMessage( 'cur' )->plain();
 
-               if ( $iscur ) {
+               if ( $isCur ) {
                        $rlink = $cur;
                } else {
-                       if( $wgUser->getID() != 0 && $title->userCan( 'edit' ) 
) {
+                       if ( $wgUser->getId() != 0 && $title->userCan( 'edit' ) 
) {
                                $rlink = Linker::linkKnown(
                                        $title,
-                                       wfMsgHtml( 'video-revert' ),
-                                       'action=revert&oldvideo=' . urlencode( 
$video )
+                                       wfMessage( 'video-revert' )->plain(),
+                                       array(),
+                                       array( 'action' => 'revert', 'oldvideo' 
=> $video )
                                );
                        } else {
                                # Having live active links for non-logged in 
users
                                # means that bots and spiders crawling our site 
can
                                # inadvertently change content. Baaaad idea.
-                               $rlink = wfMsgHtml( 'video-revert' );
+                               $rlink = wfMessage( 'video-revert' )->plain();
                        }
                }
 
@@ -297,10 +295,10 @@
                $this->articles_start_char = array();
                $this->children = array();
                $this->children_start_char = array();
-               if( $this->showGallery ) {
+               if ( $this->showGallery ) {
                        $this->gallery = new ImageGallery();
                }
-               #if( $this->showVideoGallery ) {
+               #if ( $this->showVideoGallery ) {
                        $this->videogallery = new VideoGallery();
                        $this->videogallery->setParsing();
                #}
@@ -336,20 +334,19 @@
         * If there are videos on the category, display a message indicating how
         * many videos are in the category and render the gallery of videos.
         *
-        * @return String: HTML when there are videos on the category
+        * @return string HTML when there are videos on the category
         */
        function getVideoSection() {
-               if( !$this->videogallery->isEmpty() ) {
+               if ( !$this->videogallery->isEmpty() ) {
                        return "<div id=\"mw-category-media\">\n" . '<h2>' .
-                               wfMsg(
+                               wfMessage(
                                        'category-video-header',
                                        htmlspecialchars( 
$this->title->getText() )
-                               ) . "</h2>\n" .
-                               wfMsgExt(
+                               )->text() . "</h2>\n" .
+                               wfMessage(
                                        'category-video-count',
-                                       'parsemag',
                                        $this->videogallery->count()
-                               ) . $this->videogallery->toHTML() . "\n</div>";
+                               )->parse() . $this->videogallery->toHTML() . 
"\n</div>";
                } else {
                        return '';
                }
@@ -360,7 +357,7 @@
         */
        function addVideo( $title, $sortkey, $pageLength ) {
                $video = new Video( $title, $this->getContext() );
-               if( $this->flip ) {
+               if ( $this->flip ) {
                        $this->videogallery->insert( $video );
                } else {
                        $this->videogallery->add( $video );
@@ -368,57 +365,82 @@
        }
 
        function doCategoryQuery() {
-               $dbr = wfGetDB( DB_SLAVE );
-               if( $this->from != '' ) {
-                       $pageCondition = 'cl_sortkey >= ' . $dbr->addQuotes( 
$this->from );
-                       $this->flip = false;
-               } elseif( $this->until != '' ) {
-                       $pageCondition = 'cl_sortkey < ' . $dbr->addQuotes( 
$this->until );
-                       $this->flip = true;
-               } else {
-                       $pageCondition = '1 = 1';
-                       $this->flip = false;
-               }
-               $res = $dbr->select(
-                       array( 'page', 'categorylinks' ),
-                       array( 'page_title', 'page_namespace', 'page_len', 
'cl_sortkey' ),
-                       array(
-                               $pageCondition,
-                               'cl_from = page_id',
-                               'cl_to' => $this->title->getDBKey()
-                       ),
-                       __METHOD__,
-                       array(
-                               'ORDER BY' => $this->flip ? 'cl_sortkey DESC' : 
'cl_sortkey',
-                               'LIMIT' => $this->limit + 1
-                       )
-               );
+               $dbr = wfGetDB( DB_SLAVE, 'category' );
 
-               $count = 0;
-               $this->nextPage = null;
-               foreach( $res as $x ) {
-                       if( ++$count > $this->limit ) {
-                               // We've reached the one extra which shows that 
there are
-                               // additional pages to be had. Stop here...
-                               $this->nextPage = $x->cl_sortkey;
-                               break;
+               $this->nextPage = array(
+                       'page' => null,
+                       'subcat' => null,
+                       'file' => null,
+               );
+               $this->flip = array( 'page' => false, 'subcat' => false, 'file' 
=> false );
+
+               foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
+                       # Get the sortkeys for start/end, if applicable.  Note 
that if
+                       # the collation in the database differs from the one
+                       # set in $wgCategoryCollation, pagination might go 
totally haywire.
+                       $extraConds = array( 'cl_type' => $type );
+                       if ( isset( $this->from[$type] ) && $this->from[$type] 
!== null ) {
+                               $extraConds[] = 'cl_sortkey >= '
+                                       . $dbr->addQuotes( 
$this->collation->getSortKey( $this->from[$type] ) );
+                       } elseif ( isset( $this->until[$type] ) && 
$this->until[$type] !== null ) {
+                               $extraConds[] = 'cl_sortkey < '
+                                       . $dbr->addQuotes( 
$this->collation->getSortKey( $this->until[$type] ) );
+                               $this->flip[$type] = true;
                        }
 
-                       $title = Title::makeTitle( $x->page_namespace, 
$x->page_title );
+                       $res = $dbr->select(
+                               array( 'page', 'categorylinks', 'category' ),
+                               array( 'page_id', 'page_title', 
'page_namespace', 'page_len',
+                                       'page_is_redirect', 'cl_sortkey', 
'cat_id', 'cat_title',
+                                       'cat_subcats', 'cat_pages', 'cat_files',
+                                       'cl_sortkey_prefix', 'cl_collation' ),
+                               array_merge( array( 'cl_to' => 
$this->title->getDBkey() ), $extraConds ),
+                               __METHOD__,
+                               array(
+                                       'USE INDEX' => array( 'categorylinks' 
=> 'cl_sortkey' ),
+                                       'LIMIT' => $this->limit + 1,
+                                       'ORDER BY' => $this->flip[$type] ? 
'cl_sortkey DESC' : 'cl_sortkey',
+                               ),
+                               array(
+                                       'categorylinks' => array( 'INNER JOIN', 
'cl_from = page_id' ),
+                                       'category' => array( 'LEFT JOIN', array(
+                                               'cat_title = page_title',
+                                               'page_namespace' => NS_CATEGORY
+                                       ) )
+                               )
+                       );
 
-                       if( $title->getNamespace() == NS_CATEGORY ) {
-                               $this->addSubcategoryObject(
-                                       Category::newFromTitle( $title ),
-                                       $x->cl_sortkey,
-                                       $x->page_len
-                               );
-                       } elseif( $title->getNamespace() == NS_FILE ) {
-                               $this->addImage( $title, $x->cl_sortkey, 
$x->page_len );
-                       } elseif( $title->getNamespace() == NS_VIDEO ) {
-                               $this->addVideo( $title, $x->cl_sortkey, 
$x->page_len );
-                       } else {
-                               $this->addPage( $title, $x->cl_sortkey, 
$x->page_len );
+                       $count = 0;
+                       foreach ( $res as $row ) {
+                               $title = Title::newFromRow( $row );
+                               if ( $row->cl_collation === '' ) {
+                                       // Hack to make sure that while 
updating from 1.16 schema
+                                       // and db is inconsistent, that the sky 
doesn't fall.
+                                       // See r83544. Could perhaps be removed 
in a couple decades...
+                                       $humanSortkey = $row->cl_sortkey;
+                               } else {
+                                       $humanSortkey = 
$title->getCategorySortkey( $row->cl_sortkey_prefix );
+                               }
+
+                               if ( ++$count > $this->limit ) {
+                                       # We've reached the one extra which 
shows that there
+                                       # are additional pages to be had. Stop 
here...
+                                       $this->nextPage[$type] = $humanSortkey;
+                                       break;
+                               }
+
+                               if ( $title->getNamespace() == NS_CATEGORY ) {
+                                       $cat = Category::newFromRow( $row, 
$title );
+                                       $this->addSubcategoryObject( $cat, 
$humanSortkey, $row->page_len );
+                               } elseif ( $title->getNamespace() == NS_FILE ) {
+                                       $this->addImage( $title, $humanSortkey, 
$row->page_len, $row->page_is_redirect );
+                               } elseif ( $title->getNamespace() == NS_VIDEO ) 
{
+                                       $this->addVideo( $title, 
$row->cl_sortkey, $row->page_len, $row->page_is_redirect );
+                               } else {
+                                       $this->addPage( $title, $humanSortkey, 
$row->page_len, $row->page_is_redirect );
+                               }
                        }
                }
        }
+
 }
diff --git a/VideoPageArchive.php b/VideoPageArchive.php
index 8deb4a1..8b12625 100644
--- a/VideoPageArchive.php
+++ b/VideoPageArchive.php
@@ -44,7 +44,9 @@
         * @return array(number of file revisions restored, number of video 
revisions restored, log message)
         *         on success, false on failure
         */
-       function undelete( $timestamps, $comment = '', $fileVersions = array(), 
$unsuppress = false ) {
+       function undelete( $timestamps, $comment = '', $fileVersions = array(),
+               $unsuppress = false, User $user = null
+       ) {
                // We currently restore only whole deleted videos, a restore 
link from
                // log could take us here...
                if ( $this->title->exists() ) {
@@ -67,7 +69,7 @@
                $first = true;
 
                foreach ( $result as $row ) {
-                       if( $first ) { // this is our new current revision
+                       if ( $first ) { // this is our new current revision
                                $insertCurrent = array(
                                        'video_name' => $row->ov_name,
                                        'video_url' => $row->ov_url,
@@ -105,5 +107,4 @@
 
                return array( '', '', '' );
        }
-
 }
\ No newline at end of file
diff --git a/i18n/en.json b/i18n/en.json
index 5fa4e57..b1fc602 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -38,5 +38,6 @@
        "video-no-links-to-video": "There are no pages that link to this 
video.",
        "video-more-links-to-video": "View [[Special:WhatLinksHere/$1|more 
links]] to this video.",
        "video-showhidebots": "($1 bots)",
+       "action-addvideo": "add videos from external services into the site",
        "right-addvideo": "Add videos from external services into the site"
 }
diff --git a/i18n/fi.json b/i18n/fi.json
index 58ed892..ab91b40 100644
--- a/i18n/fi.json
+++ b/i18n/fi.json
@@ -33,5 +33,6 @@
     "video-links-to-video": "{{PLURAL:$1|Seuraava sivu linkittää|Seuraavat $1 
sivua linkittävät}} tähän videoon:",
     "video-no-links-to-video": "Mikään sivu ei linkitä tähän videoon.",
     "video-more-links-to-video": "Katso [[Special:WhatLinksHere/$1|lisää 
linkkejä]] tähän videoon.",
+       "action-addvideo": "lisätä videoita ulkoisista palveluista sivustolle",
     "right-addvideo": "Lisätä videoita ulkoisista palveluista sivustolle"
 }
diff --git a/patches/MW-1.23-SpecialUndelete.patch 
b/patches/MW-1.23-SpecialUndelete.patch
new file mode 100644
index 0000000..04571b5
--- /dev/null
+++ b/patches/MW-1.23-SpecialUndelete.patch
@@ -0,0 +1,116 @@
+Index: SpecialUndelete.php
+===================================================================
+--- SpecialUndelete.php        (revision 2710)
++++ SpecialUndelete.php        (working copy)
+@@ -806,7 +806,28 @@
+                       } else {
+                               $this->showFile( $this->mFilename );
+                       }
+-              } elseif ( $this->mRestore && $this->mAction == 'submit' ) {
++              }
++              // CORE HACK for [[mw:Extension:Video]]
++              elseif ( $this->mTargetObj->inNamespace( NS_VIDEO ) ) {
++                      $file = new ArchivedVideo( $this->mTargetObj, '', 
$this->mFilename );
++                      // Check if user is allowed to see this file
++                      if ( !$file->exists() ) {
++                              $out->addWikiMsg( 'filedelete-nofile', 
$this->mFilename );
++                      } elseif ( !$file->userCan( File::DELETED_FILE, $user ) 
) {
++                              if ( $file->isDeleted( File::DELETED_RESTRICTED 
) ) {
++                                      throw new PermissionsError( 
'suppressrevision' );
++                              } else {
++                                      throw new PermissionsError( 
'deletedtext' );
++                              }
++                      }
++                      if ( $this->mRestore && $this->mAction == 'submit' ) {
++                              $this->undelete();
++                      } else {
++                              $this->showHistory();
++                      }
++              }
++              // END CORE HACK
++              elseif ( $this->mRestore && $this->mAction == 'submit' ) {
+                       $this->undelete();
+               } else {
+                       $this->showHistory();
+@@ -1240,8 +1261,15 @@
+               if ( $haveFiles ) {
+                       $batch = new LinkBatch();
+                       foreach ( $files as $row ) {
+-                              $batch->addObj( Title::makeTitleSafe( NS_USER, 
$row->fa_user_text ) );
+-                              $batch->addObj( Title::makeTitleSafe( 
NS_USER_TALK, $row->fa_user_text ) );
++                              // CORE HACK for [[mw:Extension:Video]]
++                              if ( isset( $row->ov_user_name ) && 
$row->ov_user_name ) {
++                                      $batch->addObj( Title::makeTitleSafe( 
NS_USER, $row->ov_user_name ) );
++                                      $batch->addObj( Title::makeTitleSafe( 
NS_USER_TALK, $row->ov_user_name ) );
++                              } else {
++                                      $batch->addObj( Title::makeTitleSafe( 
NS_USER, $row->fa_user_text ) );
++                                      $batch->addObj( Title::makeTitleSafe( 
NS_USER_TALK, $row->fa_user_text ) );
++                              }
++                              // END CORE HACK
+                       }
+                       $batch->execute();
+                       $files->seek( 0 );
+@@ -1458,6 +1486,27 @@
+       }
+ 
+       private function formatFileRow( $row ) {
++              // CORE HACK for [[mw:Extension:Video]]
++              if ( isset( $row->ov_name ) && $row->ov_name ) {
++                      $file = ArchivedVideo::newFromRow( $row );
++                      $ts = wfTimestamp( TS_MW, $row->ov_timestamp );
++                      $user = $this->getUser();
++
++                      if ( $this->mAllowed ) { //&& $row->fa_storage_key ) {
++                              $checkBox = Xml::check( 'fileid' ); //. 
$row->fa_id );
++                              $key = rand();//urlencode( $row->fa_storage_key 
);
++                              $pageLink = $this->getFileLink( $file, 
$this->getPageTitle(), $ts, $key );
++                      } else {
++                              $checkBox = '';
++                              $pageLink = 
$this->getLanguage()->userTimeAndDate( $ts, $user );
++                      }
++                      $userLink = $this->getFileUser( $file );
++                      $data = $comment = $revdlink = '';
++
++                      return "<li>$checkBox $revdlink $pageLink . . 
({$row->ov_type}) . . $userLink $data $comment</li>\n";
++              }
++              // END CORE HACK
++
+               $file = ArchivedFile::newFromRow( $row );
+               $ts = wfTimestamp( TS_MW, $row->fa_timestamp );
+               $user = $this->getUser();
+@@ -1551,16 +1600,25 @@
+                       return '<span class="history-deleted">' . $time . 
'</span>';
+               }
+ 
+-              $link = Linker::linkKnown(
+-                      $titleObj,
+-                      htmlspecialchars( $time ),
+-                      array(),
+-                      array(
+-                              'target' => 
$this->mTargetObj->getPrefixedText(),
+-                              'file' => $key,
+-                              'token' => $user->getEditToken( $key )
+-                      )
+-              );
++              // CORE HACK for [[mw:Extension:Video]]
++              if ( $file instanceof ArchivedVideo ) {
++                      $link = Linker::makeExternalLink(
++                              $file->getURL(), $time, /* $escape */ true, /* 
$linktype */ '',
++                              /* $attribs */ array(), $titleObj
++                      );
++              } else {
++                      $link = Linker::linkKnown(
++                              $titleObj,
++                              htmlspecialchars( $time ),
++                              array(),
++                              array(
++                                      'target' => 
$this->mTargetObj->getPrefixedText(),
++                                      'file' => $key,
++                                      'token' => $user->getEditToken( $key )
++                              )
++                      );
++              }
++              // END CORE HACK
+ 
+               if ( $file->isDeleted( File::DELETED_FILE ) ) {
+                       $link = '<span class="history-deleted">' . $link . 
'</span>';
diff --git a/providers/BaseVideoProvider.php b/providers/BaseVideoProvider.php
index 772211b..2849ee4 100644
--- a/providers/BaseVideoProvider.php
+++ b/providers/BaseVideoProvider.php
@@ -31,7 +31,7 @@
        protected $embedTemplate = null;
 
        public function __construct( $video ) {
-               if ( !($video instanceof Video) ) {
+               if ( !( $video instanceof Video ) ) {
                        throw new MWException( 'Video Provider constructor 
given bogus video object.' );
                }
 
@@ -52,7 +52,7 @@
        }
 
        /**
-        * Function to extract the video id
+        * Function to extract the video ID
         *
         * Override to use instead of regular expression
         *
diff --git a/providers/YouTubeVideo.php b/providers/YouTubeVideo.php
index d487a93..c77f2fe 100644
--- a/providers/YouTubeVideo.php
+++ b/providers/YouTubeVideo.php
@@ -11,6 +11,13 @@
        }
 
        public static function getDomains() {
-               return array( 'youtube.com' );
+               return array(
+                       'youtube.com',
+                       // YouTube's "enhanced privacy mode", in which "YouTube 
won’t
+                       // store information about visitors on your web page 
unless they
+                       // play the video"
+                       // @see 
https://support.google.com/youtube/answer/171780?expand=PrivacyEnhancedMode#privacy
+                       'youtube-nocookie.com'
+               );
        }
 }
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/161982
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5fd606c575fe94f20e1c06e4fdf795c3c9c0dd80
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Video
Gerrit-Branch: master
Gerrit-Owner: Jack Phoenix <[email protected]>
Gerrit-Reviewer: Jack Phoenix <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to