r77755 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77754‎ | r77755 | r77756 >
Date:02:38, 5 December 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r77754
Modified paths:
  • /trunk/extensions/DSMW/CHANGELOG (modified) (history)
  • /trunk/extensions/DSMW/DSMW.i18n.php (modified) (history)
  • /trunk/extensions/DSMW/DSMW.php (modified) (history)
  • /trunk/extensions/DSMW/includes/DSMW_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/DSMW/specialPage/ArticleAdminPage.php (modified) (history)
  • /trunk/extensions/DSMW/specialPage/DSMWAdmin.php (modified) (history)
  • /trunk/extensions/DSMW/specialPage/DSMWGeneralExhibits.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DSMW/CHANGELOG
@@ -1,5 +1,9 @@
22 For more documentation, see http://www.dsmw.org
33
 4+== DSMW 1.1 ==
 5+
 6+* Stylized all files using the stylize.php script.
 7+
48 == DSMW 1.0 ==
59 * Tested with MW-1.16.0
610 * better user interface with Ajax
Index: trunk/extensions/DSMW/DSMW.php
@@ -23,6 +23,7 @@
2424 }
2525
2626 require_once "$IP/includes/GlobalFunctions.php";
 27+require_once dirname( __FILE__ ) . '/includes/DSMW_GlobalFunctions.php';
2728 $wgDSMWIP = dirname( __FILE__ );
2829
2930 require_once( "$wgDSMWIP/includes/DSMWButton.php" );
@@ -135,6 +136,28 @@
136137 $wgAutoloadLocalClasses['UploadFromUrl'] = dirname( __FILE__ ) . '/api/upload/UploadFromUrl.php';
137138 }
138139
 140+function dsmwgSetupFunction() {
 141+ global $smwgNamespacesWithSemanticLinks;
139142
 143+ // This function has been deprecated in 1.16, but needed for earlier versions.
 144+ // It's present in 1.16 as a stub, but lets check if it exists in case it gets removed at some point.
 145+ if ( function_exists( 'wfLoadExtensionMessages' ) ) {
 146+ wfLoadExtensionMessages( 'DSMW' );
 147+ }
 148+
 149+ $smwgNamespacesWithSemanticLinks += array(
 150+ PATCH => true,
 151+ PUSHFEED => true,
 152+ PULLFEED => true,
 153+ CHANGESET => true
 154+ );
140155
141 -require_once dirname( __FILE__ ) . 'DSMW_Settings.php';
 156+ if ( defined( 'SRF_VERSION' ) ) {
 157+ global $wgDSMWExhibits;
 158+ if ( !is_object( $wgDSMWExhibits ) ) {
 159+ $wgDSMWExhibits = new DSMWExhibits();
 160+ }
 161+ }
 162+}
 163+
 164+require_once dirname( __FILE__ ) . '/DSMW_Settings.php';
Index: trunk/extensions/DSMW/includes/DSMW_GlobalFunctions.php
@@ -213,6 +213,7 @@
214214 wfDebugLog( 'p2p', 'push on ' );
215215 $patches = array();
216216 $tmpPatches = array();
 217+
217218 if ( isset( $_POST['name'] ) ) {
218219 $name1 = $_POST['name'];
219220 if ( !is_array( $name1 ) )
@@ -221,13 +222,17 @@
222223 wfDebugLog( 'p2p', ' - ' . $push );
223224 }
224225 }
225 - else
226 - $name1 = "";
227 - if ( $name1 == "" ) {
 226+ else {
 227+ $name1 = '';
 228+ }
 229+
 230+ if ( $name1 == '' ) {
228231 utils::writeAndFlush( '<p><b>No pushfeed selected!</b></p>' );
 232+
229233 $title = Title::newFromText( 'Special:ArticleAdminPage' );
230234 $article = new Article( $title );
231235 $article->doRedirect();
 236+
232237 return false;
233238 }
234239
@@ -381,7 +386,6 @@
382387 $article->doEdit( $newtext, $summary = "" );
383388 $article->doRedirect();
384389
385 -
386390 return false;
387391 }
388392
@@ -393,9 +397,11 @@
394398 if ( !is_array( $name1 ) )
395399 $name1 = array( $name1 );
396400 }
397 - else
398 - $name1 = "";
399 - if ( $name1 == "" ) {
 401+ else {
 402+ $name1 = '';
 403+ }
 404+
 405+ if ( $name1 == '' ) {
400406 utils::writeAndFlush( '<p><b>No pullfeed selected!</b></p> ' );
401407 $title = Title::newFromText( 'Special:ArticleAdminPage' );
402408 $article = new Article( $title );
@@ -418,23 +424,28 @@
419425 if ( $previousCSID == false ) {
420426 $previousCSID = "none";
421427 }
 428+
422429 wfDebugLog( 'p2p', ' -> pullHead : ' . $previousCSID );
 430+
423431 $relatedPushServer = getPushURL( $name );
424 - if ( is_null( $relatedPushServer )
425 -
426 - )throw new MWException( __METHOD__ . ': no relatedPushServer url' );
 432+ if ( is_null( $relatedPushServer ) ) {
 433+ throw new MWException( __METHOD__ . ': no relatedPushServer url' );
 434+ }
 435+
427436 $namePush = getPushName( $name );
428437 $namePush = str_replace( ' ', '_', $namePush );
 438+
429439 wfDebugLog( 'p2p', ' -> pushServer : ' . $relatedPushServer );
430440 wfDebugLog( 'p2p', ' -> pushName : ' . $namePush );
431 - if ( is_null( $namePush )
432 -
433 - )throw new MWException( __METHOD__ . ': no PushName' );
 441+
 442+ if ( is_null( $namePush ) ) {
 443+ throw new MWException( __METHOD__ . ': no PushName' );
 444+ }
 445+
434446 // split NS and name
435447 preg_match( "/^(.+?)_*:_*(.*)$/S", $namePush, $m );
436448 $nameWithoutNS = $m[2];
437449
438 -
439450 // $url = $relatedPushServer.'/api.php?action=query&meta=changeSet&cspushName='.$nameWithoutNS.'&cschangeSet='.$previousCSID.'&format=xml';
440451 // $url = $relatedPushServer."/api{$wgScriptExtension}?action=query&meta=changeSet&cspushName=".$nameWithoutNS.'&cschangeSet='.$previousCSID.'&format=xml';
441452 wfDebugLog( 'testlog', ' -> request ChangeSet : ' . $relatedPushServer . '/api.php?action=query&meta=changeSet&cspushName=' . $nameWithoutNS . '&cschangeSet=' . $previousCSID . '&format=xml' );
@@ -446,10 +457,10 @@
447458 if ( strpos( $cs, "<?xml version=\"1.0\"?>" ) === false ) {
448459 $cs = utils::file_get_contents_curl( utils::lcfirst( $relatedPushServer ) . "/api.php5?action=query&meta=changeSet&cspushName=" . $nameWithoutNS . '&cschangeSet=' . $previousCSID . '&format=xml' );
449460 }
450 - if ( strpos( $cs, "<?xml version=\"1.0\"?>" ) === false )
451 - $cs = false;
 461+ if ( strpos( $cs, "<?xml version=\"1.0\"?>" ) === false ) {
 462+ $cs = false;
 463+ }
452464
453 -
454465 if ( $cs === false )
455466 throw new MWException( __METHOD__ . ': Cannot connect to Push Server (ChangeSet API)' );
456467 $cs = trim( $cs );
@@ -458,13 +469,16 @@
459470
460471 $changeSet = $dom->getElementsByTagName( 'changeSet' );
461472 $CSID = null;
 473+
462474 foreach ( $changeSet as $cs ) {
463475 if ( $cs->hasAttribute( "id" ) ) {
464476 $CSID = $cs->getAttribute( 'id' );
465477 $csName = $CSID;
466478 }
467479 }
 480+
468481 wfDebugLog( 'p2p', ' -> changeSet found ' . $CSID );
 482+
469483 while ( $CSID != null ) {
470484 // if(!utils::pageExist($CSID)) {
471485 $listPatch = null;
@@ -518,10 +532,12 @@
519533 wfDebugLog( 'p2p', ' - redirect to ChangeSet:' . $csName );
520534 }
521535 }// end foreach list pullfeed
 536+
522537 utils::writeAndFlush( '<p><b>End pull</b></p>' );
523538 $title = Title::newFromText( 'Special:ArticleAdminPage' );
524539 $article = new Article( $title );
525540 $article->doRedirect();
 541+
526542 return false;
527543 } else {
528544 return true;
@@ -572,14 +588,15 @@
573589 $urlServer = 'http://' . $wgServerName . $wgScriptPath;
574590
575591 $ns = $editpage->mTitle->getNamespace();
576 - if ( ( $ns == PATCH ) || ( $ns == PUSHFEED ) || ( $ns == PULLFEED ) || ( $ns == CHANGESET )
 592+ if ( ( $ns == PATCH ) || ( $ns == PUSHFEED ) || ( $ns == PULLFEED ) || ( $ns == CHANGESET ) ) {
 593+ return true;
 594+ }
577595
578 - )return true;
579 -
580596 $actualtext = $editpage->textbox1; // V2
581597
582598 $dbr = wfGetDB( DB_SLAVE );
583599 $lastRevision = Revision::loadFromTitle( $dbr, $editpage->mTitle );
 600+
584601 if ( is_null( $lastRevision ) ) {
585602 $conctext = "";
586603 $rev_id = 0;
@@ -592,8 +609,9 @@
593610 }
594611
595612 // if there is no modification on the text
596 - if ( $actualtext == $conctext )
597 - return true;
 613+ if ( $actualtext == $conctext ) {
 614+ return true;
 615+ }
598616
599617 $model = manager::loadModel( $rev_id );
600618 $logoot = new logootEngine( $model );
@@ -618,10 +636,14 @@
619637 // creation Patch P2
620638 $tmp = serialize( $listOp1 );
621639 $patch = new Patch( false, false, $listOp1, $urlServer, $rev_id1 );
622 - if ( $editpage->mTitle->getNamespace() == 0 )
623 - $title = $editpage->mTitle->getText();
624 - else
625 - $title = $editpage->mTitle->getNsText() . ':' . $editpage->mTitle->getText();
 640+
 641+ if ( $editpage->mTitle->getNamespace() == 0 ) {
 642+ $title = $editpage->mTitle->getText();
 643+ }
 644+ else {
 645+ $title = $editpage->mTitle->getNsText() . ':' . $editpage->mTitle->getText();
 646+ }
 647+
626648 // integration: diffs between VO and V2 into V1
627649
628650 $modelAfterIntegrate = $logoot->integrate( $listOp1 );
@@ -630,6 +652,7 @@
631653 $modelAfterIntegrate = $logoot->getModel();
632654 $tmp = serialize( $listOp );
633655 $patch = new Patch( false, false, $listOp, $urlServer, $rev_id1 );
 656+
634657 if ( $editpage->mTitle->getNamespace() == 0 )
635658 $title = $editpage->mTitle->getText();
636659 else
@@ -673,21 +696,3 @@
674697 }
675698 return true;
676699 }
677 -
678 -function dsmwgSetupFunction() {
679 - global $smwgNamespacesWithSemanticLinks;
680 -
681 - $smwgNamespacesWithSemanticLinks += array(
682 - PATCH => true,
683 - PUSHFEED => true,
684 - PULLFEED => true,
685 - CHANGESET => true
686 - );
687 -
688 - if ( defined( 'SRF_VERSION' ) ) {
689 - global $wgDSMWExhibits;
690 - if ( !is_object( $wgDSMWExhibits ) ) {
691 - $wgDSMWExhibits = new DSMWExhibits();
692 - }
693 - }
694 -}
Index: trunk/extensions/DSMW/specialPage/ArticleAdminPage.php
@@ -13,19 +13,20 @@
1414 $wgExtensionFunctions[] = "wfSetupAdminPage";
1515
1616 class ArticleAdminPage extends SpecialPage {
17 -// Constructor
18 - function ArticleAdminPage() {
 17+
 18+ public function __construct() {
1919 global $wgHooks, $wgSpecialPages, $wgWatchingMessages;
 20+
2021 # Add all our needed hooks
2122 $wgHooks["UnknownAction"][] = $this;
2223 $wgHooks["SkinTemplateTabs"][] = $this;
2324 $wgHooks['SkinTemplateNavigation'][] = $this;
24 - SpecialPage::SpecialPage( 'ArticleAdminPage'/*, "block"*/ );// avec block => pasges speciales restreintes
25 - wfLoadExtensionMessages( 'DSMW' );
 25+
 26+ parent::__construct( 'ArticleAdminPage' );
2627 }
2728
28 - function getDescription() {
29 - return "DSMW Admin functions";
 29+ public function getDescription() {
 30+ return wfMsg( 'dsmw-special-admin' );
3031 }
3132
3233 /**
@@ -38,7 +39,7 @@
3940 * @global <String> $wgScriptPath
4041 * @return <bool>
4142 */
42 - function execute() {
 43+ public function execute() {
4344 global $wgOut, $wgServerName, $wgScriptPath, $wgScriptExtension; /*, $wgSitename, $wgCachePages, $wgUser, $wgTitle, $wgDenyAccessMessage, $wgAllowAnonUsers, $wgRequest, $wgMessageCache, $wgWatchingMessages, $wgDBtype, $namespace_titles;*/
4445
4546 $url = 'http://' . $wgServerName . $wgScriptPath . "/index{$wgScriptExtension}";
Index: trunk/extensions/DSMW/specialPage/DSMWAdmin.php
@@ -1,4 +1,5 @@
22 <?php
 3+
34 /**
45 * DSMW Special page
56 *
@@ -9,23 +10,23 @@
1011 require_once "$IP/includes/SpecialPage.php";
1112
1213 /* Extension variables */
13 -$wgExtensionFunctions[] = "wfSetupDSMWAdmin";
 14+$wgExtensionFunctions[] = 'wfSetupDSMWAdmin';
1415
1516 class DSMWAdmin extends SpecialPage {
16 -// Constructor
17 - function DSMWAdmin() {
 17+
 18+ public function __construct() {
1819 global $wgHooks, $wgSpecialPages, $wgWatchingMessages;
 20+
1921 # Add all our needed hooks
20 - $wgHooks["SkinTemplateTabs"][] = $this;
21 - SpecialPage::SpecialPage( 'DSMWAdmin'/*, "block"*/ );// avec block => pages speciales restreintes
22 - wfLoadExtensionMessages( 'DSMW' );
 22+ $wgHooks['SkinTemplateTabs'][] = $this;
 23+
 24+ parent::__construct( 'DSMWAdmin' );
2325 }
2426
25 - function getDescription() {
26 - return "DSMW Settings";
 27+ public function getDescription() {
 28+ return wfMsg( 'dsmw-special-settings' );
2729 }
2830
29 -
3031 /**
3132 * Executed when the user opens the DSMW administration special page
3233 * Calculates the PushFeed list and the pullfeed list (and everything that
@@ -36,7 +37,7 @@
3738 * @global <String> $wgScriptPath
3839 * @return <bool>
3940 */
40 - function execute() {
 41+ public function execute() {
4142 global $wgOut, $wgRequest, $wgServerName, $wgScriptPath, $wgDSMWIP, $wgServerName, $wgScriptPath; /*, $wgSitename, $wgCachePages, $wgUser, $wgTitle, $wgDenyAccessMessage, $wgAllowAnonUsers, $wgRequest, $wgMessageCache, $wgWatchingMessages, $wgDBtype, $namespace_titles;*/
4243 $urlServer = 'http://' . $wgServerName . $wgScriptPath;
4344
Index: trunk/extensions/DSMW/specialPage/DSMWGeneralExhibits.php
@@ -1,7 +1,10 @@
22 <?php
 3+
34 /**
45 * DSMW Special page
56 *
 7+ * TODO: only load when SRF is available?
 8+ *
69 * @copyright INRIA-LORIA-SCORE Team
710 * @author jean-Philippe Muller
811 */
@@ -9,19 +12,17 @@
1013 require_once "$IP/includes/SpecialPage.php";
1114
1215 /* Extension variables */
13 -$wgExtensionFunctions[] = "wfSetupDSMWGenExhibits";
 16+// FIXME
 17+$wgExtensionFunctions[] = 'wfSetupDSMWGenExhibits';
1418
1519 class DSMWGeneralExhibits extends SpecialPage {
16 -// Constructor
17 - function DSMWGeneralExhibits() {
18 - if ( defined( 'SRF_VERSION' ) ) {
19 - SpecialPage::SpecialPage( 'DSMWGeneralExhibits' );
20 - }
21 - wfLoadExtensionMessages( 'DSMW' );
 20+
 21+ public function __construct() {
 22+ parent::__construct( 'DSMWGeneralExhibits' );
2223 }
2324
24 - function getDescription() {
25 - return "DSMW general exhibits";
 25+ public function getDescription() {
 26+ return wfMsg( 'dsmw-special-exhibits' );
2627 }
2728
2829 /**
@@ -33,7 +34,7 @@
3435 *
3536 *
3637 */
37 - function execute() {
 38+ public function execute() {
3839 global $wgOut, $wgRequest, $wgServerName, $wgScriptPath, $wgDSMWIP, $wgServerName, $wgScriptPath;
3940
4041 // If the Semantic Results Format isn't installed, a blank warning page appears
Index: trunk/extensions/DSMW/DSMW.i18n.php
@@ -15,5 +15,9 @@
1616 $messages['en'] = array(
1717 'dsmw-desc' => 'Allows to create a network of Semantic MediaWiki servers that share common semantic wiki pages. ([http://www.dsmw.org www.dsmw.org])',
1818
19 - 'specialpages-group-dsmw_group' => 'Distributed Semantic MediaWiki'
 19+ 'specialpages-group-dsmw_group' => 'Distributed Semantic MediaWiki',
 20+
 21+ 'dsmw-special-admin' => 'DSMW Admin functions',
 22+ 'dsmw-special-settings' => 'DSMW Settings',
 23+ 'dsmw-special-exhibits' => 'DSMW general exhibits',
2024 );
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r77756Follow up to r77755jeroendedauw02:53, 5 December 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r77754Follow up to r77753jeroendedauw02:05, 5 December 2010

Status & tagging log