Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -122,6 +122,8 @@ |
123 | 123 | $wgAutoloadClasses['EPArticles'] = dirname( __FILE__ ) . '/includes/EPArticles.php'; |
124 | 124 | $wgAutoloadClasses['EPStudentActivityPager'] = dirname( __FILE__ ) . '/includes/EPStudentActivityPager.php'; |
125 | 125 | $wgAutoloadClasses['EPRevisionDiff'] = dirname( __FILE__ ) . '/includes/EPRevisionDiff.php'; |
| 126 | +$wgAutoloadClasses['EPDiffTable'] = dirname( __FILE__ ) . '/includes/EPDiffTable.php'; |
| 127 | +$wgAutoloadClasses['EPMenu'] = dirname( __FILE__ ) . '/includes/EPMenu.php'; |
126 | 128 | |
127 | 129 | $wgAutoloadClasses['CoursePage'] = dirname( __FILE__ ) . '/pages/CoursePage.php'; |
128 | 130 | $wgAutoloadClasses['EPPage'] = dirname( __FILE__ ) . '/pages/EPPage.php'; |
— | — | @@ -146,12 +148,12 @@ |
147 | 149 | |
148 | 150 | // Compat classes |
149 | 151 | foreach ( array( |
150 | | - 'ORMResult' => 'ORMResult.php', |
151 | | - 'ORMRow' => 'ORMRow.php', |
152 | | - 'ORMTable' => 'ORMTable.php', |
153 | | - 'CacheHelper' => 'CacheHelper.php', |
154 | | - 'ICacheHelper' => 'CacheHelper.php', |
155 | | - 'CachedAction' => 'CachedAction.php', |
| 152 | + 'ORMResult' => 'ORMResult.php', // MW < 1.20 |
| 153 | + 'ORMRow' => 'ORMRow.php', // MW < 1.20 |
| 154 | + 'ORMTable' => 'ORMTable.php', // MW < 1.20 |
| 155 | + 'CacheHelper' => 'CacheHelper.php', // MW < 1.20 |
| 156 | + 'ICacheHelper' => 'CacheHelper.php', // MW < 1.20 |
| 157 | + 'CachedAction' => 'CachedAction.php', // MW < 1.20 |
156 | 158 | 'SpecialCachedPage' => 'SpecialCachedPage.php' // MW < 1.20 |
157 | 159 | ) as $className => $fileName ) { |
158 | 160 | |
Index: trunk/extensions/EducationProgram/actions/EditCourseAction.php |
— | — | @@ -208,7 +208,7 @@ |
209 | 209 | 'required' => true, |
210 | 210 | 'options' => array_combine( $levels, $levels ), |
211 | 211 | ); |
212 | | -XML::languageSelector() |
| 212 | + |
213 | 213 | $langOptions = EPUtils::getLanguageOptions( $this->getLanguage()->getCode() ); |
214 | 214 | $fields['lang'] = array ( |
215 | 215 | 'type' => 'select', |
Index: trunk/extensions/EducationProgram/actions/EPRestoreAction.php |
— | — | @@ -68,8 +68,8 @@ |
69 | 69 | |
70 | 70 | if ( $diff->isValid() ) { |
71 | 71 | if ( $diff->hasChanges() ) { |
72 | | - $diff->setContext( $this->getContext() ); |
73 | | - $diff->display(); |
| 72 | + $diffTable = new EPDiffTable( $this->getContext(), $diff ); |
| 73 | + $diffTable->display(); |
74 | 74 | |
75 | 75 | $this->displayForm( $object, $revision ); |
76 | 76 | } |
Index: trunk/extensions/EducationProgram/actions/EPUndoAction.php |
— | — | @@ -68,8 +68,8 @@ |
69 | 69 | |
70 | 70 | if ( $diff->isValid() ) { |
71 | 71 | if ( $diff->hasChanges() ) { |
72 | | - $diff->setContext( $this->getContext() ); |
73 | | - $diff->display(); |
| 72 | + $diffTable = new EPDiffTable( $this->getContext(), $diff ); |
| 73 | + $diffTable->display(); |
74 | 74 | |
75 | 75 | $this->displayForm( $object, $revision ); |
76 | 76 | } |
Index: trunk/extensions/EducationProgram/includes/EPMenu.php |
— | — | @@ -0,0 +1,30 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Education Program menu. |
| 6 | + * @since 0.1 |
| 7 | + * |
| 8 | + * @file EPMenu.php |
| 9 | + * @ingroup EducationProgram |
| 10 | + * |
| 11 | + * @licence GNU GPL v2+ |
| 12 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 13 | + */ |
| 14 | +class EPMenu extends ContextSource { |
| 15 | + |
| 16 | + /** |
| 17 | + * Constructor. |
| 18 | + * |
| 19 | + * @since 0.1 |
| 20 | + * |
| 21 | + * @param IContextSource $context |
| 22 | + */ |
| 23 | + public function __construct( IContextSource $context ) { |
| 24 | + $this->setContext( $context ); |
| 25 | + } |
| 26 | + |
| 27 | + public function display() { |
| 28 | + // TODO |
| 29 | + } |
| 30 | + |
| 31 | +} |
Index: trunk/extensions/EducationProgram/includes/EPDiffTable.php |
— | — | @@ -0,0 +1,72 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Utility for visualizing diffs between two revisions. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file EPDiffTable.php |
| 10 | + * @ingroup EducationProgram |
| 11 | + * |
| 12 | + * @licence GNU GPL v2+ |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | +class EPDiffTable extends ContextSource { |
| 16 | + |
| 17 | + /** |
| 18 | + * @since 0.1 |
| 19 | + * @var EPRevisionDiff |
| 20 | + */ |
| 21 | + protected $diff; |
| 22 | + |
| 23 | + /** |
| 24 | + * Constructor. |
| 25 | + * |
| 26 | + * @since 0.1 |
| 27 | + * |
| 28 | + * @param IContextSource $context |
| 29 | + * @param EPRevisionDiff $diff |
| 30 | + */ |
| 31 | + public function __construct( IContextSource $context, EPRevisionDiff $diff ) { |
| 32 | + if ( !$diff->isValid() ) { |
| 33 | + throw new MWException( 'Ivalid EPRevisionDiff passed to EPDiffTable.' ); |
| 34 | + } |
| 35 | + |
| 36 | + $this->diff = $diff; |
| 37 | + |
| 38 | + $this->setContext( $context ); |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Display the diff as a table. |
| 43 | + * |
| 44 | + * @since 0.1 |
| 45 | + */ |
| 46 | + public function display() { |
| 47 | + $out = $this->getOutput(); |
| 48 | + |
| 49 | + $out->addHTML( '<table class="wikitable sortable"><tr>' ); |
| 50 | + |
| 51 | + $out->addElement( 'th', array(), '' ); |
| 52 | + $out->addElement( 'th', array(), $this->msg( 'ep-diff-old' )->plain() ); |
| 53 | + $out->addElement( 'th', array(), $this->msg( 'ep-diff-new' )->plain() ); |
| 54 | + |
| 55 | + $out->addHTML( '</tr>' ); |
| 56 | + |
| 57 | + foreach ( $this->diff->getChangedFields() as $field => $values ) { |
| 58 | + $out->addHtml( '<tr>' ); |
| 59 | + |
| 60 | + $source = array_key_exists( 'source', $values ) ? $values['source'] : ''; |
| 61 | + $target = array_key_exists( 'target', $values ) ? $values['target'] : ''; |
| 62 | + |
| 63 | + $out->addElement( 'th', array(), $field ); |
| 64 | + $out->addElement( 'td', array(), $source ); |
| 65 | + $out->addElement( 'td', array(), $target ); |
| 66 | + |
| 67 | + $out->addHtml( '</tr>' ); |
| 68 | + } |
| 69 | + |
| 70 | + $out->addHTML( '</table>' ); |
| 71 | + } |
| 72 | + |
| 73 | +} |
\ No newline at end of file |
Index: trunk/extensions/EducationProgram/includes/EPRevisionDiff.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * Utility for visualizing diffs between two revisions. |
| 5 | + * Repserents a diff between two revisions. |
6 | 6 | * |
7 | 7 | * @since 0.1 |
8 | 8 | * |
— | — | @@ -11,10 +11,8 @@ |
12 | 12 | * @licence GNU GPL v2+ |
13 | 13 | * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
14 | 14 | */ |
15 | | -class EPRevisionDiff extends ContextSource { |
| 15 | +class EPRevisionDiff { |
16 | 16 | |
17 | | - protected $context; |
18 | | - |
19 | 17 | protected $changedFields = array(); |
20 | 18 | |
21 | 19 | protected $isValid = true; |
— | — | @@ -92,33 +90,6 @@ |
93 | 91 | $this->changedFields = $changedFields; |
94 | 92 | } |
95 | 93 | |
96 | | - public function display() { |
97 | | - $out = $this->getOutput(); |
98 | | - |
99 | | - $out->addHTML( '<table class="wikitable sortable"><tr>' ); |
100 | | - |
101 | | - $out->addElement( 'th', array(), '' ); |
102 | | - $out->addElement( 'th', array(), $this->msg( 'ep-diff-old' )->plain() ); |
103 | | - $out->addElement( 'th', array(), $this->msg( 'ep-diff-new' )->plain() ); |
104 | | - |
105 | | - $out->addHTML( '</tr>' ); |
106 | | - |
107 | | - foreach ( $this->changedFields as $field => $values ) { |
108 | | - $out->addHtml( '<tr>' ); |
109 | | - |
110 | | - $source = array_key_exists( 'source', $values ) ? $values['source'] : ''; |
111 | | - $target = array_key_exists( 'target', $values ) ? $values['target'] : ''; |
112 | | - |
113 | | - $out->addElement( 'th', array(), $field ); |
114 | | - $out->addElement( 'td', array(), $source ); |
115 | | - $out->addElement( 'td', array(), $target ); |
116 | | - |
117 | | - $out->addHtml( '</tr>' ); |
118 | | - } |
119 | | - |
120 | | - $out->addHTML( '</table>' ); |
121 | | - } |
122 | | - |
123 | 94 | /** |
124 | 95 | * @return array |
125 | 96 | */ |