Index: trunk/extensions/Video/VideoClass.php |
— | — | @@ -69,17 +69,24 @@ |
70 | 70 | var $dataLoaded; |
71 | 71 | |
72 | 72 | /** |
| 73 | + * @var IContextSource |
| 74 | + */ |
| 75 | + protected $context; |
| 76 | + |
| 77 | + /** |
73 | 78 | * Constructor -- create a new Video object from the given Title and set |
74 | 79 | * some member variables |
75 | 80 | * |
76 | 81 | * @param $title Object: Title object associated with the Video |
| 82 | + * @param $context IContextSource nearest context object |
77 | 83 | */ |
78 | | - public function __construct( $title ) { |
| 84 | + public function __construct( $title, IContextSource $context ) { |
79 | 85 | if( !is_object( $title ) ) { |
80 | 86 | throw new MWException( 'Video constructor given bogus title.' ); |
81 | 87 | } |
82 | 88 | $this->title =& $title; |
83 | 89 | $this->name = $title->getDBkey(); |
| 90 | + $this->context = $context; |
84 | 91 | $this->height = 400; |
85 | 92 | $this->width = 400; |
86 | 93 | $this->ratio = 1; |
— | — | @@ -90,11 +97,13 @@ |
91 | 98 | * Create a Video object from a video name |
92 | 99 | * |
93 | 100 | * @param $name Mixed: name of the video, used to create a title object using Title::makeTitleSafe |
| 101 | + * @param $context IContextSource nearest context object |
| 102 | + * @return Video|null returns a Video object on success, null if the title is invalid |
94 | 103 | */ |
95 | | - public static function newFromName( $name ) { |
| 104 | + public static function newFromName( $name, IContextSource $context ) { |
96 | 105 | $title = Title::makeTitleSafe( NS_VIDEO, $name ); |
97 | 106 | if ( is_object( $title ) ) { |
98 | | - return new Video( $title ); |
| 107 | + return new Video( $title, $context ); |
99 | 108 | } else { |
100 | 109 | return null; |
101 | 110 | } |
— | — | @@ -108,9 +117,8 @@ |
109 | 118 | * @param $categories String: pipe-separated list of categories |
110 | 119 | * @param $watch Boolean: add the new video page to the user's watchlist? |
111 | 120 | */ |
112 | | - public function addVideo( $url, $type, $categories, $watch = '' ) { |
113 | | - global $wgUser, $wgContLang; |
114 | | - |
| 121 | + public function addVideo( $url, $type, $categories, $watch = false ) { |
| 122 | + $user = $this->context->getUser(); |
115 | 123 | $dbw = wfGetDB( DB_MASTER ); |
116 | 124 | |
117 | 125 | $now = $dbw->timestamp(); |
— | — | @@ -128,8 +136,8 @@ |
129 | 137 | 'video_name' => $this->getName(), |
130 | 138 | 'video_url' => $url, |
131 | 139 | 'video_type' => $type, |
132 | | - 'video_user_id' => $wgUser->getID(), |
133 | | - 'video_user_name' => $wgUser->getName(), |
| 140 | + 'video_user_id' => $user->getID(), |
| 141 | + 'video_user_name' => $user->getName(), |
134 | 142 | 'video_timestamp' => $now |
135 | 143 | ), |
136 | 144 | __METHOD__, |
— | — | @@ -172,8 +180,8 @@ |
173 | 181 | array( /* SET */ |
174 | 182 | 'video_url'=> $url, |
175 | 183 | 'video_type' => $type, |
176 | | - 'video_user_id' => $wgUser->getID(), |
177 | | - 'video_user_name' => $wgUser->getName(), |
| 184 | + 'video_user_id' => $user->getID(), |
| 185 | + 'video_user_name' => $user->getName(), |
178 | 186 | 'video_timestamp' => $now |
179 | 187 | ), |
180 | 188 | array( /* WHERE */ |
— | — | @@ -185,7 +193,7 @@ |
186 | 194 | |
187 | 195 | $descTitle = $this->getTitle(); |
188 | 196 | $article = new Article( $descTitle ); |
189 | | - $watch = $watch || $wgUser->isWatched( $descTitle ); |
| 197 | + $watch = $watch || $user->isWatched( $descTitle ); |
190 | 198 | |
191 | 199 | // Get the localized category name |
192 | 200 | $videoCategoryName = wfMsgForContent( 'video-category-name' ); |
— | — | @@ -202,7 +210,7 @@ |
203 | 211 | foreach( $categories_array as $ctg ) { |
204 | 212 | $ctg = trim( $ctg ); |
205 | 213 | if( $ctg ) { |
206 | | - $catName = $wgContLang->getNsText( NS_CATEGORY ); |
| 214 | + $catName = $this->context->getLang()->getNsText( NS_CATEGORY ); |
207 | 215 | $tag = "[[{$catName}:{$ctg}]]"; |
208 | 216 | if( strpos( $categoryWikiText, $tag ) === false ) { |
209 | 217 | $categoryWikiText .= "\n{$tag}"; |
— | — | @@ -222,7 +230,7 @@ |
223 | 231 | } |
224 | 232 | |
225 | 233 | if( $watch ) { |
226 | | - $wgUser->addWatch( $descTitle ); |
| 234 | + $user->addWatch( $descTitle ); |
227 | 235 | } |
228 | 236 | |
229 | 237 | // Add the log entry |
Index: trunk/extensions/Video/VideoGalleryPopulate.php |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | $gallery->setShowFilename( true ); |
72 | 72 | |
73 | 73 | foreach ( $res as $row ) { |
74 | | - $video = Video::newFromName( $row->page_title ); |
| 74 | + $video = Video::newFromName( $row->page_title, RequestContext::getMain() ); |
75 | 75 | $gallery->add( $video ); |
76 | 76 | } |
77 | 77 | |
Index: trunk/extensions/Video/VideoPage.php |
— | — | @@ -16,31 +16,30 @@ |
17 | 17 | * Called on every video page view. |
18 | 18 | */ |
19 | 19 | public function view() { |
20 | | - global $wgOut, $wgUser, $wgRequest; |
| 20 | + $this->video = new Video( $this->getTitle(), $this->getContext() ); |
| 21 | + $out = $this->getContext()->getOutput(); |
21 | 22 | |
22 | | - $this->video = new Video( $this->getTitle() ); |
23 | | - |
24 | 23 | $videoLinksHTML = '<br />' . Xml::element( 'h2', |
25 | 24 | array( 'id' => 'filelinks' ), wfMsg( 'video-links' ) ) . "\n"; |
26 | | - $sk = $wgUser->getSkin(); |
| 25 | + $sk = $this->getContext()->getSkin(); |
27 | 26 | |
28 | 27 | // No need to display noarticletext, we use our own message |
29 | 28 | if ( $this->getID() ) { |
30 | 29 | parent::view(); |
31 | 30 | } else { |
32 | 31 | // Just need to set the right headers |
33 | | - $wgOut->setArticleFlag( true ); |
34 | | - $wgOut->setRobotPolicy( 'index,follow' ); |
35 | | - $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); |
| 32 | + $out->setArticleFlag( true ); |
| 33 | + $out->setRobotPolicy( 'index,follow' ); |
| 34 | + $out->setPageTitle( $this->mTitle->getPrefixedText() ); |
36 | 35 | } |
37 | 36 | |
38 | 37 | if( $this->video->exists() ) { |
39 | 38 | // Display flash video |
40 | | - $wgOut->addHTML( $this->video->getEmbedCode() ); |
| 39 | + $out->addHTML( $this->video->getEmbedCode() ); |
41 | 40 | |
42 | 41 | // Force embed this code to have width of 300 |
43 | 42 | $this->video->setWidth( 300 ); |
44 | | - $wgOut->addHTML( $this->getEmbedThisTag() ); |
| 43 | + $out->addHTML( $this->getEmbedThisTag() ); |
45 | 44 | |
46 | 45 | $this->videoHistory(); |
47 | 46 | |
— | — | @@ -55,7 +54,7 @@ |
56 | 55 | array(), |
57 | 56 | array( 'wpTitle' => $this->video->getName() ) |
58 | 57 | ); |
59 | | - $wgOut->addHTML( wfMsgWikiHtml( 'video-novideo', $link ) ); |
| 58 | + $out->addHTML( wfMsgWikiHtml( 'video-novideo', $link ) ); |
60 | 59 | |
61 | 60 | //$wgOut->addHTML( $videoLinksHTML ); |
62 | 61 | //$this->videoLinks(); |
— | — | @@ -293,7 +292,7 @@ |
294 | 293 | //$oldver = wfTimestampNow() . "!{$name}"; |
295 | 294 | |
296 | 295 | // Record upload and update metadata cache |
297 | | - $video = Video::newFromName( $name ); |
| 296 | + $video = Video::newFromName( $name, $this->getContext() ); |
298 | 297 | $video->addVideo( $url, $type, '' ); |
299 | 298 | |
300 | 299 | $wgOut->setPageTitle( wfMsgHtml( 'actioncomplete' ) ); |
— | — | @@ -444,7 +443,7 @@ |
445 | 444 | * Add a page in the video namespace |
446 | 445 | */ |
447 | 446 | function addVideo( $title, $sortkey, $pageLength ) { |
448 | | - $video = new Video( $title ); |
| 447 | + $video = new Video( $title, $this->context ); |
449 | 448 | if( $this->flip ) { |
450 | 449 | $this->videogallery->insert( $video ); |
451 | 450 | } else { |
Index: trunk/extensions/Video/SpecialNewVideos.php |
— | — | @@ -22,19 +22,23 @@ |
23 | 23 | * @param $par Mixed: parameter passed to the page or null |
24 | 24 | */ |
25 | 25 | public function execute( $par ) { |
26 | | - global $wgUser, $wgOut, $wgLang, $wgRequest, $wgGroupPermissions; |
| 26 | + global $wgGroupPermissions; |
27 | 27 | |
28 | | - $wgOut->setPageTitle( wfMsgHtml( 'newvideos' ) ); |
| 28 | + $out = $this->getOutput(); |
| 29 | + $request = $this->getRequest(); |
| 30 | + $lang = $this->getLang(); |
| 31 | + |
| 32 | + $out->setPageTitle( wfMsgHtml( 'newvideos' ) ); |
29 | 33 | |
30 | | - $wpIlMatch = $wgRequest->getText( 'wpIlMatch' ); |
| 34 | + $wpIlMatch = $request->getText( 'wpIlMatch' ); |
31 | 35 | $dbr = wfGetDB( DB_SLAVE ); |
32 | | - $sk = $wgUser->getSkin(); |
| 36 | + $sk = $this->getSkin(); |
33 | 37 | $shownav = !$this->including(); |
34 | | - $hidebots = $wgRequest->getBool( 'hidebots', 1 ); |
| 38 | + $hidebots = $request->getBool( 'hidebots', 1 ); |
35 | 39 | |
36 | 40 | $hidebotsql = ''; |
37 | 41 | if( $hidebots ) { |
38 | | - /** |
| 42 | + /* |
39 | 43 | * Make a list of group names which have the 'bot' flag |
40 | 44 | * set. |
41 | 45 | */ |
— | — | @@ -49,7 +53,7 @@ |
50 | 54 | if( $botconds ) { |
51 | 55 | $isbotmember = $dbr->makeList( $botconds, LIST_OR ); |
52 | 56 | |
53 | | - /** |
| 57 | + /* |
54 | 58 | * This join, in conjunction with WHERE ug_group |
55 | 59 | * IS NULL, returns only those rows from IMAGE |
56 | 60 | * where the uploading user is not a member of |
— | — | @@ -102,10 +106,10 @@ |
103 | 107 | } |
104 | 108 | |
105 | 109 | $invertSort = false; |
106 | | - if( $until = $wgRequest->getVal( 'until' ) ) { |
| 110 | + if( $until = $request->getVal( 'until' ) ) { |
107 | 111 | $where[] = 'video_timestamp < ' . $dbr->timestamp( $until ); |
108 | 112 | } |
109 | | - if( $from = $wgRequest->getVal( 'from' ) ) { |
| 113 | + if( $from = $request->getVal( 'from' ) ) { |
110 | 114 | $where[] = 'video_timestamp >= ' . $dbr->timestamp( $from ); |
111 | 115 | $invertSort = true; |
112 | 116 | } |
— | — | @@ -123,9 +127,7 @@ |
124 | 128 | $sql.= ' LIMIT ' . ( $limit + 1 ); |
125 | 129 | $res = $dbr->query( $sql, __METHOD__ ); |
126 | 130 | |
127 | | - /** |
128 | | - * We have to flip things around to get the last N after a certain date |
129 | | - */ |
| 131 | + // We have to flip things around to get the last N after a certain date |
130 | 132 | $videos = array(); |
131 | 133 | foreach( $res as $s ) { |
132 | 134 | if( $invertSort ) { |
— | — | @@ -150,13 +152,13 @@ |
151 | 153 | $ut = $s->video_user_name; |
152 | 154 | |
153 | 155 | $nt = Title::newFromText( $name, NS_VIDEO ); |
154 | | - $vid = new Video( $nt ); |
| 156 | + $vid = new Video( $nt, $this->getContext() ); |
155 | 157 | $ul = $sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut ); |
156 | 158 | |
157 | 159 | $gallery->add( |
158 | 160 | $vid, |
159 | 161 | "$ul<br />\n<i>" . |
160 | | - $wgLang->timeanddate( $s->video_timestamp, true ) . |
| 162 | + $lang->timeanddate( $s->video_timestamp, true ) . |
161 | 163 | "</i><br />\n" |
162 | 164 | ); |
163 | 165 | |
— | — | @@ -168,17 +170,17 @@ |
169 | 171 | } |
170 | 172 | |
171 | 173 | $bydate = wfMsg( 'bydate' ); |
172 | | - $lt = $wgLang->formatNum( min( $shownVideos, $limit ) ); |
| 174 | + $lt = $lang->formatNum( min( $shownVideos, $limit ) ); |
173 | 175 | if( $shownav ) { |
174 | 176 | $text = wfMsgExt( 'imagelisttext', 'parse', $lt, $bydate ); |
175 | | - $wgOut->addHTML( $text . "\n" ); |
| 177 | + $out->addHTML( $text . "\n" ); |
176 | 178 | } |
177 | 179 | |
178 | 180 | $sub = wfMsg( 'ilsubmit' ); |
179 | 181 | $titleObj = SpecialPage::getTitleFor( 'NewVideos' ); |
180 | 182 | $action = $titleObj->escapeLocalURL( $hidebots ? '' : 'hidebots=0' ); |
181 | 183 | if( $shownav ) { |
182 | | - $wgOut->addHTML( |
| 184 | + $out->addHTML( |
183 | 185 | "<form id=\"imagesearch\" method=\"post\" action=\"{$action}\">" . |
184 | 186 | Xml::input( 'wpIlMatch', 20, $wpIlMatch ) . ' ' . |
185 | 187 | Xml::submitButton( $sub, array( 'name' => 'wpIlSubmit' ) ) . |
— | — | @@ -186,9 +188,7 @@ |
187 | 189 | ); |
188 | 190 | } |
189 | 191 | |
190 | | - /** |
191 | | - * Paging controls... |
192 | | - */ |
| 192 | + // Paging controls... |
193 | 193 | |
194 | 194 | # If we change bot visibility, this needs to be carried along. |
195 | 195 | if( !$hidebots ) { |
— | — | @@ -197,8 +197,8 @@ |
198 | 198 | $botpar = array(); |
199 | 199 | } |
200 | 200 | $now = wfTimestampNow(); |
201 | | - $date = $wgLang->date( $now, true ); |
202 | | - $time = $wgLang->time( $now, true ); |
| 201 | + $date = $lang->date( $now, true ); |
| 202 | + $time = $lang->time( $now, true ); |
203 | 203 | $query = array_merge( |
204 | 204 | array( 'from' => $now ), |
205 | 205 | $botpar, |
— | — | @@ -227,7 +227,7 @@ |
228 | 228 | ); |
229 | 229 | |
230 | 230 | $opts = array( 'parsemag', 'escapenoentities' ); |
231 | | - $prevLink = wfMsgExt( 'pager-newer-n', $opts, $wgLang->formatNum( $limit ) ); |
| 231 | + $prevLink = wfMsgExt( 'pager-newer-n', $opts, $lang->formatNum( $limit ) ); |
232 | 232 | if( $firstTimestamp && $firstTimestamp != $latestTimestamp ) { |
233 | 233 | $query = array_merge( |
234 | 234 | array( 'from' => $firstTimestamp ), |
— | — | @@ -242,7 +242,7 @@ |
243 | 243 | ); |
244 | 244 | } |
245 | 245 | |
246 | | - $nextLink = wfMsgExt( 'pager-older-n', $opts, $wgLang->formatNum( $limit ) ); |
| 246 | + $nextLink = wfMsgExt( 'pager-older-n', $opts, $lang->formatNum( $limit ) ); |
247 | 247 | if( $shownVideos > $limit && $lastTimestamp ) { |
248 | 248 | $query = array_merge( |
249 | 249 | array( 'until' => $lastTimestamp ), |
— | — | @@ -263,16 +263,16 @@ |
264 | 264 | '</p>'; |
265 | 265 | |
266 | 266 | if( $shownav ) { |
267 | | - $wgOut->addHTML( $prevnext ); |
| 267 | + $out->addHTML( $prevnext ); |
268 | 268 | } |
269 | 269 | |
270 | 270 | if( count( $videos ) ) { |
271 | | - $wgOut->addHTML( $gallery->toHTML() ); |
| 271 | + $out->addHTML( $gallery->toHTML() ); |
272 | 272 | if( $shownav ) { |
273 | | - $wgOut->addHTML( $prevnext ); |
| 273 | + $out->addHTML( $prevnext ); |
274 | 274 | } |
275 | 275 | } else { |
276 | | - $wgOut->addWikiMsg( 'video-no-videos' ); |
| 276 | + $out->addWikiMsg( 'video-no-videos' ); |
277 | 277 | } |
278 | 278 | } |
279 | 279 | } |
\ No newline at end of file |
Index: trunk/extensions/Video/VideoHooks.php |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | $name = $matches[2]; |
40 | 40 | $params = explode( '|', $name ); |
41 | 41 | $video_name = $params[0]; |
42 | | - $video = Video::newFromName( $video_name ); |
| 42 | + $video = Video::newFromName( $video_name, RequestContext::getMain() ); |
43 | 43 | $x = 1; |
44 | 44 | |
45 | 45 | foreach( $params as $param ) { |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | if ( $title->getNamespace() == NS_VIDEO ) { |
86 | 86 | if( $wgRequest->getVal( 'action' ) == 'edit' ) { |
87 | 87 | $addTitle = SpecialPage::getTitleFor( 'AddVideo' ); |
88 | | - $video = Video::newFromName( $title->getText() ); |
| 88 | + $video = Video::newFromName( $title->getText(), $article->getContext() ); |
89 | 89 | if( !$video->exists() ) { |
90 | 90 | global $wgOut; |
91 | 91 | $wgOut->redirect( |
— | — | @@ -146,7 +146,7 @@ |
147 | 147 | } |
148 | 148 | |
149 | 149 | $output = ''; |
150 | | - $video = Video::newFromName( $video_name ); |
| 150 | + $video = Video::newFromName( $video_name, RequestContext::getMain() ); |
151 | 151 | if( $video->exists() ) { |
152 | 152 | $video->setWidth( $width ); |
153 | 153 | $video->setHeight( $height ); |
— | — | @@ -162,7 +162,7 @@ |
163 | 163 | /** |
164 | 164 | * Injects Video Gallery into Category pages |
165 | 165 | * |
166 | | - * @param $cat Object: CategoryPage object |
| 166 | + * @param $cat CategoryPage object |
167 | 167 | * @return Boolean: false |
168 | 168 | */ |
169 | 169 | public static function categoryPageWithVideo( &$cat ) { |
— | — | @@ -176,7 +176,7 @@ |
177 | 177 | // here to prevent an E_NOTICE about an undefined variable... |
178 | 178 | $until = $wgRequest->getVal( 'until' ); |
179 | 179 | |
180 | | - $viewer = new CategoryWithVideoViewer( $cat->mTitle, $from, $until ); |
| 180 | + $viewer = new CategoryWithVideoViewer( $cat->mTitle, $cat->getContext(), $from, $until ); |
181 | 181 | $wgOut->addHTML( $viewer->getHTML() ); |
182 | 182 | } |
183 | 183 | |
— | — | @@ -187,7 +187,7 @@ |
188 | 188 | * Called on video deletion; this is the main logic for deleting videos. |
189 | 189 | * There is no logic related to video deletion on the VideoPage class. |
190 | 190 | * |
191 | | - * @param $articleObj Object: instance of Article or its subclass |
| 191 | + * @param $articleObj Article: instance of Article or its subclass |
192 | 192 | * @param $user Object: current User object ($wgUser) |
193 | 193 | * @param $reason String: reason for the deletion [unused] |
194 | 194 | * @param $error String: error message, if any [unused] |
— | — | @@ -197,7 +197,7 @@ |
198 | 198 | if ( $articleObj->getTitle()->getNamespace() == NS_VIDEO ) { |
199 | 199 | global $wgRequest; |
200 | 200 | |
201 | | - $videoObj = new Video( $articleObj->getTitle() ); |
| 201 | + $videoObj = new Video( $articleObj->getTitle(), $articleObj->getContext() ); |
202 | 202 | $videoName = $videoObj->getName(); |
203 | 203 | $oldVideo = $wgRequest->getVal( 'wpOldVideo', false ); |
204 | 204 | $where = array( |
Index: trunk/extensions/Video/SpecialAddVideo.php |
— | — | @@ -1,4 +1,10 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * Special:AddVideo - special page for adding Videos |
| 5 | + * |
| 6 | + * @ingroup extensions |
| 7 | + * @file |
| 8 | + */ |
3 | 9 | |
4 | 10 | class AddVideo extends SpecialPage { |
5 | 11 | |
— | — | @@ -20,15 +26,17 @@ |
21 | 27 | * Show the special page |
22 | 28 | * |
23 | 29 | * @param $par Mixed: parameter passed to the page or null |
| 30 | + * @return bool|null |
24 | 31 | */ |
25 | 32 | public function execute( $par ) { |
26 | | - global $wgRequest, $wgOut, $wgUser, $wgScriptPath; |
| 33 | + global $wgExtensionAssetsPath; |
27 | 34 | |
| 35 | + $out = $this->getRequest(); |
28 | 36 | // Add CSS |
29 | 37 | if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { |
30 | | - $wgOut->addModuleStyles( 'ext.video' ); |
| 38 | + $out->addModuleStyles( 'ext.video' ); |
31 | 39 | } else { |
32 | | - $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/Video/Video.css' ); |
| 40 | + $out->addExtensionStyle( $wgExtensionAssetsPath . '/Video/Video.css' ); |
33 | 41 | } |
34 | 42 | |
35 | 43 | // If the user doesn't have the required 'addvideo' permission, display an error |
— | — | @@ -43,8 +51,8 @@ |
44 | 52 | } |
45 | 53 | |
46 | 54 | // If user is blocked, s/he doesn't need to access this page |
47 | | - if( $wgUser->isBlocked() ) { |
48 | | - $wgOut->blockedPage( false ); |
| 55 | + if( $this->getUser()->isBlocked() ) { |
| 56 | + throw new UserBlockedError( $this->getUser()->mBlock ); |
49 | 57 | return false; |
50 | 58 | } |
51 | 59 | |
— | — | @@ -63,6 +71,12 @@ |
64 | 72 | $form->show(); |
65 | 73 | } |
66 | 74 | |
| 75 | + /** |
| 76 | + * Extracts the URL and provider type from a raw string |
| 77 | + * |
| 78 | + * @param string $value Value form the Video input |
| 79 | + * @return array Element 0 is the URL, 1 is the provider |
| 80 | + */ |
67 | 81 | protected function getUrlAndProvider( $value ) { |
68 | 82 | $url = $value; |
69 | 83 | if ( !Video::isURL( $url ) ) { |
— | — | @@ -72,6 +86,16 @@ |
73 | 87 | return array( $url, Video::getProviderByURL( $url ) ); |
74 | 88 | } |
75 | 89 | |
| 90 | + /** |
| 91 | + * Custom validator for the Video field |
| 92 | + * |
| 93 | + * Checks to see if the string given is a valid URL and corresponds |
| 94 | + * to a supported provider. |
| 95 | + * |
| 96 | + * @param $value Array |
| 97 | + * @param $allData Array |
| 98 | + * @return bool|String |
| 99 | + */ |
76 | 100 | public function validateVideoField( $value, $allData ) { |
77 | 101 | list( , $provider ) = $this->getUrlAndProvider( $value ); |
78 | 102 | |
— | — | @@ -82,8 +106,18 @@ |
83 | 107 | return true; |
84 | 108 | } |
85 | 109 | |
| 110 | + /** |
| 111 | + * Custom validator for the Title field |
| 112 | + * |
| 113 | + * Just checks that it's a valid title name and that it doesn't already |
| 114 | + * exist (unless it's an overwrite) |
| 115 | + * |
| 116 | + * @param $value Array |
| 117 | + * @param $allData Array |
| 118 | + * @return bool|String |
| 119 | + */ |
86 | 120 | public function validateTitleField( $value, $allData ) { |
87 | | - $video = Video::newFromName( $value ); |
| 121 | + $video = Video::newFromName( $value, $this->getContext() ); |
88 | 122 | |
89 | 123 | if ( $video === null || !( $video instanceof Video ) ) { |
90 | 124 | return wfMsg( 'badtitle' ); |
— | — | @@ -99,6 +133,12 @@ |
100 | 134 | return true; |
101 | 135 | } |
102 | 136 | |
| 137 | + /** |
| 138 | + * Actually inserts the Video into the DB if validation passes |
| 139 | + * |
| 140 | + * @param $data Array |
| 141 | + * @return bool |
| 142 | + */ |
103 | 143 | public function submit( array $data ) { |
104 | 144 | list( $url, $provider ) = $this->getUrlAndProvider( $data['Video'] ); |
105 | 145 | |
— | — | @@ -109,6 +149,11 @@ |
110 | 150 | return true; |
111 | 151 | } |
112 | 152 | |
| 153 | + /** |
| 154 | + * Fields for HTMLForm |
| 155 | + * |
| 156 | + * @return array |
| 157 | + */ |
113 | 158 | protected function getFormFields() { |
114 | 159 | $fields = array( |
115 | 160 | 'Title' => array( |
Index: trunk/extensions/Video/VideoGallery.php |
— | — | @@ -70,7 +70,8 @@ |
71 | 71 | $html = $pout->getText(); |
72 | 72 | */ |
73 | 73 | |
74 | | - $vg->add( new Video( $nt ), $html ); |
| 74 | + // Gah, there should be a better way to get context here |
| 75 | + $vg->add( new Video( $nt, RequestContext::getMain() ), $html ); |
75 | 76 | |
76 | 77 | } |
77 | 78 | return $vg->toHTML(); |