r111848 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111847‎ | r111848 | r111849 >
Date:23:54, 18 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on article table
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.hooks.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php (added) (history)
  • /trunk/extensions/EducationProgram/includes/EPArticleTable.php (modified) (history)
  • /trunk/extensions/EducationProgram/resources/ep.articletable.js (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -64,6 +64,7 @@
6565 $wgAutoloadClasses['EditOrgAction'] = dirname( __FILE__ ) . '/actions/EditOrgAction.php';
6666 $wgAutoloadClasses['EPEditAction'] = dirname( __FILE__ ) . '/actions/EPEditAction.php';
6767 $wgAutoloadClasses['EPHistoryAction'] = dirname( __FILE__ ) . '/actions/EPHistoryAction.php';
 68+$wgAutoloadClasses['EPRemoveArticleAction'] = dirname( __FILE__ ) . '/actions/EPRemoveArticleAction.php';
6869 $wgAutoloadClasses['EPViewAction'] = dirname( __FILE__ ) . '/actions/EPViewAction.php';
6970 $wgAutoloadClasses['OrgHistoryAction'] = dirname( __FILE__ ) . '/actions/OrgHistoryAction.php';
7071 $wgAutoloadClasses['ViewCourseAction'] = dirname( __FILE__ ) . '/actions/ViewCourseAction.php';
@@ -185,7 +186,11 @@
186187 $wgHooks['ArticleFromTitle'][] = 'EPHooks::onArticleFromTitle';
187188 $wgHooks['CanonicalNamespaces'][] = 'EPHooks::onCanonicalNamespaces';
188189 $wgHooks['TitleIsAlwaysKnown'][] = 'EPHooks::onTitleIsAlwaysKnown';
 190+$wgHooks['UnknownAction'][] = 'EPHooks::onUnknownAction';
189191
 192+// Actions
 193+$wgActions['epremarticle'] = 'EPRemoveArticleAction';
 194+
190195 // Logging
191196 $wgLogTypes[] = 'institution';
192197 $wgLogTypes[] = 'course';
Index: trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php
@@ -0,0 +1,45 @@
 2+<?php
 3+
 4+/**
 5+ *
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file EPRemoveArticleAction.php
 10+ * @ingroup EducationProgram
 11+ * @ingroup Action
 12+ *
 13+ * @licence GNU GPL v3+
 14+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 15+ */
 16+class EPRemoveArticleAction extends FormlessAction {
 17+
 18+ /**
 19+ * (non-PHPdoc)
 20+ * @see Action::getName()
 21+ */
 22+ public function getName() {
 23+ return 'epremarticle';
 24+ }
 25+
 26+ /**
 27+ * (non-PHPdoc)
 28+ * @see FormlessAction::onView()
 29+ */
 30+ public function onView() {
 31+ $req = $this->getRequest();
 32+ $user = $this->getUser();
 33+
 34+ if ( $user->matchEditToken( $req->getText( 'token' ), 'remarticle' . $req->getInt( 'article-id' ) ) ) {
 35+ EPArticles::singleton()->delete( array(
 36+ 'id' => $req->getInt( 'article-id' ),
 37+ 'user_id' => $user->getId(),
 38+ ) );
 39+ }
 40+
 41+ Action::factory( 'view', $this->page, $this->context )->show();
 42+ return '';
 43+ }
 44+
 45+
 46+}
\ No newline at end of file
Index: trunk/extensions/EducationProgram/includes/EPArticleTable.php
@@ -217,6 +217,7 @@
218218 'data-course-id' => $this->articleConds['course_id'],
219219 'data-user-name' => $name,
220220 'data-course-name' => $this->getCourseName(),
 221+ 'data-token' => $this->getUser()->getEditToken( $this->articleConds['course_id'] . 'remstudent' . $userId ),
221222 'class' => 'ep-rem-student',
222223 ),
223224 wfMsg( 'ep-artciles-remstudent' )
@@ -262,7 +263,7 @@
263264 * @param integer $rowSpan
264265 *
265266 * @return string
266 - */-
 267+ */
267268 protected function getArticleCell( EPArticle $article, $rowSpan ) {
268269 $html = Linker::link(
269270 $article->getTitle(),
@@ -273,6 +274,7 @@
274275 'href' => '#',
275276 'data-article-id' => $article->getId(),
276277 'data-article-name' => $article->getTitle()->getFullText(),
 278+ 'data-token' => $this->getUser()->getEditToken( 'remarticle' . $article->getId() ),
277279 'class' => 'ep-rem-article',
278280 );
279281
@@ -329,6 +331,7 @@
330332 'data-student-name' => $article->getUser()->getName(),
331333 'data-reviewer-name' => $user->getName(),
332334 'data-reviewer-id' => $user->getId(),
 335+ 'data-token' => $this->getUser()->getEditToken( $userId . 'remreviewer' . $article->getId() ),
333336 'class' => 'ep-rem-reviewer',
334337 ),
335338 wfMsg( 'ep-artciles-remreviewer' )
@@ -346,6 +349,7 @@
347350 'data-article-id' => $article->getId(),
348351 'data-article-name' => $article->getField( 'name' ),
349352 'data-student-name' => $article->getUser()->getName(),
 353+ 'data-token' => $this->getUser()->getEditToken( $userId . 'remreviewer' . $article->getId() ),
350354 ),
351355 wfMsg( 'ep-artciles-remreviewer-self' )
352356 );
@@ -421,6 +425,7 @@
422426 'data-article-id' => $article->getId(),
423427 'data-article-name' => $article->getTitle()->getFullText(),
424428 'data-user-name' => $article->getUser()->getName(),
 429+ 'data-token' => $this->getUser()->getEditToken( 'addreviewer' . $article->getId() ),
425430 ),
426431 wfMsg( 'ep-artciles-becomereviewer' )
427432 );
Index: trunk/extensions/EducationProgram/resources/ep.articletable.js
@@ -29,6 +29,12 @@
3030
3131 $form.append( $( '<input>' ).attr( {
3232 'type': 'hidden',
 33+ 'name': 'token',
 34+ 'value': $this.attr( 'data-token' )
 35+ } ) );
 36+
 37+ $form.append( $( '<input>' ).attr( {
 38+ 'type': 'hidden',
3339 'name': 'article-id',
3440 'value': $this.attr( 'data-article-id' )
3541 } ) );
@@ -78,6 +84,12 @@
7985
8086 $form.append( $( '<input>' ).attr( {
8187 'type': 'hidden',
 88+ 'name': 'token',
 89+ 'value': $this.attr( 'data-token' )
 90+ } ) );
 91+
 92+ $form.append( $( '<input>' ).attr( {
 93+ 'type': 'hidden',
8294 'name': 'user-id',
8395 'value': $this.attr( 'data-user-id' )
8496 } ) );
@@ -133,6 +145,12 @@
134146
135147 $form.append( $( '<input>' ).attr( {
136148 'type': 'hidden',
 149+ 'name': 'token',
 150+ 'value': $this.attr( 'data-token' )
 151+ } ) );
 152+
 153+ $form.append( $( '<input>' ).attr( {
 154+ 'type': 'hidden',
137155 'name': 'article-id',
138156 'value': $this.attr( 'data-article-id' )
139157 } ) );
@@ -186,6 +204,12 @@
187205
188206 $form.append( $( '<input>' ).attr( {
189207 'type': 'hidden',
 208+ 'name': 'token',
 209+ 'value': $this.attr( 'data-token' )
 210+ } ) );
 211+
 212+ $form.append( $( '<input>' ).attr( {
 213+ 'type': 'hidden',
190214 'name': 'article-id',
191215 'value': $this.attr( 'data-article-id' )
192216 } ) );
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php
@@ -316,5 +316,20 @@
317317
318318 return true;
319319 }
320 -
 320+
 321+ /**
 322+ * Used to add new query-string actions.
 323+ * @see https://www.mediawiki.org/wiki/Manual:Hooks/UnknownAction
 324+ *
 325+ * @since 0.1
 326+ *
 327+ * @param string $action
 328+ * @param Page $page
 329+ *
 330+ * @return true
 331+ */
 332+ public static function onUnknownAction( $action, Page $page ) {
 333+ return true;
 334+ }
 335+
321336 }

Status & tagging log