Index: trunk/extensions/EducationProgram/includes/EPArticleTable.php |
— | — | @@ -73,9 +73,6 @@ |
74 | 74 | return 'TablePager ep-students'; |
75 | 75 | } |
76 | 76 | |
77 | | - protected $currentArticleKey = 0; |
78 | | - |
79 | | - |
80 | 77 | /** |
81 | 78 | * (non-PHPdoc) |
82 | 79 | * @see TablePager::formatRow() |
— | — | @@ -107,34 +104,38 @@ |
108 | 105 | |
109 | 106 | $reviewers = $article->getField( 'reviewers' ); |
110 | 107 | |
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 ) ) ); |
119 | 109 | |
120 | 110 | foreach ( $reviewers as $nr => $userId ) { |
121 | 111 | if ( $nr !== 0 ) { |
122 | 112 | $html .= '</tr><tr>'; |
123 | 113 | } |
124 | 114 | |
125 | | - $html .= Html::rawElement( |
126 | | - 'td', |
127 | | - $this->getCellAttrs( 'reviewers', $userId ), |
128 | | - $userId // TODO |
129 | | - ); |
| 115 | + $html .= $this->getReviewerCell( $article, $userId ); |
130 | 116 | } |
| 117 | + |
| 118 | + // TODO: add reviewer adittion control for reviewers |
131 | 119 | } |
132 | 120 | |
| 121 | + // TODO: add article adittion control for student |
| 122 | + |
133 | 123 | $html .= '</tr>'; |
134 | 124 | |
135 | 125 | return $html; |
136 | 126 | } |
137 | 127 | |
| 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 | + */ |
138 | 138 | protected function getUserCell( $userId, $rowSpan ) { |
| 139 | + // TODO: add student removal control for instructors |
139 | 140 | $user = User::newFromId( $userId ); |
140 | 141 | $name = $user->getRealName() === '' ? $user->getName() : $user->getRealName(); |
141 | 142 | |
— | — | @@ -148,8 +149,56 @@ |
149 | 150 | ); |
150 | 151 | } |
151 | 152 | |
| 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 |
152 | 165 | |
| 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 | + |
153 | 179 | /** |
| 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 | + /** |
154 | 203 | * (non-PHPdoc) |
155 | 204 | * @see EPPager::getFormattedValue() |
156 | 205 | */ |
— | — | @@ -198,9 +247,9 @@ |
199 | 248 | while( $student = $this->mResult->fetchObject() ) { |
200 | 249 | $field = EPStudents::singleton()->getPrefixedField( 'user_id' ); |
201 | 250 | $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 ) ) ), |
205 | 254 | ); |
206 | 255 | } |
207 | 256 | |
Index: trunk/extensions/EducationProgram/includes/EPArticle.php |
— | — | @@ -23,10 +23,18 @@ |
24 | 24 | protected $user = false; |
25 | 25 | |
26 | 26 | /** |
27 | | - * Returns the user that authored this revision. |
| 27 | + * Cached title object for this revision. |
28 | 28 | * |
29 | 29 | * @since 0.1 |
| 30 | + * @var Title|false |
| 31 | + */ |
| 32 | + protected $title = false; |
| 33 | + |
| 34 | + /** |
| 35 | + * Returns the user that is working on this article. |
30 | 36 | * |
| 37 | + * @since 0.1 |
| 38 | + * |
31 | 39 | * @return User |
32 | 40 | */ |
33 | 41 | public function getUser() { |
— | — | @@ -63,4 +71,19 @@ |
64 | 72 | } |
65 | 73 | } |
66 | 74 | |
| 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 | + |
67 | 90 | } |