r92748 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92747‎ | r92748 | r92749 >
Date:16:09, 21 July 2011
Author:jeroendedauw
Status:ok (Comments)
Tags:
Comment:
don't abbriviate class name as per comment by Neil
Modified paths:
  • /trunk/extensions/UploadWizard/SpecialUploadCampaign.php (modified) (history)
  • /trunk/extensions/UploadWizard/SpecialUploadCampaigns.php (modified) (history)
  • /trunk/extensions/UploadWizard/UWCampaign.php (deleted) (history)
  • /trunk/extensions/UploadWizard/UploadWizard.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizardCampaign.php (added) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UWCampaign.php
@@ -1,421 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Class that represents a single upload campaign.
6 - *
7 - * @file
8 - * @ingroup Upload
9 - *
10 - * @since 1.2
11 - *
12 - * @licence GNU GPL v3+
13 - * @author Jeroen De Dauw < jeroendedauw@gmail.com >
14 - */
15 -class UWCampaign {
16 -
17 - /**
18 - * If the ID of the campaign.
19 - * Either this matched a record in the uw_campaigns table or is null.
20 - *
21 - * @since 1.2
22 - * @var integer or null
23 - */
24 - protected $id;
25 -
26 - /**
27 - * If the name of the campaign.
28 - * This name is the string used to invoke the campaign via campaign=name.
29 - *
30 - * @since 1.2
31 - * @var string
32 - */
33 - protected $name;
34 -
35 - /**
36 - * If the campaign is enabled or not.
37 - *
38 - * @since 1.2
39 - * @var boolean
40 - */
41 - protected $isEnabled;
42 -
43 - /**
44 - * The campaign configuration.
45 - *
46 - * @since 1.2
47 - * @var array
48 - */
49 - protected $config;
50 -
51 - /**
52 - * If the campaign config has been loaded or not.
53 - *
54 - * @since 1.2
55 - * @var boolean
56 - */
57 - protected $loadedConfig = false;
58 -
59 - /**
60 - * Create a new instance of $campaignName.
61 - *
62 - * @since 1.2
63 - *
64 - * @param integer $id
65 - * @param string $name
66 - * @param boolean $isEnabled
67 - * @param array $config
68 - */
69 - public function __construct( $id, $name, $isEnabled, array $config ) {
70 - $this->id = $id;
71 - $this->name = $name;
72 - $this->isEnabled = $isEnabled;
73 - $this->config = $config;
74 -
75 - $this->loadedConfig = count( $this->config ) > 0;
76 - }
77 -
78 - /**
79 - * Returns the UWCampaign with specified name, or false if there is no such campaign.
80 - *
81 - * @since 1.2
82 - *
83 - * @param string $campaignName
84 - * @param boolean $loadConfig
85 - *
86 - * @return UWCampaign or false
87 - */
88 - public static function newFromName( $campaignName, $loadConfig = true ) {
89 - return self::newFromDB( array( 'campaign_name' => $campaignName ), $loadConfig );
90 - }
91 -
92 - /**
93 - * Returns the UWCampaign with specified ID, or false if there is no such campaign.
94 - *
95 - * @since 1.2
96 - *
97 - * @param integer $campaignId
98 - * @param boolean $loadConfig
99 - *
100 - * @return UWCampaign or false
101 - */
102 - public static function newFromId( $campaignId, $loadConfig = true ) {
103 - return self::newFromDB( array( 'campaign_id' => $campaignId ), $loadConfig );
104 - }
105 -
106 - /**
107 - * Returns a new instance of UWCampaign build from a database result
108 - * obtained by doing a select with the porvided conditions on the uw_campaigns table.
109 - * If no campaign matches the conditions, false will be returned.
110 - *
111 - * @since 1.2
112 - *
113 - * @param array $conditions
114 - * @param boolean $loadConfig
115 - *
116 - * @return UWCampaign or false
117 - */
118 - protected static function newFromDB( array $conditions, $loadConfig = true ) {
119 - $dbr = wfGetDB( DB_SLAVE );
120 -
121 - $campaign = $dbr->selectRow(
122 - 'uw_campaigns',
123 - array(
124 - 'campaign_id',
125 - 'campaign_name',
126 - 'campaign_enabled',
127 - ),
128 - $conditions
129 - );
130 -
131 - if ( !$campaign ) {
132 - return false;
133 - }
134 -
135 - $config = $loadConfig ? self::getPropsFromDB( $dbr, $campaign->campaign_id ) : array();
136 -
137 - return new self(
138 - $campaign->campaign_id,
139 - $campaign->campaign_name,
140 - $campaign->campaign_enabled,
141 - $config
142 - );
143 - }
144 -
145 - /**
146 - * Returns the id of the campaign.
147 - *
148 - * @since 1.2
149 - *
150 - * @return intgere
151 - */
152 - public function getId() {
153 - return $this->id;
154 - }
155 -
156 - /**
157 - * Returns the name of the campaign.
158 - *
159 - * @since 1.2
160 - *
161 - * @return string
162 - */
163 - public function getName() {
164 - return $this->name;
165 - }
166 -
167 - /**
168 - * Returns if the campaign is enabled.
169 - *
170 - * @since 1.2
171 - *
172 - * @return boolean
173 - */
174 - public function getIsEnabled() {
175 - return $this->isEnabled;
176 - }
177 -
178 - /**
179 - * Sets all config properties.
180 - *
181 - * @since 1.2
182 - *
183 - * @param array $config
184 - */
185 - public function setConfig( array $config ) {
186 - $this->config = $config;
187 - $this->loadedConfig = true;
188 - }
189 -
190 - /**
191 - * Returns all set config properties.
192 - * Property name => property value
193 - *
194 - * @since 1.2
195 - *
196 - * @return array
197 - */
198 - public function getConfig() {
199 - if ( !$this->loadedConfig ) {
200 - if ( !is_null( $this->id ) ) {
201 - $this->config = self::getPropsFromDB( wfGetDB( DB_SLAVE ), $this->id );
202 - }
203 -
204 - $this->loadedConfig = true;
205 - }
206 -
207 - return $this->config;
208 - }
209 -
210 - /**
211 - * Returns all config properties by merging the set ones with a list of default ones.
212 - * Property name => array( 'default' => $value, 'type' => HTMLForm input type )
213 - *
214 - * @since 1.2
215 - *
216 - * @return array
217 - */
218 - public function getAllConfig() {
219 - $config = $this->getConfig();
220 -
221 - foreach ( self::getDefaultConfig() as $name => $data ) {
222 - if ( array_key_exists( $name, $config ) ) {
223 - $data['default'] = $config[$name];
224 - }
225 -
226 - $config[$name] = $data;
227 - }
228 -
229 - return $config;
230 - }
231 -
232 - /**
233 - * Returns the default configuration values.
234 - *
235 - * @since 1.2
236 - *
237 - * @return array
238 - */
239 - public static function getDefaultConfig() {
240 - return array (
241 - 'skiptutorial' => array ( 'type' => 'check', 'default' => true )
242 - );
243 - }
244 -
245 - /**
246 - * Returns the value of the specified config property.
247 - *
248 - * @since 1.2
249 - *
250 - * @param string $property
251 - *
252 - * @return mixed
253 - */
254 - public function getProperty( $property ) {
255 - global $wgUploadWizardConfig;
256 -
257 - if ( array_key_exists( $property, $this->config ) ) {
258 - return $this->config[$property];
259 - }
260 - elseif ( array_key_exists( $property, $wgUploadWizardConfig['campaignDefaults'] ) ) {
261 - return $wgUploadWizardConfig['campaignDefaults'][$property];
262 - }
263 - else {
264 - return null;
265 - }
266 - }
267 -
268 - /**
269 - * Write the campaign to the DB.
270 - * If it's already there, it'll be updated, else it'll be inserted.
271 - *
272 - * @since 1.2
273 - *
274 - * @return boolean Success indicator
275 - */
276 - public function writeToDB() {
277 - if ( is_null( $this->id ) ) {
278 - return $this->insertIntoDB();
279 - }
280 - else {
281 - return $this->updateInDB();
282 - }
283 - }
284 -
285 - /**
286 - * Insert the campaign into the DB.
287 - *
288 - * @since 1.2
289 - *
290 - * @return boolean Success indicator
291 - */
292 - protected function insertIntoDB() {
293 - $dbw = wfGetDB( DB_MASTER );
294 -
295 - $success = $dbw->insert(
296 - 'uw_campaigns',
297 - array(
298 - 'campaign_name' => $this->name,
299 - 'campaign_enabled' => $this->isEnabled,
300 - ),
301 - array( 'campaign_id' => $this->id )
302 - );
303 -
304 - if ( $success ) {
305 - $this->id = $dbw->insertId();
306 - $success &= $this->writePropsToDB( $dbw );
307 - }
308 -
309 - return $success;
310 - }
311 -
312 - /**
313 - * Update the campaign in the DB.
314 - *
315 - * @since 1.2
316 - *
317 - * @return boolean Success indicator
318 - */
319 - protected function updateInDB() {
320 - $dbw = wfGetDB( DB_MASTER );
321 -
322 - $success = $dbw->update(
323 - 'uw_campaigns',
324 - array(
325 - 'campaign_name' => $this->name,
326 - 'campaign_enabled' => $this->isEnabled,
327 - ),
328 - array( 'campaign_id' => $this->id )
329 - );
330 -
331 - // Delete and insert instead of update.
332 - // This will not result into dead-data when config vars are removed.
333 - $success &= $dbw->delete(
334 - 'uw_campaign_conf',
335 - array( 'cc_campaign_id' => $this->id )
336 - );
337 -
338 - $success &= $this->writePropsToDB( $dbw );
339 -
340 - return $success;
341 - }
342 -
343 - /**
344 - * Write (insert) the properties into the DB.
345 - *
346 - * @since 1.2
347 - *
348 - * @param Database $dbw
349 - *
350 - * @return boolean Success indicator
351 - */
352 - protected function writePropsToDB( DatabaseBase $dbw ) {
353 - $success = true;
354 -
355 - foreach ( $this->config as $prop => $value ) {
356 - $success &= $dbw->insert(
357 - 'uw_campaign_conf',
358 - array(
359 - 'cc_campaign_id' => $this->id,
360 - 'cc_property' => $prop,
361 - 'cc_value' => $value
362 - )
363 - );
364 - }
365 -
366 - return $success;
367 - }
368 -
369 - /**
370 - * Get the configuration properties from the DB.
371 - *
372 - * @since 1.2
373 - *
374 - * @param Database $dbr
375 - * @param integer $campaignId
376 - *
377 - * @return array
378 - */
379 - protected static function getPropsFromDB( DatabaseBase $dbr, $campaignId ) {
380 - $config = array();
381 -
382 - $confProps = $dbr->select(
383 - 'uw_campaign_conf',
384 - array( 'cc_property', 'cc_value' ),
385 - array( 'cc_campaign_id' => $campaignId )
386 - );
387 -
388 - foreach ( $confProps as $confProp ) {
389 - $config[$confProp->cc_property] = $confProp->cc_value;
390 - }
391 -
392 - return $config;
393 - }
394 -
395 - /**
396 - * Delete the campaign from the DB (when present).
397 - *
398 - * @since 1.2
399 - *
400 - * @return boolean Success indicator
401 - */
402 - public function deleteFromDB() {
403 - if ( is_null( $this->id ) ) {
404 - return true;
405 - }
406 -
407 - $dbw = wfGetDB( DB_MASTER );
408 -
409 - $d1 = $dbw->delete(
410 - 'uw_campaigns',
411 - array( 'campaign_id' => $this->id )
412 - );
413 -
414 - $d2 = $dbw->delete(
415 - 'uw_campaign_conf',
416 - array( 'cc_campaign_id' => $this->id )
417 - );
418 -
419 - return $d1 && $d2;
420 - }
421 -
422 -}
Index: trunk/extensions/UploadWizard/UploadWizard.php
@@ -43,7 +43,7 @@
4444 'UploadWizardMessages',
4545 'UploadWizardHooks',
4646 'UploadWizardTutorial',
47 - 'UWCampaign'
 47+ 'UploadWizardCampaign'
4848 ) as $module ) {
4949 $wgAutoloadLocalClasses[$module] = $wgUpwizDir . '/' . $module . '.php';
5050 }
Index: trunk/extensions/UploadWizard/UploadWizardCampaign.php
@@ -0,0 +1,421 @@
 2+<?php
 3+
 4+/**
 5+ * Class that represents a single upload campaign.
 6+ *
 7+ * @file
 8+ * @ingroup Upload
 9+ *
 10+ * @since 1.2
 11+ *
 12+ * @licence GNU GPL v3+
 13+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 14+ */
 15+class UploadWizardCampaign {
 16+
 17+ /**
 18+ * If the ID of the campaign.
 19+ * Either this matched a record in the uw_campaigns table or is null.
 20+ *
 21+ * @since 1.2
 22+ * @var integer or null
 23+ */
 24+ protected $id;
 25+
 26+ /**
 27+ * If the name of the campaign.
 28+ * This name is the string used to invoke the campaign via campaign=name.
 29+ *
 30+ * @since 1.2
 31+ * @var string
 32+ */
 33+ protected $name;
 34+
 35+ /**
 36+ * If the campaign is enabled or not.
 37+ *
 38+ * @since 1.2
 39+ * @var boolean
 40+ */
 41+ protected $isEnabled;
 42+
 43+ /**
 44+ * The campaign configuration.
 45+ *
 46+ * @since 1.2
 47+ * @var array
 48+ */
 49+ protected $config;
 50+
 51+ /**
 52+ * If the campaign config has been loaded or not.
 53+ *
 54+ * @since 1.2
 55+ * @var boolean
 56+ */
 57+ protected $loadedConfig = false;
 58+
 59+ /**
 60+ * Create a new instance of $campaignName.
 61+ *
 62+ * @since 1.2
 63+ *
 64+ * @param integer $id
 65+ * @param string $name
 66+ * @param boolean $isEnabled
 67+ * @param array $config
 68+ */
 69+ public function __construct( $id, $name, $isEnabled, array $config ) {
 70+ $this->id = $id;
 71+ $this->name = $name;
 72+ $this->isEnabled = $isEnabled;
 73+ $this->config = $config;
 74+
 75+ $this->loadedConfig = count( $this->config ) > 0;
 76+ }
 77+
 78+ /**
 79+ * Returns the UploadWizardCampaign with specified name, or false if there is no such campaign.
 80+ *
 81+ * @since 1.2
 82+ *
 83+ * @param string $campaignName
 84+ * @param boolean $loadConfig
 85+ *
 86+ * @return UploadWizardCampaign or false
 87+ */
 88+ public static function newFromName( $campaignName, $loadConfig = true ) {
 89+ return self::newFromDB( array( 'campaign_name' => $campaignName ), $loadConfig );
 90+ }
 91+
 92+ /**
 93+ * Returns the UploadWizardCampaign with specified ID, or false if there is no such campaign.
 94+ *
 95+ * @since 1.2
 96+ *
 97+ * @param integer $campaignId
 98+ * @param boolean $loadConfig
 99+ *
 100+ * @return UploadWizardCampaign or false
 101+ */
 102+ public static function newFromId( $campaignId, $loadConfig = true ) {
 103+ return self::newFromDB( array( 'campaign_id' => $campaignId ), $loadConfig );
 104+ }
 105+
 106+ /**
 107+ * Returns a new instance of UploadWizardCampaign build from a database result
 108+ * obtained by doing a select with the porvided conditions on the uw_campaigns table.
 109+ * If no campaign matches the conditions, false will be returned.
 110+ *
 111+ * @since 1.2
 112+ *
 113+ * @param array $conditions
 114+ * @param boolean $loadConfig
 115+ *
 116+ * @return UploadWizardCampaign or false
 117+ */
 118+ protected static function newFromDB( array $conditions, $loadConfig = true ) {
 119+ $dbr = wfGetDB( DB_SLAVE );
 120+
 121+ $campaign = $dbr->selectRow(
 122+ 'uw_campaigns',
 123+ array(
 124+ 'campaign_id',
 125+ 'campaign_name',
 126+ 'campaign_enabled',
 127+ ),
 128+ $conditions
 129+ );
 130+
 131+ if ( !$campaign ) {
 132+ return false;
 133+ }
 134+
 135+ $config = $loadConfig ? self::getPropsFromDB( $dbr, $campaign->campaign_id ) : array();
 136+
 137+ return new self(
 138+ $campaign->campaign_id,
 139+ $campaign->campaign_name,
 140+ $campaign->campaign_enabled,
 141+ $config
 142+ );
 143+ }
 144+
 145+ /**
 146+ * Returns the id of the campaign.
 147+ *
 148+ * @since 1.2
 149+ *
 150+ * @return intgere
 151+ */
 152+ public function getId() {
 153+ return $this->id;
 154+ }
 155+
 156+ /**
 157+ * Returns the name of the campaign.
 158+ *
 159+ * @since 1.2
 160+ *
 161+ * @return string
 162+ */
 163+ public function getName() {
 164+ return $this->name;
 165+ }
 166+
 167+ /**
 168+ * Returns if the campaign is enabled.
 169+ *
 170+ * @since 1.2
 171+ *
 172+ * @return boolean
 173+ */
 174+ public function getIsEnabled() {
 175+ return $this->isEnabled;
 176+ }
 177+
 178+ /**
 179+ * Sets all config properties.
 180+ *
 181+ * @since 1.2
 182+ *
 183+ * @param array $config
 184+ */
 185+ public function setConfig( array $config ) {
 186+ $this->config = $config;
 187+ $this->loadedConfig = true;
 188+ }
 189+
 190+ /**
 191+ * Returns all set config properties.
 192+ * Property name => property value
 193+ *
 194+ * @since 1.2
 195+ *
 196+ * @return array
 197+ */
 198+ public function getConfig() {
 199+ if ( !$this->loadedConfig ) {
 200+ if ( !is_null( $this->id ) ) {
 201+ $this->config = self::getPropsFromDB( wfGetDB( DB_SLAVE ), $this->id );
 202+ }
 203+
 204+ $this->loadedConfig = true;
 205+ }
 206+
 207+ return $this->config;
 208+ }
 209+
 210+ /**
 211+ * Returns all config properties by merging the set ones with a list of default ones.
 212+ * Property name => array( 'default' => $value, 'type' => HTMLForm input type )
 213+ *
 214+ * @since 1.2
 215+ *
 216+ * @return array
 217+ */
 218+ public function getAllConfig() {
 219+ $config = $this->getConfig();
 220+
 221+ foreach ( self::getDefaultConfig() as $name => $data ) {
 222+ if ( array_key_exists( $name, $config ) ) {
 223+ $data['default'] = $config[$name];
 224+ }
 225+
 226+ $config[$name] = $data;
 227+ }
 228+
 229+ return $config;
 230+ }
 231+
 232+ /**
 233+ * Returns the default configuration values.
 234+ *
 235+ * @since 1.2
 236+ *
 237+ * @return array
 238+ */
 239+ public static function getDefaultConfig() {
 240+ return array (
 241+ 'skiptutorial' => array ( 'type' => 'check', 'default' => true )
 242+ );
 243+ }
 244+
 245+ /**
 246+ * Returns the value of the specified config property.
 247+ *
 248+ * @since 1.2
 249+ *
 250+ * @param string $property
 251+ *
 252+ * @return mixed
 253+ */
 254+ public function getProperty( $property ) {
 255+ global $wgUploadWizardConfig;
 256+
 257+ if ( array_key_exists( $property, $this->config ) ) {
 258+ return $this->config[$property];
 259+ }
 260+ elseif ( array_key_exists( $property, $wgUploadWizardConfig['campaignDefaults'] ) ) {
 261+ return $wgUploadWizardConfig['campaignDefaults'][$property];
 262+ }
 263+ else {
 264+ return null;
 265+ }
 266+ }
 267+
 268+ /**
 269+ * Write the campaign to the DB.
 270+ * If it's already there, it'll be updated, else it'll be inserted.
 271+ *
 272+ * @since 1.2
 273+ *
 274+ * @return boolean Success indicator
 275+ */
 276+ public function writeToDB() {
 277+ if ( is_null( $this->id ) ) {
 278+ return $this->insertIntoDB();
 279+ }
 280+ else {
 281+ return $this->updateInDB();
 282+ }
 283+ }
 284+
 285+ /**
 286+ * Insert the campaign into the DB.
 287+ *
 288+ * @since 1.2
 289+ *
 290+ * @return boolean Success indicator
 291+ */
 292+ protected function insertIntoDB() {
 293+ $dbw = wfGetDB( DB_MASTER );
 294+
 295+ $success = $dbw->insert(
 296+ 'uw_campaigns',
 297+ array(
 298+ 'campaign_name' => $this->name,
 299+ 'campaign_enabled' => $this->isEnabled,
 300+ ),
 301+ array( 'campaign_id' => $this->id )
 302+ );
 303+
 304+ if ( $success ) {
 305+ $this->id = $dbw->insertId();
 306+ $success &= $this->writePropsToDB( $dbw );
 307+ }
 308+
 309+ return $success;
 310+ }
 311+
 312+ /**
 313+ * Update the campaign in the DB.
 314+ *
 315+ * @since 1.2
 316+ *
 317+ * @return boolean Success indicator
 318+ */
 319+ protected function updateInDB() {
 320+ $dbw = wfGetDB( DB_MASTER );
 321+
 322+ $success = $dbw->update(
 323+ 'uw_campaigns',
 324+ array(
 325+ 'campaign_name' => $this->name,
 326+ 'campaign_enabled' => $this->isEnabled,
 327+ ),
 328+ array( 'campaign_id' => $this->id )
 329+ );
 330+
 331+ // Delete and insert instead of update.
 332+ // This will not result into dead-data when config vars are removed.
 333+ $success &= $dbw->delete(
 334+ 'uw_campaign_conf',
 335+ array( 'cc_campaign_id' => $this->id )
 336+ );
 337+
 338+ $success &= $this->writePropsToDB( $dbw );
 339+
 340+ return $success;
 341+ }
 342+
 343+ /**
 344+ * Write (insert) the properties into the DB.
 345+ *
 346+ * @since 1.2
 347+ *
 348+ * @param Database $dbw
 349+ *
 350+ * @return boolean Success indicator
 351+ */
 352+ protected function writePropsToDB( DatabaseBase $dbw ) {
 353+ $success = true;
 354+
 355+ foreach ( $this->config as $prop => $value ) {
 356+ $success &= $dbw->insert(
 357+ 'uw_campaign_conf',
 358+ array(
 359+ 'cc_campaign_id' => $this->id,
 360+ 'cc_property' => $prop,
 361+ 'cc_value' => $value
 362+ )
 363+ );
 364+ }
 365+
 366+ return $success;
 367+ }
 368+
 369+ /**
 370+ * Get the configuration properties from the DB.
 371+ *
 372+ * @since 1.2
 373+ *
 374+ * @param Database $dbr
 375+ * @param integer $campaignId
 376+ *
 377+ * @return array
 378+ */
 379+ protected static function getPropsFromDB( DatabaseBase $dbr, $campaignId ) {
 380+ $config = array();
 381+
 382+ $confProps = $dbr->select(
 383+ 'uw_campaign_conf',
 384+ array( 'cc_property', 'cc_value' ),
 385+ array( 'cc_campaign_id' => $campaignId )
 386+ );
 387+
 388+ foreach ( $confProps as $confProp ) {
 389+ $config[$confProp->cc_property] = $confProp->cc_value;
 390+ }
 391+
 392+ return $config;
 393+ }
 394+
 395+ /**
 396+ * Delete the campaign from the DB (when present).
 397+ *
 398+ * @since 1.2
 399+ *
 400+ * @return boolean Success indicator
 401+ */
 402+ public function deleteFromDB() {
 403+ if ( is_null( $this->id ) ) {
 404+ return true;
 405+ }
 406+
 407+ $dbw = wfGetDB( DB_MASTER );
 408+
 409+ $d1 = $dbw->delete(
 410+ 'uw_campaigns',
 411+ array( 'campaign_id' => $this->id )
 412+ );
 413+
 414+ $d2 = $dbw->delete(
 415+ 'uw_campaign_conf',
 416+ array( 'cc_campaign_id' => $this->id )
 417+ );
 418+
 419+ return $d1 && $d2;
 420+ }
 421+
 422+}
Property changes on: trunk/extensions/UploadWizard/UploadWizardCampaign.php
___________________________________________________________________
Added: svn:eol-style
1423 + native
Index: trunk/extensions/UploadWizard/SpecialUploadCampaigns.php
@@ -54,7 +54,7 @@
5555 $this->getOutput()->redirect( SpecialPage::getTitleFor( 'UploadCampaign', $wgRequest->getVal( 'newcampaign' ) )->getLocalURL() );
5656 }
5757 elseif ( count( $subPage ) == 2 && $subPage[0] == 'del' ) {
58 - $campaign = UWCampaign::newFromName( $subPage[1], false );
 58+ $campaign = UploadWizardCampaign::newFromName( $subPage[1], false );
5959 $campaign->deleteFromDB();
6060 $this->getOutput()->redirect( $this->getTitle()->getLocalURL() );
6161 }
Index: trunk/extensions/UploadWizard/SpecialUploadCampaign.php
@@ -51,11 +51,11 @@
5252 protected function getFormFields() {
5353 $dbr = wfGetDB( DB_SLAVE );
5454
55 - $campaign = UWCampaign::newFromName( $this->subPage );
 55+ $campaign = UploadWizardCampaign::newFromName( $this->subPage );
5656
5757 $id = $campaign ? $campaign->getId() : null;
5858 $enabled = $campaign ? $campaign->getIsEnabled() : false;
59 - $configFields = $campaign ? $campaign->getAllConfig() : UWCampaign::getDefaultConfig();
 59+ $configFields = $campaign ? $campaign->getAllConfig() : UploadWizardCampaign::getDefaultConfig();
6060
6161 $fields = array ();
6262
@@ -88,7 +88,7 @@
8989 $enabled = $data['Campaignenabled'];
9090 unset( $data['Campaignenabled'] );
9191
92 - $campaign = new UWCampaign( $id, $name, $enabled, $data );
 92+ $campaign = new UploadWizardCampaign( $id, $name, $enabled, $data );
9393
9494 $success = $campaign->writeToDB();
9595

Comments

#Comment by NeilK (talk | contribs)   12:58, 22 August 2011

Wondering if we should have used array_merge_recursive to merge configs? But okaying anyway.

Status & tagging log