Index: trunk/extensions/EducationProgram/compat/SpecialCachedPage.php |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | * @return string |
82 | 82 | */ |
83 | 83 | protected function getCachedNotice( $subPage ) { |
84 | | - $refreshArgs = $_GET; |
| 84 | + $refreshArgs = $this->getRequest()->getQueryValues(); |
85 | 85 | unset( $refreshArgs['title'] ); |
86 | 86 | $refreshArgs['action'] = 'purge'; |
87 | 87 | |
— | — | @@ -91,7 +91,7 @@ |
92 | 92 | $refreshArgs |
93 | 93 | ); |
94 | 94 | |
95 | | - if ( $this->cacheExpiry < 1000000000 ) { |
| 95 | + if ( $this->cacheExpiry < 86400 * 3650 ) { |
96 | 96 | $message = $this->msg( |
97 | 97 | 'cachedspecial-viewing-cached-ttl', |
98 | 98 | $this->getDurationText( $this->cacheExpiry ) |
Index: trunk/extensions/EducationProgram/EducationProgram.settings.php |
— | — | @@ -50,6 +50,8 @@ |
51 | 51 | 'US' => 'Flag_of_the_United_States.svg', |
52 | 52 | ), |
53 | 53 | 'fallbackFlag' => 'Nuvola unknown flag.svg', |
| 54 | + 'courseDescPage' => 'Course description', |
| 55 | + 'courseOrgDescPage' => '$2/$1', // $1 = org name, $2 = courseDescPage setting |
54 | 56 | ); |
55 | 57 | } |
56 | 58 | |
Index: trunk/extensions/EducationProgram/actions/EditCourseAction.php |
— | — | @@ -252,6 +252,13 @@ |
253 | 253 | ); |
254 | 254 | |
255 | 255 | $data['term'] = $this->getRequest()->getVal( 'newterm' ); |
| 256 | + |
| 257 | + $data['description'] = $this->getDefaultDescription( array( |
| 258 | + 'institutionid' => $data['org_id'], |
| 259 | + 'name' => $data['mc'], |
| 260 | + 'title' => $data['name'], |
| 261 | + 'term' => $data['term'], |
| 262 | + ) ); |
256 | 263 | } |
257 | 264 | |
258 | 265 | return $data; |
— | — | @@ -268,5 +275,57 @@ |
269 | 276 | |
270 | 277 | return $value; |
271 | 278 | } |
| 279 | + |
| 280 | + /** |
| 281 | + * Returns the description to use as default, based |
| 282 | + * on the courseDescPage and courseOrgDescPage settings. |
| 283 | + * |
| 284 | + * @since 0.1 |
| 285 | + * |
| 286 | + * @param array $data |
| 287 | + * |
| 288 | + * @return string |
| 289 | + */ |
| 290 | + protected function getDefaultDescription( array $data ) { |
| 291 | + $primaryPage = EPSettings::get( 'courseDescPage' ); |
| 292 | + $orgPage = EPSettings::get( 'courseOrgDescPage' ); |
| 293 | + |
| 294 | + $orgTitle = EPOrgs::singleton()->selectFieldsRow( 'name', array( 'id' => $data['institutionid'] ) ); |
| 295 | + |
| 296 | + $content = false; |
| 297 | + |
| 298 | + if ( $orgTitle !== false ) { |
| 299 | + $orgPage = str_replace( |
| 300 | + array( '$1', '$2' ), |
| 301 | + array( $orgTitle, $primaryPage ), |
| 302 | + $orgPage |
| 303 | + ); |
| 304 | + |
| 305 | + $content = EPUtils::getArticleContent( $orgPage ); |
| 306 | + } |
| 307 | + |
| 308 | + if ( $content === false ) { |
| 309 | + $content = EPUtils::getArticleContent( $primaryPage ); |
| 310 | + } |
| 311 | + |
| 312 | + if ( $content === false ) { |
| 313 | + $content = ''; |
| 314 | + } |
| 315 | + else { |
| 316 | + if ( $orgTitle !== false ) { |
| 317 | + $data['institution'] = $orgTitle; |
| 318 | + } |
| 319 | + |
| 320 | + $content = str_replace( |
| 321 | + array_map( function( $name ) { |
| 322 | + return '{{{' . $name . '}}}'; |
| 323 | + }, array_keys( $data ) ), |
| 324 | + $data, |
| 325 | + $content |
| 326 | + ); |
| 327 | + } |
| 328 | + |
| 329 | + return $content; |
| 330 | + } |
272 | 331 | |
273 | 332 | } |
\ No newline at end of file |
Index: trunk/extensions/EducationProgram/includes/EPUtils.php |
— | — | @@ -249,5 +249,25 @@ |
250 | 250 | $req->setSessionData( 'epfail', false ); |
251 | 251 | } |
252 | 252 | } |
| 253 | + /** |
| 254 | + * Gets the content of the article with the provided page name, |
| 255 | + * or an empty string when there is no such article. |
| 256 | + * |
| 257 | + * @since 0.1 |
| 258 | + * |
| 259 | + * @param string $pageName |
| 260 | + * |
| 261 | + * @return string|false |
| 262 | + */ |
| 263 | + public static function getArticleContent( $pageName ) { |
| 264 | + $title = Title::newFromText( $pageName ); |
253 | 265 | |
| 266 | + if ( is_null( $title ) ) { |
| 267 | + return ''; |
| 268 | + } |
| 269 | + |
| 270 | + $article = new Article( $title, 0 ); |
| 271 | + return $article->fetchContent(); |
| 272 | + } |
| 273 | + |
254 | 274 | } |