r69607 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69606‎ | r69607 | r69608 >
Date:13:09, 20 July 2010
Author:werdna
Status:ok (Comments)
Tags:
Comment:
Commit CommunityApplications extension, the "reading" part of the CommunityHiring ecosystem. Still needs alternative (CSV) output.
Modified paths:
  • /trunk/extensions/CommunityApplications (added) (history)
  • /trunk/extensions/CommunityApplications/CommunityApplications.i18n.php (added) (history)
  • /trunk/extensions/CommunityApplications/CommunityApplications.php (added) (history)
  • /trunk/extensions/CommunityApplications/SpecialCommunityApplications.php (added) (history)

Diff [purge]

Index: trunk/extensions/CommunityApplications/CommunityApplications.i18n.php
@@ -0,0 +1,8 @@
 2+<?php
 3+
 4+$messages = array();
 5+
 6+$messages['en'] = array(
 7+ 'community-applications-title' => 'Community Applications',
 8+ 'community-applications-application-title' => 'Application $1: $2, $3',
 9+);
Index: trunk/extensions/CommunityApplications/CommunityApplications.php
@@ -0,0 +1,13 @@
 2+<?php
 3+
 4+if ( ! defined( 'MEDIAWIKI' ) ) {
 5+ die;
 6+}
 7+
 8+// Reader for CommunityHiring data
 9+$wgSpecialPages['CommunityApplications'] = 'SpecialCommunityApplications';
 10+$wgAutoloadClasses['SpecialCommunityApplications'] = dirname(__FILE__) . "/SpecialCommunityApplications.php";
 11+
 12+$wgExtensionMessagesFiles['CommunityApplications'] = dirname( __FILE__ ) . "/CommunityApplications.i18n.php";
 13+
 14+$wgCommunityHiringDatabase = false;
Index: trunk/extensions/CommunityApplications/SpecialCommunityApplications.php
@@ -0,0 +1,47 @@
 2+<?php
 3+
 4+class SpecialCommunityApplications extends SpecialPage {
 5+ function __construct() {
 6+ parent::__construct( 'CommunityApplications', 'view-community-applications' );
 7+ wfLoadExtensionMessages( 'CommunityApplications' );
 8+ }
 9+
 10+ function execute($par) {
 11+ global $wgUser, $wgOut;
 12+
 13+ if ( !$this->userCanExecute( $wgUser ) ) {
 14+ $this->displayRestrictionError();
 15+ return;
 16+ }
 17+
 18+ $wgOut->setPageTitle( wfMsg( 'community-applications-title' ) );
 19+
 20+ $dbr = wfGetDB( DB_SLAVE );
 21+
 22+ $res = $dbr->select( 'community_hiring_application', '*', 1, __METHOD__ );
 23+
 24+ foreach( $res as $row ) {
 25+ $this->showEntry( $row );
 26+ }
 27+ }
 28+
 29+ function showEntry( $row ) {
 30+ global $wgOut;
 31+ $wgOut->addHTML( "<hr/>" );
 32+ $wgOut->addHTML( "<table><tbody>" );
 33+
 34+ $data = get_object_vars(json_decode( $row->ch_data ));
 35+
 36+ $header = wfMsg( 'community-applications-application-title', $row->ch_id,
 37+ $data['family-name'], $data['given-name'] );
 38+ $wgOut->addHTML( Xml::element( 'h2', null, $header ) );
 39+ foreach( $data as $key => $value ) {
 40+ $html = Xml::element( 'td', null, $key );
 41+ $html .= Xml::element( 'td', null, $value );
 42+ $html = Xml::tags( 'tr', null, $html ) . "\n";
 43+ $wgOut->addHTML( $html );
 44+ }
 45+
 46+ $wgOut->addHTML( "</tbody></table>" );
 47+ }
 48+}

Comments

#Comment by Catrope (talk | contribs)   13:20, 20 July 2010
+		$data = get_object_vars(json_decode( $row->ch_data ));

Please use FormatJson::decode( $row->ch_data, true ); for this; that'll also work if json_decode() is not available.

#Comment by Siebrand (talk | contribs)   19:25, 20 July 2010

Given that this has been implemented as a separate extension, can you provide some insight in the "ecosystem" part? If no other Community* extensions are expected, I would suggested merging this with CommunityHiring. If more extensions are expected, should we maybe create 'extensions/Community/' and add all relevant extensions underneath it?

Status & tagging log