r111709 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111708‎ | r111709 | r111710 >
Date:01:25, 17 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on student article table
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPArticle.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPArticleTable.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPArticleTable.php
@@ -73,9 +73,6 @@
7474 return 'TablePager ep-students';
7575 }
7676
77 - protected $currentArticleKey = 0;
78 -
79 -
8077 /**
8178 * (non-PHPdoc)
8279 * @see TablePager::formatRow()
@@ -107,34 +104,38 @@
108105
109106 $reviewers = $article->getField( 'reviewers' );
110107
111 - $html .= Html::rawElement(
112 - 'td',
113 - array_merge(
114 - $this->getCellAttrs( 'articles', $article ),
115 - array( 'rowspan' => max( 1, count( $reviewers ) ) )
116 - ),
117 - serialize( $article ) // TODO
118 - );
 108+ $html .= $this->getArticleCell( $article, max( 1, count( $reviewers ) ) );
119109
120110 foreach ( $reviewers as $nr => $userId ) {
121111 if ( $nr !== 0 ) {
122112 $html .= '</tr><tr>';
123113 }
124114
125 - $html .= Html::rawElement(
126 - 'td',
127 - $this->getCellAttrs( 'reviewers', $userId ),
128 - $userId // TODO
129 - );
 115+ $html .= $this->getReviewerCell( $article, $userId );
130116 }
 117+
 118+ // TODO: add reviewer adittion control for reviewers
131119 }
132120
 121+ // TODO: add article adittion control for student
 122+
133123 $html .= '</tr>';
134124
135125 return $html;
136126 }
137127
 128+ /**
 129+ * Returns the HTML for a user cell.
 130+ *
 131+ * @since 0.1
 132+ *
 133+ * @param integer $userId
 134+ * @param integer $rowSpan
 135+ *
 136+ * @return string
 137+ */
138138 protected function getUserCell( $userId, $rowSpan ) {
 139+ // TODO: add student removal control for instructors
139140 $user = User::newFromId( $userId );
140141 $name = $user->getRealName() === '' ? $user->getName() : $user->getRealName();
141142
@@ -148,8 +149,56 @@
149150 );
150151 }
151152
 153+ /**
 154+ * Returns the HTML for an article cell.
 155+ *
 156+ * @since 0.1
 157+ *
 158+ * @param EPArticle $article
 159+ * @param integer $rowSpan
 160+ *
 161+ * @return string
 162+ */
 163+ protected function getArticleCell( EPArticle $article, $rowSpan ) {
 164+ // TODO: add article removal control for student
152165
 166+ return Html::rawElement(
 167+ 'td',
 168+ array_merge(
 169+ $this->getCellAttrs( 'articles', $article ),
 170+ array( 'rowspan' => $rowSpan )
 171+ ),
 172+ Linker::link(
 173+ $article->getTitle(),
 174+ htmlspecialchars( $article->getTitle()->getFullText() )
 175+ )
 176+ );
 177+ }
 178+
153179 /**
 180+ * Returns the HTML for a reviewer cell.
 181+ *
 182+ * @since 0.1
 183+ *
 184+ * @param EPArticle $article
 185+ * @param integer $userId
 186+ *
 187+ * @return string
 188+ */
 189+ protected function getReviewerCell( EPArticle $article, $userId ) {
 190+ // TODO: add reviewer removal control reviewer and instructors
 191+ $user = User::newFromId( $userId );
 192+ $name = $user->getRealName() === '' ? $user->getName() : $user->getRealName();
 193+
 194+ return Html::rawElement(
 195+ 'td',
 196+ $this->getCellAttrs( 'reviewers', $userId ),
 197+ Linker::userLink( $userId, $name ) . Linker::userToolLinks( $userId, $name )
 198+ );
 199+ }
 200+
 201+
 202+ /**
154203 * (non-PHPdoc)
155204 * @see EPPager::getFormattedValue()
156205 */
@@ -198,9 +247,9 @@
199248 while( $student = $this->mResult->fetchObject() ) {
200249 $field = EPStudents::singleton()->getPrefixedField( 'user_id' );
201250 $userIds[] = $student->$field;
202 - $this->articles[$student->$field] = array(
203 - EPArticles::singleton()->newFromArray( array( 'page_id' => 1, 'reviewers' => array( 'rev 0', 'rev 1' ) ) ),
204 - EPArticles::singleton()->newFromArray( array( 'page_id' => 2, 'reviewers' => array( 'rev 2', 'rev 3' ) ) ),
 251+ $this->articles[$student->$field] = array( // TODO
 252+ EPArticles::singleton()->newFromArray( array( 'page_id' => 1, 'reviewers' => array( 1, 1 ) ) ),
 253+ EPArticles::singleton()->newFromArray( array( 'page_id' => 2, 'reviewers' => array( 1, 1 ) ) ),
205254 );
206255 }
207256
Index: trunk/extensions/EducationProgram/includes/EPArticle.php
@@ -23,10 +23,18 @@
2424 protected $user = false;
2525
2626 /**
27 - * Returns the user that authored this revision.
 27+ * Cached title object for this revision.
2828 *
2929 * @since 0.1
 30+ * @var Title|false
 31+ */
 32+ protected $title = false;
 33+
 34+ /**
 35+ * Returns the user that is working on this article.
3036 *
 37+ * @since 0.1
 38+ *
3139 * @return User
3240 */
3341 public function getUser() {
@@ -63,4 +71,19 @@
6472 }
6573 }
6674
 75+ /**
 76+ * Returns the title of this article.
 77+ *
 78+ * @since 0.1
 79+ *
 80+ * @return Title
 81+ */
 82+ public function getTitle() {
 83+ if ( $this->title === false ) {
 84+ $this->title = Title::newFromID( $this->getField( 'page_id' ) );
 85+ }
 86+
 87+ return $this->title;
 88+ }
 89+
6790 }

Status & tagging log