SamanthaNguyen has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/365411 )

Change subject: [WIP] Reorganize directory structure + file renaming
......................................................................

[WIP] Reorganize directory structure + file renaming

Splits VideoPage.php into:
- includes/VideoPage.class.php
- includes/VideoHistoryList.class.php
- includes/CategoryWithVideoViewer.class.php

Splits VideoGallery.php into:
- includes/VideoGallery.class.php
- includes/parser/VideoGallery.hooks.php

Bug: T160849
Change-Id: I98be0c47f2a12048b12a9e79859f132fee57b74a
---
D VideoGalleryPopulate.php
D VideoPage.php
M extension.json
R includes/ArchivedVideo.class.php
A includes/CategoryWithVideoViewer.class.php
R includes/RevertVideoAction.class.php
R includes/Video.alias.php
R includes/Video.class.php
R includes/Video.hooks.php
R includes/Video.namespaces.php
R includes/VideoGallery.class.php
A includes/VideoHistoryList.class.php
A includes/VideoPage.class.php
R includes/VideoPageArchive.class.php
R includes/WikiVideoPage.class.php
A includes/parser/VideoGallery.hooks.php
A includes/parser/VideoGalleryPopulate.hooks.php
R includes/providers/BaseVideoProvider.class.php
R includes/providers/BlipTVVideo.php
R includes/providers/DailyMotionVideo.php
R includes/providers/GametrailersVideo.php
R includes/providers/GoogleVideo.php
R includes/providers/HuluVideo.php
R includes/providers/MTVNetworksVideo.php
R includes/providers/MetaCafeVideo.php
R includes/providers/MovieClipsVideo.php
R includes/providers/MyVideoVideo.php
R includes/providers/SouthParkStudiosVideo.php
R includes/providers/ViddlerVideo.php
R includes/providers/VimeoVideo.php
R includes/providers/WeGameVideo.php
R includes/providers/YouTubeVideo.php
R includes/specials/SpecialAddVideo.php
R includes/specials/SpecialNewVideos.php
R includes/specials/SpecialUndeleteWithVideoSupport.php
R resources/css/Video.css
R sql/video.sql
37 files changed, 625 insertions(+), 622 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Video 
refs/changes/11/365411/1

diff --git a/VideoGalleryPopulate.php b/VideoGalleryPopulate.php
deleted file mode 100644
index 81b61ed..0000000
--- a/VideoGalleryPopulate.php
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-/**
- * <videogallerypopulate> parser hook extension -- display a gallery of all
- * videos in a specific category
- *
- * @file
- * @ingroup Extensions
- */
-
-$wgHooks['ParserFirstCallInit'][] = 'wfVideoGalleryPopulate';
-
-function wfVideoGalleryPopulate( $parser ) {
-       $parser->setHook( 'videogallerypopulate', 'VideoGalleryPopulate' );
-       return true;
-}
-
-function VideoGalleryPopulate( $input, $args, $parser ) {
-       $parser->disableCache();
-
-       $category = ( isset( $args['category'] ) ) ? $args['category'] : '';
-       $limit = ( isset( $args['limit'] ) ) ? intval( $args['limit'] ) : 10;
-
-       if ( empty( $category ) ) {
-               return '';
-       }
-
-       // Use Parser::recursivePreprocess() if available instead of creating 
another Parser instance
-       if ( is_callable( array( $parser, 'recursivePreprocess' ) ) ) {
-               $category = $parser->recursivePreprocess( $category );
-       } else {
-               $newParser = new Parser();
-               $category = $newParser->preprocess( $category, 
$parser->getTitle(), $parser->getOptions() );
-       }
-       $category_title = Title::newFromText( $category );
-       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 ) ) {
-               return '';
-       }
-
-       $params['ORDER BY'] = 'page_id';
-       if ( $limit ) {
-               $params['LIMIT'] = $limit;
-       }
-
-       $dbr = wfGetDB( DB_SLAVE );
-       $res = $dbr->select(
-               array( 'page', 'categorylinks' ),
-               'page_title',
-               array(
-                       'cl_to' => array(
-                               $category_title->getDBkey(),
-                               $category_title_secondary->getDBkey()
-                       ),
-                       'page_namespace' => NS_VIDEO
-               ),
-               __METHOD__,
-               $params,
-               array( 'categorylinks' => array( 'INNER JOIN', 'cl_from = 
page_id' ) )
-       );
-
-       $gallery = new VideoGallery();
-       $gallery->setParsing( true );
-       $gallery->setShowFilename( true );
-
-       foreach ( $res as $row ) {
-               $video = Video::newFromName( $row->page_title, 
RequestContext::getMain() );
-               $gallery->add( $video );
-       }
-
-       return $gallery->toHtml();
-}
diff --git a/VideoPage.php b/VideoPage.php
deleted file mode 100644
index f441ede..0000000
--- a/VideoPage.php
+++ /dev/null
@@ -1,437 +0,0 @@
-<?php
-
-class VideoPage extends Article {
-
-       public $title = null;
-
-       /**
-        * Constructor and clear the article
-        * @param Title $title
-        */
-       public function __construct( $title ) {
-               parent::__construct( $title );
-       }
-
-       /**
-        * Overridden to return WikiVideoPage
-        *
-        * @param Title $title
-        * @return WikiVideoPage
-        */
-       protected function newPage( Title $title ) {
-               return new WikiVideoPage( $title );
-       }
-
-       /**
-        * Called on every video page view.
-        */
-       public function view() {
-               $ctx = $this->getContext();
-               $this->video = new Video( $this->getTitle(), $ctx );
-               $out = $ctx->getOutput();
-
-               // No need to display noarticletext, we use our own message
-               if ( $this->getID() ) {
-                       parent::view();
-               } else {
-                       // Just need to set the right headers
-                       $out->setArticleFlag( true );
-                       $out->setRobotPolicy( 'index,follow' );
-                       $out->setPageTitle( $this->mTitle->getPrefixedText() );
-               }
-
-               if ( $this->video->exists() ) {
-                       // Display flash video
-                       $out->addHTML( $this->video->getEmbedCode() );
-
-                       // Force embed this code to have width of 300
-                       $this->video->setWidth( 300 );
-                       $out->addHTML( $this->getEmbedThisTag() );
-
-                       $this->videoHistory();
-
-                       $out->addWikiText( '== ' . $ctx->msg( 'video-links' 
)->escaped() . " ==\n" );
-                       $this->videoLinks();
-               } else {
-                       // Video doesn't exist, so give a link allowing user to 
add one with this name
-                       $title = SpecialPage::getTitleFor( 'AddVideo' );
-                       $link = Linker::linkKnown(
-                               $title,
-                               $ctx->msg( 'video-novideo-linktext' )->plain(),
-                               array(),
-                               array( 'wpTitle' => $this->video->getName() )
-                       );
-                       $out->addHTML( $ctx->msg( 'video-novideo', $link 
)->text() );
-
-                       $out->addWikiText( '== ' . $ctx->msg( 'video-links' 
)->escaped() . " ==\n" );
-                       $this->videoLinks();
-                       $this->mPage->doViewUpdates( $ctx->getUser() );
-               }
-       }
-
-       /**
-        * Display pages linking to that video on the video page.
-        */
-       function videoLinks() {
-               $out = $this->getContext()->getOutput();
-
-               $limit = 100;
-
-               $dbr = wfGetDB( DB_SLAVE );
-
-               // WikiaVideo used the imagelinks table here because that 
extension
-               // adds everything into core (archive, filearchive, imagelinks, 
etc.)
-               // tables instead of using its own tables
-               $res = $dbr->select(
-                       array( 'pagelinks', 'page' ),
-                       array( 'page_namespace', 'page_title' ),
-                       array(
-                               'pl_namespace' => NS_VIDEO,
-                               'pl_title' => $this->getTitle()->getDBkey(),
-                               'pl_from = page_id',
-                       ),
-                       __METHOD__,
-                       array( 'LIMIT' => $limit + 1 )
-               );
-
-               $count = $dbr->numRows( $res );
-
-               if ( $count == 0 ) {
-                       $out->addHTML( '<div id="mw-imagepage-nolinkstoimage">' 
. "\n" );
-                       $out->addWikiMsg( 'video-no-links-to-video' );
-                       $out->addHTML( "</div>\n" );
-                       return;
-               }
-
-               $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() ) {
-                       $count++;
-                       if ( $count <= $limit ) {
-                               // We have not yet reached the extra one that 
tells us there is
-                               // more to fetch
-                               $name = Title::makeTitle( $s->page_namespace, 
$s->page_title );
-                               $link = Linker::linkKnown( $name );
-                               $out->addHTML( "<li>{$link}</li>\n" );
-                       }
-               }
-               $out->addHTML( "</ul></div>\n" );
-               $res->free();
-
-               // Add a link to [[Special:WhatLinksHere]]
-               if ( $count > $limit ) {
-                       $out->addWikiMsg(
-                               'video-more-links-to-video',
-                               $this->mTitle->getPrefixedDBkey()
-                       );
-               }
-       }
-
-       /**
-        * Get the HTML table that contains the code for embedding the current
-        * video on a wiki page.
-        *
-        * @return string HTML
-        */
-       public function getEmbedThisTag() {
-               $code = $this->video->getEmbedThisCode();
-               $code = preg_replace( '/[\n\r\t]/', '', $code ); // replace any 
non-space whitespace with a space
-               $code = str_replace( '_', ' ', $code ); // replace underscores 
with spaces
-               return '<br /><br />
-               <table cellpadding="0" cellspacing="2" border="0">
-                       <tr>
-                               <td>
-                                       <b>' . wfMessage( 'video-embed' 
)->plain() . '</b>
-                               </td>
-                               <td>
-                               <form name="embed_video" action="">
-                                       <input name="embed_code" style="width: 
300px; font-size: 10px;" type="text" value="' . $code . '" 
onclick="javascript:document.embed_video.embed_code.focus();document.embed_video.embed_code.select();"
 readonly="readonly" />
-                               </form>
-                               </td>
-                       </tr>
-               </table>';
-       }
-
-       /**
-        * If the page we've just displayed is in the "Video" namespace,
-        * we follow it with an upload history of the video and its usage.
-        */
-       function videoHistory() {
-               $line = $this->video->nextHistoryLine();
-
-               if ( $line ) {
-                       $list = new VideoHistoryList();
-                       $s = $list->beginVideoHistoryList() .
-                               $list->videoHistoryLine(
-                                       true,
-                                       wfTimestamp( TS_MW, 
$line->video_timestamp ),
-                                       $this->mTitle->getDBkey(),
-                                       $line->video_user_id,
-                                       $line->video_user_name,
-                                       strip_tags( $line->video_url ),
-                                       $line->video_type,
-                                       $this->getTitle()
-                               );
-
-                       while ( $line = $this->video->nextHistoryLine() ) {
-                               $s .= $list->videoHistoryLine( false, 
$line->video_timestamp,
-                                       $line->ov_archive_name, 
$line->video_user_id,
-                                       $line->video_user_name, strip_tags( 
$line->video_url ), $line->video_type,
-                                       $this->getTitle()
-                               );
-                       }
-                       $s .= $list->endVideoHistoryList();
-               } else {
-                       $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() ) {
-                       $this->uploadLinksBox();
-               }
-       }
-
-       /**
-        * Print out the reupload link at the bottom of a video page for 
privileged
-        * users.
-        */
-       function uploadLinksBox() {
-               $out = $this->getContext()->getOutput();
-               $out->addHTML( '<br /><ul>' );
-
-               // "Upload a new version of this video" link
-               if ( $this->getContext()->getUser()->isAllowed( 'reupload' ) ) {
-                       $ulink = Linker::link(
-                               SpecialPage::getTitleFor( 'AddVideo' ),
-                               $this->getContext()->msg( 
'video-upload-new-version' )->plain(),
-                               array(),
-                               array(
-                                       'wpTitle' => $this->video->getName(),
-                                       'forReUpload' => 1,
-                               )
-                       );
-                       $out->addHTML( "<li>{$ulink}</li>" );
-               }
-
-               $out->addHTML( '</ul>' );
-       }
-}
-
-/**
- * @todo document
- */
-class VideoHistoryList {
-       function beginVideoHistoryList() {
-               $s = "\n" .
-                       Xml::element( 'h2', array( 'id' => 'filehistory' ), 
wfMessage( 'video-history' )->plain() ) .
-                       "\n<p>" . wfMessage( 'video-histlegend' )->parse() . 
"</p>\n" . '<ul class="special">';
-               return $s;
-       }
-
-       function endVideoHistoryList() {
-               $s = "</ul>\n";
-               return $s;
-       }
-
-       function videoHistoryLine( $isCur, $timestamp, $video, $user_id, 
$user_name, $url, $type, $title ) {
-               global $wgUser, $wgLang;
-
-               $datetime = $wgLang->timeanddate( $timestamp, true );
-               $cur = wfMessage( 'cur' )->plain();
-
-               if ( $isCur ) {
-                       $rlink = $cur;
-               } else {
-                       if ( $wgUser->getId() != 0 && $title->userCan( 'edit' ) 
) {
-                               $rlink = Linker::linkKnown(
-                                       $title,
-                                       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 = wfMessage( 'video-revert' )->plain();
-                       }
-               }
-
-               $userlink = Linker::userLink( $user_id, $user_name ) .
-                       Linker::userToolLinks( $user_id, $user_name );
-
-               $style = htmlspecialchars( strtr( urldecode( $url ), '_', ' ') 
);
-
-               $s = "<li>({$rlink}) <a href=\"{$url}\" 
title=\"{$style}\">{$datetime}</a> . . ({$type}) . . {$userlink}";
-
-               $s .= Linker::commentBlock( /*$description*/'', $title );
-               $s .= "</li>\n";
-               return $s;
-       }
-
-}
-
-/**
- * This is like a normal CategoryViewer, except that it supports videos.
- * This is initialized for every category page by
- * VideoHooks::categoryPageWithVideo function in VideoHooks.php.
- */
-class CategoryWithVideoViewer extends CategoryViewer {
-
-       function clearCategoryState() {
-               $this->articles = array();
-               $this->articles_start_char = array();
-               $this->children = array();
-               $this->children_start_char = array();
-               if ( $this->showGallery ) {
-                       $this->gallery = ImageGalleryBase::factory();
-               }
-               #if ( $this->showVideoGallery ) {
-                       $this->videogallery = new VideoGallery();
-                       $this->videogallery->setParsing();
-               #}
-       }
-
-       /**
-        * Format the category data list.
-        *
-        * @return string HTML output
-        */
-       function getHTML() {
-               global $wgOut, $wgCategoryMagicGallery;
-
-               $this->showGallery = $wgCategoryMagicGallery && 
!$wgOut->mNoGallery;
-
-               $this->clearCategoryState();
-               $this->doCategoryQuery();
-               $this->finaliseCategoryState();
-
-               $r = $this->getCategoryTop() .
-                       $this->getSubcategorySection() .
-                       $this->getPagesSection() .
-                       $this->getImageSection() .
-                       $this->getVideoSection() .
-                       $this->getCategoryBottom();
-
-               return $r;
-       }
-
-       /**
-        * 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
-        */
-       function getVideoSection() {
-               if ( !$this->videogallery->isEmpty() ) {
-                       return "<div id=\"mw-category-media\">\n" . '<h2>' .
-                               wfMessage(
-                                       'category-video-header',
-                                       htmlspecialchars( 
$this->title->getText() )
-                               )->text() . "</h2>\n" .
-                               wfMessage(
-                                       'category-video-count',
-                                       $this->videogallery->count()
-                               )->parse() . $this->videogallery->toHTML() . 
"\n</div>";
-               } else {
-                       return '';
-               }
-       }
-
-       /**
-        * Add a page in the video namespace
-        */
-       function addVideo( $title, $sortkey, $pageLength ) {
-               $video = new Video( $title, $this->getContext() );
-               if ( $this->flip ) {
-                       $this->videogallery->insert( $video );
-               } else {
-                       $this->videogallery->add( $video );
-               }
-       }
-
-       function doCategoryQuery() {
-               $dbr = wfGetDB( DB_SLAVE, 'category' );
-
-               $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;
-                       }
-
-                       $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
-                                       ) )
-                               )
-                       );
-
-                       $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/extension.json b/extension.json
index d0fda38..91e1b1f 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
 {
        "name": "Video",
-       "version": "1.5.7",
+       "version": "1.6.0",
        "author": [
                "David Pean",
                "Jack Phoenix",
@@ -34,38 +34,40 @@
                }
        ],
        "ExtensionMessagesFiles": {
-               "VideoAlias": "Video.alias.php",
-               "VideoNamespaces": "Video.namespaces.php"
+               "VideoAlias": "includes/Video.alias.php",
+               "VideoNamespaces": "includes/Video.namespaces.php"
        },
        "AutoloadClasses": {
-               "Video": "VideoClass.php",
-               "BlipTVVideoProvider": "providers/BlipTVVideo.php",
-               "DailyMotionVideoProvider": "providers/DailyMotionVideo.php",
-               "BaseVideoProvider": "providers/BaseVideoProvider.php",
-               "GametrailersVideoProvider": "providers/GametrailersVideo.php",
-               "GoogleVideoProvider": "providers/GoogleVideo.php",
-               "HuluVideoProvider": "providers/HuluVideo.php",
-               "MetaCafeVideoProvider": "providers/MetaCafeVideo.php",
-               "MovieClipsVideoProvider": "providers/MovieClipsVideo.php",
-               "MTVNetworksVideoProvider": "providers/MTVNetworksVideo.php",
-               "MyVideoVideoProvider": "providers/MyVideoVideo.php",
-               "SouthParkStudiosVideoProvider": 
"providers/SouthParkStudiosVideo.php",
-               "ViddlerVideoProvider": "providers/ViddlerVideo.php",
-               "VimeoVideoProvider": "providers/VimeoVideo.php",
-               "WeGameVideoProvider": "providers/WeGameVideo.php",
-               "YouTubeVideoProvider": "providers/YouTubeVideo.php",
-               "VideoPage": "VideoPage.php",
-               "WikiVideoPage": "WikiVideoPage.php",
-               "RevertVideoAction": "RevertVideoAction.php",
-               "VideoHistoryList": "VideoPage.php",
-               "CategoryWithVideoViewer": "VideoPage.php",
-               "VideoGallery": "VideoGallery.php",
-               "VideoPageArchive": "VideoPageArchive.php",
-               "ArchivedVideo": "ArchivedVideo.php",
-               "AddVideo": "SpecialAddVideo.php",
-               "NewVideos": "SpecialNewVideos.php",
-               "SpecialUndeleteWithVideoSupport": 
"SpecialUndeleteWithVideoSupport.php",
-               "VideoHooks": "VideoHooks.php"
+               "Video": "includes/Video.class.php",
+               "BlipTVVideoProvider": "includes/providers/BlipTVVideo.php",
+               "DailyMotionVideoProvider": 
"includes/providers/DailyMotionVideo.php",
+               "BaseVideoProvider": 
"includes/providers/BaseVideoProvider.class.php",
+               "GametrailersVideoProvider": 
"includes/providers/GametrailersVideo.php",
+               "GoogleVideoProvider": "includes/providers/GoogleVideo.php",
+               "HuluVideoProvider": "includes/providers/HuluVideo.php",
+               "MetaCafeVideoProvider": "includes/providers/MetaCafeVideo.php",
+               "MovieClipsVideoProvider": 
"includes/providers/MovieClipsVideo.php",
+               "MTVNetworksVideoProvider": 
"includes/providers/MTVNetworksVideo.php",
+               "MyVideoVideoProvider": "includes/providers/MyVideoVideo.php",
+               "SouthParkStudiosVideoProvider": 
"includes/providers/SouthParkStudiosVideo.php",
+               "ViddlerVideoProvider": "includes/providers/ViddlerVideo.php",
+               "VimeoVideoProvider": "includes/providers/VimeoVideo.php",
+               "WeGameVideoProvider": "includes/providers/WeGameVideo.php",
+               "YouTubeVideoProvider": "includes/providers/YouTubeVideo.php",
+               "VideoPage": "includes/VideoPage.class.php",
+               "WikiVideoPage": "includes/WikiVideoPage.class.php",
+               "RevertVideoAction": "includes/RevertVideoAction.class.php",
+               "VideoHistoryList": "includes/VideoHistoryList.class.php",
+               "CategoryWithVideoViewer": 
"includes/CategoryWithVideoViewer.class.php",
+               "VideoGallery": "includes/VideoGallery.php",
+               "VideoGalleryHooks": "includes/parser/VideoGallery.hooks.php",
+               "VideoGalleryPopulateHooks": 
"includes/parser/VideoGalleryPopulate.hooks.php",
+               "VideoPageArchive": "includes/VideoPageArchive.class.php",
+               "ArchivedVideo": "includes/ArchivedVideo.class.php",
+               "AddVideo": "includes/specials/SpecialAddVideo.php",
+               "NewVideos": "includes/specials/SpecialNewVideos.php",
+               "SpecialUndeleteWithVideoSupport": 
"includes/specials/SpecialUndeleteWithVideoSupport.php",
+               "VideoHooks": "includes/Video.hooks.php"
        },
        "Hooks": {
                "ArticleFromTitle": [
@@ -78,7 +80,9 @@
                        "VideoHooks::videoTag"
                ],
                "ParserFirstCallInit": [
-                       "VideoHooks::registerVideoHook"
+                       "VideoHooks::onParserFirstCallInit",
+                       "VideoGalleryHooks::onParserFirstCallInit",
+                       "VideoGalleryPopulateHooks::onParserFirstCallInit"
                ],
                "ArticleDelete": [
                        "VideoHooks::onVideoDelete"
@@ -108,7 +112,7 @@
        },
        "ResourceModules": {
                "ext.video": {
-                       "styles": "Video.css",
+                       "styles": "resources/css/Video.css",
                        "position": "top"
                }
        },
diff --git a/ArchivedVideo.php b/includes/ArchivedVideo.class.php
similarity index 100%
rename from ArchivedVideo.php
rename to includes/ArchivedVideo.class.php
diff --git a/includes/CategoryWithVideoViewer.class.php 
b/includes/CategoryWithVideoViewer.class.php
new file mode 100644
index 0000000..770f335
--- /dev/null
+++ b/includes/CategoryWithVideoViewer.class.php
@@ -0,0 +1,159 @@
+<?php
+/**
+ * This is like a normal CategoryViewer, except that it supports videos.
+ * This is initialized for every category page by
+ * VideoHooks::categoryPageWithVideo function in Video.hooks.php.
+ */
+class CategoryWithVideoViewer extends CategoryViewer {
+
+       function clearCategoryState() {
+               $this->articles = array();
+               $this->articles_start_char = array();
+               $this->children = array();
+               $this->children_start_char = array();
+               if ( $this->showGallery ) {
+                       $this->gallery = ImageGalleryBase::factory();
+               }
+               #if ( $this->showVideoGallery ) {
+                       $this->videogallery = new VideoGallery();
+                       $this->videogallery->setParsing();
+               #}
+       }
+
+       /**
+        * Format the category data list.
+        *
+        * @return string HTML output
+        */
+       function getHTML() {
+               global $wgOut, $wgCategoryMagicGallery;
+
+               $this->showGallery = $wgCategoryMagicGallery && 
!$wgOut->mNoGallery;
+
+               $this->clearCategoryState();
+               $this->doCategoryQuery();
+               $this->finaliseCategoryState();
+
+               $r = $this->getCategoryTop() .
+                       $this->getSubcategorySection() .
+                       $this->getPagesSection() .
+                       $this->getImageSection() .
+                       $this->getVideoSection() .
+                       $this->getCategoryBottom();
+
+               return $r;
+       }
+
+       /**
+        * 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
+        */
+       function getVideoSection() {
+               if ( !$this->videogallery->isEmpty() ) {
+                       return "<div id=\"mw-category-media\">\n" . '<h2>' .
+                               wfMessage(
+                                       'category-video-header',
+                                       htmlspecialchars( 
$this->title->getText() )
+                               )->text() . "</h2>\n" .
+                               wfMessage(
+                                       'category-video-count',
+                                       $this->videogallery->count()
+                               )->parse() . $this->videogallery->toHTML() . 
"\n</div>";
+               } else {
+                       return '';
+               }
+       }
+
+       /**
+        * Add a page in the video namespace
+        */
+       function addVideo( $title, $sortkey, $pageLength ) {
+               $video = new Video( $title, $this->getContext() );
+               if ( $this->flip ) {
+                       $this->videogallery->insert( $video );
+               } else {
+                       $this->videogallery->add( $video );
+               }
+       }
+
+       function doCategoryQuery() {
+               $dbr = wfGetDB( DB_SLAVE, 'category' );
+
+               $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;
+                       }
+
+                       $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
+                                       ) )
+                               )
+                       );
+
+                       $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/RevertVideoAction.php b/includes/RevertVideoAction.class.php
similarity index 100%
rename from RevertVideoAction.php
rename to includes/RevertVideoAction.class.php
diff --git a/Video.alias.php b/includes/Video.alias.php
similarity index 100%
rename from Video.alias.php
rename to includes/Video.alias.php
diff --git a/VideoClass.php b/includes/Video.class.php
similarity index 100%
rename from VideoClass.php
rename to includes/Video.class.php
diff --git a/VideoHooks.php b/includes/Video.hooks.php
similarity index 98%
rename from VideoHooks.php
rename to includes/Video.hooks.php
index cec7f2f..53a8435 100644
--- a/VideoHooks.php
+++ b/includes/Video.hooks.php
@@ -104,7 +104,7 @@
         * @param Parser $parser
         * @return bool
         */
-       public static function registerVideoHook( &$parser ) {
+       public static function onParserFirstCallInit( &$parser ) {
                $parser->setHook( 'video', 'VideoHooks::videoEmbed' );
                return true;
        }
@@ -325,4 +325,3 @@
                return true;
        }
 }
-
diff --git a/Video.namespaces.php b/includes/Video.namespaces.php
similarity index 100%
rename from Video.namespaces.php
rename to includes/Video.namespaces.php
diff --git a/VideoGallery.php b/includes/VideoGallery.class.php
similarity index 77%
rename from VideoGallery.php
rename to includes/VideoGallery.class.php
index 7b19bbb..a4cbf70 100644
--- a/VideoGallery.php
+++ b/includes/VideoGallery.class.php
@@ -1,83 +1,10 @@
 <?php
 /**
- * <videogallery> parser hook tag
- *
- * @file
- * @ingroup Extensions
- */
-
-$wgHooks['ParserFirstCallInit'][] = 'wfVideoGallery';
-
-function wfVideoGallery( &$parser ) {
-       $parser->setHook( 'videogallery', 'wfRenderVideoGallery' );
-       return true;
-}
-
-function wfRenderVideoGallery( $input, $argv, $parser ) {
-       $vg = new VideoGallery();
-       $vg->setContextTitle( $parser->getTitle()->getText() );
-       $vg->setShowFilename( true );
-       $vg->setParsing();
-
-       if ( isset( $argv['perrow'] ) ) {
-               $vg->setPerRow( $argv['perrow'] );
-       }
-       if ( isset( $params['widths'] ) ) {
-               $vg->setWidths( $argv['widths'] );
-       }
-       if ( isset( $params['heights'] ) ) {
-               $vg->setHeights( $argv['heights'] );
-       }
-
-       $lines = explode( "\n", $input );
-
-       foreach ( $lines as $line ) {
-               // match lines like these:
-               // Video:Some video name|This is some video
-               $matches = array();
-               preg_match( "/^([^|]+)(\\|(.*))?$/", $line, $matches );
-
-               // Skip empty lines
-               if ( count( $matches ) == 0 ) {
-                       continue;
-               }
-
-               $tp = Title::newFromText( $matches[1] );
-               $nt =& $tp;
-               if ( is_null( $nt ) ) {
-                       // Bogus title. Ignore these so we don't bomb out later.
-                       continue;
-               }
-
-               if ( isset( $matches[3] ) ) {
-                       $label = $matches[3];
-               } else {
-                       $label = '';
-               }
-
-               $html = '';
-               /*
-               $pout = $this->parse( $label,
-                       $this->mTitle,
-                       $this->mOptions,
-                       false, // Strip whitespace...?
-                       false  // Don't clear state!
-               );
-               $html = $pout->getText();
-               */
-
-               // Gah, there should be a better way to get context here
-               $vg->add( new Video( $nt, RequestContext::getMain() ), $html );
-
-       }
-       return $vg->toHTML();
-}
-
-/**
  * Video gallery
  *
  * Add videos to the gallery using add(), then render that list to HTML using 
toHTML().
  */
+
 class VideoGallery {
        public $mVideos, $mShowFilename;
 
diff --git a/includes/VideoHistoryList.class.php 
b/includes/VideoHistoryList.class.php
new file mode 100644
index 0000000..6acb630
--- /dev/null
+++ b/includes/VideoHistoryList.class.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * @todo document
+ */
+class VideoHistoryList {
+       function beginVideoHistoryList() {
+               $s = "\n" .
+                       Xml::element( 'h2', array( 'id' => 'filehistory' ), 
wfMessage( 'video-history' )->plain() ) .
+                       "\n<p>" . wfMessage( 'video-histlegend' )->parse() . 
"</p>\n" . '<ul class="special">';
+               return $s;
+       }
+
+       function endVideoHistoryList() {
+               $s = "</ul>\n";
+               return $s;
+       }
+
+       function videoHistoryLine( $isCur, $timestamp, $video, $user_id, 
$user_name, $url, $type, $title ) {
+               global $wgUser, $wgLang;
+
+               $datetime = $wgLang->timeanddate( $timestamp, true );
+               $cur = wfMessage( 'cur' )->plain();
+
+               if ( $isCur ) {
+                       $rlink = $cur;
+               } else {
+                       if ( $wgUser->getId() != 0 && $title->userCan( 'edit' ) 
) {
+                               $rlink = Linker::linkKnown(
+                                       $title,
+                                       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 = wfMessage( 'video-revert' )->plain();
+                       }
+               }
+
+               $userlink = Linker::userLink( $user_id, $user_name ) .
+                       Linker::userToolLinks( $user_id, $user_name );
+
+               $style = htmlspecialchars( strtr( urldecode( $url ), '_', ' ') 
);
+
+               $s = "<li>({$rlink}) <a href=\"{$url}\" 
title=\"{$style}\">{$datetime}</a> . . ({$type}) . . {$userlink}";
+
+               $s .= Linker::commentBlock( /*$description*/'', $title );
+               $s .= "</li>\n";
+               return $s;
+       }
+
+}
diff --git a/includes/VideoPage.class.php b/includes/VideoPage.class.php
new file mode 100644
index 0000000..d62dab9
--- /dev/null
+++ b/includes/VideoPage.class.php
@@ -0,0 +1,223 @@
+<?php
+
+class VideoPage extends Article {
+
+       public $title = null;
+
+       /**
+        * Constructor and clear the article
+        * @param Title $title
+        */
+       public function __construct( $title ) {
+               parent::__construct( $title );
+       }
+
+       /**
+        * Overridden to return WikiVideoPage
+        *
+        * @param Title $title
+        * @return WikiVideoPage
+        */
+       protected function newPage( Title $title ) {
+               return new WikiVideoPage( $title );
+       }
+
+       /**
+        * Called on every video page view.
+        */
+       public function view() {
+               $ctx = $this->getContext();
+               $this->video = new Video( $this->getTitle(), $ctx );
+               $out = $ctx->getOutput();
+
+               // No need to display noarticletext, we use our own message
+               if ( $this->getID() ) {
+                       parent::view();
+               } else {
+                       // Just need to set the right headers
+                       $out->setArticleFlag( true );
+                       $out->setRobotPolicy( 'index,follow' );
+                       $out->setPageTitle( $this->mTitle->getPrefixedText() );
+               }
+
+               if ( $this->video->exists() ) {
+                       // Display flash video
+                       $out->addHTML( $this->video->getEmbedCode() );
+
+                       // Force embed this code to have width of 300
+                       $this->video->setWidth( 300 );
+                       $out->addHTML( $this->getEmbedThisTag() );
+
+                       $this->videoHistory();
+
+                       $out->addWikiText( '== ' . $ctx->msg( 'video-links' 
)->escaped() . " ==\n" );
+                       $this->videoLinks();
+               } else {
+                       // Video doesn't exist, so give a link allowing user to 
add one with this name
+                       $title = SpecialPage::getTitleFor( 'AddVideo' );
+                       $link = Linker::linkKnown(
+                               $title,
+                               $ctx->msg( 'video-novideo-linktext' )->plain(),
+                               array(),
+                               array( 'wpTitle' => $this->video->getName() )
+                       );
+                       $out->addHTML( $ctx->msg( 'video-novideo', $link 
)->text() );
+
+                       $out->addWikiText( '== ' . $ctx->msg( 'video-links' 
)->escaped() . " ==\n" );
+                       $this->videoLinks();
+                       $this->mPage->doViewUpdates( $ctx->getUser() );
+               }
+       }
+
+       /**
+        * Display pages linking to that video on the video page.
+        */
+       function videoLinks() {
+               $out = $this->getContext()->getOutput();
+
+               $limit = 100;
+
+               $dbr = wfGetDB( DB_SLAVE );
+
+               // WikiaVideo used the imagelinks table here because that 
extension
+               // adds everything into core (archive, filearchive, imagelinks, 
etc.)
+               // tables instead of using its own tables
+               $res = $dbr->select(
+                       array( 'pagelinks', 'page' ),
+                       array( 'page_namespace', 'page_title' ),
+                       array(
+                               'pl_namespace' => NS_VIDEO,
+                               'pl_title' => $this->getTitle()->getDBkey(),
+                               'pl_from = page_id',
+                       ),
+                       __METHOD__,
+                       array( 'LIMIT' => $limit + 1 )
+               );
+
+               $count = $dbr->numRows( $res );
+
+               if ( $count == 0 ) {
+                       $out->addHTML( '<div id="mw-imagepage-nolinkstoimage">' 
. "\n" );
+                       $out->addWikiMsg( 'video-no-links-to-video' );
+                       $out->addHTML( "</div>\n" );
+                       return;
+               }
+
+               $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() ) {
+                       $count++;
+                       if ( $count <= $limit ) {
+                               // We have not yet reached the extra one that 
tells us there is
+                               // more to fetch
+                               $name = Title::makeTitle( $s->page_namespace, 
$s->page_title );
+                               $link = Linker::linkKnown( $name );
+                               $out->addHTML( "<li>{$link}</li>\n" );
+                       }
+               }
+               $out->addHTML( "</ul></div>\n" );
+               $res->free();
+
+               // Add a link to [[Special:WhatLinksHere]]
+               if ( $count > $limit ) {
+                       $out->addWikiMsg(
+                               'video-more-links-to-video',
+                               $this->mTitle->getPrefixedDBkey()
+                       );
+               }
+       }
+
+       /**
+        * Get the HTML table that contains the code for embedding the current
+        * video on a wiki page.
+        *
+        * @return string HTML
+        */
+       public function getEmbedThisTag() {
+               $code = $this->video->getEmbedThisCode();
+               $code = preg_replace( '/[\n\r\t]/', '', $code ); // replace any 
non-space whitespace with a space
+               $code = str_replace( '_', ' ', $code ); // replace underscores 
with spaces
+               return '<br /><br />
+               <table cellpadding="0" cellspacing="2" border="0">
+                       <tr>
+                               <td>
+                                       <b>' . wfMessage( 'video-embed' 
)->plain() . '</b>
+                               </td>
+                               <td>
+                               <form name="embed_video" action="">
+                                       <input name="embed_code" style="width: 
300px; font-size: 10px;" type="text" value="' . $code . '" 
onclick="javascript:document.embed_video.embed_code.focus();document.embed_video.embed_code.select();"
 readonly="readonly" />
+                               </form>
+                               </td>
+                       </tr>
+               </table>';
+       }
+
+       /**
+        * If the page we've just displayed is in the "Video" namespace,
+        * we follow it with an upload history of the video and its usage.
+        */
+       function videoHistory() {
+               $line = $this->video->nextHistoryLine();
+
+               if ( $line ) {
+                       $list = new VideoHistoryList();
+                       $s = $list->beginVideoHistoryList() .
+                               $list->videoHistoryLine(
+                                       true,
+                                       wfTimestamp( TS_MW, 
$line->video_timestamp ),
+                                       $this->mTitle->getDBkey(),
+                                       $line->video_user_id,
+                                       $line->video_user_name,
+                                       strip_tags( $line->video_url ),
+                                       $line->video_type,
+                                       $this->getTitle()
+                               );
+
+                       while ( $line = $this->video->nextHistoryLine() ) {
+                               $s .= $list->videoHistoryLine( false, 
$line->video_timestamp,
+                                       $line->ov_archive_name, 
$line->video_user_id,
+                                       $line->video_user_name, strip_tags( 
$line->video_url ), $line->video_type,
+                                       $this->getTitle()
+                               );
+                       }
+                       $s .= $list->endVideoHistoryList();
+               } else {
+                       $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() ) {
+                       $this->uploadLinksBox();
+               }
+       }
+
+       /**
+        * Print out the reupload link at the bottom of a video page for 
privileged
+        * users.
+        */
+       function uploadLinksBox() {
+               $out = $this->getContext()->getOutput();
+               $out->addHTML( '<br /><ul>' );
+
+               // "Upload a new version of this video" link
+               if ( $this->getContext()->getUser()->isAllowed( 'reupload' ) ) {
+                       $ulink = Linker::link(
+                               SpecialPage::getTitleFor( 'AddVideo' ),
+                               $this->getContext()->msg( 
'video-upload-new-version' )->plain(),
+                               array(),
+                               array(
+                                       'wpTitle' => $this->video->getName(),
+                                       'forReUpload' => 1,
+                               )
+                       );
+                       $out->addHTML( "<li>{$ulink}</li>" );
+               }
+
+               $out->addHTML( '</ul>' );
+       }
+}
diff --git a/VideoPageArchive.php b/includes/VideoPageArchive.class.php
similarity index 100%
rename from VideoPageArchive.php
rename to includes/VideoPageArchive.class.php
diff --git a/WikiVideoPage.php b/includes/WikiVideoPage.class.php
similarity index 100%
rename from WikiVideoPage.php
rename to includes/WikiVideoPage.class.php
diff --git a/includes/parser/VideoGallery.hooks.php 
b/includes/parser/VideoGallery.hooks.php
new file mode 100644
index 0000000..f06c8fa
--- /dev/null
+++ b/includes/parser/VideoGallery.hooks.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * <videogallery> parser hook tag
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+class VideoGalleryHooks {
+       public static function onParserFirstCallInit( &$parser ) {
+               $parser->setHook( 'videogallery', 'renderVideoGallery' );
+               return true;
+       }
+
+       public static function renderVideoGallery( $input, $argv, $parser ) {
+               $vg = new VideoGallery();
+               $vg->setContextTitle( $parser->getTitle()->getText() );
+               $vg->setShowFilename( true );
+               $vg->setParsing();
+
+               if ( isset( $argv['perrow'] ) ) {
+                       $vg->setPerRow( $argv['perrow'] );
+               }
+               if ( isset( $params['widths'] ) ) {
+                       $vg->setWidths( $argv['widths'] );
+               }
+               if ( isset( $params['heights'] ) ) {
+                       $vg->setHeights( $argv['heights'] );
+               }
+
+               $lines = explode( "\n", $input );
+
+               foreach ( $lines as $line ) {
+                       // match lines like these:
+                       // Video:Some video name|This is some video
+                       $matches = array();
+                       preg_match( "/^([^|]+)(\\|(.*))?$/", $line, $matches );
+
+                       // Skip empty lines
+                       if ( count( $matches ) == 0 ) {
+                               continue;
+                       }
+
+                       $tp = Title::newFromText( $matches[1] );
+                       $nt =& $tp;
+                       if ( is_null( $nt ) ) {
+                               // Bogus title. Ignore these so we don't bomb 
out later.
+                               continue;
+                       }
+
+                       if ( isset( $matches[3] ) ) {
+                               $label = $matches[3];
+                       } else {
+                               $label = '';
+                       }
+
+                       $html = '';
+                       /*
+                       $pout = $this->parse( $label,
+                               $this->mTitle,
+                               $this->mOptions,
+                               false, // Strip whitespace...?
+                               false  // Don't clear state!
+                       );
+                       $html = $pout->getText();
+                       */
+
+                       // Gah, there should be a better way to get context here
+                       $vg->add( new Video( $nt, RequestContext::getMain() ), 
$html );
+
+               }
+               return $vg->toHTML();
+       }
+}
diff --git a/includes/parser/VideoGalleryPopulate.hooks.php 
b/includes/parser/VideoGalleryPopulate.hooks.php
new file mode 100644
index 0000000..14e8af9
--- /dev/null
+++ b/includes/parser/VideoGalleryPopulate.hooks.php
@@ -0,0 +1,76 @@
+<?php
+/**
+ * <videogallerypopulate> parser hook extension -- display a gallery of all
+ * videos in a specific category
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+class VideoGalleryPopulate {
+       public static function onParserFirstCallInit( $parser ) {
+               $parser->setHook( 'videogallerypopulate', 
'renderVideoGalleryPopulate' );
+               return true;
+       }
+
+       public static function renderVideoGalleryPopulate( $input, $args, 
$parser ) {
+               $parser->disableCache();
+
+               $category = ( isset( $args['category'] ) ) ? $args['category'] 
: '';
+               $limit = ( isset( $args['limit'] ) ) ? intval( $args['limit'] ) 
: 10;
+
+               if ( empty( $category ) ) {
+                       return '';
+               }
+
+               // Use Parser::recursivePreprocess() if available instead of 
creating another Parser instance
+               if ( is_callable( array( $parser, 'recursivePreprocess' ) ) ) {
+                       $category = $parser->recursivePreprocess( $category );
+               } else {
+                       $newParser = new Parser();
+                       $category = $newParser->preprocess( $category, 
$parser->getTitle(), $parser->getOptions() );
+               }
+               $category_title = Title::newFromText( $category );
+               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 ) ) {
+                       return '';
+               }
+
+               $params['ORDER BY'] = 'page_id';
+               if ( $limit ) {
+                       $params['LIMIT'] = $limit;
+               }
+
+               $dbr = wfGetDB( DB_SLAVE );
+               $res = $dbr->select(
+                       array( 'page', 'categorylinks' ),
+                       'page_title',
+                       array(
+                               'cl_to' => array(
+                                       $category_title->getDBkey(),
+                                       $category_title_secondary->getDBkey()
+                               ),
+                               'page_namespace' => NS_VIDEO
+                       ),
+                       __METHOD__,
+                       $params,
+                       array( 'categorylinks' => array( 'INNER JOIN', 'cl_from 
= page_id' ) )
+               );
+
+               $gallery = new VideoGallery();
+               $gallery->setParsing( true );
+               $gallery->setShowFilename( true );
+
+               foreach ( $res as $row ) {
+                       $video = Video::newFromName( $row->page_title, 
RequestContext::getMain() );
+                       $gallery->add( $video );
+               }
+
+               return $gallery->toHtml();
+       }
+}
diff --git a/providers/BaseVideoProvider.php 
b/includes/providers/BaseVideoProvider.class.php
similarity index 100%
rename from providers/BaseVideoProvider.php
rename to includes/providers/BaseVideoProvider.class.php
diff --git a/providers/BlipTVVideo.php b/includes/providers/BlipTVVideo.php
similarity index 100%
rename from providers/BlipTVVideo.php
rename to includes/providers/BlipTVVideo.php
diff --git a/providers/DailyMotionVideo.php 
b/includes/providers/DailyMotionVideo.php
similarity index 100%
rename from providers/DailyMotionVideo.php
rename to includes/providers/DailyMotionVideo.php
diff --git a/providers/GametrailersVideo.php 
b/includes/providers/GametrailersVideo.php
similarity index 100%
rename from providers/GametrailersVideo.php
rename to includes/providers/GametrailersVideo.php
diff --git a/providers/GoogleVideo.php b/includes/providers/GoogleVideo.php
similarity index 100%
rename from providers/GoogleVideo.php
rename to includes/providers/GoogleVideo.php
diff --git a/providers/HuluVideo.php b/includes/providers/HuluVideo.php
similarity index 100%
rename from providers/HuluVideo.php
rename to includes/providers/HuluVideo.php
diff --git a/providers/MTVNetworksVideo.php 
b/includes/providers/MTVNetworksVideo.php
similarity index 100%
rename from providers/MTVNetworksVideo.php
rename to includes/providers/MTVNetworksVideo.php
diff --git a/providers/MetaCafeVideo.php b/includes/providers/MetaCafeVideo.php
similarity index 100%
rename from providers/MetaCafeVideo.php
rename to includes/providers/MetaCafeVideo.php
diff --git a/providers/MovieClipsVideo.php 
b/includes/providers/MovieClipsVideo.php
similarity index 100%
rename from providers/MovieClipsVideo.php
rename to includes/providers/MovieClipsVideo.php
diff --git a/providers/MyVideoVideo.php b/includes/providers/MyVideoVideo.php
similarity index 100%
rename from providers/MyVideoVideo.php
rename to includes/providers/MyVideoVideo.php
diff --git a/providers/SouthParkStudiosVideo.php 
b/includes/providers/SouthParkStudiosVideo.php
similarity index 100%
rename from providers/SouthParkStudiosVideo.php
rename to includes/providers/SouthParkStudiosVideo.php
diff --git a/providers/ViddlerVideo.php b/includes/providers/ViddlerVideo.php
similarity index 100%
rename from providers/ViddlerVideo.php
rename to includes/providers/ViddlerVideo.php
diff --git a/providers/VimeoVideo.php b/includes/providers/VimeoVideo.php
similarity index 100%
rename from providers/VimeoVideo.php
rename to includes/providers/VimeoVideo.php
diff --git a/providers/WeGameVideo.php b/includes/providers/WeGameVideo.php
similarity index 100%
rename from providers/WeGameVideo.php
rename to includes/providers/WeGameVideo.php
diff --git a/providers/YouTubeVideo.php b/includes/providers/YouTubeVideo.php
similarity index 100%
rename from providers/YouTubeVideo.php
rename to includes/providers/YouTubeVideo.php
diff --git a/SpecialAddVideo.php b/includes/specials/SpecialAddVideo.php
similarity index 100%
rename from SpecialAddVideo.php
rename to includes/specials/SpecialAddVideo.php
diff --git a/SpecialNewVideos.php b/includes/specials/SpecialNewVideos.php
similarity index 100%
rename from SpecialNewVideos.php
rename to includes/specials/SpecialNewVideos.php
diff --git a/SpecialUndeleteWithVideoSupport.php 
b/includes/specials/SpecialUndeleteWithVideoSupport.php
similarity index 100%
rename from SpecialUndeleteWithVideoSupport.php
rename to includes/specials/SpecialUndeleteWithVideoSupport.php
diff --git a/Video.css b/resources/css/Video.css
similarity index 100%
rename from Video.css
rename to resources/css/Video.css
diff --git a/video.sql b/sql/video.sql
similarity index 100%
rename from video.sql
rename to sql/video.sql

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I98be0c47f2a12048b12a9e79859f132fee57b74a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Video
Gerrit-Branch: master
Gerrit-Owner: SamanthaNguyen <samanthanguyen1...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to