Index: trunk/extensions/CentralNotice/CentralNotice.php |
— | — | @@ -149,6 +149,8 @@ |
150 | 150 | $base . '/patches/patch-notice_projects.sql' ); |
151 | 151 | $wgExtNewTables[] = array( 'cn_notice_log', |
152 | 152 | $base . '/patches/patch-notice_log.sql' ); |
| 153 | + $wgExtNewTables[] = array( 'cn_template_log', |
| 154 | + $base . '/patches/patch-template_log.sql' ); |
153 | 155 | } |
154 | 156 | } else { |
155 | 157 | if ( $updater->getDB()->getType() == 'mysql' ) { |
— | — | @@ -168,6 +170,8 @@ |
169 | 171 | $base . '/patches/patch-notice_projects.sql', true ) ); |
170 | 172 | $updater->addExtensionUpdate( array( 'addTable', 'cn_notice_log', |
171 | 173 | $base . '/patches/patch-notice_log.sql', true ) ); |
| 174 | + $updater->addExtensionUpdate( array( 'addTable', 'cn_template_log', |
| 175 | + $base . '/patches/patch-template_log.sql', true ) ); |
172 | 176 | } |
173 | 177 | } |
174 | 178 | return true; |
Index: trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php |
— | — | @@ -51,32 +51,41 @@ |
52 | 52 | |
53 | 53 | $htmlOut .= Xml::openElement( 'form', array( 'method' => 'post' ) ); |
54 | 54 | $htmlOut .= Xml::element( 'h2', null, wfMsg( 'centralnotice-view-logs' ) ); |
| 55 | + // TODO: interface for switching between log types. |
| 56 | + $htmlOut .= Xml::openElement( 'div', array( 'id' => 'cn-log-switcher' ) ); |
| 57 | + |
| 58 | + $htmlOut .= Xml::radio( 'log_type', 'campaign', true ); |
| 59 | + $htmlOut .= Xml::label( wfMsg( 'centralnotice-campaign-settings' ), 'campaign' ); |
| 60 | + |
| 61 | + $htmlOut .= Xml::radio( 'log_type', 'banner', false ); |
| 62 | + $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-settings' ), 'banner' ); |
| 63 | + |
| 64 | + $htmlOut .= Xml::closeElement( 'div' ); |
55 | 65 | $htmlOut .= Xml::closeElement( 'form' ); |
56 | 66 | |
57 | 67 | // End log selection fieldset |
58 | | - // Uncomment when we have multiple logs |
59 | | - //$htmlOut .= Xml::closeElement( 'fieldset' ); |
| 68 | + $htmlOut .= Xml::closeElement( 'fieldset' ); |
60 | 69 | |
61 | 70 | $wgOut->addHTML( $htmlOut ); |
62 | 71 | |
63 | | - $this->showLog( $this->logType ); |
| 72 | + $this->showCampaignLog( $this->logType ); |
64 | 73 | |
65 | 74 | // End Banners tab content |
66 | 75 | $wgOut->addHTML( Xml::closeElement( 'div' ) ); |
67 | 76 | } |
68 | 77 | |
69 | 78 | /** |
70 | | - * Show a log. |
| 79 | + * Show a log of campaign changes. |
71 | 80 | */ |
72 | | - function showLog( $logType ) { |
| 81 | + function showCampaignLog( $logType ) { |
73 | 82 | global $wgOut; |
74 | 83 | |
75 | | - $pager = new CentralNoticeLogPager( $this ); |
| 84 | + //$pager = new CentralNoticeLogPager( $this ); |
| 85 | + $pager = new CentralNoticeBannerLogPager( $this ); |
76 | 86 | $htmlOut = ''; |
77 | 87 | |
78 | 88 | // Begin log fieldset |
79 | | - // Uncomment when we have multiple logs |
80 | | - //$htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); |
| 89 | + $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); |
81 | 90 | |
82 | 91 | // Show paginated list of log entries |
83 | 92 | $htmlOut .= Xml::tags( 'div', |
— | — | @@ -397,4 +406,137 @@ |
398 | 407 | $htmlOut .= Xml::closeElement( 'table' ); |
399 | 408 | return $htmlOut; |
400 | 409 | } |
| 410 | + |
401 | 411 | } |
| 412 | + |
| 413 | +class CentralNoticeBannerLogPager extends ReverseChronologicalPager { |
| 414 | + var $viewPage, $special; |
| 415 | + |
| 416 | + function __construct( $special ) { |
| 417 | + $this->special = $special; |
| 418 | + parent::__construct(); |
| 419 | + |
| 420 | + $this->viewPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' ); |
| 421 | + } |
| 422 | + |
| 423 | + /** |
| 424 | + * Sort the log list by timestamp |
| 425 | + */ |
| 426 | + function getIndexField() { |
| 427 | + return 'templog_timestamp'; |
| 428 | + } |
| 429 | + |
| 430 | + /** |
| 431 | + * Pull log entries from the database |
| 432 | + */ |
| 433 | + function getQueryInfo() { |
| 434 | + return array( |
| 435 | + 'tables' => array( 'cn_template_log' ), |
| 436 | + 'fields' => '*', |
| 437 | + ); |
| 438 | + } |
| 439 | + |
| 440 | + /** |
| 441 | + * Generate the content of each table row (1 row = 1 log entry) |
| 442 | + */ |
| 443 | + function formatRow( $row ) { |
| 444 | + global $wgLang, $wgExtensionAssetsPath; |
| 445 | + |
| 446 | + // Create a user object so we can pull the name, user page, etc. |
| 447 | + $loggedUser = User::newFromId( $row->templog_user_id ); |
| 448 | + // Create the user page link |
| 449 | + $userLink = $this->getSkin()->makeLinkObj( $loggedUser->getUserPage(), |
| 450 | + $loggedUser->getName() ); |
| 451 | + $userTalkLink = $this->getSkin()->makeLinkObj( $loggedUser->getTalkPage(), |
| 452 | + wfMsg ( 'centralnotice-talk-link' ) ); |
| 453 | + |
| 454 | + // Create the banner link |
| 455 | + $bannerLink = $this->getSkin()->makeLinkObj( $this->viewPage, |
| 456 | + htmlspecialchars( $row->templog_template_name ), |
| 457 | + 'template=' . urlencode( $row->templog_template_name ) ); |
| 458 | + |
| 459 | + // Begin log entry primary row |
| 460 | + $htmlOut = Xml::openElement( 'tr' ); |
| 461 | + |
| 462 | + $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); |
| 463 | + if ( $row->templog_action !== 'removed' ) { |
| 464 | + $htmlOut .= '<a href="javascript:toggleDisplay(\''.$row->templog_id.'\')">'. |
| 465 | + '<img src="'.$wgExtensionAssetsPath.'/CentralNotice/collapsed.png" id="cn-collapsed-'.$row->templog_id.'" style="display:block;vertical-align:baseline;"/>'. |
| 466 | + '<img src="'.$wgExtensionAssetsPath.'/CentralNotice/uncollapsed.png" id="cn-uncollapsed-'.$row->templog_id.'" style="display:none;vertical-align:baseline;"/>'. |
| 467 | + '</a>'; |
| 468 | + } |
| 469 | + $htmlOut .= Xml::closeElement( 'td' ); |
| 470 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
| 471 | + $wgLang->date( $row->templog_timestamp ) . ' ' . $wgLang->time( $row->templog_timestamp ) |
| 472 | + ); |
| 473 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
| 474 | + wfMsg ( 'centralnotice-user-links', $userLink, $userTalkLink ) |
| 475 | + ); |
| 476 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
| 477 | + $row->templog_action |
| 478 | + ); |
| 479 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
| 480 | + $bannerLink |
| 481 | + ); |
| 482 | + $htmlOut .= Xml::tags( 'td', array(), |
| 483 | + ' ' |
| 484 | + ); |
| 485 | + |
| 486 | + // End log entry primary row |
| 487 | + $htmlOut .= Xml::closeElement( 'tr' ); |
| 488 | + |
| 489 | + if ( $row->templog_action !== 'removed' ) { |
| 490 | + // Begin log entry secondary row |
| 491 | + $htmlOut .= Xml::openElement( 'tr', array( 'id' => 'cn-log-details-'.$row->templog_id, 'style' => 'display:none;' ) ); |
| 492 | + |
| 493 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
| 494 | + ' ' // force a table cell in older browsers |
| 495 | + ); |
| 496 | + $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top', 'colspan' => '5' ) ); |
| 497 | + if ( $row->templog_action == 'created' ) { |
| 498 | + //$htmlOut .= $this->showInitialSettings( $row ); |
| 499 | + } else if ( $row->templog_action == 'modified' ) { |
| 500 | + //$htmlOut .= $this->showChanges( $row ); |
| 501 | + } |
| 502 | + $htmlOut .= Xml::closeElement( 'td' ); |
| 503 | + |
| 504 | + // End log entry primary row |
| 505 | + $htmlOut .= Xml::closeElement( 'tr' ); |
| 506 | + } |
| 507 | + |
| 508 | + return $htmlOut; |
| 509 | + } |
| 510 | + |
| 511 | + function getStartBody() { |
| 512 | + $htmlOut = ''; |
| 513 | + $htmlOut .= Xml::openElement( 'table', array( 'id' => 'cn-campaign-logs', 'cellpadding' => 3 ) ); |
| 514 | + $htmlOut .= Xml::openElement( 'tr' ); |
| 515 | + $htmlOut .= Xml::element( 'th', array( 'style' => 'width: 20px;' ) ); |
| 516 | + $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 130px;' ), |
| 517 | + wfMsg ( 'centralnotice-timestamp' ) |
| 518 | + ); |
| 519 | + $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), |
| 520 | + wfMsg ( 'centralnotice-user' ) |
| 521 | + ); |
| 522 | + $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 100px;' ), |
| 523 | + wfMsg ( 'centralnotice-action' ) |
| 524 | + ); |
| 525 | + $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), |
| 526 | + wfMsg ( 'centralnotice-banner' ) |
| 527 | + ); |
| 528 | + $htmlOut .= Xml::tags( 'td', array(), |
| 529 | + ' ' |
| 530 | + ); |
| 531 | + $htmlOut .= Xml::closeElement( 'tr' ); |
| 532 | + return $htmlOut; |
| 533 | + } |
| 534 | + |
| 535 | + /** |
| 536 | + * Close table |
| 537 | + */ |
| 538 | + function getEndBody() { |
| 539 | + $htmlOut = ''; |
| 540 | + $htmlOut .= Xml::closeElement( 'table' ); |
| 541 | + return $htmlOut; |
| 542 | + } |
| 543 | +} |
Index: trunk/extensions/CentralNotice/patches/patch-template_log.sql |
— | — | @@ -0,0 +1,22 @@ |
| 2 | +-- Update to allow for logging of changes to banner settings. |
| 3 | + |
| 4 | +CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/cn_template_log ( |
| 5 | + `templog_id` int unsigned NOT NULL PRIMARY KEY auto_increment, |
| 6 | + `templog_timestamp` binary(14) NOT NULL, |
| 7 | + `templog_user_id` int unsigned NOT NULL, |
| 8 | + `templog_action` enum('created','modified','removed') NOT NULL DEFAULT 'modified', |
| 9 | + `templog_template_id` int unsigned NOT NULL, |
| 10 | + `templog_template_name` varchar(255) DEFAULT NULL, |
| 11 | + `templog_begin_anon_display` tinyint(1) DEFAULT NULL, |
| 12 | + `templog_end_anon_display` tinyint(1) DEFAULT NULL, |
| 13 | + `templog_begin_account_display` tinyint(1) DEFAULT NULL, |
| 14 | + `templog_end_account_display` tinyint(1) DEFAULT NULL, |
| 15 | + `templog_begin_fundraising` tinyint(1) DEFAULT NULL, |
| 16 | + `templog_end_fundraising` tinyint(1) DEFAULT NULL, |
| 17 | + `templog_begin_landing_pages` varchar(255) DEFAULT NULL, |
| 18 | + `templog_end_landing_pages` varchar(255) DEFAULT NULL, |
| 19 | + `templog_content_change` tinyint(1) DEFAULT 0 |
| 20 | +) /*$wgDBTableOptions*/; |
| 21 | +CREATE INDEX /*i*/templog_timestamp ON /*_*/cn_template_log (templog_timestamp); |
| 22 | +CREATE INDEX /*i*/templog_user_id ON /*_*/cn_template_log (templog_user_id, templog_timestamp); |
| 23 | +CREATE INDEX /*i*/templog_template_id ON /*_*/cn_template_log (templog_template_id, templog_timestamp); |
\ No newline at end of file |
Index: trunk/extensions/CentralNotice/CentralNotice.i18n.php |
— | — | @@ -161,6 +161,8 @@ |
162 | 162 | 'centralnotice-talk-link' => 'talk', |
163 | 163 | 'centralnotice-user-links' => '$1 ($2)', |
164 | 164 | 'centralnotice-log-label' => '<span class="cn-log-label">$1:</span> $2', |
| 165 | + 'centralnotice-campaign-settings' => 'Campaign settings', |
| 166 | + 'centralnotice-banner-settings' => 'Banner settings', |
165 | 167 | ); |
166 | 168 | |
167 | 169 | /** Message documentation (Message documentation) |
— | — | @@ -253,6 +255,8 @@ |
254 | 256 | 'centralnotice-talk-link' => 'Link for user talk page; should be lower case.', |
255 | 257 | 'centralnotice-user-links' => '$1 is a link to the user page, $2 is a link to the user talk page.', |
256 | 258 | 'centralnotice-log-label' => '$1 is a label for a setting, $2 is the value of the setting (or changes to the setting)', |
| 259 | + 'centralnotice-campaign-settings' => 'Label for a radio button', |
| 260 | + 'centralnotice-banner-settings' => 'Label for a radio button', |
257 | 261 | ); |
258 | 262 | |
259 | 263 | /** Afrikaans (Afrikaans) |