https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114739

Revision: 114739
Author:   jeroendedauw
Date:     2012-04-05 14:34:45 +0000 (Thu, 05 Apr 2012)
Log Message:
-----------
split logic from display

Modified Paths:
--------------
    trunk/extensions/EducationProgram/EducationProgram.php
    trunk/extensions/EducationProgram/actions/EPRestoreAction.php
    trunk/extensions/EducationProgram/actions/EPUndoAction.php
    trunk/extensions/EducationProgram/actions/EditCourseAction.php
    trunk/extensions/EducationProgram/includes/EPRevisionDiff.php

Added Paths:
-----------
    trunk/extensions/EducationProgram/includes/EPDiffTable.php
    trunk/extensions/EducationProgram/includes/EPMenu.php

Modified: trunk/extensions/EducationProgram/EducationProgram.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.php      2012-04-05 
12:02:58 UTC (rev 114738)
+++ trunk/extensions/EducationProgram/EducationProgram.php      2012-04-05 
14:34:45 UTC (rev 114739)
@@ -122,6 +122,8 @@
 $wgAutoloadClasses['EPArticles']                                       = 
dirname( __FILE__ ) . '/includes/EPArticles.php';
 $wgAutoloadClasses['EPStudentActivityPager']           = dirname( __FILE__ ) . 
'/includes/EPStudentActivityPager.php';
 $wgAutoloadClasses['EPRevisionDiff']                           = dirname( 
__FILE__ ) . '/includes/EPRevisionDiff.php';
+$wgAutoloadClasses['EPDiffTable']                                      = 
dirname( __FILE__ ) . '/includes/EPDiffTable.php';
+$wgAutoloadClasses['EPMenu']                                           = 
dirname( __FILE__ ) . '/includes/EPMenu.php';
 
 $wgAutoloadClasses['CoursePage']                                       = 
dirname( __FILE__ ) . '/pages/CoursePage.php';
 $wgAutoloadClasses['EPPage']                                           = 
dirname( __FILE__ ) . '/pages/EPPage.php';
@@ -146,12 +148,12 @@
 
 // Compat classes
 foreach ( array(
-       'ORMResult' => 'ORMResult.php',
-       'ORMRow' => 'ORMRow.php',
-       'ORMTable' => 'ORMTable.php',
-       'CacheHelper' => 'CacheHelper.php',
-       'ICacheHelper' => 'CacheHelper.php',
-       'CachedAction' => 'CachedAction.php',
+       'ORMResult' => 'ORMResult.php', // MW < 1.20
+       'ORMRow' => 'ORMRow.php', // MW < 1.20
+       'ORMTable' => 'ORMTable.php', // MW < 1.20
+       'CacheHelper' => 'CacheHelper.php', // MW < 1.20
+       'ICacheHelper' => 'CacheHelper.php', // MW < 1.20
+       'CachedAction' => 'CachedAction.php', // MW < 1.20
        'SpecialCachedPage' => 'SpecialCachedPage.php' // MW < 1.20
        ) as $className => $fileName ) {
 

Modified: trunk/extensions/EducationProgram/actions/EPRestoreAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPRestoreAction.php       
2012-04-05 12:02:58 UTC (rev 114738)
+++ trunk/extensions/EducationProgram/actions/EPRestoreAction.php       
2012-04-05 14:34:45 UTC (rev 114739)
@@ -68,8 +68,8 @@
 
                                                if ( $diff->isValid() ) {
                                                        if ( 
$diff->hasChanges() ) {
-                                                               
$diff->setContext( $this->getContext() );
-                                                               
$diff->display();
+                                                               $diffTable = 
new EPDiffTable( $this->getContext(), $diff );
+                                                               
$diffTable->display();
 
                                                                
$this->displayForm( $object, $revision );
                                                        }

Modified: trunk/extensions/EducationProgram/actions/EPUndoAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPUndoAction.php  2012-04-05 
12:02:58 UTC (rev 114738)
+++ trunk/extensions/EducationProgram/actions/EPUndoAction.php  2012-04-05 
14:34:45 UTC (rev 114739)
@@ -68,8 +68,8 @@
 
                                                if ( $diff->isValid() ) {
                                                        if ( 
$diff->hasChanges() ) {
-                                                               
$diff->setContext( $this->getContext() );
-                                                               
$diff->display();
+                                                               $diffTable = 
new EPDiffTable( $this->getContext(), $diff );
+                                                               
$diffTable->display();
 
                                                                
$this->displayForm( $object, $revision );
                                                        }

Modified: trunk/extensions/EducationProgram/actions/EditCourseAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EditCourseAction.php      
2012-04-05 12:02:58 UTC (rev 114738)
+++ trunk/extensions/EducationProgram/actions/EditCourseAction.php      
2012-04-05 14:34:45 UTC (rev 114739)
@@ -208,7 +208,7 @@
                        'required' => true,
                        'options' => array_combine( $levels, $levels ),
                );
-XML::languageSelector()
+
                $langOptions = EPUtils::getLanguageOptions( 
$this->getLanguage()->getCode() );
                $fields['lang'] = array (
                        'type' => 'select',

Added: trunk/extensions/EducationProgram/includes/EPDiffTable.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPDiffTable.php                  
        (rev 0)
+++ trunk/extensions/EducationProgram/includes/EPDiffTable.php  2012-04-05 
14:34:45 UTC (rev 114739)
@@ -0,0 +1,72 @@
+<?php
+
+/**
+ * Utility for visualizing diffs between two revisions.
+ *
+ * @since 0.1
+ *
+ * @file EPDiffTable.php
+ * @ingroup EducationProgram
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+class EPDiffTable extends ContextSource {
+
+       /**
+        * @since 0.1
+        * @var EPRevisionDiff
+        */
+       protected $diff;
+
+       /**
+        * Constructor.
+        *
+        * @since 0.1
+        *
+        * @param IContextSource $context
+        * @param EPRevisionDiff $diff
+        */
+       public function __construct( IContextSource $context, EPRevisionDiff 
$diff ) {
+               if ( !$diff->isValid() ) {
+                       throw new MWException( 'Ivalid EPRevisionDiff passed to 
EPDiffTable.' );
+               }
+
+               $this->diff = $diff;
+
+               $this->setContext( $context );
+       }
+
+       /**
+        * Display the diff as a table.
+        *
+        * @since 0.1
+        */
+       public function display() {
+               $out = $this->getOutput();
+
+               $out->addHTML( '<table class="wikitable sortable"><tr>' );
+
+               $out->addElement( 'th', array(), '' );
+               $out->addElement( 'th', array(), $this->msg( 'ep-diff-old' 
)->plain() );
+               $out->addElement( 'th', array(), $this->msg( 'ep-diff-new' 
)->plain() );
+
+               $out->addHTML( '</tr>' );
+
+               foreach ( $this->diff->getChangedFields() as $field => $values 
) {
+                       $out->addHtml( '<tr>' );
+
+                       $source = array_key_exists( 'source', $values ) ? 
$values['source'] : '';
+                       $target = array_key_exists( 'target', $values ) ? 
$values['target'] : '';
+
+                       $out->addElement( 'th', array(), $field );
+                       $out->addElement( 'td', array(), $source );
+                       $out->addElement( 'td', array(), $target );
+
+                       $out->addHtml( '</tr>' );
+               }
+
+               $out->addHTML( '</table>' );
+       }
+
+}
\ No newline at end of file

Added: trunk/extensions/EducationProgram/includes/EPMenu.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPMenu.php                       
        (rev 0)
+++ trunk/extensions/EducationProgram/includes/EPMenu.php       2012-04-05 
14:34:45 UTC (rev 114739)
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * Education Program menu.
+ * @since 0.1
+ *
+ * @file EPMenu.php
+ * @ingroup EducationProgram
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+class EPMenu extends ContextSource {
+
+       /**
+        * Constructor.
+        *
+        * @since 0.1
+        *
+        * @param IContextSource $context
+        */
+       public function __construct( IContextSource $context ) {
+               $this->setContext( $context );
+       }
+
+       public function display() {
+               // TODO
+       }
+
+}

Modified: trunk/extensions/EducationProgram/includes/EPRevisionDiff.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPRevisionDiff.php       
2012-04-05 12:02:58 UTC (rev 114738)
+++ trunk/extensions/EducationProgram/includes/EPRevisionDiff.php       
2012-04-05 14:34:45 UTC (rev 114739)
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * Utility for visualizing diffs between two revisions.
+ * Repserents a diff between two revisions.
  *
  * @since 0.1
  *
@@ -11,10 +11,8 @@
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
  */
-class EPRevisionDiff extends ContextSource {
+class EPRevisionDiff {
 
-       protected $context;
-
        protected $changedFields = array();
 
        protected $isValid = true;
@@ -92,33 +90,6 @@
                $this->changedFields = $changedFields;
        }
 
-       public function display() {
-               $out = $this->getOutput();
-
-               $out->addHTML( '<table class="wikitable sortable"><tr>' );
-
-               $out->addElement( 'th', array(), '' );
-               $out->addElement( 'th', array(), $this->msg( 'ep-diff-old' 
)->plain() );
-               $out->addElement( 'th', array(), $this->msg( 'ep-diff-new' 
)->plain() );
-
-               $out->addHTML( '</tr>' );
-
-               foreach ( $this->changedFields as $field => $values ) {
-                       $out->addHtml( '<tr>' );
-
-                       $source = array_key_exists( 'source', $values ) ? 
$values['source'] : '';
-                       $target = array_key_exists( 'target', $values ) ? 
$values['target'] : '';
-
-                       $out->addElement( 'th', array(), $field );
-                       $out->addElement( 'td', array(), $source );
-                       $out->addElement( 'td', array(), $target );
-
-                       $out->addHtml( '</tr>' );
-               }
-
-               $out->addHTML( '</table>' );
-       }
-
        /**
         * @return array
         */


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to