| Index: trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.body.php |
| — | — | @@ -76,11 +76,11 @@ |
| 77 | 77 | |
| 78 | 78 | if ( self::$isFilePage && self::$acceptBilling !== 'yes' ) { |
| 79 | 79 | $acceptBillingYes = Html::rawElement( 'a', |
| 80 | | - array('href' => $wgRequest->appendQuery( 'renderZeroRatedBanner=true&acceptbilling=yes' ) ), |
| | 80 | + array( 'href' => $wgRequest->appendQuery( 'renderZeroRatedBanner=true&acceptbilling=yes' ) ), |
| 81 | 81 | wfMsg( 'zero-rated-mobile-access-banner-text-data-charges-yes' ) ); |
| 82 | 82 | $referrer = $wgRequest->getHeader( 'referer' ); |
| 83 | 83 | $acceptBillingNo = Html::rawElement( 'a', |
| 84 | | - array('href' => $wgRequest->appendQuery( 'acceptbilling=no&returnto=' . urlencode( $referrer ) ) ), |
| | 84 | + array( 'href' => $wgRequest->appendQuery( 'acceptbilling=no&returnto=' . urlencode( $referrer ) ) ), |
| 85 | 85 | wfMsg( 'zero-rated-mobile-access-banner-text-data-charges-no' ) ); |
| 86 | 86 | $bannerText = Html::rawElement( 'h3', |
| 87 | 87 | array( 'id' => 'zero-rated-banner-text' ), |
| — | — | @@ -93,11 +93,11 @@ |
| 94 | 94 | } elseif ( self::$renderZeroRatedRedirect === true ) { |
| 95 | 95 | $returnto = $wgRequest->getVal( 'returnto' ); |
| 96 | 96 | $acceptBillingYes = Html::rawElement( 'a', |
| 97 | | - array('href' => $wgRequest->appendQuery( 'renderZeroRatedBanner=true&acceptbilling=yes&returnto=' . urlencode( $returnto ) ) ), |
| | 97 | + array( 'href' => $wgRequest->appendQuery( 'renderZeroRatedBanner=true&acceptbilling=yes&returnto=' . urlencode( $returnto ) ) ), |
| 98 | 98 | wfMsg( 'zero-rated-mobile-access-banner-text-data-charges-yes' ) ); |
| 99 | 99 | $referrer = $wgRequest->getHeader( 'referer' ); |
| 100 | 100 | $acceptBillingNo = Html::rawElement( 'a', |
| 101 | | - array('href' => $wgRequest->appendQuery( 'acceptbilling=no&returnto=' . urlencode( $referrer ) ) ), |
| | 101 | + array( 'href' => $wgRequest->appendQuery( 'acceptbilling=no&returnto=' . urlencode( $referrer ) ) ), |
| 102 | 102 | wfMsg( 'zero-rated-mobile-access-banner-text-data-charges-no' ) ); |
| 103 | 103 | $bannerText = Html::rawElement( 'h3', |
| 104 | 104 | array( 'id' => 'zero-rated-banner-text' ), |
| — | — | @@ -147,7 +147,7 @@ |
| 148 | 148 | self::addDebugOutput( $country ); |
| 149 | 149 | } |
| 150 | 150 | $languageOptions = self::createLanguageOptionsFromWikiText(); |
| 151 | | - //self::$displayDebugOutput = true; |
| | 151 | + // self::$displayDebugOutput = true; |
| 152 | 152 | $languagesForCountry = ( isset( $languageOptions[self::getFullCountryNameFromCode( $country )] ) ) ? |
| 153 | 153 | $languageOptions[self::getFullCountryNameFromCode( $country )] : null; |
| 154 | 154 | self::addDebugOutput( self::getFullCountryNameFromCode( $country ) ); |
| — | — | @@ -206,7 +206,7 @@ |
| 207 | 207 | |
| 208 | 208 | /** |
| 209 | 209 | * Returns information about carrier |
| 210 | | - * |
| | 210 | + * |
| 211 | 211 | * @param String $carrier: Name of carrier e.g., "Verizon Wireless" |
| 212 | 212 | * @return Array |
| 213 | 213 | */ |
| — | — | @@ -229,7 +229,7 @@ |
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | 232 | * Returns the Html of a page with the various links appended with zeropartner parameter |
| 233 | | - * |
| | 233 | + * |
| 234 | 234 | * @param String $html: Html of current page |
| 235 | 235 | * @return String |
| 236 | 236 | */ |
| — | — | @@ -283,7 +283,7 @@ |
| 284 | 284 | $zeroPartnerUrl = wfAppendQuery( $zeroRatedLinkHref, |
| 285 | 285 | array( 'zeropartner' => $partnerId, 'renderZeroRatedBanner' => 'true' ) ); |
| 286 | 286 | if ( $zeroPartnerUrl ) { |
| 287 | | - $zeroRatedExternalLink->setAttribute( 'href', '?renderZeroRatedRedirect=true&returnto=' . urlencode($zeroRatedExternalLinkHref) ); |
| | 287 | + $zeroRatedExternalLink->setAttribute( 'href', '?renderZeroRatedRedirect=true&returnto=' . urlencode( $zeroRatedExternalLinkHref ) ); |
| 288 | 288 | } |
| 289 | 289 | } |
| 290 | 290 | } |
| — | — | @@ -295,7 +295,7 @@ |
| 296 | 296 | |
| 297 | 297 | /** |
| 298 | 298 | * Adds object to debugOutput Array |
| 299 | | - * |
| | 299 | + * |
| 300 | 300 | * @param Object $object: any valid PHP object |
| 301 | 301 | * @return bool |
| 302 | 302 | */ |
| — | — | @@ -317,7 +317,7 @@ |
| 318 | 318 | wfProfileIn( __METHOD__ ); |
| 319 | 319 | if ( self::$debugOutput && self::$displayDebugOutput === true ) { |
| 320 | 320 | echo "<pre>"; |
| 321 | | - foreach( self::$debugOutput as $debugOutput ) { |
| | 321 | + foreach ( self::$debugOutput as $debugOutput ) { |
| 322 | 322 | var_dump( $debugOutput ); |
| 323 | 323 | } |
| 324 | 324 | echo "</pre>"; |
| — | — | @@ -328,7 +328,7 @@ |
| 329 | 329 | |
| 330 | 330 | /** |
| 331 | 331 | * Returns the carrier options array parsed from a valid wiki page |
| 332 | | - * |
| | 332 | + * |
| 333 | 333 | * @return Array |
| 334 | 334 | */ |
| 335 | 335 | private static function createCarrierOptionsFromWikiText() { |
| — | — | @@ -365,7 +365,7 @@ |
| 366 | 366 | if ( $i % 3 === 1 ) { |
| 367 | 367 | $carrierOptions[$carrierName]['url'] = trim( str_replace( '** ', '', $line ) ); |
| 368 | 368 | $carrierLink = Html::rawElement( 'a', |
| 369 | | - array('href' => $carrierOptions[$carrierName]['url'] ), |
| | 369 | + array( 'href' => $carrierOptions[$carrierName]['url'] ), |
| 370 | 370 | $carrierOptions[$carrierName]['name'] ); |
| 371 | 371 | $carrierOptions[$carrierName]['link'] = $carrierLink; |
| 372 | 372 | } elseif ( $i % 3 === 2 ) { |
| — | — | @@ -382,7 +382,7 @@ |
| 383 | 383 | |
| 384 | 384 | /** |
| 385 | 385 | * Returns the foreign wiki options array from a valid wiki page |
| 386 | | - * |
| | 386 | + * |
| 387 | 387 | * @return Array |
| 388 | 388 | */ |
| 389 | 389 | private static function getOptionsFromForeignWiki( $pageName ) { |
| — | — | @@ -421,7 +421,7 @@ |
| 422 | 422 | $key = null; |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | | - foreach( $jsonData['query']['pages'] as $pages ) { |
| | 425 | + foreach ( $jsonData['query']['pages'] as $pages ) { |
| 426 | 426 | if ( isset( $pages['revisions'][0]['*'] ) ) { |
| 427 | 427 | $rev = $pages['revisions'][0]['*']; |
| 428 | 428 | } |
| — | — | @@ -473,7 +473,7 @@ |
| 474 | 474 | $countryName = strtoupper( str_replace( '* ', '', $line ) ); |
| 475 | 475 | $languageOptions[$countryName] = ''; |
| 476 | 476 | } elseif ( strpos( $line, '**' ) === 0 && $i > 0 ) { |
| 477 | | - $lineParts = explode('#', $line); |
| | 477 | + $lineParts = explode( '#', $line ); |
| 478 | 478 | $language = ( isset( $lineParts[0] ) ) ? |
| 479 | 479 | trim( str_replace( '** ', '', $lineParts[0] ) ) : |
| 480 | 480 | trim( str_replace( '** ', '', $line ) ) ; |
| Index: trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccessTemplate.php |
| — | — | @@ -24,7 +24,7 @@ |
| 25 | 25 | * @param $options array |
| 26 | 26 | */ |
| 27 | 27 | public function setByArray( $options ) { |
| 28 | | - foreach ($options as $name => $value ) { |
| | 28 | + foreach ( $options as $name => $value ) { |
| 29 | 29 | $this->set( $name, $value ); |
| 30 | 30 | } |
| 31 | 31 | } |
| Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js |
| — | — | @@ -225,7 +225,7 @@ |
| 226 | 226 | * Bucket 1: Share Your Feedback |
| 227 | 227 | */ |
| 228 | 228 | '1': { |
| 229 | | - |
| | 229 | + |
| 230 | 230 | /** |
| 231 | 231 | * Currently displayed placeholder text. This is a workaround for Chrome/FF |
| 232 | 232 | * automatic focus in overlays. |
| — | — | @@ -1912,10 +1912,10 @@ |
| 1913 | 1913 | |
| 1914 | 1914 | return $block; |
| 1915 | 1915 | }, |
| 1916 | | - |
| | 1916 | + |
| 1917 | 1917 | // }}} |
| 1918 | 1918 | // {{{ afterBuild |
| 1919 | | - |
| | 1919 | + |
| 1920 | 1920 | /** |
| 1921 | 1921 | * Perform adjustments after build |
| 1922 | 1922 | */ |
| — | — | @@ -1982,7 +1982,7 @@ |
| 1983 | 1983 | |
| 1984 | 1984 | // }}} |
| 1985 | 1985 | // {{{ afterBuild |
| 1986 | | - |
| | 1986 | + |
| 1987 | 1987 | /** |
| 1988 | 1988 | * Perform adjustments after build |
| 1989 | 1989 | */ |
| — | — | @@ -2657,7 +2657,7 @@ |
| 2658 | 2658 | if ( 'afterBuild' in cta ) { |
| 2659 | 2659 | cta.afterBuild(); |
| 2660 | 2660 | } |
| 2661 | | - |
| | 2661 | + |
| 2662 | 2662 | // The close element needs to be created anyway, to serve as an anchor. However, it needs |
| 2663 | 2663 | // to be hidden when the CTA is not displayed in a dialog |
| 2664 | 2664 | if( !$.articleFeedbackv5.inDialog ) { |
| Index: trunk/extensions/ArticleFeedbackv5/modules/ext.articleFeedbackv5/ext.articleFeedbackv5.startup.js |
| — | — | @@ -15,7 +15,7 @@ |
| 16 | 16 | |
| 17 | 17 | /*** Main entry point ***/ |
| 18 | 18 | jQuery( function( $ ) { |
| 19 | | - |
| | 19 | + |
| 20 | 20 | var ua = navigator.userAgent.toLowerCase(); |
| 21 | 21 | // Rule out MSIE 6, iPhone, iPod, iPad, Android |
| 22 | 22 | if( |
| — | — | @@ -29,8 +29,8 @@ |
| 30 | 30 | (ua.indexOf( 'ipad' ) != -1) |
| 31 | 31 | ) { |
| 32 | 32 | return; |
| 33 | | - } |
| 34 | | - |
| | 33 | + } |
| | 34 | + |
| 35 | 35 | // Load check, is this page ArticleFeedbackv5-enabled ? |
| 36 | 36 | // Keep in sync with ApiArticleFeedbackv5.php |
| 37 | 37 | if ( |
| Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php |
| — | — | @@ -257,11 +257,11 @@ |
| 258 | 258 | $wgHooks['ArticleSaveComplete'][] = 'ArticleFeedbackv5Hooks::trackEditSuccess'; |
| 259 | 259 | |
| 260 | 260 | // API Registration |
| 261 | | -//$wgAPIListModules['articlefeedbackv5-view-ratings'] = 'ApiViewRatingsArticleFeedbackv5'; |
| 262 | | -//$wgAPIListModules['articlefeedbackv5-view-feedback'] = 'ApiViewFeedbackArticleFeedbackv5'; |
| 263 | | -//$wgAPIModules['articlefeedbackv5-flag-feedback'] = 'ApiFlagFeedbackArticleFeedbackv5'; |
| | 261 | +// $wgAPIListModules['articlefeedbackv5-view-ratings'] = 'ApiViewRatingsArticleFeedbackv5'; |
| | 262 | +// $wgAPIListModules['articlefeedbackv5-view-feedback'] = 'ApiViewFeedbackArticleFeedbackv5'; |
| | 263 | +// $wgAPIModules['articlefeedbackv5-flag-feedback'] = 'ApiFlagFeedbackArticleFeedbackv5'; |
| 264 | 264 | $wgAPIModules['articlefeedbackv5'] = 'ApiArticleFeedbackv5'; |
| 265 | 265 | |
| 266 | 266 | // Special Page |
| 267 | | -//$wgSpecialPages['ArticleFeedbackv5'] = 'SpecialArticleFeedbackv5'; |
| 268 | | -//$wgSpecialPageGroups['ArticleFeedbackv5'] = 'other'; |
| | 267 | +// $wgSpecialPages['ArticleFeedbackv5'] = 'SpecialArticleFeedbackv5'; |
| | 268 | +// $wgSpecialPageGroups['ArticleFeedbackv5'] = 'other'; |
| Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php |
| — | — | @@ -8,7 +8,7 @@ |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | | - * This class pulls the individual ratings/comments for the feedback page. |
| | 12 | + * This class pulls the individual ratings/comments for the feedback page. |
| 13 | 13 | * |
| 14 | 14 | * @package ArticleFeedback |
| 15 | 15 | * @subpackage Api |
| — | — | @@ -91,7 +91,7 @@ |
| 92 | 92 | 'flagtype' => array( |
| 93 | 93 | ApiBase::PARAM_REQUIRED => true, |
| 94 | 94 | ApiBase::PARAM_ISMULTI => false, |
| 95 | | - ApiBase::PARAM_TYPE => array( |
| | 95 | + ApiBase::PARAM_TYPE => array( |
| 96 | 96 | 'abuse', 'hide' ) |
| 97 | 97 | ), |
| 98 | 98 | ); |
| Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php |
| — | — | @@ -206,7 +206,7 @@ |
| 207 | 207 | # Not actually a requirement, but I can see this being a thing, |
| 208 | 208 | # not letting people post the entire text of 1984 in a comment |
| 209 | 209 | # or something like that. |
| 210 | | - if( $wgArticleFeedbackv5MaxCommentLength > 0 |
| | 210 | + if ( $wgArticleFeedbackv5MaxCommentLength > 0 |
| 211 | 211 | && strlen( $value ) > $wgArticleFeedbackv5MaxCommentLength ) { |
| 212 | 212 | $length_error = 1; |
| 213 | 213 | } |
| — | — | @@ -224,7 +224,7 @@ |
| 225 | 225 | * @param $data array the user's validated feedback answers |
| 226 | 226 | */ |
| 227 | 227 | public function updateRollupTables( $page, $revision, $data ) { |
| 228 | | - foreach( array( 'rating', 'boolean', 'option_id' ) as $type ) { |
| | 228 | + foreach ( array( 'rating', 'boolean', 'option_id' ) as $type ) { |
| 229 | 229 | $this->updateRollup( $page, $revision, $type, $data ); |
| 230 | 230 | } |
| 231 | 231 | } |
| — | — | @@ -237,7 +237,7 @@ |
| 238 | 238 | * @return int the oldest revision to still count |
| 239 | 239 | */ |
| 240 | 240 | public function getRevisionLimit( $pageId ) { |
| 241 | | - if( $this->revision_limit === null ) { |
| | 241 | + if ( $this->revision_limit === null ) { |
| 242 | 242 | $this->revision_limit = ApiArticleFeedbackv5Utils::getRevisionLimit( $pageId ); |
| 243 | 243 | } |
| 244 | 244 | return $this->revision_limit; |
| — | — | @@ -292,7 +292,7 @@ |
| 293 | 293 | $field = $row['aa_field_id']; |
| 294 | 294 | $value = $row["aa_response_$type"]; |
| 295 | 295 | |
| 296 | | - if( $type == 'option_id' ) { |
| | 296 | + if ( $type == 'option_id' ) { |
| 297 | 297 | // Selects are kind of a odd bird. We store one row |
| 298 | 298 | // per option per field, and each one has the number |
| 299 | 299 | // of times that option was chosen, and the number of |
| — | — | @@ -312,7 +312,7 @@ |
| 313 | 313 | // For each option this field has, make sure we have |
| 314 | 314 | // a row by inserting one - will fail silently if the |
| 315 | 315 | // row already exists. |
| 316 | | - foreach( $options as $option ) { |
| | 316 | + foreach ( $options as $option ) { |
| 317 | 317 | // These inserts could possibly fail or succeed |
| 318 | 318 | // individually, so we can't use the multiple- |
| 319 | 319 | // insert functionality of the insert class. |
| — | — | @@ -399,7 +399,7 @@ |
| 400 | 400 | |
| 401 | 401 | // Select rollup data for revisions, grouped up by field, so we |
| 402 | 402 | // can drop it into the page rollups. |
| 403 | | - if( $type == 'option_id' ) { |
| | 403 | + if ( $type == 'option_id' ) { |
| 404 | 404 | $table = 'aft_article_feedback_select_rollup'; |
| 405 | 405 | $prefix = 'afsr_'; |
| 406 | 406 | $rows = $dbr->select( |
| — | — | @@ -419,7 +419,7 @@ |
| 420 | 420 | ); |
| 421 | 421 | |
| 422 | 422 | $page_data = array(); |
| 423 | | - foreach( $rows as $row ) { |
| | 423 | + foreach ( $rows as $row ) { |
| 424 | 424 | $page_data[] = array( |
| 425 | 425 | 'afsr_page_id' => $pageId, |
| 426 | 426 | 'afsr_field_id' => $field, |
| — | — | @@ -517,7 +517,7 @@ |
| 518 | 518 | // Find the link ID using the order of the link buckets ('-' = 0, 'A' = 1, |
| 519 | 519 | // 'B' = 2, etc.) |
| 520 | 520 | $links = array_flip( array_keys( $wgArticleFeedbackv5LinkBuckets['buckets'] ) ); |
| 521 | | - $linkId = isset($links[$linkName]) ? $links[$linkName] : 0; |
| | 521 | + $linkId = isset( $links[$linkName] ) ? $links[$linkName] : 0; |
| 522 | 522 | |
| 523 | 523 | $dbw->begin(); |
| 524 | 524 | |
| — | — | @@ -534,7 +534,7 @@ |
| 535 | 535 | |
| 536 | 536 | $feedbackId = $dbw->insertID(); |
| 537 | 537 | |
| 538 | | - foreach($data as $key => $item) { |
| | 538 | + foreach ( $data as $key => $item ) { |
| 539 | 539 | $data[$key]['aa_feedback_id'] = $feedbackId; |
| 540 | 540 | } |
| 541 | 541 | |
| — | — | @@ -548,8 +548,8 @@ |
| 549 | 549 | $dbw->commit(); |
| 550 | 550 | |
| 551 | 551 | return array( |
| 552 | | - 'cta_id' => ($ctaId ? $ctaId : 0), |
| 553 | | - 'feedback_id' => ($feedbackId ? $feedbackId : 0) |
| | 552 | + 'cta_id' => ( $ctaId ? $ctaId : 0 ), |
| | 553 | + 'feedback_id' => ( $feedbackId ? $feedbackId : 0 ) |
| 554 | 554 | ); |
| 555 | 555 | } |
| 556 | 556 | |
| — | — | @@ -564,7 +564,7 @@ |
| 565 | 565 | $rows = array(); |
| 566 | 566 | |
| 567 | 567 | // Only save data for logged-in users. |
| 568 | | - if( !$wgUser->isLoggedIn() ) { |
| | 568 | + if ( !$wgUser->isLoggedIn() ) { |
| 569 | 569 | return null; |
| 570 | 570 | } |
| 571 | 571 | |
| Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php |
| — | — | @@ -42,7 +42,7 @@ |
| 43 | 43 | ); |
| 44 | 44 | |
| 45 | 45 | foreach ( $feedback as $record ) { |
| 46 | | - $html .= $this->renderFeedback($record); |
| | 46 | + $html .= $this->renderFeedback( $record ); |
| 47 | 47 | $length++; |
| 48 | 48 | } |
| 49 | 49 | |
| — | — | @@ -58,7 +58,7 @@ |
| 59 | 59 | $where['af_page_id'] = $pageId; |
| 60 | 60 | |
| 61 | 61 | # Until this is done properly, just don't do anything. |
| 62 | | - return 0; |
| | 62 | + return 0; |
| 63 | 63 | |
| 64 | 64 | # return $dbr->selectField( |
| 65 | 65 | # array( 'aft_article_feedback' ), |
| — | — | @@ -77,8 +77,8 @@ |
| 78 | 78 | $order; |
| 79 | 79 | |
| 80 | 80 | # Newest first is the only option right now. |
| 81 | | - switch($order) { |
| 82 | | - case 'oldest': |
| | 81 | + switch( $order ) { |
| | 82 | + case 'oldest': |
| 83 | 83 | $order = 'af_id ASC'; |
| 84 | 84 | break; |
| 85 | 85 | case 'newest': |
| — | — | @@ -102,11 +102,11 @@ |
| 103 | 103 | 'ORDER BY' => $order |
| 104 | 104 | ) |
| 105 | 105 | ); |
| 106 | | - foreach($id_query as $id) { |
| | 106 | + foreach ( $id_query as $id ) { |
| 107 | 107 | $ids[] = $id->af_id; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | | - if( !count( $ids ) ) { |
| | 110 | + if ( !count( $ids ) ) { |
| 111 | 111 | return array(); |
| 112 | 112 | } |
| 113 | 113 | |
| — | — | @@ -118,7 +118,7 @@ |
| 119 | 119 | array( 'af_id', 'af_bucket_id', 'afi_name', 'afo_name', |
| 120 | 120 | 'aa_response_text', 'aa_response_boolean', |
| 121 | 121 | 'aa_response_rating', 'aa_response_option_id', |
| 122 | | - 'afi_data_type', 'af_created', 'user_name', |
| | 122 | + 'afi_data_type', 'af_created', 'user_name', |
| 123 | 123 | 'af_user_ip', 'af_hide_count', 'af_abuse_count' |
| 124 | 124 | ), |
| 125 | 125 | array( 'af_id' => $ids ), |
| — | — | @@ -141,15 +141,15 @@ |
| 142 | 142 | ) |
| 143 | 143 | ); |
| 144 | 144 | |
| 145 | | - foreach( $rows as $row ) { |
| 146 | | - if( !array_key_exists( $row->af_id, $rv ) ) { |
| | 145 | + foreach ( $rows as $row ) { |
| | 146 | + if ( !array_key_exists( $row->af_id, $rv ) ) { |
| 147 | 147 | $rv[$row->af_id] = array(); |
| 148 | 148 | $rv[$row->af_id][0] = $row; |
| 149 | 149 | $rv[$row->af_id][0]->user_name = $row->user_name ? $row->user_name : $row->af_user_ip; |
| 150 | 150 | } |
| 151 | 151 | $rv[$row->af_id][$row->afi_name] = $row; |
| 152 | 152 | } |
| 153 | | - |
| | 153 | + |
| 154 | 154 | return $rv; |
| 155 | 155 | } |
| 156 | 156 | |
| — | — | @@ -188,37 +188,37 @@ |
| 189 | 189 | |
| 190 | 190 | # TODO: permalinks |
| 191 | 191 | return Html::openElement( 'div', array( 'id' => 'aft5-feedback' ) ) |
| 192 | | - .Html::openElement( 'p' ) |
| 193 | | - .Html::element( 'a', array( 'class' => 'aft5-comment-name', 'href' => 'profilepage or whatever' ), $id ) |
| 194 | | - .Html::element( 'span', array( 'class' => 'aft5-comment-timestamp' ), $record[0]->af_created ) |
| 195 | | - .Html::closeElement( 'p' ) |
| 196 | | - .wfMessage( 'articlefeedbackv5-form-optionid', $record[0]->af_bucket_id )->escaped() |
| 197 | | - .$content |
| 198 | | - .wfMessage( 'articlefeedbackv5-form-helpful-label' )->escaped() |
| 199 | | - .Html::openElement( 'div', array( 'id' => 'aft5-feedback-tools' ) ) |
| 200 | | - .Html::element( 'h3', array(), wfMessage( 'articlefeedbackv5-form-tools-label' )->text() ) |
| 201 | | - .Html::openElement( 'ul' ) |
| 202 | | - .($can_flag ? Html::rawElement( 'li', array(), Html::element( 'a', array( |
| | 192 | + . Html::openElement( 'p' ) |
| | 193 | + . Html::element( 'a', array( 'class' => 'aft5-comment-name', 'href' => 'profilepage or whatever' ), $id ) |
| | 194 | + . Html::element( 'span', array( 'class' => 'aft5-comment-timestamp' ), $record[0]->af_created ) |
| | 195 | + . Html::closeElement( 'p' ) |
| | 196 | + . wfMessage( 'articlefeedbackv5-form-optionid', $record[0]->af_bucket_id )->escaped() |
| | 197 | + . $content |
| | 198 | + . wfMessage( 'articlefeedbackv5-form-helpful-label' )->escaped() |
| | 199 | + . Html::openElement( 'div', array( 'id' => 'aft5-feedback-tools' ) ) |
| | 200 | + . Html::element( 'h3', array(), wfMessage( 'articlefeedbackv5-form-tools-label' )->text() ) |
| | 201 | + . Html::openElement( 'ul' ) |
| | 202 | + . ( $can_flag ? Html::rawElement( 'li', array(), Html::element( 'a', array( |
| 203 | 203 | 'id' => "aft5-hide-link-$id", |
| 204 | 204 | 'class' => 'aft5-hide-link' |
| 205 | 205 | ), wfMessage( 'articlefeedbackv5-form-hide', $record[0]->af_hide_count )->text() ) ) : '' ) |
| 206 | | - .($can_hide ? Html::rawElement( 'li', array(), Html::element( 'a', array( |
| | 206 | + . ( $can_hide ? Html::rawElement( 'li', array(), Html::element( 'a', array( |
| 207 | 207 | 'id' => "aft5-abuse-link-$id", |
| 208 | 208 | 'class' => 'aft5-abuse-link' |
| 209 | 209 | ), wfMessage( 'articlefeedbackv5-form-abuse', $record[0]->af_abuse_count )->text() ) ) : '' ) |
| 210 | | - .($can_delete ? Html::rawElement( 'li', array(), Html::element( 'a', array( |
| | 210 | + . ( $can_delete ? Html::rawElement( 'li', array(), Html::element( 'a', array( |
| 211 | 211 | 'id' => "aft5-delete-link-$id", |
| 212 | 212 | 'class' => 'aft5-delete-link' |
| 213 | 213 | ), wfMessage( 'articlefeedbackv5-form-delete' )->text() ) ) : '' ) |
| 214 | | - .Html::closeElement( 'ul' ) |
| 215 | | - .Html::closeElement( 'div' ) |
| 216 | | - .Html::closeElement( 'div' ) |
| 217 | | - .Html::element( 'hr' ); |
| | 214 | + . Html::closeElement( 'ul' ) |
| | 215 | + . Html::closeElement( 'div' ) |
| | 216 | + . Html::closeElement( 'div' ) |
| | 217 | + . Html::element( 'hr' ); |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | private function renderBucket1( $record ) { |
| 221 | 221 | $name = htmlspecialchars( $record[0]->user_name ); |
| 222 | | - if( $record['found']->aa_response_boolean ) { |
| | 222 | + if ( $record['found']->aa_response_boolean ) { |
| 223 | 223 | $found = wfMessage( |
| 224 | 224 | 'articlefeedbackv5-form1-header-found', |
| 225 | 225 | $name |
| — | — | @@ -230,8 +230,8 @@ |
| 231 | 231 | )->escaped(); |
| 232 | 232 | } |
| 233 | 233 | return "$found |
| 234 | | - <blockquote>".htmlspecialchars( $record['comment']->aa_response_text ) |
| 235 | | - .'</blockquote>'; |
| | 234 | + <blockquote>" . htmlspecialchars( $record['comment']->aa_response_text ) |
| | 235 | + . '</blockquote>'; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | private function renderBucket2( $record ) { |
| — | — | @@ -243,16 +243,16 @@ |
| 244 | 244 | // * articlefeedbackv5-form2-header-question |
| 245 | 245 | // * articlefeedbackv5-form2-header-suggestion |
| 246 | 246 | return wfMessage( 'articlefeedbackv5-form2-header-' . $type, $name )->escaped() |
| 247 | | - .'<blockquote>'.htmlspecialchars( $record['comment']->aa_response_text ) |
| 248 | | - .'</blockquote>'; |
| | 247 | + . '<blockquote>' . htmlspecialchars( $record['comment']->aa_response_text ) |
| | 248 | + . '</blockquote>'; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | private function renderBucket3( $record ) { |
| 252 | 252 | $name = htmlspecialchars( $record[0]->user_name ); |
| 253 | 253 | $rating = htmlspecialchars( $record['rating']->aa_response_rating ); |
| 254 | 254 | return wfMessage( 'articlefeedbackv5-form3-header', $name, $rating )->escaped() |
| 255 | | - .'<blockquote>'.htmlspecialchars( $record['comment']->aa_response_text ) |
| 256 | | - .'</blockquote>'; |
| | 255 | + . '<blockquote>' . htmlspecialchars( $record['comment']->aa_response_text ) |
| | 256 | + . '</blockquote>'; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | private function renderBucket4( $record ) { |
| — | — | @@ -263,13 +263,13 @@ |
| 264 | 264 | $name = htmlspecialchars( $record[0]->user_name ); |
| 265 | 265 | $rv = wfMessage( 'articlefeedbackv5-form5-header', $name )->escaped(); |
| 266 | 266 | $rv .= '<ul>'; |
| 267 | | - foreach( $record as $key => $answer ) { |
| 268 | | - if( $answer->afi_data_type == 'rating' && $key != '0' ) { |
| | 267 | + foreach ( $record as $key => $answer ) { |
| | 268 | + if ( $answer->afi_data_type == 'rating' && $key != '0' ) { |
| 269 | 269 | $rv .= "<li>" |
| 270 | | - .htmlspecialchars( $answer->afi_name ) |
| 271 | | - .': ' |
| 272 | | - .htmlspecialchars( $answer->aa_response_rating ) |
| 273 | | - ."</li>"; |
| | 270 | + . htmlspecialchars( $answer->afi_name ) |
| | 271 | + . ': ' |
| | 272 | + . htmlspecialchars( $answer->aa_response_rating ) |
| | 273 | + . "</li>"; |
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | 276 | $rv .= "</ul>"; |
| Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewRatingsArticleFeedbackv5.php |
| — | — | @@ -67,9 +67,9 @@ |
| 68 | 68 | $where['arr_page_id'] = $pageId; |
| 69 | 69 | $where[] = 'arr_field_id = afi_id'; |
| 70 | 70 | $rows = $dbr->select( |
| 71 | | - array( |
| 72 | | - 'aft_article_feedback_ratings_rollup', |
| 73 | | - 'aft_article_field' |
| | 71 | + array( |
| | 72 | + 'aft_article_feedback_ratings_rollup', |
| | 73 | + 'aft_article_field' |
| 74 | 74 | ), |
| 75 | 75 | array( |
| 76 | 76 | 'afi_name AS field_name', |
| Index: trunk/extensions/ArticleFeedbackv5/SpecialArticleFeedbackv5.php |
| — | — | @@ -52,10 +52,10 @@ |
| 53 | 53 | # TODO: Fix links. |
| 54 | 54 | $out->addHTML( |
| 55 | 55 | Html::openElement( |
| 56 | | - 'div', |
| | 56 | + 'div', |
| 57 | 57 | array( 'id' => 'aft5-header-links' ) |
| 58 | 58 | ) |
| 59 | | - .Linker::link( |
| | 59 | + . Linker::link( |
| 60 | 60 | Title::newFromText( $param ), |
| 61 | 61 | $this->msg( 'articlefeedbackv5-go-to-article' )->escaped() |
| 62 | 62 | ) |
| — | — | @@ -69,30 +69,30 @@ |
| 70 | 70 | Title::newFromText( $param ), |
| 71 | 71 | $this->msg( 'articlefeedbackv5-whats-this' )->escaped() |
| 72 | 72 | ) |
| 73 | | - .Html::closeElement( 'div' ) |
| | 73 | + . Html::closeElement( 'div' ) |
| 74 | 74 | ); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | | - $out->addHTML( |
| | 77 | + $out->addHTML( |
| 78 | 78 | Html::openElement( |
| 79 | | - 'div', |
| | 79 | + 'div', |
| 80 | 80 | array( 'id' => 'aft5-showing-count-wrap' ) |
| 81 | 81 | ) |
| 82 | | - .$this->msg( |
| | 82 | + . $this->msg( |
| 83 | 83 | 'articlefeedbackv5-special-showing', |
| 84 | 84 | Html::element( 'span', array( 'id' => 'aft-feedback-count-total' ), '0' ) |
| 85 | 85 | ) |
| 86 | | - .Html::closeElement( 'div' ) |
| | 86 | + . Html::closeElement( 'div' ) |
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | 89 | if ( $found ) { |
| 90 | 90 | $out->addHtml( |
| 91 | 91 | Html::openElement( |
| 92 | | - 'div', |
| | 92 | + 'div', |
| 93 | 93 | array( 'id' => 'aft5-percent-found-wrap' ) |
| 94 | 94 | ) |
| 95 | | - .$this->msg( 'articlefeedbackv5-percent-found', $found )->escaped() |
| 96 | | - .Html::closeElement( 'div' ) |
| | 95 | + . $this->msg( 'articlefeedbackv5-percent-found', $found )->escaped() |
| | 96 | + . Html::closeElement( 'div' ) |
| 97 | 97 | ); |
| 98 | 98 | } |
| 99 | 99 | |
| — | — | @@ -108,15 +108,15 @@ |
| 109 | 109 | |
| 110 | 110 | $sortLabels = array(); |
| 111 | 111 | $sortOpts = array( 'newest', 'oldest' ); |
| 112 | | - foreach( $sortOpts as $sort ) { |
| 113 | | - $sortLabels[] = Html::element( |
| | 112 | + foreach ( $sortOpts as $sort ) { |
| | 113 | + $sortLabels[] = Html::element( |
| 114 | 114 | 'a', |
| 115 | 115 | array( |
| 116 | 116 | 'href' => '#', |
| 117 | | - 'id' => 'articlefeedbackv5-special-sort-'.$sort, |
| 118 | | - 'class' => 'aft5-sort-link' |
| | 117 | + 'id' => 'articlefeedbackv5-special-sort-' . $sort, |
| | 118 | + 'class' => 'aft5-sort-link' |
| 119 | 119 | ), |
| 120 | | - $this->msg( 'articlefeedbackv5-special-sort-'.$sort )->text() |
| | 120 | + $this->msg( 'articlefeedbackv5-special-sort-' . $sort )->text() |
| 121 | 121 | ); |
| 122 | 122 | } |
| 123 | 123 | |
| — | — | @@ -125,21 +125,21 @@ |
| 126 | 126 | 'articlefeedbackv5-special-filter-visible' => 'visible', |
| 127 | 127 | 'articlefeedbackv5-special-filter-invisible' => 'invisible', |
| 128 | 128 | 'articlefeedbackv5-special-filter-all' => 'all', |
| 129 | | - ))); |
| | 129 | + ) ) ); |
| 130 | 130 | |
| 131 | 131 | $out->addHTML( |
| 132 | 132 | Html::openElement( |
| 133 | | - 'div', |
| | 133 | + 'div', |
| 134 | 134 | array( 'id' => 'aft5-sort-filter-controls' ) |
| 135 | 135 | ) |
| 136 | | - .$this->msg( 'articlefeedbackv5-special-sort-label-before' )->escaped() |
| 137 | | - .implode( $this->msg( 'pipe-separator' )->escaped(), $sortLabels ) |
| 138 | | - .$this->msg( 'articlefeedbackv5-special-sort-label-after' )->escaped() |
| | 136 | + . $this->msg( 'articlefeedbackv5-special-sort-label-before' )->escaped() |
| | 137 | + . implode( $this->msg( 'pipe-separator' )->escaped(), $sortLabels ) |
| | 138 | + . $this->msg( 'articlefeedbackv5-special-sort-label-after' )->escaped() |
| 139 | 139 | |
| 140 | | - .$this->msg( 'articlefeedbackv5-special-filter-label-before' )->escaped() |
| 141 | | - .$filterSelect->getHTML() |
| 142 | | - .$this->msg( 'articlefeedbackv5-special-filter-label-after' )->escaped() |
| 143 | | - .Html::element( |
| | 140 | + . $this->msg( 'articlefeedbackv5-special-filter-label-before' )->escaped() |
| | 141 | + . $filterSelect->getHTML() |
| | 142 | + . $this->msg( 'articlefeedbackv5-special-filter-label-after' )->escaped() |
| | 143 | + . Html::element( |
| 144 | 144 | 'a', |
| 145 | 145 | array( |
| 146 | 146 | 'href' => '#', |
| — | — | @@ -147,22 +147,22 @@ |
| 148 | 148 | ), |
| 149 | 149 | $this->msg( 'articlefeedbackv5-special-add-feedback' )->text() |
| 150 | 150 | ) |
| 151 | | - .Html::closeElement( 'div' ) |
| | 151 | + . Html::closeElement( 'div' ) |
| 152 | 152 | ); |
| 153 | 153 | |
| 154 | 154 | $out->addHTML( |
| 155 | 155 | Html::element( |
| 156 | | - 'div', |
| | 156 | + 'div', |
| 157 | 157 | array( |
| 158 | 158 | 'id' => 'aft5-show-feedback', |
| 159 | 159 | 'style' => 'border:1px solid red;' |
| 160 | 160 | ), '' |
| 161 | 161 | ) |
| 162 | | - .Html::element( |
| 163 | | - 'a', |
| 164 | | - array( |
| 165 | | - 'href' => '#', |
| 166 | | - 'id' => 'aft5-show-more' |
| | 162 | + . Html::element( |
| | 163 | + 'a', |
| | 164 | + array( |
| | 165 | + 'href' => '#', |
| | 166 | + 'id' => 'aft5-show-more' |
| 167 | 167 | ), |
| 168 | 168 | $this->msg( 'articlefeedbackv5-special-more' )->text() |
| 169 | 169 | ) |
| Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php |
| — | — | @@ -282,7 +282,7 @@ |
| 283 | 283 | */ |
| 284 | 284 | public static function getPreferences( $user, &$preferences ) { |
| 285 | 285 | // need to check for existing key, if deployed simultaneously with AFTv4 |
| 286 | | - if( !array_key_exists( 'articlefeedback-disable', $preferences ) ) { |
| | 286 | + if ( !array_key_exists( 'articlefeedback-disable', $preferences ) ) { |
| 287 | 287 | $preferences['articlefeedback-disable'] = array( |
| 288 | 288 | 'type' => 'check', |
| 289 | 289 | 'section' => 'rendering/advancedrendering', |
| Index: trunk/extensions/EducationProgram/specials/SpecialInstitution.php |
| — | — | @@ -32,20 +32,20 @@ |
| 33 | 33 | */ |
| 34 | 34 | public function execute( $subPage ) { |
| 35 | 35 | parent::execute( $subPage ); |
| 36 | | - |
| | 36 | + |
| 37 | 37 | $out = $this->getOutput(); |
| 38 | | - |
| | 38 | + |
| 39 | 39 | if ( trim( $subPage ) === '' ) { |
| 40 | 40 | $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Institutions' )->getLocalURL() ); |
| 41 | 41 | } |
| 42 | 42 | else { |
| 43 | 43 | $out->setPageTitle( wfMsgExt( 'ep-institution-title', 'parsemag', $this->subPage ) ); |
| 44 | | - |
| | 44 | + |
| 45 | 45 | $org = EPOrg::selectRow( null, array( 'name' => $this->subPage ) ); |
| 46 | | - |
| | 46 | + |
| 47 | 47 | if ( $org === false ) { |
| 48 | 48 | $this->displayNavigation(); |
| 49 | | - |
| | 49 | + |
| 50 | 50 | if ( $this->getUser()->isAllowed( 'epadmin' ) ) { |
| 51 | 51 | $out->addWikiMsg( 'ep-institution-create', $this->subPage ); |
| 52 | 52 | EPOrg::displayAddNewControl( $this->getContext(), array( 'name' => $this->subPage ) ); |
| — | — | @@ -56,17 +56,17 @@ |
| 57 | 57 | } |
| 58 | 58 | else { |
| 59 | 59 | $links = array(); |
| 60 | | - |
| | 60 | + |
| 61 | 61 | if ( $this->getUser()->isAllowed( 'epadmin' ) ) { |
| 62 | 62 | $links[wfMsg( 'ep-institution-nav-edit' )] = SpecialPage::getTitleFor( 'EditInstitution', $this->subPage ); |
| 63 | 63 | } |
| 64 | | - |
| | 64 | + |
| 65 | 65 | $this->displayNavigation( $links ); |
| 66 | | - |
| | 66 | + |
| 67 | 67 | $this->displaySummary( $org ); |
| 68 | | - |
| | 68 | + |
| 69 | 69 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-institution-courses' ) ) ); |
| 70 | | - |
| | 70 | + |
| 71 | 71 | EPCourse::displayPager( $this->getContext(), array( 'org_id' => $org->getId() ) ); |
| 72 | 72 | |
| 73 | 73 | if ( $this->getUser()->isAllowed( 'epadmin' ) ) { |
| — | — | @@ -77,7 +77,7 @@ |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | | - |
| | 81 | + |
| 82 | 82 | /** |
| 83 | 83 | * Gets the summary data. |
| 84 | 84 | * |
| — | — | @@ -92,7 +92,7 @@ |
| 93 | 93 | |
| 94 | 94 | $stats['name'] = $org->getField( 'name' ); |
| 95 | 95 | $stats['city'] = $org->getField( 'city' ); |
| 96 | | - |
| | 96 | + |
| 97 | 97 | $countries = CountryNames::getNames( $this->getLanguage()->getCode() ); |
| 98 | 98 | $stats['country'] = $countries[$org->getField( 'country' )]; |
| 99 | 99 | |
| — | — | @@ -102,5 +102,5 @@ |
| 103 | 103 | |
| 104 | 104 | return $stats; |
| 105 | 105 | } |
| 106 | | - |
| | 106 | + |
| 107 | 107 | } |
| Index: trunk/extensions/EducationProgram/specials/SpecialEnroll.php |
| — | — | @@ -39,7 +39,7 @@ |
| 40 | 40 | parent::execute( $subPage ); |
| 41 | 41 | |
| 42 | 42 | $args = explode( '/', $this->subPage, 2 ); |
| 43 | | - |
| | 43 | + |
| 44 | 44 | if ( !ctype_digit( $args[0] ) ) { |
| 45 | 45 | $this->showWarning( wfMessage( $args[0] === '' ? 'ep-enroll-no-id' : 'ep-enroll-invalid-id' ) ); |
| 46 | 46 | } |
| — | — | @@ -52,7 +52,7 @@ |
| 53 | 53 | 'id' => $args[0], |
| 54 | 54 | 'token' => $args[1] |
| 55 | 55 | ) ); |
| 56 | | - |
| | 56 | + |
| 57 | 57 | if ( $term === false ) { |
| 58 | 58 | $this->showWarning( wfMessage( 'ep-enroll-invalid-token' ) ); |
| 59 | 59 | } |
| — | — | @@ -103,12 +103,12 @@ |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * Show links to signup. |
| 107 | | - * |
| | 107 | + * |
| 108 | 108 | * @since 0.1 |
| 109 | 109 | */ |
| 110 | 110 | protected function showSignupLink() { |
| 111 | 111 | $out = $this->getOutput(); |
| 112 | | - |
| | 112 | + |
| 113 | 113 | $out->addWikiMsg( 'ep-enroll-login-first' ); |
| 114 | 114 | |
| 115 | 115 | $out->addHTML( '<ul><li>' ); |
| — | — | @@ -174,12 +174,12 @@ |
| 175 | 175 | |
| 176 | 176 | return $success; |
| 177 | 177 | } |
| 178 | | - |
| | 178 | + |
| 179 | 179 | /** |
| 180 | 180 | * Create and display the enrollment form. |
| 181 | | - * |
| | 181 | + * |
| 182 | 182 | * @since 0.1 |
| 183 | | - * |
| | 183 | + * |
| 184 | 184 | * @param EPTerm $term |
| 185 | 185 | */ |
| 186 | 186 | protected function showEnrollmentForm( EPTerm $term ) { |
| — | — | @@ -232,7 +232,7 @@ |
| 233 | 233 | 'label-message' => 'ep-enroll-gender', |
| 234 | 234 | 'validation-callback' => function( $value, array $alldata = null ) { |
| 235 | 235 | return in_array( $value, array( 'male', 'female', 'unknown' ) ) ? true : wfMsg( 'ep-enroll-invalid-gender' ); |
| 236 | | - }, |
| | 236 | + } , |
| 237 | 237 | 'options' => array( |
| 238 | 238 | wfMsg( 'gender-male' ) => 'male', |
| 239 | 239 | wfMsg( 'gender-female' ) => 'female', |
| Index: trunk/extensions/EducationProgram/specials/SpecialAmbassadors.php |
| — | — | @@ -38,7 +38,7 @@ |
| 39 | 39 | } |
| 40 | 40 | else { |
| 41 | 41 | // TODO |
| 42 | | - //$this->getOutput()->redirect( SpecialPage::getTitleFor( 'Institution', $this->subPage )->getLocalURL() ); |
| | 42 | + // $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Institution', $this->subPage )->getLocalURL() ); |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| Index: trunk/extensions/EducationProgram/specials/SpecialEditInstitution.php |
| — | — | @@ -37,18 +37,18 @@ |
| 38 | 38 | 'required' => true, |
| 39 | 39 | 'validation-callback' => function ( $value, array $alldata = null ) { |
| 40 | 40 | return strlen( $value ) < 2 ? wfMsg( 'educationprogram-org-invalid-name' ) : true; |
| 41 | | - }, |
| | 41 | + } , |
| 42 | 42 | ); |
| 43 | | - |
| | 43 | + |
| 44 | 44 | $fields['city'] = array ( |
| 45 | 45 | 'type' => 'text', |
| 46 | 46 | 'label-message' => 'educationprogram-org-edit-city', |
| 47 | 47 | 'required' => true, |
| 48 | 48 | 'validation-callback' => function ( $value, array $alldata = null ) { |
| 49 | 49 | return strlen( $value ) < 2 ? wfMsg( 'educationprogram-org-invalid-city' ) : true; |
| 50 | | - }, |
| | 50 | + } , |
| 51 | 51 | ); |
| 52 | | - |
| | 52 | + |
| 53 | 53 | $fields['country'] = array ( |
| 54 | 54 | 'type' => 'select', |
| 55 | 55 | 'label-message' => 'educationprogram-org-edit-country', |
| — | — | @@ -60,24 +60,24 @@ |
| 61 | 61 | |
| 62 | 62 | return $this->processFormFields( $fields ); |
| 63 | 63 | } |
| 64 | | - |
| | 64 | + |
| 65 | 65 | /** |
| 66 | 66 | * Returns true if the country value is valid or an error message if it's not. |
| 67 | | - * |
| | 67 | + * |
| 68 | 68 | * @since 0.1 |
| 69 | | - * |
| | 69 | + * |
| 70 | 70 | * @param string $value |
| 71 | 71 | * @param array $alldata |
| 72 | | - * |
| | 72 | + * |
| 73 | 73 | * @return string|true |
| 74 | 74 | */ |
| 75 | 75 | public function countryIsValid( $value, array $alldata = null ) { |
| 76 | 76 | $countries = array_keys( CountryNames::getNames( $this->getLanguage()->getCode() ) ); |
| 77 | | - |
| | 77 | + |
| 78 | 78 | if ( $this->isNew() ) { |
| 79 | 79 | array_unshift( $countries, '' ); |
| 80 | 80 | } |
| 81 | | - |
| | 81 | + |
| 82 | 82 | return in_array( $value, $countries ) ? true : wfMsg( 'educationprogram-org-invalid-country' ); |
| 83 | 83 | } |
| 84 | 84 | |
| Index: trunk/extensions/EducationProgram/specials/SpecialCourse.php |
| — | — | @@ -34,18 +34,18 @@ |
| 35 | 35 | parent::execute( $subPage ); |
| 36 | 36 | |
| 37 | 37 | $out = $this->getOutput(); |
| 38 | | - |
| | 38 | + |
| 39 | 39 | if ( trim( $subPage ) === '' ) { |
| 40 | 40 | $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Courses' )->getLocalURL() ); |
| 41 | 41 | } |
| 42 | 42 | else { |
| 43 | 43 | $out->setPageTitle( wfMsgExt( 'ep-course-title', 'parsemag', $this->subPage ) ); |
| 44 | | - |
| | 44 | + |
| 45 | 45 | $course = EPCourse::selectRow( null, array( 'name' => $this->subPage ) ); |
| 46 | | - |
| | 46 | + |
| 47 | 47 | if ( $course === false ) { |
| 48 | 48 | $this->displayNavigation(); |
| 49 | | - |
| | 49 | + |
| 50 | 50 | if ( $this->getUser()->isAllowed( 'epadmin' ) || $this->getUser()->isAllowed( 'epmentor' ) ) { |
| 51 | 51 | $out->addWikiMsg( 'ep-course-create', $this->subPage ); |
| 52 | 52 | EPCourse::displayAddNewRegion( $this->getContext(), array( 'name' => $this->subPage ) ); |
| — | — | @@ -56,21 +56,21 @@ |
| 57 | 57 | } |
| 58 | 58 | else { |
| 59 | 59 | $links = array(); |
| 60 | | - |
| | 60 | + |
| 61 | 61 | if ( $course->useCanManage( $this->getUser() ) ) { |
| 62 | 62 | $links[wfMsg( 'ep-course-nav-edit' )] = SpecialPage::getTitleFor( 'EditCourse', $this->subPage ); |
| 63 | 63 | } |
| 64 | | - |
| | 64 | + |
| 65 | 65 | $this->displayNavigation( $links ); |
| 66 | | - |
| | 66 | + |
| 67 | 67 | $this->displaySummary( $course ); |
| 68 | | - |
| | 68 | + |
| 69 | 69 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-description' ) ) ); |
| 70 | | - |
| | 70 | + |
| 71 | 71 | $out->addHTML( $this->getOutput()->parse( $course->getField( 'description' ) ) ); |
| 72 | | - |
| | 72 | + |
| 73 | 73 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-terms' ) ) ); |
| 74 | | - |
| | 74 | + |
| 75 | 75 | EPTerm::displayPager( $this->getContext(), array( 'course_id' => $course->getId() ) ); |
| 76 | 76 | |
| 77 | 77 | if ( $course->useCanManage( $this->getUser() ) ) { |
| — | — | @@ -81,7 +81,7 @@ |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | | - |
| | 85 | + |
| 86 | 86 | /** |
| 87 | 87 | * Gets the summary data. |
| 88 | 88 | * |
| Index: trunk/extensions/EducationProgram/specials/SpecialEPPage.php |
| — | — | @@ -17,7 +17,7 @@ |
| 18 | 18 | /** |
| 19 | 19 | * The subpage, ie the part after Special:PageName/ |
| 20 | 20 | * Empty string if none is provided. |
| 21 | | - * |
| | 21 | + * |
| 22 | 22 | * @since 0.1 |
| 23 | 23 | * @var string |
| 24 | 24 | */ |
| — | — | @@ -122,37 +122,37 @@ |
| 123 | 123 | public function getLanguage() { |
| 124 | 124 | return method_exists( get_parent_class(), 'getLanguage' ) ? parent::getLanguage() : $this->getLang(); |
| 125 | 125 | } |
| 126 | | - |
| | 126 | + |
| 127 | 127 | /** |
| 128 | 128 | * Adds a navigation menu with the provided links. |
| 129 | 129 | * Links should be provided in an array with: |
| 130 | 130 | * label => Title (object) |
| 131 | | - * |
| | 131 | + * |
| 132 | 132 | * @since 0.1 |
| 133 | | - * |
| | 133 | + * |
| 134 | 134 | * @param array $items |
| 135 | 135 | */ |
| 136 | 136 | protected function displayNavigation( array $items = array() ) { |
| 137 | 137 | $links = array(); |
| 138 | 138 | $items = array_merge( $this->getDefaultNavigationItems(), $items ); |
| 139 | | - |
| | 139 | + |
| 140 | 140 | foreach ( $items as $label => $target ) { |
| 141 | 141 | $links[] = Linker::linkKnown( |
| 142 | 142 | $target, |
| 143 | 143 | htmlspecialchars( $label ) |
| 144 | 144 | ); |
| 145 | 145 | } |
| 146 | | - |
| | 146 | + |
| 147 | 147 | $this->getOutput()->addHTML( |
| 148 | 148 | Html::rawElement( 'p', array(), $this->getLanguage()->pipeList( $links ) ) |
| 149 | 149 | ); |
| 150 | 150 | } |
| 151 | | - |
| | 151 | + |
| 152 | 152 | /** |
| 153 | 153 | * Returns the default nav items for @see displayNavigation. |
| 154 | | - * |
| | 154 | + * |
| 155 | 155 | * @since 0.1 |
| 156 | | - * |
| | 156 | + * |
| 157 | 157 | * @return array |
| 158 | 158 | */ |
| 159 | 159 | protected function getDefaultNavigationItems() { |
| — | — | @@ -166,34 +166,34 @@ |
| 167 | 167 | $items[wfMsg( 'ep-nav-students' )] = SpecialPage::getTitleFor( 'Students' ); |
| 168 | 168 | $items[wfMsg( 'ep-nav-mentors' )] = SpecialPage::getTitleFor( 'Ambassadors' ); |
| 169 | 169 | } |
| 170 | | - |
| | 170 | + |
| 171 | 171 | if ( $this->getUser()->isAllowed( 'epmentor' ) || EPStudent::has( array( 'user_id' => $this->getUser()->getId() ) ) ) { |
| 172 | 172 | $items[wfMsg( 'ep-nav-mycourses' )] = SpecialPage::getTitleFor( 'MyCourses' ); |
| 173 | 173 | } |
| 174 | | - |
| | 174 | + |
| 175 | 175 | return $items; |
| 176 | 176 | } |
| 177 | | - |
| | 177 | + |
| 178 | 178 | /** |
| 179 | 179 | * Display the summary data. |
| 180 | | - * |
| | 180 | + * |
| 181 | 181 | * @since 0.1 |
| 182 | | - * |
| | 182 | + * |
| 183 | 183 | * @param EPDBObject $item |
| 184 | 184 | * @param boolean $collapsed |
| 185 | 185 | * @param array $summaryData |
| 186 | 186 | */ |
| 187 | 187 | protected function displaySummary( EPDBObject $item, $collapsed = false, array $summaryData = null ) { |
| 188 | 188 | $out = $this->getOutput(); |
| 189 | | - |
| | 189 | + |
| 190 | 190 | $class = 'wikitable ep-summary mw-collapsible'; |
| 191 | | - |
| | 191 | + |
| 192 | 192 | if ( $collapsed ) { |
| 193 | | - $class.= ' mw-collapsed'; |
| | 193 | + $class .= ' mw-collapsed'; |
| 194 | 194 | } |
| 195 | | - |
| | 195 | + |
| 196 | 196 | $out->addHTML( Html::openElement( 'table', array( 'class' => $class ) ) ); |
| 197 | | - |
| | 197 | + |
| 198 | 198 | $out->addHTML( '<tr>' . Html::element( 'th', array( 'colspan' => 2 ), wfMsg( 'ep-item-summary' ) ) . '</tr>' ); |
| 199 | 199 | |
| 200 | 200 | $summaryData = is_null( $summaryData ) ? $this->getSummaryData( $item ) : $summaryData; |
| — | — | @@ -218,7 +218,7 @@ |
| 219 | 219 | |
| 220 | 220 | $out->addHTML( Html::closeElement( 'table' ) ); |
| 221 | 221 | } |
| 222 | | - |
| | 222 | + |
| 223 | 223 | /** |
| 224 | 224 | * Gets the summary data. |
| 225 | 225 | * Returned values must be escaped. |
| Index: trunk/extensions/EducationProgram/specials/SpecialEducationProgram.php |
| — | — | @@ -1,8 +1,8 @@ |
| 2 | 2 | <?php |
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | | - * |
| 6 | 5 | * |
| | 6 | + * |
| 7 | 7 | * @since 0.1 |
| 8 | 8 | * |
| 9 | 9 | * @file SpecialEducationProgram.php |
| Index: trunk/extensions/EducationProgram/specials/SpecialEditCourse.php |
| — | — | @@ -37,11 +37,11 @@ |
| 38 | 38 | 'required' => true, |
| 39 | 39 | 'validation-callback' => function ( $value, array $alldata = null ) { |
| 40 | 40 | return strlen( $value ) < 5 ? wfMsgExt( 'ep-course-invalid-name', 'parsemag', 5 ) : true; |
| 41 | | - }, |
| | 41 | + } , |
| 42 | 42 | ); |
| 43 | | - |
| | 43 | + |
| 44 | 44 | $orgOptions = EPOrg::getOrgOptions( EPOrg::getEditableOrgs( $this->getUser() ) ); |
| 45 | | - |
| | 45 | + |
| 46 | 46 | $fields['org_id'] = array ( |
| 47 | 47 | 'type' => 'select', |
| 48 | 48 | 'label-message' => 'ep-course-edit-org', |
| — | — | @@ -49,22 +49,22 @@ |
| 50 | 50 | 'options' => $orgOptions, |
| 51 | 51 | 'validation-callback' => function ( $value, array $alldata = null ) use ( $orgOptions ) { |
| 52 | 52 | return in_array( (int)$value, array_values( $orgOptions ) ) ? true : wfMsg( 'ep-course-invalid-org' ); |
| 53 | | - }, |
| | 53 | + } , |
| 54 | 54 | ); |
| 55 | | - |
| | 55 | + |
| 56 | 56 | $fields['description'] = array ( |
| 57 | 57 | 'type' => 'textarea', |
| 58 | 58 | 'label-message' => 'ep-course-edit-description', |
| 59 | 59 | 'required' => true, |
| 60 | 60 | 'validation-callback' => function ( $value, array $alldata = null ) { |
| 61 | 61 | return strlen( $value ) < 10 ? wfMsgExt( 'ep-course-invalid-description', 'parsemag', 10 ) : true; |
| 62 | | - }, |
| | 62 | + } , |
| 63 | 63 | 'rows' => 10 |
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | 66 | return $this->processFormFields( $fields ); |
| 67 | 67 | } |
| 68 | | - |
| | 68 | + |
| 69 | 69 | /** |
| 70 | 70 | * (non-PHPdoc) |
| 71 | 71 | * @see SpecialEPFormPage::getNewData() |
| — | — | @@ -75,5 +75,5 @@ |
| 76 | 76 | 'name' => $this->getRequest()->getVal( 'newname' ), |
| 77 | 77 | ); |
| 78 | 78 | } |
| 79 | | - |
| | 79 | + |
| 80 | 80 | } |
| Index: trunk/extensions/EducationProgram/specials/SpecialTerm.php |
| — | — | @@ -34,18 +34,18 @@ |
| 35 | 35 | parent::execute( $subPage ); |
| 36 | 36 | |
| 37 | 37 | $out = $this->getOutput(); |
| 38 | | - |
| | 38 | + |
| 39 | 39 | if ( trim( $subPage ) === '' ) { |
| 40 | 40 | $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Terms' )->getLocalURL() ); |
| 41 | 41 | } |
| 42 | 42 | else { |
| 43 | 43 | $out->setPageTitle( wfMsgExt( 'ep-term-title', 'parsemag', $this->subPage ) ); |
| 44 | | - |
| | 44 | + |
| 45 | 45 | $term = EPTerm::selectRow( null, array( 'id' => $this->subPage ) ); |
| 46 | | - |
| | 46 | + |
| 47 | 47 | if ( $term === false ) { |
| 48 | 48 | $this->displayNavigation(); |
| 49 | | - |
| | 49 | + |
| 50 | 50 | if ( $this->getUser()->isAllowed( 'epadmin' ) || $this->getUser()->isAllowed( 'epmentor' ) ) { |
| 51 | 51 | $out->addWikiMsg( 'ep-term-create', $this->subPage ); |
| 52 | 52 | EPTerm::displayAddNewRegion( $this->getContext(), array( 'id' => $this->subPage ) ); |
| — | — | @@ -56,26 +56,26 @@ |
| 57 | 57 | } |
| 58 | 58 | else { |
| 59 | 59 | $links = array(); |
| 60 | | - |
| | 60 | + |
| 61 | 61 | if ( $term->useCanManage( $this->getUser() ) ) { |
| 62 | 62 | $links[wfMsg( 'ep-term-nav-edit' )] = SpecialPage::getTitleFor( 'EditTerm', $this->subPage ); |
| 63 | 63 | } |
| 64 | | - |
| | 64 | + |
| 65 | 65 | $this->displayNavigation( $links ); |
| 66 | | - |
| | 66 | + |
| 67 | 67 | $this->displaySummary( $term ); |
| 68 | | - |
| | 68 | + |
| 69 | 69 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-term-description' ) ) ); |
| 70 | | - |
| | 70 | + |
| 71 | 71 | $out->addHTML( $this->getOutput()->parse( $term->getField( 'description' ) ) ); |
| 72 | | - |
| | 72 | + |
| 73 | 73 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-term-students' ) ) ); |
| 74 | | - |
| | 74 | + |
| 75 | 75 | // TODO: students |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | | - |
| | 79 | + |
| 80 | 80 | /** |
| 81 | 81 | * Gets the summary data. |
| 82 | 82 | * |
| — | — | @@ -112,7 +112,7 @@ |
| 113 | 113 | htmlspecialchars( $term->getField( 'token' ) ) |
| 114 | 114 | ); |
| 115 | 115 | } |
| 116 | | - |
| | 116 | + |
| 117 | 117 | return $stats; |
| 118 | 118 | } |
| 119 | 119 | |
| Index: trunk/extensions/EducationProgram/specials/SpecialAmbassador.php |
| — | — | @@ -33,7 +33,7 @@ |
| 34 | 34 | parent::execute( $subPage ); |
| 35 | 35 | |
| 36 | 36 | $out = $this->getOutput(); |
| 37 | | - |
| | 37 | + |
| 38 | 38 | if ( trim( $subPage ) === '' ) { |
| 39 | 39 | $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Ambassadors' )->getLocalURL() ); |
| 40 | 40 | } |
| — | — | @@ -42,8 +42,8 @@ |
| 43 | 43 | |
| 44 | 44 | $this->displayNavigation(); |
| 45 | 45 | |
| 46 | | - $mentor = false; //EPMentor::selectRow( null, array( 'id' => $this->subPage ) ); |
| 47 | | - |
| | 46 | + $mentor = false; // EPMentor::selectRow( null, array( 'id' => $this->subPage ) ); |
| | 47 | + |
| 48 | 48 | if ( $mentor === false ) { |
| 49 | 49 | $this->showWarning( wfMessage( 'ep-ambassador-does-not-exist', $this->subPage ) ); |
| 50 | 50 | } |
| — | — | @@ -52,7 +52,7 @@ |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | | - |
| | 56 | + |
| 57 | 57 | /** |
| 58 | 58 | * Gets the summary data. |
| 59 | 59 | * |
| Index: trunk/extensions/EducationProgram/specials/SpecialInstitutions.php |
| — | — | @@ -42,5 +42,5 @@ |
| 43 | 43 | $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Institution', $this->subPage )->getLocalURL() ); |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | | - |
| | 46 | + |
| 47 | 47 | } |
| Index: trunk/extensions/EducationProgram/specials/SpecialEditTerm.php |
| — | — | @@ -20,7 +20,7 @@ |
| 21 | 21 | */ |
| 22 | 22 | public function __construct() { |
| 23 | 23 | parent::__construct( 'EditTerm', 'epmentor', 'EPTerm', 'Terms' ); |
| 24 | | - |
| | 24 | + |
| 25 | 25 | $this->getOutput()->addModules( 'ep.datepicker' ); |
| 26 | 26 | } |
| 27 | 27 | |
| — | — | @@ -31,9 +31,9 @@ |
| 32 | 32 | */ |
| 33 | 33 | protected function getFormFields() { |
| 34 | 34 | $fields = parent::getFormFields(); |
| 35 | | - |
| | 35 | + |
| 36 | 36 | $courseOptions = EPCourse::getCourseOptions( EPCourse::getEditableCourses( $this->getUser() ) ); |
| 37 | | - |
| | 37 | + |
| 38 | 38 | $fields['course_id'] = array ( |
| 39 | 39 | 'type' => 'select', |
| 40 | 40 | 'label-message' => 'ep-term-edit-course', |
| — | — | @@ -41,9 +41,9 @@ |
| 42 | 42 | 'options' => $courseOptions, |
| 43 | 43 | 'validation-callback' => function ( $value, array $alldata = null ) use ( $courseOptions ) { |
| 44 | 44 | return in_array( (int)$value, array_values( $courseOptions ) ) ? true : wfMsg( 'ep-term-invalid-course' ); |
| 45 | | - }, |
| | 45 | + } , |
| 46 | 46 | ); |
| 47 | | - |
| | 47 | + |
| 48 | 48 | $fields['token'] = array ( |
| 49 | 49 | 'type' => 'text', |
| 50 | 50 | 'label-message' => 'ep-term-edit-token', |
| — | — | @@ -52,9 +52,9 @@ |
| 53 | 53 | 'size' => 20, |
| 54 | 54 | 'validation-callback' => function ( $value, array $alldata = null ) { |
| 55 | 55 | return strlen( $value ) < 2 ? wfMsgExt( 'ep-term-invalid-token', 'parsemag', 2 ) : true; |
| 56 | | - }, |
| | 56 | + } , |
| 57 | 57 | ); |
| 58 | | - |
| | 58 | + |
| 59 | 59 | $fields['year'] = array ( |
| 60 | 60 | 'type' => 'int', |
| 61 | 61 | 'label-message' => 'ep-term-edit-year', |
| — | — | @@ -63,32 +63,32 @@ |
| 64 | 64 | 'max' => 9001, |
| 65 | 65 | 'size' => 15, |
| 66 | 66 | ); |
| 67 | | - |
| | 67 | + |
| 68 | 68 | $fields['start'] = array ( |
| 69 | 69 | 'class' => 'EPHTMLDateField', |
| 70 | 70 | 'label-message' => 'ep-term-edit-start', |
| 71 | 71 | 'required' => true, |
| 72 | 72 | ); |
| 73 | | - |
| | 73 | + |
| 74 | 74 | $fields['end'] = array ( |
| 75 | 75 | 'class' => 'EPHTMLDateField', |
| 76 | 76 | 'label-message' => 'ep-term-edit-end', |
| 77 | 77 | 'required' => true, |
| 78 | 78 | ); |
| 79 | | - |
| | 79 | + |
| 80 | 80 | $fields['description'] = array ( |
| 81 | 81 | 'type' => 'textarea', |
| 82 | 82 | 'label-message' => 'ep-term-edit-description', |
| 83 | 83 | 'required' => true, |
| 84 | 84 | 'validation-callback' => function ( $value, array $alldata = null ) { |
| 85 | 85 | return strlen( $value ) < 10 ? wfMsgExt( 'ep-term-invalid-description', 'parsemag', 10 ) : true; |
| 86 | | - }, |
| | 86 | + } , |
| 87 | 87 | 'rows' => 10 |
| 88 | 88 | ); |
| 89 | | - |
| | 89 | + |
| 90 | 90 | return $this->processFormFields( $fields ); |
| 91 | 91 | } |
| 92 | | - |
| | 92 | + |
| 93 | 93 | /** |
| 94 | 94 | * (non-PHPdoc) |
| 95 | 95 | * @see SpecialEPFormPage::getTitleConditions() |
| — | — | @@ -96,7 +96,7 @@ |
| 97 | 97 | protected function getTitleConditions() { |
| 98 | 98 | return array( 'id' => $this->subPage ); |
| 99 | 99 | } |
| 100 | | - |
| | 100 | + |
| 101 | 101 | /** |
| 102 | 102 | * (non-PHPdoc) |
| 103 | 103 | * @see SpecialEPFormPage::getNewData() |
| — | — | @@ -107,7 +107,7 @@ |
| 108 | 108 | 'year' => $this->getRequest()->getVal( 'newyear' ), |
| 109 | 109 | ); |
| 110 | 110 | } |
| 111 | | - |
| | 111 | + |
| 112 | 112 | /** |
| 113 | 113 | * (non-PHPdoc) |
| 114 | 114 | * @see SpecialEPFormPage::handleKnownField() |
| — | — | @@ -116,31 +116,31 @@ |
| 117 | 117 | if ( in_array( $name, array( 'end', 'start' ) ) ) { |
| 118 | 118 | $value = wfTimestamp( TS_MW, strtotime( $value ) ); |
| 119 | 119 | } |
| 120 | | - |
| | 120 | + |
| 121 | 121 | return $value; |
| 122 | 122 | } |
| 123 | | - |
| | 123 | + |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | class EPHTMLDateField extends HTMLTextField { |
| 127 | | - |
| | 127 | + |
| 128 | 128 | public function __construct( $params ) { |
| 129 | 129 | parent::__construct( $params ); |
| 130 | | - |
| | 130 | + |
| 131 | 131 | $this->mClass .= " ep-datepicker-tr"; |
| 132 | 132 | } |
| 133 | | - |
| | 133 | + |
| 134 | 134 | function getSize() { |
| 135 | 135 | return isset( $this->mParams['size'] ) |
| 136 | 136 | ? $this->mParams['size'] |
| 137 | 137 | : 20; |
| 138 | 138 | } |
| 139 | | - |
| | 139 | + |
| 140 | 140 | function getInputHTML( $value ) { |
| 141 | 141 | $value = explode( 'T', wfTimestamp( TS_ISO_8601, strtotime( $value ) ) ); |
| 142 | 142 | return parent::getInputHTML( $value[0] ); |
| 143 | 143 | } |
| 144 | | - |
| | 144 | + |
| 145 | 145 | function validate( $value, $alldata ) { |
| 146 | 146 | $p = parent::validate( $value, $alldata ); |
| 147 | 147 | |
| — | — | @@ -149,9 +149,9 @@ |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | $value = trim( $value ); |
| 153 | | - |
| | 153 | + |
| 154 | 154 | // TODO: further validation |
| 155 | | - |
| | 155 | + |
| 156 | 156 | return true; |
| 157 | 157 | } |
| 158 | 158 | } |
| Index: trunk/extensions/EducationProgram/specials/SpecialCourses.php |
| — | — | @@ -42,5 +42,5 @@ |
| 43 | 43 | $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Course', $this->subPage )->getLocalURL() ); |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | | - |
| | 46 | + |
| 47 | 47 | } |
| Index: trunk/extensions/EducationProgram/specials/SpecialEPFormPage.php |
| — | — | @@ -15,35 +15,35 @@ |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Instance of the object being edited or created. |
| 19 | | - * |
| | 19 | + * |
| 20 | 20 | * @since 0.1 |
| 21 | 21 | * @var EPDBObject|false |
| 22 | 22 | */ |
| 23 | | - protected $item = false; |
| | 23 | + protected $item = false; |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Name of the class of the object being edited or created. |
| 27 | | - * |
| | 27 | + * |
| 28 | 28 | * @since 0.1 |
| 29 | 29 | * @var string |
| 30 | 30 | */ |
| 31 | 31 | protected $itemClass; |
| 32 | | - |
| | 32 | + |
| 33 | 33 | /** |
| 34 | 34 | * Name of the special page listing the items. |
| 35 | 35 | * For example, for "EditLolcat", it could be "Lolcats". |
| 36 | | - * |
| | 36 | + * |
| 37 | 37 | * @since 0.1 |
| 38 | 38 | * @var string |
| 39 | 39 | */ |
| 40 | 40 | protected $listPage; |
| 41 | | - |
| | 41 | + |
| 42 | 42 | /** |
| 43 | 43 | * Constructor. |
| 44 | 44 | * |
| 45 | 45 | * @since 0.1 |
| 46 | | - * |
| 47 | | - * @param string $name Name of the page |
| | 46 | + * |
| | 47 | + * @param string $name Name of the page |
| 48 | 48 | * @param string $right Right needed to access the page |
| 49 | 49 | * @param string $itemClass Name of the item class |
| 50 | 50 | * @param string $listPage Name of the page listing the items |
| — | — | @@ -51,12 +51,12 @@ |
| 52 | 52 | public function __construct( $name, $right, $itemClass, $listPage ) { |
| 53 | 53 | $this->itemClass = $itemClass; |
| 54 | 54 | $this->listPage = $listPage; |
| 55 | | - |
| | 55 | + |
| 56 | 56 | parent::__construct( $name, $right, false ); |
| 57 | | - |
| | 57 | + |
| 58 | 58 | $this->getOutput()->addModules( 'ep.formpage' ); |
| 59 | 59 | } |
| 60 | | - |
| | 60 | + |
| 61 | 61 | /** |
| 62 | 62 | * @see SpecialPage::getDescription |
| 63 | 63 | * |
| — | — | @@ -90,7 +90,7 @@ |
| 91 | 91 | */ |
| 92 | 92 | public function execute( $subPage ) { |
| 93 | 93 | parent::execute( $subPage ); |
| 94 | | - |
| | 94 | + |
| 95 | 95 | if ( $this->getRequest()->wasPosted() && $this->getUser()->matchEditToken( $this->getRequest()->getVal( 'wpEditToken' ) ) ) { |
| 96 | 96 | $this->showForm(); |
| 97 | 97 | } |
| — | — | @@ -98,7 +98,7 @@ |
| 99 | 99 | $this->showContent(); |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | | - |
| | 102 | + |
| 103 | 103 | /** |
| 104 | 104 | * Display the form and set the item field, or redirect the user. |
| 105 | 105 | * |
| — | — | @@ -106,7 +106,7 @@ |
| 107 | 107 | */ |
| 108 | 108 | protected function showContent() { |
| 109 | 109 | $c = $this->itemClass; // Yeah, this is needed in PHP 5.3 >_> |
| 110 | | - |
| | 110 | + |
| 111 | 111 | if ( $this->isNew() ) { |
| 112 | 112 | $data = $this->getNewData(); |
| 113 | 113 | |
| — | — | @@ -137,22 +137,22 @@ |
| 138 | 138 | $this->showForm(); |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | | - |
| | 141 | + |
| 142 | 142 | /** |
| 143 | 143 | * Returns if the page should work in insertion mode rather then modification mode. |
| 144 | | - * |
| | 144 | + * |
| 145 | 145 | * @since 0.1 |
| 146 | | - * |
| | 146 | + * |
| 147 | 147 | * @return boolean |
| 148 | 148 | */ |
| 149 | 149 | protected function isNew() { |
| 150 | 150 | static $isNew = null; |
| 151 | | - |
| | 151 | + |
| 152 | 152 | if ( is_null( $isNew ) ) { |
| 153 | 153 | $isNew = $this->getRequest()->wasPosted() && |
| 154 | 154 | ( $this->getRequest()->getCheck( 'isnew' ) || $this->getRequest()->getCheck( 'wpisnew' ) ); |
| 155 | 155 | } |
| 156 | | - |
| | 156 | + |
| 157 | 157 | return $isNew; |
| 158 | 158 | } |
| 159 | 159 | |
| — | — | @@ -174,25 +174,25 @@ |
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | | - |
| | 178 | + |
| 179 | 179 | /** |
| 180 | 180 | * Returns the data to use as condition for selecting the object, |
| 181 | 181 | * or in case nothing matches the selection, the data to initialize |
| 182 | 182 | * it with. This is typically an identifier such as name or id. |
| 183 | | - * |
| | 183 | + * |
| 184 | 184 | * @since 0.1 |
| 185 | | - * |
| | 185 | + * |
| 186 | 186 | * @return array |
| 187 | 187 | */ |
| 188 | 188 | protected function getNewData() { |
| 189 | 189 | return array( 'name' => $this->getRequest()->getVal( 'newname' ) ); |
| 190 | 190 | } |
| 191 | | - |
| | 191 | + |
| 192 | 192 | /** |
| 193 | 193 | * Get the query conditions to obtain the item based on the page title. |
| 194 | | - * |
| | 194 | + * |
| 195 | 195 | * @since 0.1 |
| 196 | | - * |
| | 196 | + * |
| 197 | 197 | * @return array |
| 198 | 198 | */ |
| 199 | 199 | protected function getTitleConditions() { |
| — | — | @@ -221,7 +221,7 @@ |
| 222 | 222 | |
| 223 | 223 | $action = $this->isNew() ? 'add' : 'edit'; |
| 224 | 224 | $form->setWrapperLegend( $this->msg( strtolower( $this->getName() ) . '-' . $action . '-legend' ) ); |
| 225 | | - |
| | 225 | + |
| 226 | 226 | $form->addButton( |
| 227 | 227 | 'cancelEdit', |
| 228 | 228 | wfMsg( 'cancel' ), |
| — | — | @@ -239,7 +239,7 @@ |
| 240 | 240 | |
| 241 | 241 | return $form; |
| 242 | 242 | } |
| 243 | | - |
| | 243 | + |
| 244 | 244 | /** |
| 245 | 245 | * (non-PHPdoc) |
| 246 | 246 | * @see FormSpecialPage::getFormFields() |
| — | — | @@ -258,16 +258,16 @@ |
| 259 | 259 | && $req->getCheck( 'wpitem-id' ) ) { |
| 260 | 260 | $fields['id']['default'] = $req->getInt( 'wpitem-id' ); |
| 261 | 261 | } |
| 262 | | - |
| | 262 | + |
| 263 | 263 | return $fields; |
| 264 | 264 | } |
| 265 | | - |
| | 265 | + |
| 266 | 266 | /** |
| 267 | 267 | * Populates the form fields with the data of the item |
| 268 | 268 | * and prefixes their names. |
| 269 | | - * |
| | 269 | + * |
| 270 | 270 | * @since 0.1 |
| 271 | | - * |
| | 271 | + * |
| 272 | 272 | * @param array $fields |
| 273 | 273 | * |
| 274 | 274 | * @return array |
| — | — | @@ -280,7 +280,7 @@ |
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | | - |
| | 284 | + |
| 285 | 285 | $mappedFields = array(); |
| 286 | 286 | |
| 287 | 287 | foreach ( $fields as $name => $field ) { |
| — | — | @@ -290,36 +290,36 @@ |
| 291 | 291 | unset( $field['validation-callback'] ); |
| 292 | 292 | unset( $field['required'] ); |
| 293 | 293 | } |
| 294 | | - |
| | 294 | + |
| 295 | 295 | $mappedFields['item-' . $name] = $field; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | return $mappedFields; |
| 299 | 299 | } |
| 300 | | - |
| | 300 | + |
| 301 | 301 | /** |
| 302 | 302 | * Gets the default value for a field from the item. |
| 303 | | - * |
| | 303 | + * |
| 304 | 304 | * @since 0.1 |
| 305 | | - * |
| | 305 | + * |
| 306 | 306 | * @param EPDBObject $item |
| 307 | 307 | * @param string $name |
| 308 | | - * |
| | 308 | + * |
| 309 | 309 | * @return mixed |
| 310 | 310 | */ |
| 311 | 311 | protected function getDefaultFromItem( EPDBObject $item, $name ) { |
| 312 | 312 | return $item->getField( $name ); |
| 313 | 313 | } |
| 314 | | - |
| | 314 | + |
| 315 | 315 | /** |
| 316 | 316 | * Gets called after the form is saved. |
| 317 | | - * |
| | 317 | + * |
| 318 | 318 | * @since 0.1 |
| 319 | 319 | */ |
| 320 | 320 | public function onSuccess() { |
| 321 | 321 | $this->getOutput()->redirect( SpecialPage::getTitleFor( $this->listPage )->getLocalURL() ); |
| 322 | 322 | } |
| 323 | | - |
| | 323 | + |
| 324 | 324 | /** |
| 325 | 325 | * Process the form. At this point we know that the user passes all the criteria in |
| 326 | 326 | * userCanExecute(). |
| — | — | @@ -341,7 +341,7 @@ |
| 342 | 342 | if ( $matches[1] === 'id' && ( $value === '' || $value === '0' ) ) { |
| 343 | 343 | $value = null; |
| 344 | 344 | } |
| 345 | | - |
| | 345 | + |
| 346 | 346 | if ( $c::canHasField( $matches[1] ) ) { |
| 347 | 347 | $fields[$matches[1]] = $value; |
| 348 | 348 | } |
| — | — | @@ -353,7 +353,7 @@ |
| 354 | 354 | |
| 355 | 355 | $keys = array_keys( $fields ); |
| 356 | 356 | $fields = array_combine( $keys, array_map( array( $this, 'handleKnownField' ), $keys, $fields ) ); |
| 357 | | - |
| | 357 | + |
| 358 | 358 | /* EPDBObject */ $item = new $c( $fields, is_null( $fields['id'] ) ); |
| 359 | 359 | |
| 360 | 360 | foreach ( $unknownValues as $name => $value ) { |
| — | — | @@ -369,12 +369,12 @@ |
| 370 | 370 | return array(); // TODO |
| 371 | 371 | } |
| 372 | 372 | } |
| 373 | | - |
| | 373 | + |
| 374 | 374 | /** |
| 375 | 375 | * Gets called for evey unknown submitted value, so they can be dealt with if needed. |
| 376 | | - * |
| | 376 | + * |
| 377 | 377 | * @since 0.1 |
| 378 | | - * |
| | 378 | + * |
| 379 | 379 | * @param EPDBObject $item |
| 380 | 380 | * @param string $name |
| 381 | 381 | * @param string $value This is a string, since it comes from request data, but might be a number or other type. |
| — | — | @@ -382,20 +382,20 @@ |
| 383 | 383 | protected function handleUnknownField( EPDBObject $item, $name, $value ) { |
| 384 | 384 | // Override to use. |
| 385 | 385 | } |
| 386 | | - |
| | 386 | + |
| 387 | 387 | /** |
| 388 | 388 | * Gets called for evey known submitted value, so they can be dealt with if needed. |
| 389 | | - * |
| | 389 | + * |
| 390 | 390 | * @since 0.1 |
| 391 | | - * |
| | 391 | + * |
| 392 | 392 | * @param string $name |
| 393 | 393 | * @param string $value This is a string, since it comes from request data, but might be a number or other type. |
| 394 | | - * |
| | 394 | + * |
| 395 | 395 | * @return mixed The new value |
| 396 | 396 | */ |
| 397 | 397 | protected function handleKnownField( $name, $value ) { |
| 398 | 398 | // Override to use. |
| 399 | 399 | return $value; |
| 400 | 400 | } |
| 401 | | - |
| | 401 | + |
| 402 | 402 | } |
| Index: trunk/extensions/EducationProgram/specials/SpecialStudent.php |
| — | — | @@ -1,8 +1,8 @@ |
| 2 | 2 | <?php |
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | | - * |
| 6 | 5 | * |
| | 6 | + * |
| 7 | 7 | * @since 0.1 |
| 8 | 8 | * |
| 9 | 9 | * @file SpecialStudent.php |
| Index: trunk/extensions/EducationProgram/INSTALL |
| — | — | @@ -1,5 +1,5 @@ |
| 2 | 2 | These is the install file for the Education Program extension. |
| 3 | | - |
| | 3 | + |
| 4 | 4 | Extension page on mediawiki.org: https://www.mediawiki.org/wiki/Extension:Education_Program |
| 5 | 5 | Latest version of the install file: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/EducationProgram/INSTALL?view=co |
| 6 | 6 | |
| Index: trunk/extensions/EducationProgram/includes/EPMentor.php |
| — | — | @@ -15,12 +15,12 @@ |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Cached array of the linked EPOrg objects. |
| 19 | | - * |
| | 19 | + * |
| 20 | 20 | * @since 0.1 |
| 21 | 21 | * @var array|false |
| 22 | 22 | */ |
| 23 | 23 | protected $orgs = false; |
| 24 | | - |
| | 24 | + |
| 25 | 25 | /** |
| 26 | 26 | * @see parent::getFieldTypes |
| 27 | 27 | * |
| — | — | @@ -34,26 +34,26 @@ |
| 35 | 35 | 'user_id' => 'id', |
| 36 | 36 | ); |
| 37 | 37 | } |
| 38 | | - |
| | 38 | + |
| 39 | 39 | /** |
| 40 | 40 | * Returns the orgs this mentor is part of. |
| 41 | 41 | * Caches the result when no conditions are provided and all fields are selected. |
| 42 | | - * |
| | 42 | + * |
| 43 | 43 | * @since 0.1 |
| 44 | | - * |
| | 44 | + * |
| 45 | 45 | * @param array|null $fields |
| 46 | 46 | * @param array $conditions |
| 47 | | - * |
| | 47 | + * |
| 48 | 48 | * @return array of EPOrg |
| 49 | 49 | */ |
| 50 | 50 | public function getOrgs( array $fields = null, array $conditions = array() ) { |
| 51 | 51 | if ( count( $conditions ) !== 0 ) { |
| 52 | 52 | return $this->doGetOrgs( $fields, $conditions ); |
| 53 | 53 | } |
| 54 | | - |
| | 54 | + |
| 55 | 55 | if ( $this->orgs === false ) { |
| 56 | 56 | $orgs = $this->doGetOrgs( $fields, $conditions ); |
| 57 | | - |
| | 57 | + |
| 58 | 58 | if ( is_null( $fields ) ) { |
| 59 | 59 | $this->orgs = $orgs; |
| 60 | 60 | } |
| — | — | @@ -64,15 +64,15 @@ |
| 65 | 65 | return $this->orgs; |
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | | - |
| | 68 | + |
| 69 | 69 | /** |
| 70 | 70 | * Returns the orgs this mentor is part of. |
| 71 | | - * |
| | 71 | + * |
| 72 | 72 | * @since 0.1 |
| 73 | | - * |
| | 73 | + * |
| 74 | 74 | * @param array|null $fields |
| 75 | 75 | * @param array $conditions |
| 76 | | - * |
| | 76 | + * |
| 77 | 77 | * @return array of EPOrg |
| 78 | 78 | */ |
| 79 | 79 | protected function doGetOrgs( $fields, array $conditions ) { |
| — | — | @@ -80,7 +80,7 @@ |
| 81 | 81 | array( array( 'ep_mentors', 'id' ), $this->getId() ), |
| 82 | 82 | $conditions |
| 83 | 83 | ); |
| 84 | | - |
| | 84 | + |
| 85 | 85 | return EPOrg::select( |
| 86 | 86 | $fields, |
| 87 | 87 | $conditions, |
| — | — | @@ -91,15 +91,15 @@ |
| 92 | 92 | ) |
| 93 | 93 | ); |
| 94 | 94 | } |
| 95 | | - |
| | 95 | + |
| 96 | 96 | /** |
| 97 | | - * Retruns the courses this mentor can manage. |
| 98 | | - * |
| | 97 | + * Retruns the courses this mentor can manage. |
| | 98 | + * |
| 99 | 99 | * @since 0.1 |
| 100 | | - * |
| | 100 | + * |
| 101 | 101 | * @param array|null $fields |
| 102 | 102 | * @param array $conditions |
| 103 | | - * |
| | 103 | + * |
| 104 | 104 | * @return array of EPCourse |
| 105 | 105 | */ |
| 106 | 106 | public function getCourses( array $fields = null, array $conditions = array() ) { |
| — | — | @@ -107,19 +107,19 @@ |
| 108 | 108 | $this->getOrgs( $fields, $conditions ), |
| 109 | 109 | function( array $courses, EPOrg $org ) use ( $fields ) { |
| 110 | 110 | return array_merge( $courses, $org->getCourses( $fields ) ); |
| 111 | | - }, |
| | 111 | + } , |
| 112 | 112 | array() |
| 113 | 113 | ); |
| 114 | 114 | } |
| 115 | | - |
| | 115 | + |
| 116 | 116 | /** |
| 117 | | - * Retruns the terms this mentor can manage. |
| 118 | | - * |
| | 117 | + * Retruns the terms this mentor can manage. |
| | 118 | + * |
| 119 | 119 | * @since 0.1 |
| 120 | | - * |
| | 120 | + * |
| 121 | 121 | * @param array|null $fields |
| 122 | 122 | * @param array $conditions |
| 123 | | - * |
| | 123 | + * |
| 124 | 124 | * @return array of EPTerm |
| 125 | 125 | */ |
| 126 | 126 | public function getTerms( array $fields = null, array $conditions = array() ) { |
| — | — | @@ -127,31 +127,31 @@ |
| 128 | 128 | $this->getOrgs( $fields, $conditions ), |
| 129 | 129 | function( array $terms, EPOrg $org ) use ( $fields ) { |
| 130 | 130 | return array_merge( $terms, $org->getTerms( $fields ) ); |
| 131 | | - }, |
| | 131 | + } , |
| 132 | 132 | array() |
| 133 | 133 | ); |
| 134 | 134 | } |
| 135 | | - |
| | 135 | + |
| 136 | 136 | /** |
| 137 | | - * Retruns if the mentor has any course matching the provided contitions. |
| 138 | | - * |
| | 137 | + * Retruns if the mentor has any course matching the provided contitions. |
| | 138 | + * |
| 139 | 139 | * @since 0.1 |
| 140 | | - * |
| | 140 | + * |
| 141 | 141 | * @param array $conditions |
| 142 | | - * |
| | 142 | + * |
| 143 | 143 | * @return boolean |
| 144 | 144 | */ |
| 145 | 145 | public function hasCourse( array $conditions = array() ) { |
| 146 | 146 | return count( $this->getCourses( 'id', $conditions ) ) > 0; |
| 147 | 147 | } |
| 148 | | - |
| | 148 | + |
| 149 | 149 | /** |
| 150 | 150 | * Retruns if the mentor has any term matching the provided conditions. |
| 151 | | - * |
| | 151 | + * |
| 152 | 152 | * @since 0.1 |
| 153 | | - * |
| | 153 | + * |
| 154 | 154 | * @param array $conditions |
| 155 | | - * |
| | 155 | + * |
| 156 | 156 | * @return boolean |
| 157 | 157 | */ |
| 158 | 158 | public function hasTerm( array $conditions = array() ) { |
| Index: trunk/extensions/EducationProgram/includes/EPStudentPager.php |
| — | — | @@ -39,7 +39,7 @@ |
| 40 | 40 | 'active_enroll', |
| 41 | 41 | ); |
| 42 | 42 | } |
| 43 | | - |
| | 43 | + |
| 44 | 44 | /** |
| 45 | 45 | * (non-PHPdoc) |
| 46 | 46 | * @see TablePager::getRowClass() |
| — | — | @@ -47,12 +47,12 @@ |
| 48 | 48 | function getRowClass( $row ) { |
| 49 | 49 | return 'ep-student-row'; |
| 50 | 50 | } |
| 51 | | - |
| | 51 | + |
| 52 | 52 | /** |
| 53 | 53 | * (non-PHPdoc) |
| 54 | 54 | * @see TablePager::getTableClass() |
| 55 | 55 | */ |
| 56 | | - public function getTableClass(){ |
| | 56 | + public function getTableClass() { |
| 57 | 57 | return 'TablePager ep-students'; |
| 58 | 58 | } |
| 59 | 59 | |
| — | — | @@ -81,7 +81,7 @@ |
| 82 | 82 | $value = $this->getLanguage()->pipeList( array_map( |
| 83 | 83 | function( EPCourse $course ) { |
| 84 | 84 | return $course->getLink(); |
| 85 | | - }, |
| | 85 | + } , |
| 86 | 86 | $this->currentObject->getCurrentCourses( 'name' ) |
| 87 | 87 | ) ); |
| 88 | 88 | break; |
| Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php |
| — | — | @@ -39,7 +39,7 @@ |
| 40 | 40 | 'active', |
| 41 | 41 | ); |
| 42 | 42 | } |
| 43 | | - |
| | 43 | + |
| 44 | 44 | /** |
| 45 | 45 | * (non-PHPdoc) |
| 46 | 46 | * @see TablePager::getRowClass() |
| — | — | @@ -47,12 +47,12 @@ |
| 48 | 48 | function getRowClass( $row ) { |
| 49 | 49 | return 'ep-org-row'; |
| 50 | 50 | } |
| 51 | | - |
| | 51 | + |
| 52 | 52 | /** |
| 53 | 53 | * (non-PHPdoc) |
| 54 | 54 | * @see TablePager::getTableClass() |
| 55 | 55 | */ |
| 56 | | - public function getTableClass(){ |
| | 56 | + public function getTableClass() { |
| 57 | 57 | return 'TablePager ep-orgs'; |
| 58 | 58 | } |
| 59 | 59 | |
| — | — | @@ -138,28 +138,28 @@ |
| 139 | 139 | ), |
| 140 | 140 | ); |
| 141 | 141 | } |
| 142 | | - |
| | 142 | + |
| 143 | 143 | /** |
| 144 | 144 | * (non-PHPdoc) |
| 145 | 145 | * @see EPPager::getControlLinks() |
| 146 | 146 | */ |
| 147 | 147 | protected function getControlLinks( EPDBObject $item ) { |
| 148 | 148 | $links = parent::getControlLinks( $item ); |
| 149 | | - |
| | 149 | + |
| 150 | 150 | $links[] = $value = Linker::linkKnown( |
| 151 | 151 | SpecialPage::getTitleFor( 'Institution', $item->getField( 'name' ) ), |
| 152 | 152 | wfMsgHtml( 'view' ) |
| 153 | 153 | ); |
| 154 | | - |
| | 154 | + |
| 155 | 155 | if ( $this->getUser()->isAllowed( 'epadmin' ) ) { |
| 156 | 156 | $links[] = $value = Linker::linkKnown( |
| 157 | 157 | SpecialPage::getTitleFor( 'EditInstitution', $item->getField( 'name' ) ), |
| 158 | 158 | wfMsgHtml( 'edit' ) |
| 159 | 159 | ); |
| 160 | | - |
| | 160 | + |
| 161 | 161 | $links[] = $this->getDeletionLink( 'org', $item->getId() ); |
| 162 | 162 | } |
| 163 | | - |
| | 163 | + |
| 164 | 164 | return $links; |
| 165 | 165 | } |
| 166 | 166 | |
| Index: trunk/extensions/EducationProgram/includes/EPStudent.php |
| — | — | @@ -39,15 +39,15 @@ |
| 40 | 40 | 'active_enroll' => 'bool', |
| 41 | 41 | ); |
| 42 | 42 | } |
| 43 | | - |
| | 43 | + |
| 44 | 44 | /** |
| 45 | 45 | * Get the student object of a user, or false if there is none. |
| 46 | | - * |
| | 46 | + * |
| 47 | 47 | * @since 0.1 |
| 48 | | - * |
| | 48 | + * |
| 49 | 49 | * @param User $user |
| 50 | 50 | * @param string|array|null $fields |
| 51 | | - * |
| | 51 | + * |
| 52 | 52 | * @return EPStudent|false |
| 53 | 53 | */ |
| 54 | 54 | public static function newFromUser( User $user, $fields = null ) { |
| — | — | @@ -137,7 +137,7 @@ |
| 138 | 138 | function( array $ids, EPTerm $term ) { |
| 139 | 139 | $ids[] = $term->getField( 'course_id' ); |
| 140 | 140 | return $ids; |
| 141 | | - }, |
| | 141 | + } , |
| 142 | 142 | array() |
| 143 | 143 | ); |
| 144 | 144 | |
| — | — | @@ -244,5 +244,5 @@ |
| 245 | 245 | $context->getOutput()->addWikiMsg( 'ep-students-noresults' ); |
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | | - |
| | 248 | + |
| 249 | 249 | } |
| Index: trunk/extensions/EducationProgram/includes/EPTermPager.php |
| — | — | @@ -36,7 +36,7 @@ |
| 37 | 37 | 'end', |
| 38 | 38 | ); |
| 39 | 39 | } |
| 40 | | - |
| | 40 | + |
| 41 | 41 | /** |
| 42 | 42 | * (non-PHPdoc) |
| 43 | 43 | * @see TablePager::getRowClass() |
| — | — | @@ -44,12 +44,12 @@ |
| 45 | 45 | function getRowClass( $row ) { |
| 46 | 46 | return 'ep-term-row'; |
| 47 | 47 | } |
| 48 | | - |
| | 48 | + |
| 49 | 49 | /** |
| 50 | 50 | * (non-PHPdoc) |
| 51 | 51 | * @see TablePager::getTableClass() |
| 52 | 52 | */ |
| 53 | | - public function getTableClass(){ |
| | 53 | + public function getTableClass() { |
| 54 | 54 | return 'TablePager ep-terms'; |
| 55 | 55 | } |
| 56 | 56 | |
| — | — | @@ -67,7 +67,7 @@ |
| 68 | 68 | break; |
| 69 | 69 | case 'course_id': |
| 70 | 70 | $value = EPCourse::selectRow( 'name', array( 'id' => $value ) )->getField( 'name' ); |
| 71 | | - |
| | 71 | + |
| 72 | 72 | $value = Linker::linkKnown( |
| 73 | 73 | SpecialPage::getTitleFor( 'Course', $value ), |
| 74 | 74 | htmlspecialchars( $value ) |
| — | — | @@ -114,7 +114,7 @@ |
| 115 | 115 | |
| 116 | 116 | return $fields; |
| 117 | 117 | } |
| 118 | | - |
| | 118 | + |
| 119 | 119 | /** |
| 120 | 120 | * (non-PHPdoc) |
| 121 | 121 | * @see EPPager::getFilterOptions() |
| — | — | @@ -166,31 +166,31 @@ |
| 167 | 167 | |
| 168 | 168 | return $options; |
| 169 | 169 | } |
| 170 | | - |
| | 170 | + |
| 171 | 171 | /** |
| 172 | 172 | * (non-PHPdoc) |
| 173 | 173 | * @see EPPager::getControlLinks() |
| 174 | 174 | */ |
| 175 | 175 | protected function getControlLinks( EPDBObject $item ) { |
| 176 | 176 | $links = parent::getControlLinks( $item ); |
| 177 | | - |
| | 177 | + |
| 178 | 178 | $links[] = $value = Linker::linkKnown( |
| 179 | 179 | SpecialPage::getTitleFor( 'Term', $item->getId() ), |
| 180 | 180 | wfMsgHtml( 'view' ) |
| 181 | 181 | ); |
| 182 | | - |
| | 182 | + |
| 183 | 183 | if ( $this->getUser()->isAllowed( 'epadmin' ) ) { |
| 184 | 184 | $links[] = $value = Linker::linkKnown( |
| 185 | 185 | SpecialPage::getTitleFor( 'EditTerm', $item->getId() ), |
| 186 | 186 | wfMsgHtml( 'edit' ) |
| 187 | 187 | ); |
| 188 | | - |
| | 188 | + |
| 189 | 189 | $links[] = $this->getDeletionLink( 'term', $item->getId() ); |
| 190 | 190 | } |
| 191 | | - |
| | 191 | + |
| 192 | 192 | return $links; |
| 193 | 193 | } |
| 194 | | - |
| | 194 | + |
| 195 | 195 | /** |
| 196 | 196 | * (non-PHPdoc) |
| 197 | 197 | * @see EPPager::getMultipleItemActions() |
| Index: trunk/extensions/EducationProgram/includes/EPOrg.php |
| — | — | @@ -15,20 +15,20 @@ |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Cached array of the linked EPCourse objects. |
| 19 | | - * |
| | 19 | + * |
| 20 | 20 | * @since 0.1 |
| 21 | 21 | * @var array|false |
| 22 | 22 | */ |
| 23 | 23 | protected $courses = false; |
| 24 | | - |
| | 24 | + |
| 25 | 25 | /** |
| 26 | 26 | * Cached array of the linked EPTerm objects. |
| 27 | | - * |
| | 27 | + * |
| 28 | 28 | * @since 0.1 |
| 29 | 29 | * @var array|false |
| 30 | 30 | */ |
| 31 | 31 | protected $terms = false; |
| 32 | | - |
| | 32 | + |
| 33 | 33 | /** |
| 34 | 34 | * @see parent::getFieldTypes |
| 35 | 35 | * |
| — | — | @@ -39,7 +39,7 @@ |
| 40 | 40 | protected static function getFieldTypes() { |
| 41 | 41 | return array( |
| 42 | 42 | 'id' => 'id', |
| 43 | | - |
| | 43 | + |
| 44 | 44 | 'name' => 'str', |
| 45 | 45 | 'city' => 'str', |
| 46 | 46 | 'country' => 'str', |
| — | — | @@ -133,54 +133,54 @@ |
| 134 | 134 | |
| 135 | 135 | $this->setFields( $fields ); |
| 136 | 136 | } |
| 137 | | - |
| | 137 | + |
| 138 | 138 | /** |
| 139 | 139 | * (non-PHPdoc) |
| 140 | 140 | * @see EPDBObject::removeFromDB() |
| 141 | 141 | */ |
| 142 | 142 | public function removeFromDB() { |
| 143 | 143 | $id = $this->getId(); |
| 144 | | - |
| | 144 | + |
| 145 | 145 | $success = parent::removeFromDB(); |
| 146 | | - |
| | 146 | + |
| 147 | 147 | if ( $success ) { |
| 148 | 148 | $success = wfGetDB( DB_MASTER )->delete( 'ep_mentors_per_org', array( 'mpo_org_id' => $id ) ) && $success; |
| 149 | | - |
| | 149 | + |
| 150 | 150 | foreach ( EPCourse::select( 'id', array( 'org_id' => $id ) ) as /* EPCourse */ $course ) { |
| 151 | 151 | $success = $course->removeFromDB() && $success; |
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | | - |
| | 154 | + |
| 155 | 155 | return $success; |
| 156 | 156 | } |
| 157 | | - |
| | 157 | + |
| 158 | 158 | /** |
| 159 | 159 | * Returns a list of orgs in an array that can be fed to select inputs. |
| 160 | | - * |
| | 160 | + * |
| 161 | 161 | * @since 0.1 |
| 162 | | - * |
| | 162 | + * |
| 163 | 163 | * @param array $orgs |
| 164 | | - * |
| | 164 | + * |
| 165 | 165 | * @return array |
| 166 | 166 | */ |
| 167 | 167 | public static function getOrgOptions( array /* EPOrg */ $orgs ) { |
| 168 | 168 | $options = array(); |
| 169 | | - |
| | 169 | + |
| 170 | 170 | foreach ( $orgs as /* EPOrg */ $org ) { |
| 171 | 171 | $options[$org->getField( 'name' )] = $org->getId(); |
| 172 | 172 | } |
| 173 | | - |
| | 173 | + |
| 174 | 174 | return $options; |
| 175 | 175 | } |
| 176 | | - |
| | 176 | + |
| 177 | 177 | /** |
| 178 | 178 | * Returns the list of orgs that the specified user can edit. |
| 179 | | - * |
| | 179 | + * |
| 180 | 180 | * @since 0.1 |
| 181 | | - * |
| | 181 | + * |
| 182 | 182 | * @param User|int $user |
| 183 | 183 | * @param array|null $fields |
| 184 | | - * |
| | 184 | + * |
| 185 | 185 | * @return array of EPOrg |
| 186 | 186 | */ |
| 187 | 187 | public static function getEditableOrgs( $user, array $fields = null ) { |
| — | — | @@ -191,7 +191,7 @@ |
| 192 | 192 | else { |
| 193 | 193 | $userId = $user->getId(); |
| 194 | 194 | } |
| 195 | | - |
| | 195 | + |
| 196 | 196 | if ( $user->isAllowed( 'epadmin' ) ) { |
| 197 | 197 | return self::select( $fields ); |
| 198 | 198 | } |
| — | — | @@ -203,25 +203,25 @@ |
| 204 | 204 | return array(); |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | | - |
| | 207 | + |
| 208 | 208 | /** |
| 209 | 209 | * Adds a control to add a new org to the provided context. |
| 210 | 210 | * Adittional arguments can be provided to set the default values for the control fields. |
| 211 | | - * |
| | 211 | + * |
| 212 | 212 | * @since 0.1 |
| 213 | | - * |
| | 213 | + * |
| 214 | 214 | * @param IContextSource $context |
| 215 | 215 | * @param array $args |
| 216 | | - * |
| | 216 | + * |
| 217 | 217 | * @return boolean |
| 218 | 218 | */ |
| 219 | 219 | public static function displayAddNewControl( IContextSource $context, array $args = array() ) { |
| 220 | 220 | if ( !$context->getUser()->isAllowed( 'epadmin' ) ) { |
| 221 | 221 | return false; |
| 222 | 222 | } |
| 223 | | - |
| | 223 | + |
| 224 | 224 | $out = $context->getOutput(); |
| 225 | | - |
| | 225 | + |
| 226 | 226 | $out->addHTML( Html::openElement( |
| 227 | 227 | 'form', |
| 228 | 228 | array( |
| — | — | @@ -253,21 +253,21 @@ |
| 254 | 254 | $out->addHTML( Html::hidden( 'isnew', 1 ) ); |
| 255 | 255 | |
| 256 | 256 | $out->addHTML( '</fieldset></form>' ); |
| 257 | | - |
| | 257 | + |
| 258 | 258 | return true; |
| 259 | 259 | } |
| 260 | | - |
| | 260 | + |
| 261 | 261 | /** |
| 262 | 262 | * Display a pager with courses. |
| 263 | | - * |
| | 263 | + * |
| 264 | 264 | * @since 0.1 |
| 265 | | - * |
| | 265 | + * |
| 266 | 266 | * @param IContextSource $context |
| 267 | 267 | * @param array $conditions |
| 268 | 268 | */ |
| 269 | 269 | public static function displayPager( IContextSource $context, array $conditions = array() ) { |
| 270 | 270 | $pager = new EPOrgPager( $context, $conditions ); |
| 271 | | - |
| | 271 | + |
| 272 | 272 | if ( $pager->getNumRows() ) { |
| 273 | 273 | $context->getOutput()->addHTML( |
| 274 | 274 | $pager->getFilterControl() . |
| — | — | @@ -282,38 +282,38 @@ |
| 283 | 283 | $context->getOutput()->addWikiMsg( 'ep-institutions-noresults' ); |
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | | - |
| | 286 | + |
| 287 | 287 | /** |
| 288 | | - * Retruns the courses linked to this org. |
| 289 | | - * |
| | 288 | + * Retruns the courses linked to this org. |
| | 289 | + * |
| 290 | 290 | * @since 0.1 |
| 291 | | - * |
| | 291 | + * |
| 292 | 292 | * @param array|null $fields |
| 293 | | - * |
| | 293 | + * |
| 294 | 294 | * @return array of EPCourse |
| 295 | 295 | */ |
| 296 | 296 | public function getCourses( array $fields = null ) { |
| 297 | 297 | if ( $this->courses === false ) { |
| 298 | 298 | $this->courses = EPCourse::select( $fields, array( 'org_id' => $this->getId() ) ); |
| 299 | 299 | } |
| 300 | | - |
| | 300 | + |
| 301 | 301 | return $this->courses; |
| 302 | 302 | } |
| 303 | | - |
| | 303 | + |
| 304 | 304 | /** |
| 305 | | - * Retruns the terms linked to this org. |
| 306 | | - * |
| | 305 | + * Retruns the terms linked to this org. |
| | 306 | + * |
| 307 | 307 | * @since 0.1 |
| 308 | | - * |
| | 308 | + * |
| 309 | 309 | * @param array|null $fields |
| 310 | | - * |
| | 310 | + * |
| 311 | 311 | * @return array of EPTerm |
| 312 | 312 | */ |
| 313 | 313 | public function getTerms( array $fields = null ) { |
| 314 | 314 | if ( $this->terms === false ) { |
| 315 | 315 | $this->terms = EPTerm::select( $fields, array( 'org_id' => $this->getId() ) ); |
| 316 | 316 | } |
| 317 | | - |
| | 317 | + |
| 318 | 318 | return $this->terms; |
| 319 | 319 | } |
| 320 | 320 | |
| — | — | @@ -330,5 +330,5 @@ |
| 331 | 331 | htmlspecialchars( $this->getField( 'name' ) ) |
| 332 | 332 | ); |
| 333 | 333 | } |
| 334 | | - |
| | 334 | + |
| 335 | 335 | } |
| Index: trunk/extensions/EducationProgram/includes/EPTerm.php |
| — | — | @@ -16,15 +16,15 @@ |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Field for caching the linked course. |
| 20 | | - * |
| | 20 | + * |
| 21 | 21 | * @since 0.1 |
| 22 | 22 | * @var EPCourse|false |
| 23 | 23 | */ |
| 24 | 24 | protected $course = false; |
| 25 | | - |
| | 25 | + |
| 26 | 26 | /** |
| 27 | 27 | * Field for caching the linked org. |
| 28 | | - * |
| | 28 | + * |
| 29 | 29 | * @since 0.1 |
| 30 | 30 | * @var EPOrg|false |
| 31 | 31 | */ |
| — | — | @@ -77,7 +77,7 @@ |
| 78 | 78 | 'id' => 'id', |
| 79 | 79 | 'course_id' => 'id', |
| 80 | 80 | 'org_id' => 'id', |
| 81 | | - |
| | 81 | + |
| 82 | 82 | 'year' => 'int', |
| 83 | 83 | 'start' => 'str', // TS_MW |
| 84 | 84 | 'end' => 'str', // TS_MW |
| — | — | @@ -85,7 +85,7 @@ |
| 86 | 86 | 'token' => 'str', |
| 87 | 87 | ); |
| 88 | 88 | } |
| 89 | | - |
| | 89 | + |
| 90 | 90 | /** |
| 91 | 91 | * (non-PHPdoc) |
| 92 | 92 | * @see EPDBObject::getDefaults() |
| — | — | @@ -139,7 +139,7 @@ |
| 140 | 140 | |
| 141 | 141 | return $success; |
| 142 | 142 | } |
| 143 | | - |
| | 143 | + |
| 144 | 144 | /** |
| 145 | 145 | * (non-PHPdoc) |
| 146 | 146 | * @see EPDBObject::removeFromDB() |
| — | — | @@ -154,7 +154,7 @@ |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | $success = parent::removeFromDB(); |
| 158 | | - |
| | 158 | + |
| 159 | 159 | if ( $success && $this->updateSummaries ) { |
| 160 | 160 | EPCourse::updateSummaryFields( 'students', array( 'id' => $courseId ) ); |
| 161 | 161 | EPOrg::updateSummaryFields( array( 'terms', 'students', 'active' ), array( 'id' => $orgId ) ); |
| — | — | @@ -201,52 +201,52 @@ |
| 202 | 202 | |
| 203 | 203 | return $success; |
| 204 | 204 | } |
| 205 | | - |
| | 205 | + |
| 206 | 206 | /** |
| 207 | 207 | * Returns the course associated with this term. |
| 208 | | - * |
| | 208 | + * |
| 209 | 209 | * @since 0.1 |
| 210 | | - * |
| | 210 | + * |
| 211 | 211 | * @param string|array|null $fields |
| 212 | | - * |
| | 212 | + * |
| 213 | 213 | * @return EPCourse |
| 214 | 214 | */ |
| 215 | 215 | public function getCourse( $fields = null ) { |
| 216 | 216 | if ( $this->course === false ) { |
| 217 | 217 | $this->course = EPCourse::selectRow( $fields, array( 'id' => $this->loadAndGetField( 'course_id' ) ) ); |
| 218 | 218 | } |
| 219 | | - |
| | 219 | + |
| 220 | 220 | return $this->course; |
| 221 | 221 | } |
| 222 | | - |
| | 222 | + |
| 223 | 223 | /** |
| 224 | 224 | * Returns the org associated with this term. |
| 225 | | - * |
| | 225 | + * |
| 226 | 226 | * @since 0.1 |
| 227 | | - * |
| | 227 | + * |
| 228 | 228 | * @param string|array|null $fields |
| 229 | | - * |
| | 229 | + * |
| 230 | 230 | * @return EPOrg |
| 231 | 231 | */ |
| 232 | 232 | public function getOrg( $fields = null ) { |
| 233 | 233 | if ( $this->org === false ) { |
| 234 | 234 | $this->org = EPOrg::selectRow( $fields, array( 'id' => $this->loadAndGetField( 'org_id' ) ) ); |
| 235 | 235 | } |
| 236 | | - |
| | 236 | + |
| 237 | 237 | return $this->org; |
| 238 | 238 | } |
| 239 | | - |
| | 239 | + |
| 240 | 240 | /** |
| 241 | 241 | * Display a pager with terms. |
| 242 | | - * |
| | 242 | + * |
| 243 | 243 | * @since 0.1 |
| 244 | | - * |
| | 244 | + * |
| 245 | 245 | * @param IContextSource $context |
| 246 | 246 | * @param array $conditions |
| 247 | 247 | */ |
| 248 | 248 | public static function displayPager( IContextSource $context, array $conditions = array() ) { |
| 249 | 249 | $pager = new EPTermPager( $context, $conditions ); |
| 250 | | - |
| | 250 | + |
| 251 | 251 | if ( $pager->getNumRows() ) { |
| 252 | 252 | $context->getOutput()->addHTML( |
| 253 | 253 | $pager->getFilterControl() . |
| — | — | @@ -261,23 +261,23 @@ |
| 262 | 262 | $context->getOutput()->addWikiMsg( 'ep-terms-noresults' ); |
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | | - |
| | 265 | + |
| 266 | 266 | /** |
| 267 | 267 | * Adds a control to add a term org to the provided context. |
| 268 | 268 | * Additional arguments can be provided to set the default values for the control fields. |
| 269 | | - * |
| | 269 | + * |
| 270 | 270 | * @since 0.1 |
| 271 | | - * |
| | 271 | + * |
| 272 | 272 | * @param IContextSource $context |
| 273 | 273 | * @param array $args |
| 274 | | - * |
| | 274 | + * |
| 275 | 275 | * @return boolean |
| 276 | 276 | */ |
| 277 | 277 | public static function displayAddNewControl( IContextSource $context, array $args ) { |
| 278 | 278 | if ( !$context->getUser()->isAllowed( 'epmentor' ) ) { |
| 279 | 279 | return false; |
| 280 | 280 | } |
| 281 | | - |
| | 281 | + |
| 282 | 282 | $out = $context->getOutput(); |
| 283 | 283 | |
| 284 | 284 | $out->addHTML( Html::openElement( |
| — | — | @@ -295,16 +295,16 @@ |
| 296 | 296 | $out->addHTML( Html::element( 'p', array(), wfMsg( 'ep-terms-namedoc' ) ) ); |
| 297 | 297 | |
| 298 | 298 | $out->addHTML( Html::element( 'label', array( 'for' => 'newcourse' ), wfMsg( 'ep-terms-newcourse' ) ) ); |
| 299 | | - |
| | 299 | + |
| 300 | 300 | $select = new XmlSelect( |
| 301 | 301 | 'newcourse', |
| 302 | 302 | 'newcourse', |
| 303 | 303 | array_key_exists( 'course', $args ) ? $args['course'] : false |
| 304 | 304 | ); |
| 305 | | - |
| | 305 | + |
| 306 | 306 | $select->addOptions( EPCourse::getCourseOptions( EPCourse::getEditableCourses( $context->getUser() ) ) ); |
| 307 | 307 | $out->addHTML( $select->getHTML() ); |
| 308 | | - |
| | 308 | + |
| 309 | 309 | $out->addHTML( ' ' . Xml::inputLabel( wfMsg( 'ep-terms-newyear' ), 'newyear', 'newyear', 10 ) ); |
| 310 | 310 | |
| 311 | 311 | $out->addHTML( ' ' . Html::input( |
| — | — | @@ -314,24 +314,24 @@ |
| 315 | 315 | ) ); |
| 316 | 316 | |
| 317 | 317 | $out->addHTML( Html::hidden( 'isnew', 1 ) ); |
| 318 | | - |
| | 318 | + |
| 319 | 319 | $out->addHTML( '</fieldset></form>' ); |
| 320 | | - |
| | 320 | + |
| 321 | 321 | return true; |
| 322 | 322 | } |
| 323 | | - |
| | 323 | + |
| 324 | 324 | /** |
| 325 | 325 | * Adds a control to add a new term to the provided context |
| 326 | 326 | * or show a message if this is not possible for some reason. |
| 327 | | - * |
| | 327 | + * |
| 328 | 328 | * @since 0.1 |
| 329 | | - * |
| | 329 | + * |
| 330 | 330 | * @param IContextSource $context |
| 331 | 331 | * @param array $args |
| 332 | 332 | */ |
| 333 | 333 | public static function displayAddNewRegion( IContextSource $context, array $args = array() ) { |
| 334 | 334 | $courses = EPCourse::getEditableCourses( $context->getUser() ); |
| 335 | | - |
| | 335 | + |
| 336 | 336 | if ( count( $courses ) > 0 ) { |
| 337 | 337 | EPTerm::displayAddNewControl( $context, $args ); |
| 338 | 338 | } |
| — | — | @@ -342,29 +342,29 @@ |
| 343 | 343 | $context->getOutput()->addWikiMsg( 'ep-terms-addcoursefirst' ); |
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | | - |
| | 346 | + |
| 347 | 347 | /** |
| 348 | 348 | * Returns if the provided user can manage the term or not. |
| 349 | | - * |
| | 349 | + * |
| 350 | 350 | * @since 0.1 |
| 351 | | - * |
| | 351 | + * |
| 352 | 352 | * @param User $user |
| 353 | | - * |
| | 353 | + * |
| 354 | 354 | * @return boolean |
| 355 | 355 | */ |
| 356 | 356 | public function useCanManage( User $user ) { |
| 357 | 357 | if ( $user->isAllowed( 'epadmin' ) ) { |
| 358 | 358 | return true; |
| 359 | 359 | } |
| 360 | | - |
| | 360 | + |
| 361 | 361 | if ( $user->isAllowed( 'epmentor' ) ) { |
| 362 | 362 | $mentor = EPMentor::selectRow( 'id', array( 'user_id' => $user->getId() ) ); |
| 363 | | - |
| | 363 | + |
| 364 | 364 | if ( $mentor !== false ) { |
| 365 | 365 | return $mentor->hasTerm( array( 'id' => $this->getId() ) ); |
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | | - |
| | 368 | + |
| 369 | 369 | return false; |
| 370 | 370 | } |
| 371 | 371 | |
| — | — | @@ -403,7 +403,7 @@ |
| 404 | 404 | if ( $this->getDaysLeft() <= 0 ) { |
| 405 | 405 | $status = 'passed'; |
| 406 | 406 | } |
| 407 | | - elseif( $this->getDaysPassed() <= 0 ) { |
| | 407 | + elseif ( $this->getDaysPassed() <= 0 ) { |
| 408 | 408 | $status = 'planned'; |
| 409 | 409 | } |
| 410 | 410 | else { |
| Index: trunk/extensions/EducationProgram/includes/EPDBObject.php |
| — | — | @@ -2,12 +2,12 @@ |
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Abstract base class for representing objects that are stored in some DB table. |
| 6 | | - * |
| | 6 | + * |
| 7 | 7 | * These methods must be implemented in deriving classes: |
| 8 | 8 | * * getDBTable |
| 9 | 9 | * * getFieldPrefix |
| 10 | 10 | * * getFieldTypes |
| 11 | | - * |
| | 11 | + * |
| 12 | 12 | * These methods are likely candidates for overriding: |
| 13 | 13 | * * getDefaults |
| 14 | 14 | * |
| — | — | @@ -51,9 +51,9 @@ |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * Returns the name of the database table objects of this type are stored in. |
| 55 | | - * |
| | 55 | + * |
| 56 | 56 | * @since 0.1 |
| 57 | | - * |
| | 57 | + * |
| 58 | 58 | * @throws MWException |
| 59 | 59 | * @return string |
| 60 | 60 | */ |
| — | — | @@ -68,10 +68,10 @@ |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | | - * Gets the db field prefix. |
| 73 | | - * |
| | 72 | + * Gets the db field prefix. |
| | 73 | + * |
| 74 | 74 | * @since 0.1 |
| 75 | | - * |
| | 75 | + * |
| 76 | 76 | * @throws MWException |
| 77 | 77 | * @return string |
| 78 | 78 | */ |
| — | — | @@ -84,7 +84,7 @@ |
| 85 | 85 | throw new MWException( 'Class "' . get_called_class() . '" not found in $egEPDBObjects' ); |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | | - |
| | 88 | + |
| 89 | 89 | /** |
| 90 | 90 | * Returns an array with the fields and their types this object contains. |
| 91 | 91 | * This corresponds directly to the fields in the database, without prefix. |
| — | — | @@ -119,7 +119,7 @@ |
| 120 | 120 | public static function getDefaults() { |
| 121 | 121 | return array(); |
| 122 | 122 | } |
| 123 | | - |
| | 123 | + |
| 124 | 124 | /** |
| 125 | 125 | * Constructor. |
| 126 | 126 | * |
| — | — | @@ -515,7 +515,7 @@ |
| 516 | 516 | public static function newFromArray( array $data, $loadDefaults = false ) { |
| 517 | 517 | return new static( $data, $loadDefaults ); |
| 518 | 518 | } |
| 519 | | - |
| | 519 | + |
| 520 | 520 | /** |
| 521 | 521 | * Get the database type used for read operations. |
| 522 | 522 | * |
| — | — | @@ -583,13 +583,13 @@ |
| 584 | 584 | */ |
| 585 | 585 | public static function getPrefixedField( $field ) { |
| 586 | 586 | static $prefixes = false; |
| 587 | | - |
| | 587 | + |
| 588 | 588 | if ( $prefixes === false ) { |
| 589 | 589 | foreach ( $GLOBALS['egEPDBObjects'] as $classInfo ) { |
| 590 | 590 | $prefixes[$classInfo['table']] = $classInfo['prefix']; |
| 591 | 591 | } |
| 592 | 592 | } |
| 593 | | - |
| | 593 | + |
| 594 | 594 | if ( is_array( $field ) && count( $field ) > 1 ) { |
| 595 | 595 | if ( array_key_exists( $field[0], $prefixes ) ) { |
| 596 | 596 | $prefix = $prefixes[$field[0]]; |
| — | — | @@ -602,7 +602,7 @@ |
| 603 | 603 | else { |
| 604 | 604 | $prefix = static::getFieldPrefix(); |
| 605 | 605 | } |
| 606 | | - |
| | 606 | + |
| 607 | 607 | return $prefix . $field; |
| 608 | 608 | } |
| 609 | 609 | |
| — | — | @@ -610,7 +610,7 @@ |
| 611 | 611 | * Takes in an associative array with field names as keys and |
| 612 | 612 | * their values as value. The field names are prefixed with the |
| 613 | 613 | * db field prefix. |
| 614 | | - * |
| | 614 | + * |
| 615 | 615 | * Field names can also be provided as an array with as first element a table name, such as |
| 616 | 616 | * $conditions = array( |
| 617 | 617 | * array( array( 'tablename', 'fieldname' ), $value ), |
| — | — | @@ -638,7 +638,7 @@ |
| 639 | 639 | continue; |
| 640 | 640 | } |
| 641 | 641 | } |
| 642 | | - |
| | 642 | + |
| 643 | 643 | $prefixedValues[static::getPrefixedField( $field )] = $value; |
| 644 | 644 | } |
| 645 | 645 | |
| — | — | @@ -663,27 +663,27 @@ |
| 664 | 664 | array_values( $result ) |
| 665 | 665 | ); |
| 666 | 666 | } |
| 667 | | - |
| | 667 | + |
| 668 | 668 | /** |
| 669 | 669 | * Takes a field name with prefix and returns the unprefixed equivalent. |
| 670 | | - * |
| | 670 | + * |
| 671 | 671 | * @since 0.1 |
| 672 | | - * |
| | 672 | + * |
| 673 | 673 | * @param string $fieldName |
| 674 | | - * |
| | 674 | + * |
| 675 | 675 | * @return string |
| 676 | 676 | */ |
| 677 | 677 | public static function unprefixFieldName( $fieldName ) { |
| 678 | 678 | return substr( $fieldName, strlen( static::getFieldPrefix() ) ); |
| 679 | 679 | } |
| 680 | | - |
| | 680 | + |
| 681 | 681 | /** |
| 682 | 682 | * Takes an array of field names with prefix and returns the unprefixed equivalent. |
| 683 | | - * |
| | 683 | + * |
| 684 | 684 | * @since 0.1 |
| 685 | | - * |
| | 685 | + * |
| 686 | 686 | * @param array $fieldNames |
| 687 | | - * |
| | 687 | + * |
| 688 | 688 | * @return array |
| 689 | 689 | */ |
| 690 | 690 | public static function unprefixFieldNames( array $fieldNames ) { |
| — | — | @@ -783,13 +783,13 @@ |
| 784 | 784 | |
| 785 | 785 | return $objects; |
| 786 | 786 | } |
| 787 | | - |
| | 787 | + |
| 788 | 788 | /** |
| 789 | 789 | * Selects the the specified fields of the records matching the provided |
| 790 | 790 | * conditions and returns them as associative arrays. |
| 791 | 791 | * Provided field names get prefixed. |
| 792 | 792 | * Returned field names will not have a prefix. |
| 793 | | - * |
| | 793 | + * |
| 794 | 794 | * When $collapse is true: |
| 795 | 795 | * If one field is selected, each item in the result array will be this field. |
| 796 | 796 | * If two fields are selected, each item in the result array will have as key |
| — | — | @@ -830,46 +830,46 @@ |
| 831 | 831 | foreach ( $result as $record ) { |
| 832 | 832 | $objects[] = static::getFieldsFromDBResult( $record ); |
| 833 | 833 | } |
| 834 | | - |
| | 834 | + |
| 835 | 835 | if ( $collapse ) { |
| 836 | 836 | if ( count( $fields ) === 1 ) { |
| 837 | | - $objects = array_map( function( $object ) { return array_shift( $object ); }, $objects ); |
| | 837 | + $objects = array_map( function( $object ) { return array_shift( $object ); } , $objects ); |
| 838 | 838 | } |
| 839 | 839 | elseif ( count( $fields ) === 2 ) { |
| 840 | 840 | $o = array(); |
| 841 | | - |
| | 841 | + |
| 842 | 842 | foreach ( $objects as $object ) { |
| 843 | 843 | $o[array_shift( $object )] = array_shift( $object ); |
| 844 | 844 | } |
| 845 | | - |
| | 845 | + |
| 846 | 846 | $objects = $o; |
| 847 | 847 | } |
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | return $objects; |
| 851 | 851 | } |
| 852 | | - |
| | 852 | + |
| 853 | 853 | /** |
| 854 | 854 | * Process the join conditions. This includes prefixing table and field names, |
| 855 | | - * and adding of needed tables. |
| 856 | | - * |
| | 855 | + * and adding of needed tables. |
| | 856 | + * |
| 857 | 857 | * @since 0.1 |
| 858 | | - * |
| | 858 | + * |
| 859 | 859 | * @param array $joinConds Join conditions without prefixes and fields in array rather then string with equals sign. |
| 860 | 860 | * @param array $tables List of tables to which the extra needed ones get added. |
| 861 | | - * |
| | 861 | + * |
| 862 | 862 | * @return array Join conditions ready to be fed to MediaWikis native select function. |
| 863 | 863 | */ |
| 864 | 864 | protected static function getProcessedJoinConds( array $joinConds, array &$tables ) { |
| 865 | 865 | $conds = array(); |
| 866 | | - |
| | 866 | + |
| 867 | 867 | foreach ( $joinConds as $table => $joinCond ) { |
| 868 | 868 | if ( !in_array( $table, $tables ) ) { |
| 869 | 869 | $tables[] = $table; |
| 870 | 870 | } |
| 871 | | - |
| | 871 | + |
| 872 | 872 | $cond = array( $joinCond[0], array() ); |
| 873 | | - |
| | 873 | + |
| 874 | 874 | foreach ( $joinCond[1] as $joinCondPart ) { |
| 875 | 875 | $parts = array( |
| 876 | 876 | static::getPrefixedField( $joinCondPart[0] ), |
| — | — | @@ -884,9 +884,9 @@ |
| 885 | 885 | $tables[] = $joinCondPart[1][0]; |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | | - $cond[1][] = implode( '=', $parts ); |
| | 888 | + $cond[1][] = implode( '=', $parts ); |
| 889 | 889 | } |
| 890 | | - |
| | 890 | + |
| 891 | 891 | $conds[] = $cond; |
| 892 | 892 | } |
| 893 | 893 | |
| — | — | @@ -992,7 +992,7 @@ |
| 993 | 993 | if ( is_null( $tables ) ) { |
| 994 | 994 | $tables = static::getDBTable(); |
| 995 | 995 | } |
| 996 | | - |
| | 996 | + |
| 997 | 997 | $dbr = wfGetDB( static::getReadDb() ); |
| 998 | 998 | |
| 999 | 999 | return $dbr->select( |
| Index: trunk/extensions/EducationProgram/includes/EPPager.php |
| — | — | @@ -20,7 +20,7 @@ |
| 21 | 21 | * @var array |
| 22 | 22 | */ |
| 23 | 23 | protected $conds; |
| 24 | | - |
| | 24 | + |
| 25 | 25 | /** |
| 26 | 26 | * Name of the class deriving from EPDBObject. |
| 27 | 27 | * @since 0.1 |
| — | — | @@ -34,14 +34,14 @@ |
| 35 | 35 | * @var EPDBObject |
| 36 | 36 | */ |
| 37 | 37 | protected $currentObject; |
| 38 | | - |
| | 38 | + |
| 39 | 39 | /** |
| 40 | 40 | * Context in which this pager is being shown. |
| 41 | 41 | * @since 0.1 |
| 42 | 42 | * @var IContextSource |
| 43 | 43 | */ |
| 44 | 44 | protected $context; |
| 45 | | - |
| | 45 | + |
| 46 | 46 | /** |
| 47 | 47 | * Constructor. |
| 48 | 48 | * |
| — | — | @@ -53,16 +53,16 @@ |
| 54 | 54 | $this->conds = $conds; |
| 55 | 55 | $this->className = $className; |
| 56 | 56 | $this->context = $context; |
| 57 | | - |
| | 57 | + |
| 58 | 58 | $this->mDefaultDirection = true; |
| 59 | | - |
| | 59 | + |
| 60 | 60 | if ( method_exists( 'TablePager', 'getUser' ) ) { |
| 61 | 61 | parent::__construct( $context ); |
| 62 | 62 | } |
| 63 | 63 | else { |
| 64 | 64 | parent::__construct(); |
| 65 | 65 | } |
| 66 | | - |
| | 66 | + |
| 67 | 67 | $this->context->getOutput()->addModules( 'ep.pager' ); |
| 68 | 68 | } |
| 69 | 69 | |
| — | — | @@ -89,7 +89,7 @@ |
| 90 | 90 | public function getLanguage() { |
| 91 | 91 | return method_exists( $this->context, 'getLanguage' ) ? $this->context->getLanguage() : $this->context->getLang(); |
| 92 | 92 | } |
| 93 | | - |
| | 93 | + |
| 94 | 94 | /** |
| 95 | 95 | * Get the User being used for this instance. |
| 96 | 96 | * IndexPager extends ContextSource as of 1.19. |
| — | — | @@ -101,7 +101,7 @@ |
| 102 | 102 | public function getUser() { |
| 103 | 103 | return $this->context->getUser(); |
| 104 | 104 | } |
| 105 | | - |
| | 105 | + |
| 106 | 106 | /** |
| 107 | 107 | * Get the WebRequest being used for this instance. |
| 108 | 108 | * IndexPager extends ContextSource as of 1.19. |
| — | — | @@ -113,7 +113,7 @@ |
| 114 | 114 | public function getRequest() { |
| 115 | 115 | return $this->context->getRequest(); |
| 116 | 116 | } |
| 117 | | - |
| | 117 | + |
| 118 | 118 | /** |
| 119 | 119 | * Get the Title being used for this instance. |
| 120 | 120 | * IndexPager extends ContextSource as of 1.19. |
| — | — | @@ -125,7 +125,7 @@ |
| 126 | 126 | public function getTitle() { |
| 127 | 127 | return $this->context->getTitle(); |
| 128 | 128 | } |
| 129 | | - |
| | 129 | + |
| 130 | 130 | /** |
| 131 | 131 | * (non-PHPdoc) |
| 132 | 132 | * @see TablePager::formatRow() |
| — | — | @@ -133,7 +133,7 @@ |
| 134 | 134 | function formatRow( $row ) { |
| 135 | 135 | $c = $this->className; // Yeah, this is needed in PHP 5.3 >_> |
| 136 | 136 | $this->currentObject = $c::newFromDBResult( $row ); |
| 137 | | - |
| | 137 | + |
| 138 | 138 | $cells = array(); |
| 139 | 139 | |
| 140 | 140 | foreach ( $this->getFieldNames() as $field => $name ) { |
| — | — | @@ -157,13 +157,13 @@ |
| 158 | 158 | $prefixedField = $c::getPrefixedField( $field ); |
| 159 | 159 | $value = isset( $row->$prefixedField ) ? $row->$prefixedField : null; |
| 160 | 160 | } |
| 161 | | - |
| | 161 | + |
| 162 | 162 | $formatted = strval( $this->formatValue( $field, $value ) ); |
| 163 | | - |
| | 163 | + |
| 164 | 164 | if ( $formatted == '' ) { |
| 165 | 165 | $formatted = ' '; |
| 166 | 166 | } |
| 167 | | - |
| | 167 | + |
| 168 | 168 | $cells[] = Html::rawElement( 'td', $this->getCellAttrs( $field, $value ), $formatted ); |
| 169 | 169 | } |
| 170 | 170 | |
| — | — | @@ -172,9 +172,9 @@ |
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | 175 | * Returns the relevant field names. |
| 176 | | - * |
| | 176 | + * |
| 177 | 177 | * @since 0.1 |
| 178 | | - * |
| | 178 | + * |
| 179 | 179 | * @return array |
| 180 | 180 | */ |
| 181 | 181 | public function getFieldNames() { |
| — | — | @@ -196,20 +196,20 @@ |
| 197 | 197 | |
| 198 | 198 | return $fields; |
| 199 | 199 | } |
| 200 | | - |
| | 200 | + |
| 201 | 201 | /** |
| 202 | 202 | * Returns HTML for the multiple item control. |
| 203 | 203 | * With actions coming from @see getMultipleItemActions. |
| 204 | | - * |
| | 204 | + * |
| 205 | 205 | * @since 0.1 |
| 206 | | - * |
| | 206 | + * |
| 207 | 207 | * @return string |
| 208 | 208 | */ |
| 209 | 209 | public function getMultipleItemControl() { |
| 210 | 210 | if ( !$this->hasMultipleItemControl() ) { |
| 211 | 211 | return ''; |
| 212 | 212 | } |
| 213 | | - |
| | 213 | + |
| 214 | 214 | $controls = array(); |
| 215 | 215 | |
| 216 | 216 | foreach ( $this->getMultipleItemActions() as $label => $attribs ) { |
| — | — | @@ -235,13 +235,13 @@ |
| 236 | 236 | implode( '', $controls ) . |
| 237 | 237 | '</fieldset>'; |
| 238 | 238 | } |
| 239 | | - |
| | 239 | + |
| 240 | 240 | /** |
| 241 | 241 | * Return the multiple item actions the current user can do. |
| 242 | 242 | * Override in deriving classes to add actions. |
| 243 | | - * |
| | 243 | + * |
| 244 | 244 | * @since 0.1 |
| 245 | | - * |
| | 245 | + * |
| 246 | 246 | * @return array |
| 247 | 247 | */ |
| 248 | 248 | protected function getMultipleItemActions() { |
| — | — | @@ -278,54 +278,54 @@ |
| 279 | 279 | protected function hasActionsColumn() { |
| 280 | 280 | return true; |
| 281 | 281 | } |
| 282 | | - |
| | 282 | + |
| 283 | 283 | /** |
| 284 | 284 | * Returns the fields to display. |
| 285 | 285 | * Similar to @see getFieldNames, but fields should not be prefixed, and |
| 286 | 286 | * non-relevant fields will be removed. |
| 287 | | - * |
| | 287 | + * |
| 288 | 288 | * @since 0.1 |
| 289 | | - * |
| | 289 | + * |
| 290 | 290 | * @return array |
| 291 | 291 | */ |
| 292 | 292 | protected abstract function getFields(); |
| 293 | | - |
| | 293 | + |
| 294 | 294 | /** |
| 295 | 295 | * (non-PHPdoc) |
| 296 | 296 | * @see IndexPager::getQueryInfo() |
| 297 | 297 | */ |
| 298 | 298 | function getQueryInfo() { |
| 299 | | - $c = $this->className; // Yeah, this is needed in PHP 5.3 >_> |
| | 299 | + $c = $this->className; // Yeah, this is needed in PHP 5.3 >_> |
| 300 | 300 | return array( |
| 301 | 301 | 'tables' => array( $c::getDBTable() ), |
| 302 | 302 | 'fields' => $c::getPrefixedFields( $c::getFieldNames() ), |
| 303 | 303 | 'conds' => $c::getPrefixedValues( $this->getConditions() ), |
| 304 | 304 | ); |
| 305 | 305 | } |
| 306 | | - |
| | 306 | + |
| 307 | 307 | /** |
| 308 | 308 | * Get the conditions to use in the query. |
| 309 | 309 | * This is done by merging the filter controls conditions with those provided to the constructor. |
| 310 | | - * |
| | 310 | + * |
| 311 | 311 | * @since 0.1 |
| 312 | | - * |
| | 312 | + * |
| 313 | 313 | * @return array |
| 314 | 314 | */ |
| 315 | 315 | protected function getConditions() { |
| 316 | 316 | $conds = array(); |
| 317 | | - |
| | 317 | + |
| 318 | 318 | $filterOptions = $this->getFilterOptions(); |
| 319 | 319 | $this->addFilterValues( $filterOptions, false ); |
| 320 | | - |
| | 320 | + |
| 321 | 321 | foreach ( $filterOptions as $optionName => $optionData ) { |
| 322 | 322 | if ( array_key_exists( 'value', $optionData ) && $optionData['value'] !== '' ) { |
| 323 | 323 | $conds[$optionName] = $optionData['value']; |
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | | - |
| | 326 | + |
| 327 | 327 | return array_merge( $conds, $this->conds ); |
| 328 | 328 | } |
| 329 | | - |
| | 329 | + |
| 330 | 330 | /** |
| 331 | 331 | * (non-PHPdoc) |
| 332 | 332 | * @see TablePager::isFieldSortable() |
| — | — | @@ -342,63 +342,63 @@ |
| 343 | 343 | $c = $this->className; // Yeah, this is needed in PHP 5.3 >_> |
| 344 | 344 | return $c::getPrefixedField( 'id' ); |
| 345 | 345 | } |
| 346 | | - |
| | 346 | + |
| 347 | 347 | /** |
| 348 | 348 | * Should return an array with the names of the fields that are sortable. |
| 349 | | - * |
| | 349 | + * |
| 350 | 350 | * @since 0.1 |
| 351 | | - * |
| | 351 | + * |
| 352 | 352 | * @return array of string |
| 353 | 353 | */ |
| 354 | 354 | protected abstract function getSortableFields(); |
| 355 | | - |
| | 355 | + |
| 356 | 356 | /** |
| 357 | 357 | * Returns a list with the filter options. |
| 358 | | - * |
| | 358 | + * |
| 359 | 359 | * @since 0.1 |
| 360 | | - * |
| 361 | | - * @return array |
| | 360 | + * |
| | 361 | + * @return array |
| 362 | 362 | */ |
| 363 | 363 | protected function getFilterOptions() { |
| 364 | 364 | return array(); |
| 365 | 365 | } |
| 366 | | - |
| | 366 | + |
| 367 | 367 | /** |
| 368 | 368 | * Gets the HTML for a filter control. |
| 369 | | - * |
| | 369 | + * |
| 370 | 370 | * @since 0.1 |
| 371 | | - * |
| 372 | | - * @param boolean $hideWhenNoResults When true, there are no results, and no filters are applied, an empty string is returned. |
| 373 | | - * |
| | 371 | + * |
| | 372 | + * @param boolean $hideWhenNoResults When true, there are no results, and no filters are applied, an empty string is returned. |
| | 373 | + * |
| 374 | 374 | * @return string |
| 375 | 375 | */ |
| 376 | 376 | public function getFilterControl( $hideWhenNoResults = true ) { |
| 377 | 377 | $filterOptions = $this->getFilterOptions(); |
| 378 | | - |
| | 378 | + |
| 379 | 379 | foreach ( $this->conds as $name => $value ) { |
| 380 | 380 | if ( array_key_exists( $name, $filterOptions ) ) { |
| 381 | 381 | unset( $filterOptions[$name] ); |
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | | - |
| | 384 | + |
| 385 | 385 | if ( count( $filterOptions ) < 1 ) { |
| 386 | 386 | return ''; |
| 387 | 387 | } |
| 388 | | - |
| | 388 | + |
| 389 | 389 | $this->addFilterValues( $filterOptions ); |
| 390 | | - |
| | 390 | + |
| 391 | 391 | if ( $hideWhenNoResults && $this->getNumRows() < 1 ) { |
| 392 | 392 | $noFiltersSet = array_reduce( $filterOptions, function( $current, array $data ) { |
| 393 | 393 | return $current && ( $data['value'] === '' || is_null( $data['value'] ) ); |
| 394 | | - }, true ); |
| 395 | | - |
| | 394 | + } , true ); |
| | 395 | + |
| 396 | 396 | if ( $noFiltersSet ) { |
| 397 | 397 | return ''; |
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | | - |
| | 400 | + |
| 401 | 401 | $controls = array(); |
| 402 | | - |
| | 402 | + |
| 403 | 403 | foreach ( $filterOptions as $optionName => $optionData ) { |
| 404 | 404 | switch ( $optionData['type'] ) { |
| 405 | 405 | case 'select': |
| — | — | @@ -407,14 +407,14 @@ |
| 408 | 408 | $control = $select->getHTML(); |
| 409 | 409 | break; |
| 410 | 410 | } |
| 411 | | - |
| | 411 | + |
| 412 | 412 | $control = ' ' . $this->getMsg( 'filter-' . $optionName ) . ' ' . $control; |
| 413 | | - |
| | 413 | + |
| 414 | 414 | $controls[] = $control; |
| 415 | 415 | } |
| 416 | | - |
| | 416 | + |
| 417 | 417 | $title = $this->getTitle()->getFullText(); |
| 418 | | - |
| | 418 | + |
| 419 | 419 | return |
| 420 | 420 | '<fieldset>' . |
| 421 | 421 | '<legend>' . wfMsgHtml( 'ep-pager-showonly' ) . '</legend>' . |
| — | — | @@ -426,16 +426,16 @@ |
| 427 | 427 | '</form>' . |
| 428 | 428 | '</fieldset>'; |
| 429 | 429 | } |
| 430 | | - |
| | 430 | + |
| 431 | 431 | /** |
| 432 | 432 | * Changes the provided filter options list by replacing the values by what's set |
| 433 | | - * in the request, or as fallback, what's set in the session. |
| 434 | | - * |
| | 433 | + * in the request, or as fallback, what's set in the session. |
| | 434 | + * |
| 435 | 435 | * @since 0.1 |
| 436 | | - * |
| | 436 | + * |
| 437 | 437 | * @param array $filterOptions |
| 438 | 438 | * @param boolean $cast Should values with non-string type be casted (ie to have a select with int values have the correct val selected). |
| 439 | | - * |
| | 439 | + * |
| 440 | 440 | * @return boolean If anything was changed from the default |
| 441 | 441 | */ |
| 442 | 442 | protected function addFilterValues( array &$filterOptions, $cast = true ) { |
| — | — | @@ -447,7 +447,7 @@ |
| 448 | 448 | $optionData['value'] = $req->getVal( $optionName ); |
| 449 | 449 | $req->setSessionData( get_called_class() . $optionName, $optionData['value'] ); |
| 450 | 450 | $changed = true; |
| 451 | | - |
| | 451 | + |
| 452 | 452 | if ( $cast && array_key_exists( 'datatype', $optionData ) ) { |
| 453 | 453 | switch ( $optionData['datatype'] ) { |
| 454 | 454 | case 'int': |
| — | — | @@ -464,24 +464,24 @@ |
| 465 | 465 | $changed = true; |
| 466 | 466 | } |
| 467 | 467 | } |
| 468 | | - |
| | 468 | + |
| 469 | 469 | return $changed; |
| 470 | 470 | } |
| 471 | | - |
| | 471 | + |
| 472 | 472 | /** |
| 473 | 473 | * Takes a message key and prefixes it with the extension name and name of the pager, |
| 474 | 474 | * feeds it to wfMsg, and returns it. |
| 475 | | - * |
| | 475 | + * |
| 476 | 476 | * @since 0.1 |
| 477 | | - * |
| | 477 | + * |
| 478 | 478 | * @param string $messageKey |
| 479 | | - * |
| | 479 | + * |
| 480 | 480 | * @return string |
| 481 | 481 | */ |
| 482 | 482 | protected function getMsg( $messageKey ) { |
| 483 | 483 | return wfMsg( strtolower( $this->className ) . 'pager-' . str_replace( '_', '-', $messageKey ) ); |
| 484 | 484 | } |
| 485 | | - |
| | 485 | + |
| 486 | 486 | /** |
| 487 | 487 | * (non-PHPdoc) |
| 488 | 488 | * @see TablePager::formatValue() |
| — | — | @@ -489,41 +489,41 @@ |
| 490 | 490 | public final function formatValue( $name, $value ) { |
| 491 | 491 | return $this->getFormattedValue( $name, $value ); |
| 492 | 492 | } |
| 493 | | - |
| | 493 | + |
| 494 | 494 | /** |
| 495 | 495 | * Similar to TablePager::formatValue, but passes along the name of the field without prefix. |
| 496 | 496 | * Returned values need to be escaped! |
| 497 | 497 | * |
| 498 | 498 | * @since 0.1 |
| 499 | | - * |
| | 499 | + * |
| 500 | 500 | * @param string $name |
| 501 | 501 | * @param string $value |
| 502 | | - * |
| | 502 | + * |
| 503 | 503 | * @return string |
| 504 | 504 | */ |
| 505 | 505 | protected abstract function getFormattedValue( $name, $value ); |
| 506 | | - |
| | 506 | + |
| 507 | 507 | /** |
| 508 | 508 | * Returns a list of (escaped, html) links to add in an additional column. |
| 509 | | - * |
| | 509 | + * |
| 510 | 510 | * @since 0.1 |
| 511 | | - * |
| | 511 | + * |
| 512 | 512 | * @param EPDBObject $item |
| 513 | | - * |
| | 513 | + * |
| 514 | 514 | * @return array |
| 515 | 515 | */ |
| 516 | 516 | protected function getControlLinks( EPDBObject $item ) { |
| 517 | 517 | return array(); |
| 518 | 518 | } |
| 519 | | - |
| | 519 | + |
| 520 | 520 | /** |
| 521 | 521 | * Returns a deletion link. |
| 522 | | - * |
| | 522 | + * |
| 523 | 523 | * @since 0.1 |
| 524 | | - * |
| | 524 | + * |
| 525 | 525 | * @param string $type |
| 526 | 526 | * @param integer $id |
| 527 | | - * |
| | 527 | + * |
| 528 | 528 | * @return string |
| 529 | 529 | */ |
| 530 | 530 | protected function getDeletionLink( $type, $id ) { |
| — | — | @@ -542,7 +542,7 @@ |
| 543 | 543 | /** |
| 544 | 544 | * (non-PHPdoc) |
| 545 | 545 | * @see TablePager::getStartBody() |
| 546 | | - * |
| | 546 | + * |
| 547 | 547 | * Mostly just a copy of parent class function. |
| 548 | 548 | * Allows for having a checlbox in the selection column header. |
| 549 | 549 | * Would obviously be better if parent class supported doing this nicer. |
| — | — | @@ -551,10 +551,10 @@ |
| 552 | 552 | global $wgStylePath; |
| 553 | 553 | $tableClass = htmlspecialchars( $this->getTableClass() ); |
| 554 | 554 | $sortClass = htmlspecialchars( $this->getSortHeaderClass() ); |
| 555 | | - |
| | 555 | + |
| 556 | 556 | $s = "<table style='border:1;' class=\"mw-datatable $tableClass\"><thead><tr>\n"; |
| 557 | 557 | $fields = $this->getFieldNames(); |
| 558 | | - |
| | 558 | + |
| 559 | 559 | # Make table header |
| 560 | 560 | foreach ( $fields as $field => $name ) { |
| 561 | 561 | $c = $this->className; // Yeah, this is needed in PHP 5.3 >_> |
| Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php |
| — | — | @@ -35,7 +35,7 @@ |
| 36 | 36 | 'active', |
| 37 | 37 | ); |
| 38 | 38 | } |
| 39 | | - |
| | 39 | + |
| 40 | 40 | /** |
| 41 | 41 | * (non-PHPdoc) |
| 42 | 42 | * @see TablePager::getRowClass() |
| — | — | @@ -43,12 +43,12 @@ |
| 44 | 44 | function getRowClass( $row ) { |
| 45 | 45 | return 'ep-course-row'; |
| 46 | 46 | } |
| 47 | | - |
| | 47 | + |
| 48 | 48 | /** |
| 49 | 49 | * (non-PHPdoc) |
| 50 | 50 | * @see TablePager::getTableClass() |
| 51 | 51 | */ |
| 52 | | - public function getTableClass(){ |
| | 52 | + public function getTableClass() { |
| 53 | 53 | return 'TablePager ep-courses'; |
| 54 | 54 | } |
| 55 | 55 | |
| — | — | @@ -66,7 +66,7 @@ |
| 67 | 67 | break; |
| 68 | 68 | case 'org_id': |
| 69 | 69 | $value = EPOrg::selectRow( 'name', array( 'id' => $value ) )->getField( 'name' ); |
| 70 | | - |
| | 70 | + |
| 71 | 71 | $value = Linker::linkKnown( |
| 72 | 72 | SpecialPage::getTitleFor( 'Institution', $value ), |
| 73 | 73 | htmlspecialchars( $value ) |
| — | — | @@ -99,7 +99,7 @@ |
| 100 | 100 | 'active', |
| 101 | 101 | ); |
| 102 | 102 | } |
| 103 | | - |
| | 103 | + |
| 104 | 104 | /** |
| 105 | 105 | * (non-PHPdoc) |
| 106 | 106 | * @see EPPager::getFilterOptions() |
| — | — | @@ -126,29 +126,29 @@ |
| 127 | 127 | ), |
| 128 | 128 | ); |
| 129 | 129 | } |
| 130 | | - |
| | 130 | + |
| 131 | 131 | /** |
| 132 | 132 | * (non-PHPdoc) |
| 133 | 133 | * @see EPPager::getControlLinks() |
| 134 | 134 | */ |
| 135 | 135 | protected function getControlLinks( EPDBObject $item ) { |
| 136 | 136 | $links = parent::getControlLinks( $item ); |
| 137 | | - |
| | 137 | + |
| 138 | 138 | $links[] = $value = Linker::linkKnown( |
| 139 | 139 | SpecialPage::getTitleFor( 'Course', $item->getField( 'name' ) ), |
| 140 | 140 | wfMsgHtml( 'view' ) |
| 141 | 141 | ); |
| 142 | | - |
| | 142 | + |
| 143 | 143 | if ( $this->getUser()->isAllowed( 'epadmin' ) ) { |
| 144 | 144 | $links[] = $value = Linker::linkKnown( |
| 145 | 145 | SpecialPage::getTitleFor( 'EditCourse', $item->getField( 'name' ) ), |
| 146 | 146 | wfMsgHtml( 'edit' ) |
| 147 | 147 | ); |
| 148 | | - |
| | 148 | + |
| 149 | 149 | $links[] = $this->getDeletionLink( 'course', $item->getId() ); |
| 150 | 150 | } |
| 151 | | - |
| | 151 | + |
| 152 | 152 | return $links; |
| 153 | 153 | } |
| 154 | | - |
| | 154 | + |
| 155 | 155 | } |
| Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
| — | — | @@ -16,12 +16,12 @@ |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Field for caching the linked org. |
| 20 | | - * |
| | 20 | + * |
| 21 | 21 | * @since 0.1 |
| 22 | 22 | * @var EPOrg|false |
| 23 | 23 | */ |
| 24 | 24 | protected $org = false; |
| 25 | | - |
| | 25 | + |
| 26 | 26 | /** |
| 27 | 27 | * @see parent::getFieldTypes |
| 28 | 28 | * |
| — | — | @@ -33,7 +33,7 @@ |
| 34 | 34 | return array( |
| 35 | 35 | 'id' => 'id', |
| 36 | 36 | 'org_id' => 'id', |
| 37 | | - |
| | 37 | + |
| 38 | 38 | 'name' => 'str', |
| 39 | 39 | 'description' => 'str', |
| 40 | 40 | 'lang' => 'str', |
| — | — | @@ -42,7 +42,7 @@ |
| 43 | 43 | 'students' => 'int', |
| 44 | 44 | ); |
| 45 | 45 | } |
| 46 | | - |
| | 46 | + |
| 47 | 47 | /** |
| 48 | 48 | * (non-PHPdoc) |
| 49 | 49 | * @see EPDBObject::getDefaults() |
| — | — | @@ -99,7 +99,7 @@ |
| 100 | 100 | |
| 101 | 101 | $this->setFields( $fields ); |
| 102 | 102 | } |
| 103 | | - |
| | 103 | + |
| 104 | 104 | /** |
| 105 | 105 | * (non-PHPdoc) |
| 106 | 106 | * @see EPDBObject::removeFromDB() |
| — | — | @@ -113,7 +113,7 @@ |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $success = parent::removeFromDB(); |
| 117 | | - |
| | 117 | + |
| 118 | 118 | if ( $success ) { |
| 119 | 119 | foreach ( EPTerm::select( 'id', array( 'course_id' => $id ) ) as /* EPTerm */ $term ) { |
| 120 | 120 | $term->setUpdateSummaries( false ); |
| — | — | @@ -162,100 +162,100 @@ |
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | 165 | * Returns the org associated with this course. |
| 166 | | - * |
| | 166 | + * |
| 167 | 167 | * @since 0.1 |
| 168 | | - * |
| | 168 | + * |
| 169 | 169 | * @param string|array|null $fields |
| 170 | | - * |
| | 170 | + * |
| 171 | 171 | * @return EPOrg |
| 172 | 172 | */ |
| 173 | 173 | public function getOrg( $fields = null ) { |
| 174 | 174 | if ( $this->org === false ) { |
| 175 | 175 | $this->org = EPOrg::selectRow( $fields, array( 'id' => $this->getField( 'org_id' ) ) ); |
| 176 | 176 | } |
| 177 | | - |
| | 177 | + |
| 178 | 178 | return $this->org; |
| 179 | 179 | } |
| 180 | | - |
| | 180 | + |
| 181 | 181 | /** |
| 182 | 182 | * Returns a list of courses in an array that can be fed to select inputs. |
| 183 | | - * |
| | 183 | + * |
| 184 | 184 | * @since 0.1 |
| 185 | | - * |
| | 185 | + * |
| 186 | 186 | * @param array $courses |
| 187 | | - * |
| | 187 | + * |
| 188 | 188 | * @return array |
| 189 | 189 | */ |
| 190 | 190 | public static function getCourseOptions( array /* EPCourse */ $courses ) { |
| 191 | 191 | $options = array(); |
| 192 | | - |
| | 192 | + |
| 193 | 193 | foreach ( $courses as /* EPCourse */ $course ) { |
| 194 | 194 | $options[$course->getField( 'name' )] = $course->getId(); |
| 195 | 195 | } |
| 196 | | - |
| | 196 | + |
| 197 | 197 | return $options; |
| 198 | 198 | } |
| 199 | | - |
| | 199 | + |
| 200 | 200 | /** |
| 201 | 201 | * Returns the list of orgs that the specified user can edit. |
| 202 | | - * |
| | 202 | + * |
| 203 | 203 | * @since 0.1 |
| 204 | | - * |
| | 204 | + * |
| 205 | 205 | * @param User|int $user |
| 206 | 206 | * @param array|null $fields |
| 207 | | - * |
| | 207 | + * |
| 208 | 208 | * @return array of EPCourse |
| 209 | 209 | */ |
| 210 | 210 | public static function getEditableCourses( $user, array $fields = null ) { |
| 211 | 211 | static $cache = array(); |
| 212 | | - |
| | 212 | + |
| 213 | 213 | if ( is_int( $user ) ) { |
| 214 | 214 | $userId = $user; |
| 215 | 215 | } |
| 216 | 216 | else { |
| 217 | 217 | $userId = $user->getId(); |
| 218 | 218 | } |
| 219 | | - |
| | 219 | + |
| 220 | 220 | if ( !array_key_exists( $userId, $cache ) ) { |
| 221 | 221 | if ( is_int( $user ) ) { |
| 222 | 222 | $user = User::newFromId( $userId ); |
| 223 | 223 | } |
| 224 | | - |
| | 224 | + |
| 225 | 225 | $courses = array(); |
| 226 | | - |
| | 226 | + |
| 227 | 227 | if ( $user->isAllowed( 'epadmin' ) ) { |
| 228 | 228 | $courses = self::select( $fields ); |
| 229 | 229 | } |
| 230 | 230 | elseif ( $user->isAllowed( 'epmentor' ) ) { |
| 231 | 231 | $mentor = EPMentor::select( array( 'user_id' => $user->getId() ) ); |
| 232 | | - |
| | 232 | + |
| 233 | 233 | if ( $mentor !== false ) { |
| 234 | 234 | $courses = $mentor->getCourses( $fields ); |
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | | - |
| | 237 | + |
| 238 | 238 | $cache[$userId] = $courses; |
| 239 | 239 | } |
| 240 | | - |
| | 240 | + |
| 241 | 241 | return $cache[$userId]; |
| 242 | 242 | } |
| 243 | | - |
| | 243 | + |
| 244 | 244 | /** |
| 245 | 245 | * Adds a control to add a new course to the provided context. |
| 246 | 246 | * Additional arguments can be provided to set the default values for the control fields. |
| 247 | | - * |
| | 247 | + * |
| 248 | 248 | * @since 0.1 |
| 249 | | - * |
| | 249 | + * |
| 250 | 250 | * @param IContextSource $context |
| 251 | 251 | * @param array $args |
| 252 | | - * |
| | 252 | + * |
| 253 | 253 | * @return boolean |
| 254 | 254 | */ |
| 255 | 255 | public static function displayAddNewControl( IContextSource $context, array $args = array() ) { |
| 256 | 256 | if ( !$context->getUser()->isAllowed( 'epmentor' ) ) { |
| 257 | 257 | return false; |
| 258 | 258 | } |
| 259 | | - |
| | 259 | + |
| 260 | 260 | $out = $context->getOutput(); |
| 261 | 261 | |
| 262 | 262 | $out->addHTML( Html::openElement( |
| — | — | @@ -273,7 +273,7 @@ |
| 274 | 274 | $out->addHTML( Html::element( 'p', array(), wfMsg( 'ep-courses-namedoc' ) ) ); |
| 275 | 275 | |
| 276 | 276 | $out->addHTML( Html::element( 'label', array( 'for' => 'neworg' ), wfMsg( 'ep-courses-neworg' ) ) ); |
| 277 | | - |
| | 277 | + |
| 278 | 278 | $out->addHTML( ' ' ); |
| 279 | 279 | |
| 280 | 280 | $select = new XmlSelect( |
| — | — | @@ -284,9 +284,9 @@ |
| 285 | 285 | |
| 286 | 286 | $select->addOptions( EPOrg::getOrgOptions( EPOrg::getEditableOrgs( $context->getUser() ) ) ); |
| 287 | 287 | $out->addHTML( $select->getHTML() ); |
| 288 | | - |
| | 288 | + |
| 289 | 289 | $out->addHTML( ' ' ); |
| 290 | | - |
| | 290 | + |
| 291 | 291 | $out->addHTML( Xml::inputLabel( |
| 292 | 292 | wfMsg( 'ep-courses-newname' ), |
| 293 | 293 | 'newname', |
| — | — | @@ -296,7 +296,7 @@ |
| 297 | 297 | ) ); |
| 298 | 298 | |
| 299 | 299 | $out->addHTML( ' ' ); |
| 300 | | - |
| | 300 | + |
| 301 | 301 | $out->addHTML( Html::input( |
| 302 | 302 | 'addneworg', |
| 303 | 303 | wfMsg( 'ep-courses-add' ), |
| — | — | @@ -306,22 +306,22 @@ |
| 307 | 307 | $out->addHTML( Html::hidden( 'isnew', 1 ) ); |
| 308 | 308 | |
| 309 | 309 | $out->addHTML( '</fieldset></form>' ); |
| 310 | | - |
| | 310 | + |
| 311 | 311 | return true; |
| 312 | 312 | } |
| 313 | | - |
| | 313 | + |
| 314 | 314 | /** |
| 315 | 315 | * Adds a control to add a new course to the provided context |
| 316 | 316 | * or show a message if this is not possible for some reason. |
| 317 | | - * |
| | 317 | + * |
| 318 | 318 | * @since 0.1 |
| 319 | | - * |
| | 319 | + * |
| 320 | 320 | * @param IContextSource $context |
| 321 | 321 | * @param array $args |
| 322 | 322 | */ |
| 323 | 323 | public static function displayAddNewRegion( IContextSource $context, array $args = array() ) { |
| 324 | 324 | $orgs = EPOrg::getEditableOrgs( $context->getUser() ); |
| 325 | | - |
| | 325 | + |
| 326 | 326 | if ( count( $orgs ) > 0 ) { |
| 327 | 327 | EPCourse::displayAddNewControl( $context, $args ); |
| 328 | 328 | } |
| — | — | @@ -332,18 +332,18 @@ |
| 333 | 333 | $context->getOutput()->addWikiMsg( 'ep-courses-addorgfirst' ); |
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | | - |
| | 336 | + |
| 337 | 337 | /** |
| 338 | 338 | * Display a pager with courses. |
| 339 | | - * |
| | 339 | + * |
| 340 | 340 | * @since 0.1 |
| 341 | | - * |
| | 341 | + * |
| 342 | 342 | * @param IContextSource $context |
| 343 | 343 | * @param array $conditions |
| 344 | 344 | */ |
| 345 | 345 | public static function displayPager( IContextSource $context, array $conditions = array() ) { |
| 346 | 346 | $pager = new EPCoursePager( $context, $conditions ); |
| 347 | | - |
| | 347 | + |
| 348 | 348 | if ( $pager->getNumRows() ) { |
| 349 | 349 | $context->getOutput()->addHTML( |
| 350 | 350 | $pager->getFilterControl() . |
| — | — | @@ -358,29 +358,29 @@ |
| 359 | 359 | $context->getOutput()->addWikiMsg( 'ep-courses-noresults' ); |
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | | - |
| | 362 | + |
| 363 | 363 | /** |
| 364 | 364 | * Returns if the provided user can manage the course or not. |
| 365 | | - * |
| | 365 | + * |
| 366 | 366 | * @since 0.1 |
| 367 | | - * |
| | 367 | + * |
| 368 | 368 | * @param User $user |
| 369 | | - * |
| | 369 | + * |
| 370 | 370 | * @return boolean |
| 371 | 371 | */ |
| 372 | 372 | public function useCanManage( User $user ) { |
| 373 | 373 | if ( $user->isAllowed( 'epadmin' ) ) { |
| 374 | 374 | return true; |
| 375 | 375 | } |
| 376 | | - |
| | 376 | + |
| 377 | 377 | if ( $user->isAllowed( 'epmentor' ) ) { |
| 378 | 378 | $mentor = EPMentor::selectRow( 'id', array( 'user_id' => $user->getId() ) ); |
| 379 | | - |
| | 379 | + |
| 380 | 380 | if ( $mentor !== false ) { |
| 381 | 381 | return $mentor->hasCourse( array( 'id' => $this->getId() ) ); |
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | | - |
| | 384 | + |
| 385 | 385 | return false; |
| 386 | 386 | } |
| 387 | 387 | |
| Index: trunk/extensions/EducationProgram/includes/EPMentorPager.php |
| — | — | @@ -12,7 +12,6 @@ |
| 13 | 13 | * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | 14 | */ |
| 15 | 15 | class EPMentorPager extends EPPager { |
| 16 | | - |
| 17 | 16 | /** |
| 18 | 17 | * Constructor. |
| 19 | 18 | * |
| — | — | @@ -36,7 +35,7 @@ |
| 37 | 36 | 'user_id', |
| 38 | 37 | ); |
| 39 | 38 | } |
| 40 | | - |
| | 39 | + |
| 41 | 40 | /** |
| 42 | 41 | * (non-PHPdoc) |
| 43 | 42 | * @see TablePager::getRowClass() |
| — | — | @@ -44,12 +43,12 @@ |
| 45 | 44 | function getRowClass( $row ) { |
| 46 | 45 | return 'ep-mentor-row'; |
| 47 | 46 | } |
| 48 | | - |
| | 47 | + |
| 49 | 48 | /** |
| 50 | 49 | * (non-PHPdoc) |
| 51 | 50 | * @see TablePager::getTableClass() |
| 52 | 51 | */ |
| 53 | | - public function getTableClass(){ |
| | 52 | + public function getTableClass() { |
| 54 | 53 | return 'TablePager ep-mentors'; |
| 55 | 54 | } |
| 56 | 55 | |
| Index: trunk/extensions/EducationProgram/EducationProgram.php |
| — | — | @@ -151,17 +151,17 @@ |
| 152 | 152 | |
| 153 | 153 | # Users that can manage the education program. |
| 154 | 154 | $wgGroupPermissions['*' ]['epadmin'] = false; |
| 155 | | -//$wgGroupPermissions['user' ]['epadmin'] = false; |
| 156 | | -//$wgGroupPermissions['autoconfirmed']['epadmin'] = false; |
| 157 | | -//$wgGroupPermissions['bot' ]['epadmin'] = false; |
| | 155 | +// $wgGroupPermissions['user' ]['epadmin'] = false; |
| | 156 | +// $wgGroupPermissions['autoconfirmed']['epadmin'] = false; |
| | 157 | +// $wgGroupPermissions['bot' ]['epadmin'] = false; |
| 158 | 158 | $wgGroupPermissions['sysop' ]['epadmin'] = true; |
| 159 | 159 | $wgGroupPermissions['epadmin' ]['epadmin'] = true; |
| 160 | 160 | |
| 161 | 161 | # Users that can enroll as students in the education program. |
| 162 | 162 | $wgGroupPermissions['*' ]['epstudent'] = false; |
| 163 | 163 | $wgGroupPermissions['user' ]['epstudent'] = true; |
| 164 | | -//$wgGroupPermissions['autoconfirmed']['epstudent'] = true; |
| 165 | | -//$wgGroupPermissions['bot' ]['epstudent'] = false; |
| | 164 | +// $wgGroupPermissions['autoconfirmed']['epstudent'] = true; |
| | 165 | +// $wgGroupPermissions['bot' ]['epstudent'] = false; |
| 166 | 166 | $wgGroupPermissions['sysop' ]['epstudent'] = true; |
| 167 | 167 | $wgGroupPermissions['epadmin']['epstudent'] = true; |
| 168 | 168 | $wgGroupPermissions['epstudent' ]['epstudent'] = true; |
| — | — | @@ -170,8 +170,8 @@ |
| 171 | 171 | # Users that act as mentors in the education program. |
| 172 | 172 | $wgGroupPermissions['*' ]['epmentor'] = false; |
| 173 | 173 | $wgGroupPermissions['user' ]['epmentor'] = true; |
| 174 | | -//$wgGroupPermissions['autoconfirmed']['epmentor'] = true; |
| 175 | | -//$wgGroupPermissions['bot' ]['epmentor'] = false; |
| | 174 | +// $wgGroupPermissions['autoconfirmed']['epmentor'] = true; |
| | 175 | +// $wgGroupPermissions['bot' ]['epmentor'] = false; |
| 176 | 176 | $wgGroupPermissions['sysop' ]['epmentor'] = true; |
| 177 | 177 | $wgGroupPermissions['epadmin']['epmentor'] = true; |
| 178 | 178 | $wgGroupPermissions['epmentor' ]['epmentor'] = true; |
| — | — | @@ -237,12 +237,12 @@ |
| 238 | 238 | $countries = CountryNames::getNames( $langCode ); |
| 239 | 239 | |
| 240 | 240 | return array_merge( |
| 241 | | - array( '' => '' ), |
| | 241 | + array( '' => '' ), |
| 242 | 242 | array_combine( |
| 243 | 243 | array_map( |
| 244 | 244 | function( $value, $key ) { |
| 245 | 245 | return $key . ' - ' . $value; |
| 246 | | - }, |
| | 246 | + } , |
| 247 | 247 | array_values( $countries ), |
| 248 | 248 | array_keys( $countries ) |
| 249 | 249 | ), |
| Index: trunk/extensions/EducationProgram/api/ApiDeleteEducation.php |
| — | — | @@ -47,10 +47,10 @@ |
| 48 | 48 | |
| 49 | 49 | return $map[$className]; |
| 50 | 50 | } |
| 51 | | - |
| | 51 | + |
| 52 | 52 | public function execute() { |
| 53 | 53 | $params = $this->extractRequestParams(); |
| 54 | | - |
| | 54 | + |
| 55 | 55 | if ( !$this->userIsAllowed( $params['type'], $params ) || $this->getUser()->isBlocked() ) { |
| 56 | 56 | $this->dieUsageMsg( array( 'badaccess-groups' ) ); |
| 57 | 57 | } |
| — | — | @@ -71,12 +71,12 @@ |
| 72 | 72 | $everythingOk |
| 73 | 73 | ); |
| 74 | 74 | } |
| 75 | | - |
| | 75 | + |
| 76 | 76 | /** |
| 77 | 77 | * Returns if the user is allowed to delete the specified object(s). |
| 78 | 78 | * |
| 79 | 79 | * @since 0.1 |
| 80 | | - * |
| | 80 | + * |
| 81 | 81 | * @param string $type |
| 82 | 82 | * @param array $params |
| 83 | 83 | * |
| — | — | @@ -84,22 +84,22 @@ |
| 85 | 85 | */ |
| 86 | 86 | protected function userIsAllowed( $type, array $params ) { |
| 87 | 87 | $user = $this->getUser(); |
| 88 | | - |
| | 88 | + |
| 89 | 89 | if ( $type === 'student' ) { |
| 90 | 90 | return EPStudent::selectField( 'id', array( 'user_id' => $user->getId() ) ) === $params['id']; |
| 91 | 91 | } |
| 92 | | - |
| | 92 | + |
| 93 | 93 | if ( $type === 'mentor' ) { |
| 94 | 94 | return EPMentor::selectField( 'id', array( 'user_id' => $user->getId() ) ) === $params['id']; |
| 95 | 95 | } |
| 96 | | - |
| | 96 | + |
| 97 | 97 | if ( $user->isAllowed( 'epadmin' ) ) { |
| 98 | 98 | return true; |
| 99 | 99 | } |
| 100 | | - |
| | 100 | + |
| 101 | 101 | if ( $user->isAllowed( 'epmentor' ) ) { |
| 102 | 102 | $mentor = new EPMentor( null, array( 'user_id' => $user->getId() ) ); |
| 103 | | - |
| | 103 | + |
| 104 | 104 | if ( $mentor !== false ) { |
| 105 | 105 | if ( $type === 'course' ) { |
| 106 | 106 | return $mentor->hasCourse( array( 'id' => $params['id'] ) ); |
| — | — | @@ -109,7 +109,7 @@ |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | | - |
| | 113 | + |
| 114 | 114 | return false; |
| 115 | 115 | } |
| 116 | 116 | |
| — | — | @@ -124,7 +124,7 @@ |
| 125 | 125 | public function getUser() { |
| 126 | 126 | return method_exists( 'ApiBase', 'getUser' ) ? parent::getUser() : $GLOBALS['wgUser']; |
| 127 | 127 | } |
| 128 | | - |
| | 128 | + |
| 129 | 129 | public function needsToken() { |
| 130 | 130 | return true; |
| 131 | 131 | } |
| Index: trunk/extensions/EducationProgram/resources/ep.api.js |
| — | — | @@ -7,9 +7,9 @@ |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | window.educationProgram = new( function() { |
| 11 | | - |
| | 11 | + |
| 12 | 12 | this.api = new( function() { |
| 13 | | - |
| | 13 | + |
| 14 | 14 | this.remove = function( data, callback ) { |
| 15 | 15 | var requestArgs = { |
| 16 | 16 | 'action': 'deleteeducation', |
| — | — | @@ -18,21 +18,21 @@ |
| 19 | 19 | 'ids': data.ids.join( '|' ), |
| 20 | 20 | 'type': data.type |
| 21 | 21 | }; |
| 22 | | - |
| | 22 | + |
| 23 | 23 | $.post( |
| 24 | 24 | wgScriptPath + '/api.php', |
| 25 | 25 | requestArgs, |
| 26 | 26 | function( data ) { |
| 27 | 27 | var success = data.hasOwnProperty( 'success' ) && data.success; |
| 28 | | - |
| | 28 | + |
| 29 | 29 | callback( { |
| 30 | 30 | 'success': success |
| 31 | 31 | } ); |
| 32 | | - } |
| 33 | | - ); |
| | 32 | + } |
| | 33 | + ); |
| 34 | 34 | }; |
| 35 | | - |
| | 35 | + |
| 36 | 36 | } ); |
| 37 | | - |
| | 37 | + |
| 38 | 38 | } ); |
| 39 | 39 | |
| Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php |
| — | — | @@ -120,5 +120,5 @@ |
| 121 | 121 | |
| 122 | 122 | return true; |
| 123 | 123 | } |
| 124 | | - |
| | 124 | + |
| 125 | 125 | } |
| Index: trunk/extensions/EducationProgram/README |
| — | — | @@ -1,5 +1,5 @@ |
| 2 | 2 | These is the readme file for the Education Program extension. |
| 3 | | - |
| | 3 | + |
| 4 | 4 | Extension page on mediawiki.org: https://www.mediawiki.org/wiki/Extension:Education_Program |
| 5 | 5 | Latest version of the readme file: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/EducationProgram/README?view=co |
| 6 | 6 | |
| Index: trunk/extensions/ShortUrl/populateShortUrlTable.php |
| — | — | @@ -29,7 +29,7 @@ |
| 30 | 30 | |
| 31 | 31 | $last_processed_id = 0; |
| 32 | 32 | |
| 33 | | - while( true ) { |
| | 33 | + while ( true ) { |
| 34 | 34 | $insertBuffer = array(); |
| 35 | 35 | $res = $dbr->select( |
| 36 | 36 | 'page', |
| — | — | @@ -38,11 +38,11 @@ |
| 39 | 39 | __METHOD__, |
| 40 | 40 | array( 'LIMIT' => 100, 'ORDER BY' => 'page_id' ) |
| 41 | 41 | ); |
| 42 | | - if( $res->numRows() == 0 ) { |
| | 42 | + if ( $res->numRows() == 0 ) { |
| 43 | 43 | break; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | | - foreach( $res as $row ) { |
| | 46 | + foreach ( $res as $row ) { |
| 47 | 47 | $rowCount++; |
| 48 | 48 | |
| 49 | 49 | $rowData = array( |
| Index: trunk/extensions/ShortUrl/README |
| — | — | @@ -8,7 +8,7 @@ |
| 9 | 9 | |
| 10 | 10 | == Installing == |
| 11 | 11 | |
| 12 | | -Copy the ShortUrl directory into the extensions folder of your |
| | 12 | +Copy the ShortUrl directory into the extensions folder of your |
| 13 | 13 | MediaWiki installation. Then add the following lines to your |
| 14 | 14 | LocalSettings.php file (near the end): |
| 15 | 15 | |
| — | — | @@ -16,6 +16,6 @@ |
| 17 | 17 | |
| 18 | 18 | == Configuration == |
| 19 | 19 | |
| 20 | | -$wgShortUrlPrefix specifies the prefix to use before the shorturl. |
| | 20 | +$wgShortUrlPrefix specifies the prefix to use before the shorturl. |
| 21 | 21 | Defaults to using the longer form (with Special:ShortUrl). Can be |
| 22 | 22 | condensed down to use anything else, via mod_rewrite rules |
| Index: trunk/extensions/MobileFrontend/FooterTemplate.php |
| — | — | @@ -1,11 +1,11 @@ |
| 2 | 2 | <?php |
| 3 | 3 | |
| 4 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| | 4 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 5 | 5 | die( -1 ); |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | class FooterTemplate extends MobileFrontendTemplate { |
| 9 | | - |
| | 9 | + |
| 10 | 10 | public function getHTML() { |
| 11 | 11 | |
| 12 | 12 | $regularSite = $this->data['messages']['mobile-frontend-regular-site']; |
| Index: trunk/extensions/MobileFrontend/LeaveFeedbackTemplate.php |
| — | — | @@ -1,11 +1,11 @@ |
| 2 | 2 | <?php |
| 3 | 3 | |
| 4 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| | 4 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 5 | 5 | die( -1 ); |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | class LeaveFeedbackTemplate extends MobileFrontendTemplate { |
| 9 | | - |
| | 9 | + |
| 10 | 10 | public function getHTML() { |
| 11 | 11 | |
| 12 | 12 | $leaveFeedbackHtml = <<<HTML |
| Index: trunk/extensions/MobileFrontend/ApplicationTemplate.php |
| — | — | @@ -1,6 +1,6 @@ |
| 2 | 2 | <?php |
| 3 | 3 | |
| 4 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| | 4 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 5 | 5 | die( -1 ); |
| 6 | 6 | } |
| 7 | 7 | |
| — | — | @@ -13,7 +13,7 @@ |
| 14 | 14 | } else { |
| 15 | 15 | $appleTouchIconTag = ''; |
| 16 | 16 | } |
| 17 | | - |
| | 17 | + |
| 18 | 18 | $zeroRatedBanner = ( isset( $this->data['zeroRatedBanner'] ) ) ? str_replace( 'style="display:none;"', '', $this->data['zeroRatedBanner'] ) : ''; |
| 19 | 19 | |
| 20 | 20 | $betaPrefix = ( $this->data['isBetaGroupMember'] ) ? 'beta_' : ''; |
| Index: trunk/extensions/MobileFrontend/DisableTemplate.php |
| — | — | @@ -1,6 +1,6 @@ |
| 2 | 2 | <?php |
| 3 | 3 | |
| 4 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| | 4 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 5 | 5 | die( -1 ); |
| 6 | 6 | } |
| 7 | 7 | |
| Index: trunk/extensions/MobileFrontend/SearchTemplate.php |
| — | — | @@ -1,11 +1,11 @@ |
| 2 | 2 | <?php |
| 3 | 3 | |
| 4 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| | 4 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 5 | 5 | die( -1 ); |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | class SearchTemplate extends MobileFrontendTemplate { |
| 9 | | - |
| | 9 | + |
| 10 | 10 | public function getHTML() { |
| 11 | 11 | |
| 12 | 12 | $searchField = htmlspecialchars( $this->data['searchField'] ); |
| Index: trunk/extensions/MobileFrontend/MobileFrontendTemplate.php |
| — | — | @@ -1,6 +1,6 @@ |
| 2 | 2 | <?php |
| 3 | 3 | |
| 4 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| | 4 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 5 | 5 | die( -1 ); |
| 6 | 6 | } |
| 7 | 7 | |
| — | — | @@ -29,7 +29,7 @@ |
| 30 | 30 | * @param $value |
| 31 | 31 | */ |
| 32 | 32 | public function setByArray( $options ) { |
| 33 | | - foreach ($options as $name => $value ) { |
| | 33 | + foreach ( $options as $name => $value ) { |
| 34 | 34 | $this->set( $name, $value ); |
| 35 | 35 | } |
| 36 | 36 | } |
| Index: trunk/extensions/MobileFrontend/MobileFrontend.php |
| — | — | @@ -378,7 +378,7 @@ |
| 379 | 379 | 'lang' => $wgLanguageCode, |
| 380 | 380 | ); |
| 381 | 381 | |
| 382 | | - foreach( $wgOut->getLanguageLinks() as $l ) { |
| | 382 | + foreach ( $wgOut->getLanguageLinks() as $l ) { |
| 383 | 383 | $tmp = explode( ':', $l, 2 ); |
| 384 | 384 | $class = 'interwiki-' . $tmp[0]; |
| 385 | 385 | $lang = $tmp[0]; |
| — | — | @@ -424,7 +424,7 @@ |
| 425 | 425 | wfProfileOut( __METHOD__ ); |
| 426 | 426 | return true; |
| 427 | 427 | } |
| 428 | | - |
| | 428 | + |
| 429 | 429 | /** |
| 430 | 430 | * @param $parsedUrl wfParseUrl Array |
| 431 | 431 | * @return string |
| — | — | @@ -471,7 +471,7 @@ |
| 472 | 472 | |
| 473 | 473 | $redirect = $this->parsePageRedirect( $parsedUrl ); |
| 474 | 474 | } |
| 475 | | - } else if ($out->getTitle()->isSpecial( 'Randompage' ) ) { |
| | 475 | + } else if ( $out->getTitle()->isSpecial( 'Randompage' ) ) { |
| 476 | 476 | $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : ''; |
| 477 | 477 | if ( $xDevice ) { |
| 478 | 478 | $parsedUrl = wfParseUrl( $redirect ); |
| — | — | @@ -740,7 +740,7 @@ |
| 741 | 741 | if ( !empty( $_SERVER['HTTP_APPLICATION_VERSION'] ) && |
| 742 | 742 | strpos( $_SERVER['HTTP_APPLICATION_VERSION'], 'Wikipedia Mobile' ) !== false ) { |
| 743 | 743 | self::$hideSearchBox = true; |
| 744 | | - if (strpos( $_SERVER['HTTP_APPLICATION_VERSION'], 'Android' ) !== false ) { |
| | 744 | + if ( strpos( $_SERVER['HTTP_APPLICATION_VERSION'], 'Android' ) !== false ) { |
| 745 | 745 | self::$hideLogo = true; |
| 746 | 746 | } |
| 747 | 747 | } |
| — | — | @@ -1238,7 +1238,7 @@ |
| 1239 | 1239 | |
| 1240 | 1240 | $content = $this->mainPage->createElement( 'div' ); |
| 1241 | 1241 | $content->setAttribute( 'id', 'content' ); |
| 1242 | | - |
| | 1242 | + |
| 1243 | 1243 | if ( $zeroLandingPage ) { |
| 1244 | 1244 | $content->appendChild( $zeroLandingPage ); |
| 1245 | 1245 | } |
| — | — | @@ -1301,7 +1301,7 @@ |
| 1302 | 1302 | 'id' => 'wpName1', |
| 1303 | 1303 | 'tabindex' => '1', |
| 1304 | 1304 | 'size' => '20', |
| 1305 | | - 'required') ) . |
| | 1305 | + 'required' ) ) . |
| 1306 | 1306 | Html::closeElement( 'td' ) . |
| 1307 | 1307 | Html::closeElement( 'tr' ) . |
| 1308 | 1308 | Html::openElement( 'tr' ) . |
| — | — | @@ -1318,7 +1318,7 @@ |
| 1319 | 1319 | array( 'class' => 'loginPassword', |
| 1320 | 1320 | 'id' => 'wpPassword1', |
| 1321 | 1321 | 'tabindex' => '2', |
| 1322 | | - 'size' => '20') ) . |
| | 1322 | + 'size' => '20' ) ) . |
| 1323 | 1323 | Html::closeElement( 'td' ) . |
| 1324 | 1324 | Html::closeElement( 'tr' ) . |
| 1325 | 1325 | Html::openElement( 'tr' ) . |
| — | — | @@ -1329,7 +1329,7 @@ |
| 1330 | 1330 | array( 'class' => 'mw-submit' ) ) . |
| 1331 | 1331 | Html::input( 'wpLoginAttempt', self::$messages['mobile-frontend-login'], 'submit', |
| 1332 | 1332 | array( 'id' => 'wpLoginAttempt', |
| 1333 | | - 'tabindex' => '3') ) . |
| | 1333 | + 'tabindex' => '3' ) ) . |
| 1334 | 1334 | Html::closeElement( 'td' ) . |
| 1335 | 1335 | Html::closeElement( 'tr' ) . |
| 1336 | 1336 | Html::closeElement( 'tbody' ) . |
| — | — | @@ -1354,7 +1354,7 @@ |
| 1355 | 1355 | $dom->preserveWhiteSpace = false; |
| 1356 | 1356 | $dom->strictErrorChecking = false; |
| 1357 | 1357 | $dom->encoding = 'UTF-8'; |
| 1358 | | - $node = $dom->getElementsByTagName( $tagName )->item(0); |
| | 1358 | + $node = $dom->getElementsByTagName( $tagName )->item( 0 ); |
| 1359 | 1359 | wfProfileOut( __METHOD__ ); |
| 1360 | 1360 | return $node; |
| 1361 | 1361 | } |
| — | — | @@ -1378,7 +1378,7 @@ |
| 1379 | 1379 | $itemToRemoveRecords = $this->parseItemsToRemove(); |
| 1380 | 1380 | |
| 1381 | 1381 | $zeroRatedBannerElement = $this->doc->getElementById( 'zero-rated-banner' ); |
| 1382 | | - |
| | 1382 | + |
| 1383 | 1383 | if ( !$zeroRatedBannerElement ) { |
| 1384 | 1384 | $zeroRatedBannerElement = $this->doc->getElementById( 'zero-rated-banner-red' ); |
| 1385 | 1385 | } |
| — | — | @@ -1395,7 +1395,7 @@ |
| 1396 | 1396 | self::$logoutHtml = $this->doc->saveXML( $ptLogoutLink, LIBXML_NOEMPTYTAG ); |
| 1397 | 1397 | } |
| 1398 | 1398 | $ptAnonLogin = $this->doc->getElementById( 'pt-anonlogin' ); |
| 1399 | | - |
| | 1399 | + |
| 1400 | 1400 | if ( !$ptAnonLogin ) { |
| 1401 | 1401 | $ptAnonLogin = $this->doc->getElementById( 'pt-login' ); |
| 1402 | 1402 | } |
| — | — | @@ -1448,7 +1448,7 @@ |
| 1449 | 1449 | $itemToRemoveRecords['CLASS'][] = "thumbcaption"; |
| 1450 | 1450 | $itemToRemoveRecords['CLASS'][] = "gallery"; |
| 1451 | 1451 | } |
| 1452 | | - |
| | 1452 | + |
| 1453 | 1453 | $tagToRemoveNodeIdAttributeValues = array( 'zero-language-search' ); |
| 1454 | 1454 | |
| 1455 | 1455 | $domElemsToRemove = array(); |
| — | — | @@ -1554,7 +1554,7 @@ |
| 1555 | 1555 | $contentHtml = preg_replace( '#</?' . $element . '[^>]*>#is', '', $contentHtml ); |
| 1556 | 1556 | } |
| 1557 | 1557 | |
| 1558 | | - //Wml for searching |
| | 1558 | + // Wml for searching |
| 1559 | 1559 | $searchWml = '<p><input emptyok="true" format="*M" type="text" name="search" value="" size="16" />' . |
| 1560 | 1560 | '<do type="accept" label="' . self::$messages['mobile-frontend-search-submit'] . '">' . |
| 1561 | 1561 | '<go href="' . $wgScript . '?title=Special%3ASearch&search=$(search)"></go></do></p>'; |
| — | — | @@ -1695,7 +1695,7 @@ |
| 1696 | 1696 | $output = Html::openElement( 'select', |
| 1697 | 1697 | array( 'id' => 'languageselection', |
| 1698 | 1698 | 'onchange' => 'javascript:navigateToLanguageSelection();' ) ); |
| 1699 | | - foreach (self::$languageUrls as $languageUrl) { |
| | 1699 | + foreach ( self::$languageUrls as $languageUrl ) { |
| 1700 | 1700 | if ( $languageUrl['lang'] == $wgLanguageCode ) { |
| 1701 | 1701 | $output .= Html::element( 'option', |
| 1702 | 1702 | array( 'value' => $languageUrl['href'], 'selected' => 'selected' ), |
| Index: trunk/extensions/MobileFrontend/tests/DeviceDetectionTest.php |
| — | — | @@ -4,7 +4,7 @@ |
| 5 | 5 | * @group MobileFrontend |
| 6 | 6 | */ |
| 7 | 7 | class DeviceDetectionTest extends MediaWikiTestCase { |
| 8 | | - |
| | 8 | + |
| 9 | 9 | /** |
| 10 | 10 | * @dataProvider provideTestFormatName |
| 11 | 11 | */ |
| Index: trunk/extensions/MobileFrontend/ApplicationWmlTemplate.php |
| — | — | @@ -1,11 +1,11 @@ |
| 2 | 2 | <?php |
| 3 | 3 | |
| 4 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| | 4 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 5 | 5 | die( -1 ); |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | class ApplicationWmlTemplate extends MobileFrontendTemplate { |
| 9 | | - |
| | 9 | + |
| 10 | 10 | public function getHTML() { |
| 11 | 11 | $mainPageUrl = $this->data['mainPageUrl']; |
| 12 | 12 | $randomPageUrl = $this->data['randomPageUrl']; |
| — | — | @@ -14,7 +14,7 @@ |
| 15 | 15 | |
| 16 | 16 | $applicationHtml = <<<HTML |
| 17 | 17 | <?xml version='1.0' encoding='utf-8' ?> |
| 18 | | - <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" |
| | 18 | + <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" |
| 19 | 19 | "http://www.wapforum.org/DTD/wml13.dtd"> |
| 20 | 20 | <wml xml:lang="{$code}" dir="{$dir}"> |
| 21 | 21 | <template> |
| Index: trunk/extensions/MobileFrontend/OptInTemplate.php |
| — | — | @@ -1,11 +1,11 @@ |
| 2 | 2 | <?php |
| 3 | 3 | |
| 4 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| | 4 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 5 | 5 | die( -1 ); |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | class OptInTemplate extends MobileFrontendTemplate { |
| 9 | | - |
| | 9 | + |
| 10 | 10 | public function getHTML() { |
| 11 | 11 | |
| 12 | 12 | $optInHtml = <<<HTML |
| Index: trunk/extensions/MobileFrontend/OptOutTemplate.php |
| — | — | @@ -1,11 +1,11 @@ |
| 2 | 2 | <?php |
| 3 | 3 | |
| 4 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| | 4 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 5 | 5 | die( -1 ); |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | class OptOutTemplate extends MobileFrontendTemplate { |
| 9 | | - |
| | 9 | + |
| 10 | 10 | public function getHTML() { |
| 11 | 11 | $optOutHtml = <<<HTML |
| 12 | 12 | <h1> |
| Index: trunk/extensions/MobileFrontend/ThanksNoticeTemplate.php |
| — | — | @@ -1,11 +1,11 @@ |
| 2 | 2 | <?php |
| 3 | 3 | |
| 4 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| | 4 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 5 | 5 | die( -1 ); |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | class ThanksNoticeTemplate extends MobileFrontendTemplate { |
| 9 | | - |
| | 9 | + |
| 10 | 10 | public function getHTML() { |
| 11 | 11 | |
| 12 | 12 | $thanks = $this->data['messages']['mobile-frontend-leave-feedback-thanks']; |
| Index: trunk/extensions/SwiftMedia/SwiftMedia.i18n.php |
| — | — | @@ -2,7 +2,7 @@ |
| 3 | 3 | $messages = array(); |
| 4 | 4 | |
| 5 | 5 | $messages['en'] = array( |
| 6 | | - 'swiftmedia' => 'Openstack\'s Swift is a very large scale reliable object store. It will serve multiple petabytes of media files. |
| | 6 | + 'swiftmedia' => 'Openstack\'s Swift is a very large scale reliable object store. It will serve multiple petabytes of media files. |
| 7 | 7 | [[Extension:SwiftMedia]] allows MediaWiki uploads to be stored in Swift.', |
| 8 | 8 | ); |
| 9 | 9 | |
| Index: trunk/extensions/SwiftMedia/TODO |
| — | — | @@ -57,7 +57,7 @@ |
| 58 | 58 | neilk_: in the old design, in essence, all this does is move a file into an NFS directory, and creates the matching database entry which creates a wiki page. |
| 59 | 59 | neilk_: so far I don't think this should be news? |
| 60 | 60 | nelson____: right |
| 61 | | -neilk_: So that's includes/specials/SpecialUpload.php |
| | 61 | +neilk_: So that's includes/specials/SpecialUpload.php |
| 62 | 62 | neilk_: then there's includes/api/ApiUpload.php |
| 63 | 63 | neilk_: which is similar but not quite the same |
| 64 | 64 | |
| — | — | @@ -72,7 +72,7 @@ |
| 73 | 73 | nelson____: yes. |
| 74 | 74 | neilk_: ok so that's the overview of the upload methods & stashing, what else |
| 75 | 75 | nelson____: I think that part of the problem is that various parts of the system feel free to make the jump from "stored" to "accessible as full path". |
| 76 | | -neilk_: yes |
| | 76 | +neilk_: yes |
| 77 | 77 | neilk_: it drove me nuts too |
| 78 | 78 | neilk_: and the code intentionally conflates a number of cases, because MediaWiki at heart just wants to throw a number of files into a directory, not manage millions of them |
| 79 | 79 | nelson____: I gotta figure out how to mark the difference, so that something is either 1) a locally stored file, or 2) a blind token from the repo. |
| — | — | @@ -91,7 +91,7 @@ |
| 92 | 92 | nelson____: maybe ... what I should do is throw an exception if SwiftRepo::resolveVirtualUrl ever gets called without a mwrepo url, and then just go test everything. |
| 93 | 93 | nelson____: I think maybe I'm trying to overanalyze the code. |
| 94 | 94 | neilk_: I sympathize |
| 95 | | -nelson____: I should trust the code more. |
| | 95 | +nelson____: I should trust the code more. |
| 96 | 96 | neilk_: hm, I think not |
| 97 | 97 | nelson____: Trust but verify. |
| 98 | 98 | neilk_: also, this is sad but stashing is done in two slightly different ways, too. |
| Index: trunk/extensions/SwiftMedia/php-fakecloudfiles/fake_cloudfiles.php |
| — | — | @@ -15,12 +15,12 @@ |
| 16 | 16 | die( "Nothing to see here.\n" ); |
| 17 | 17 | } |
| 18 | 18 | require_once( dirname( __FILE__ ) . "/../php-cloudfiles/cloudfiles_exceptions.php" ); |
| 19 | | -define("DEFAULT_CF_API_VERSION", 1); |
| 20 | | -define("MAX_CONTAINER_NAME_LEN", 256); |
| 21 | | -define("MAX_OBJECT_NAME_LEN", 1024); |
| 22 | | -define("MAX_OBJECT_SIZE", 5*1024*1024*1024+1); |
| 23 | | -define("US_AUTHURL", "https://auth.api.rackspacecloud.com"); |
| 24 | | -define("UK_AUTHURL", "https://lon.auth.api.rackspacecloud.com"); |
| | 19 | +define( "DEFAULT_CF_API_VERSION", 1 ); |
| | 20 | +define( "MAX_CONTAINER_NAME_LEN", 256 ); |
| | 21 | +define( "MAX_OBJECT_NAME_LEN", 1024 ); |
| | 22 | +define( "MAX_OBJECT_SIZE", 5 * 1024 * 1024 * 1024 + 1 ); |
| | 23 | +define( "US_AUTHURL", "https://auth.api.rackspacecloud.com" ); |
| | 24 | +define( "UK_AUTHURL", "https://lon.auth.api.rackspacecloud.com" ); |
| 25 | 25 | /** |
| 26 | 26 | * Class for handling Cloud Files Authentication, call it's {@link authenticate()} |
| 27 | 27 | * method to obtain authorized service urls and an authentication token. |
| — | — | @@ -76,7 +76,7 @@ |
| 77 | 77 | * @param string $account <i>Account name</i> |
| 78 | 78 | * @param string $auth_host <i>Authentication service URI</i> |
| 79 | 79 | */ |
| 80 | | - function __construct($username=NULL, $api_key=NULL, $account=NULL, $auth_host=US_AUTHURL) |
| | 80 | + function __construct( $username = NULL, $api_key = NULL, $account = NULL, $auth_host = US_AUTHURL ) |
| 81 | 81 | { |
| 82 | 82 | |
| 83 | 83 | $this->dbug = False; |
| — | — | @@ -88,7 +88,7 @@ |
| 89 | 89 | $this->storage_url = NULL; |
| 90 | 90 | $this->cdnm_url = NULL; |
| 91 | 91 | $this->auth_token = NULL; |
| 92 | | - |
| | 92 | + |
| 93 | 93 | $this->cfs_http = NULL; |
| 94 | 94 | } |
| 95 | 95 | |
| — | — | @@ -115,7 +115,7 @@ |
| 116 | 116 | * @throws AuthenticationException invalid credentials |
| 117 | 117 | * @throws InvalidResponseException invalid response |
| 118 | 118 | */ |
| 119 | | - function authenticate($version=DEFAULT_CF_API_VERSION) |
| | 119 | + function authenticate( $version = DEFAULT_CF_API_VERSION ) |
| 120 | 120 | { |
| 121 | 121 | $this->storage_url = 'http://localhost/swift/storage/someuserurl'; |
| 122 | 122 | $this->cdnm_url = 'http://localhost/swift/curl/someuserurl'; |
| — | — | @@ -132,14 +132,14 @@ |
| 133 | 133 | * #Pass Cached URL's and Token as Args |
| 134 | 134 | * $auth->load_cached_credentials("auth_token", "storage_url", "cdn_management_url"); |
| 135 | 135 | * </code> |
| 136 | | - * |
| | 136 | + * |
| 137 | 137 | * @param string $auth_token A Cloud Files Auth Token (Required) |
| 138 | 138 | * @param string $storage_url The Cloud Files Storage URL (Required) |
| 139 | 139 | * @param string $cdnm_url CDN Management URL (Required) |
| 140 | | - * @return boolean <kbd>True</kbd> if successful |
| | 140 | + * @return boolean <kbd>True</kbd> if successful |
| 141 | 141 | * @throws SyntaxException If any of the Required Arguments are missing |
| 142 | 142 | */ |
| 143 | | - function load_cached_credentials($auth_token, $storage_url, $cdnm_url) |
| | 143 | + function load_cached_credentials( $auth_token, $storage_url, $cdnm_url ) |
| 144 | 144 | { |
| 145 | 145 | $this->storage_url = $storage_url; |
| 146 | 146 | $this->cdnm_url = $cdnm_url; |
| — | — | @@ -156,7 +156,7 @@ |
| 157 | 157 | * $auth->authenticate(); |
| 158 | 158 | * $array = $auth->export_credentials(); |
| 159 | 159 | * </code> |
| 160 | | - * |
| | 160 | + * |
| 161 | 161 | * @return array of url's and an auth token. |
| 162 | 162 | */ |
| 163 | 163 | function export_credentials() |
| — | — | @@ -180,7 +180,7 @@ |
| 181 | 181 | */ |
| 182 | 182 | function authenticated() |
| 183 | 183 | { |
| 184 | | - if (!($this->storage_url || $this->cdnm_url) || !$this->auth_token) { |
| | 184 | + if ( !( $this->storage_url || $this->cdnm_url ) || !$this->auth_token ) { |
| 185 | 185 | return False; |
| 186 | 186 | } |
| 187 | 187 | return True; |
| — | — | @@ -189,7 +189,7 @@ |
| 190 | 190 | /** |
| 191 | 191 | * Toggle debugging - set cURL verbose flag |
| 192 | 192 | */ |
| 193 | | - function setDebug($bool) |
| | 193 | + function setDebug( $bool ) |
| 194 | 194 | { |
| 195 | 195 | $this->dbug = $bool; |
| 196 | 196 | } |
| — | — | @@ -264,15 +264,15 @@ |
| 265 | 265 | * @param boolean $servicenet enable/disable access via Rackspace servicenet. |
| 266 | 266 | * @throws AuthenticationException not authenticated |
| 267 | 267 | */ |
| 268 | | - function __construct($cfs_auth, $servicenet=False) |
| | 268 | + function __construct( $cfs_auth, $servicenet = False ) |
| 269 | 269 | { |
| 270 | | - if (isset($_ENV['RACKSPACE_SERVICENET'])) |
| 271 | | - $servicenet=True; |
| | 270 | + if ( isset( $_ENV['RACKSPACE_SERVICENET'] ) ) |
| | 271 | + $servicenet = True; |
| 272 | 272 | $this->cfs_auth = $cfs_auth; |
| 273 | | - if (!$this->cfs_auth->authenticated()) { |
| | 273 | + if ( !$this->cfs_auth->authenticated() ) { |
| 274 | 274 | $e = "Need to pass in a previously authenticated "; |
| 275 | 275 | $e .= "CF_Authentication instance."; |
| 276 | | - throw new AuthenticationException($e); |
| | 276 | + throw new AuthenticationException( $e ); |
| 277 | 277 | } |
| 278 | 278 | $this->dbug = False; |
| 279 | 279 | } |
| — | — | @@ -282,7 +282,7 @@ |
| 283 | 283 | * |
| 284 | 284 | * @param boolean $bool enable/disable cURL debugging |
| 285 | 285 | */ |
| 286 | | - function setDebug($bool) |
| | 286 | + function setDebug( $bool ) |
| 287 | 287 | { |
| 288 | 288 | $this->dbug = (boolean) $bool; |
| 289 | 289 | } |
| — | — | @@ -292,13 +292,13 @@ |
| 293 | 293 | * |
| 294 | 294 | * Example: |
| 295 | 295 | * <code> |
| 296 | | - * |
| | 296 | + * |
| 297 | 297 | * $conn->close(); |
| 298 | | - * |
| | 298 | + * |
| 299 | 299 | * </code> |
| 300 | 300 | * |
| 301 | 301 | * Will close all current cUrl active connections. |
| 302 | | - * |
| | 302 | + * |
| 303 | 303 | */ |
| 304 | 304 | public function close() |
| 305 | 305 | { |
| — | — | @@ -324,30 +324,30 @@ |
| 325 | 325 | * @throws SyntaxException invalid name |
| 326 | 326 | * @throws InvalidResponseException unexpected response |
| 327 | 327 | */ |
| 328 | | - function create_container($container_name=NULL) |
| | 328 | + function create_container( $container_name = NULL ) |
| 329 | 329 | { |
| 330 | | - if ($container_name != "0" and !isset($container_name)) |
| 331 | | - throw new SyntaxException("Container name not set."); |
| 332 | | - |
| 333 | | - if (!isset($container_name) or $container_name == "") |
| 334 | | - throw new SyntaxException("Container name not set."); |
| | 330 | + if ( $container_name != "0" and !isset( $container_name ) ) |
| | 331 | + throw new SyntaxException( "Container name not set." ); |
| 335 | 332 | |
| 336 | | - if (strpos($container_name, "/") !== False) { |
| 337 | | - $r = "Container name '".$container_name; |
| | 333 | + if ( !isset( $container_name ) or $container_name == "" ) |
| | 334 | + throw new SyntaxException( "Container name not set." ); |
| | 335 | + |
| | 336 | + if ( strpos( $container_name, "/" ) !== False ) { |
| | 337 | + $r = "Container name '" . $container_name; |
| 338 | 338 | $r .= "' cannot contain a '/' character."; |
| 339 | | - throw new SyntaxException($r); |
| | 339 | + throw new SyntaxException( $r ); |
| 340 | 340 | } |
| 341 | | - if (strlen($container_name) > MAX_CONTAINER_NAME_LEN) { |
| 342 | | - throw new SyntaxException(sprintf( |
| | 341 | + if ( strlen( $container_name ) > MAX_CONTAINER_NAME_LEN ) { |
| | 342 | + throw new SyntaxException( sprintf( |
| 343 | 343 | "Container name exeeds %d bytes.", |
| 344 | | - MAX_CONTAINER_NAME_LEN)); |
| | 344 | + MAX_CONTAINER_NAME_LEN ) ); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | if ( !is_dir( FAKE_SWIFT_CONTAINER_PATH . "/$container_name" ) ) { |
| 348 | 348 | mkdir( FAKE_SWIFT_CONTAINER_PATH . "/$container_name" ); |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | | - return new CF_Container($this->cfs_auth, $this->cfs_http, $container_name); |
| | 351 | + return new CF_Container( $this->cfs_auth, $this->cfs_http, $container_name ); |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
| — | — | @@ -372,29 +372,29 @@ |
| 373 | 373 | * @throws NonEmptyContainerException container not empty |
| 374 | 374 | * @throws NoSuchContainerException remote container does not exist |
| 375 | 375 | */ |
| 376 | | - function delete_container($container=NULL) |
| | 376 | + function delete_container( $container = NULL ) |
| 377 | 377 | { |
| 378 | 378 | $container_name = NULL; |
| 379 | | - |
| 380 | | - if (is_object($container)) { |
| 381 | | - if (get_class($container) == "CF_Container") { |
| | 379 | + |
| | 380 | + if ( is_object( $container ) ) { |
| | 381 | + if ( get_class( $container ) == "CF_Container" ) { |
| 382 | 382 | $container_name = $container->name; |
| 383 | 383 | } |
| 384 | 384 | } |
| 385 | | - if (is_string($container)) { |
| | 385 | + if ( is_string( $container ) ) { |
| 386 | 386 | $container_name = $container; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | | - if ($container_name != "0" and !isset($container_name)) |
| 390 | | - throw new SyntaxException("Must specify container object or name."); |
| | 389 | + if ( $container_name != "0" and !isset( $container_name ) ) |
| | 390 | + throw new SyntaxException( "Must specify container object or name." ); |
| 391 | 391 | |
| 392 | 392 | if ( !is_dir( FAKE_SWIFT_CONTAINER_PATH . "/$container_name" ) ) { |
| 393 | 393 | throw new NoSuchContainerException( |
| 394 | | - "Specified container did not exist to delete."); |
| | 394 | + "Specified container did not exist to delete." ); |
| 395 | 395 | } |
| 396 | 396 | if ( !rmdir( FAKE_SWIFT_CONTAINER_PATH . "/$container_name" ) ) { |
| 397 | 397 | throw new NonEmptyContainerException( |
| 398 | | - "Container must be empty prior to removing it."); |
| | 398 | + "Container must be empty prior to removing it." ); |
| 399 | 399 | } |
| 400 | 400 | return True; |
| 401 | 401 | } |
| — | — | @@ -421,14 +421,14 @@ |
| 422 | 422 | * @throws NoSuchContainerException thrown if no remote Container |
| 423 | 423 | * @throws InvalidResponseException unexpected response |
| 424 | 424 | */ |
| 425 | | - function get_container($container_name=NULL) |
| | 425 | + function get_container( $container_name = NULL ) |
| 426 | 426 | { |
| 427 | 427 | if ( !is_dir( FAKE_SWIFT_CONTAINER_PATH . "/$container_name" ) ) { |
| 428 | | - throw new NoSuchContainerException("Container not found."); |
| | 428 | + throw new NoSuchContainerException( "Container not found." ); |
| 429 | 429 | } |
| 430 | 430 | $count = $bytes = -1; // not implemented |
| 431 | | - return new CF_Container($this->cfs_auth, $this->cfs_http, |
| 432 | | - $container_name, $count, $bytes); |
| | 431 | + return new CF_Container( $this->cfs_auth, $this->cfs_http, |
| | 432 | + $container_name, $count, $bytes ); |
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | |
| — | — | @@ -473,16 +473,16 @@ |
| 474 | 474 | * @param int $bytes number of bytes stored in this Container |
| 475 | 475 | * @throws SyntaxException invalid Container name |
| 476 | 476 | */ |
| 477 | | - function __construct(&$cfs_auth, &$cfs_http, $name, $count=0, |
| 478 | | - $bytes=0, $docdn=True) |
| | 477 | + function __construct( &$cfs_auth, &$cfs_http, $name, $count = 0, |
| | 478 | + $bytes = 0, $docdn = True ) |
| 479 | 479 | { |
| 480 | | - if (strlen($name) > MAX_CONTAINER_NAME_LEN) { |
| 481 | | - throw new SyntaxException("Container name exceeds " |
| 482 | | - . "maximum allowed length."); |
| | 480 | + if ( strlen( $name ) > MAX_CONTAINER_NAME_LEN ) { |
| | 481 | + throw new SyntaxException( "Container name exceeds " |
| | 482 | + . "maximum allowed length." ); |
| 483 | 483 | } |
| 484 | | - if (strpos($name, "/") !== False) { |
| | 484 | + if ( strpos( $name, "/" ) !== False ) { |
| 485 | 485 | throw new SyntaxException( |
| 486 | | - "Container names cannot contain a '/' character."); |
| | 486 | + "Container names cannot contain a '/' character." ); |
| 487 | 487 | } |
| 488 | 488 | $this->cfs_auth = $cfs_auth; |
| 489 | 489 | $this->cfs_http = $cfs_http; |
| — | — | @@ -521,9 +521,9 @@ |
| 522 | 522 | * @param string $obj_name name of storage Object |
| 523 | 523 | * @return obj CF_Object instance |
| 524 | 524 | */ |
| 525 | | - function create_object($obj_name=NULL) |
| | 525 | + function create_object( $obj_name = NULL ) |
| 526 | 526 | { |
| 527 | | - return new CF_Object($this, $obj_name); |
| | 527 | + return new CF_Object( $this, $obj_name ); |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | /** |
| — | — | @@ -550,9 +550,9 @@ |
| 551 | 551 | * @param string $obj_name name of storage Object |
| 552 | 552 | * @return obj CF_Object instance |
| 553 | 553 | */ |
| 554 | | - function get_object($obj_name=NULL) |
| | 554 | + function get_object( $obj_name = NULL ) |
| 555 | 555 | { |
| 556 | | - return new CF_Object($this, $obj_name, True); |
| | 556 | + return new CF_Object( $this, $obj_name, True ); |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | /** |
| — | — | @@ -573,7 +573,7 @@ |
| 574 | 574 | * # Grab subsets of all storage objects |
| 575 | 575 | * # |
| 576 | 576 | * $first_ten = $images->list_objects(10); |
| 577 | | - * |
| | 577 | + * |
| 578 | 578 | * # Note the use of the previous result's last object name being |
| 579 | 579 | * # used as the 'marker' parameter to fetch the next 10 objects |
| 580 | 580 | * # |
| — | — | @@ -599,7 +599,7 @@ |
| 600 | 600 | * @return array array of strings |
| 601 | 601 | * @throws InvalidResponseException unexpected response |
| 602 | 602 | */ |
| 603 | | - function list_objects($limit=0, $marker=NULL, $prefix=NULL, $path=NULL) |
| | 603 | + function list_objects( $limit = 0, $marker = NULL, $prefix = NULL, $path = NULL ) |
| 604 | 604 | { |
| 605 | 605 | $names = array(); |
| 606 | 606 | // $prefix must be a dir in mock class |
| — | — | @@ -643,24 +643,24 @@ |
| 644 | 644 | * @throws NoSuchObjectException remote Object does not exist |
| 645 | 645 | * @throws InvalidResponseException unexpected response |
| 646 | 646 | */ |
| 647 | | - function delete_object($obj) |
| | 647 | + function delete_object( $obj ) |
| 648 | 648 | { |
| 649 | 649 | $obj_name = NULL; |
| 650 | | - if (is_object($obj)) { |
| 651 | | - if (get_class($obj) == "CF_Object") { |
| | 650 | + if ( is_object( $obj ) ) { |
| | 651 | + if ( get_class( $obj ) == "CF_Object" ) { |
| 652 | 652 | $obj_name = $obj->name; |
| 653 | 653 | } |
| 654 | 654 | } |
| 655 | | - if (is_string($obj)) { |
| | 655 | + if ( is_string( $obj ) ) { |
| 656 | 656 | $obj_name = $obj; |
| 657 | 657 | } |
| 658 | | - if (!$obj_name) { |
| 659 | | - throw new SyntaxException("Object name not set."); |
| | 658 | + if ( !$obj_name ) { |
| | 659 | + throw new SyntaxException( "Object name not set." ); |
| 660 | 660 | } |
| 661 | 661 | if ( !@unlink( $this->getObjectFSPath( $obj_name ) ) ) { |
| 662 | | - $m = "Specified object '".$this->name."/".$obj_name; |
| 663 | | - $m.= "' did not exist to delete."; |
| 664 | | - throw new NoSuchObjectException($m); |
| | 662 | + $m = "Specified object '" . $this->name . "/" . $obj_name; |
| | 663 | + $m .= "' did not exist to delete."; |
| | 664 | + throw new NoSuchObjectException( $m ); |
| 665 | 665 | } |
| 666 | 666 | return True; |
| 667 | 667 | } |
| — | — | @@ -675,7 +675,7 @@ |
| 676 | 676 | * Object operations |
| 677 | 677 | * |
| 678 | 678 | * An Object is analogous to a file on a conventional filesystem. You can |
| 679 | | - * read data from, or write data to your Objects. You can also associate |
| | 679 | + * read data from, or write data to your Objects. You can also associate |
| 680 | 680 | * arbitrary metadata with them. |
| 681 | 681 | * |
| 682 | 682 | * @package php-cloudfiles |
| — | — | @@ -698,16 +698,16 @@ |
| 699 | 699 | * @param string $name name of Object |
| 700 | 700 | * @param boolean $force_exists if set, throw an error if Object doesn't exist |
| 701 | 701 | */ |
| 702 | | - function __construct(&$container, $name, $force_exists=False, $dohead=True) |
| | 702 | + function __construct( &$container, $name, $force_exists = False, $dohead = True ) |
| 703 | 703 | { |
| 704 | | - if ($name[0] == "/") { |
| 705 | | - $r = "Object name '".$name; |
| | 704 | + if ( $name[0] == "/" ) { |
| | 705 | + $r = "Object name '" . $name; |
| 706 | 706 | $r .= "' cannot contain begin with a '/' character."; |
| 707 | | - throw new SyntaxException($r); |
| | 707 | + throw new SyntaxException( $r ); |
| 708 | 708 | } |
| 709 | | - if (strlen($name) > MAX_OBJECT_NAME_LEN) { |
| 710 | | - throw new SyntaxException("Object name exceeds " |
| 711 | | - . "maximum allowed length."); |
| | 709 | + if ( strlen( $name ) > MAX_OBJECT_NAME_LEN ) { |
| | 710 | + throw new SyntaxException( "Object name exceeds " |
| | 711 | + . "maximum allowed length." ); |
| 712 | 712 | } |
| 713 | 713 | $this->container = $container; |
| 714 | 714 | $this->name = $name; |
| — | — | @@ -718,9 +718,9 @@ |
| 719 | 719 | $this->content_length = 0; |
| 720 | 720 | $this->metadata = array(); |
| 721 | 721 | $this->manifest = NULL; |
| 722 | | - if ($dohead) { |
| 723 | | - if (!$this->_initialize() && $force_exists) { |
| 724 | | - throw new NoSuchObjectException("No such object '".$name."'"); |
| | 722 | + if ( $dohead ) { |
| | 723 | + if ( !$this->_initialize() && $force_exists ) { |
| | 724 | + throw new NoSuchObjectException( "No such object '" . $name . "'" ); |
| 725 | 725 | } |
| 726 | 726 | } |
| 727 | 727 | } |
| — | — | @@ -754,51 +754,51 @@ |
| 755 | 755 | * |
| 756 | 756 | * if fileinfo is not available it will try to use the internal |
| 757 | 757 | * mime_content_type function. |
| 758 | | - * |
| | 758 | + * |
| 759 | 759 | * @param string $handle name of file or buffer to guess the type from |
| 760 | 760 | * @return boolean <kbd>True</kbd> if successful |
| 761 | 761 | * @throws BadContentTypeException |
| 762 | 762 | */ |
| 763 | | - function _guess_content_type($handle) { |
| 764 | | - if ($this->content_type) |
| | 763 | + function _guess_content_type( $handle ) { |
| | 764 | + if ( $this->content_type ) |
| 765 | 765 | return; |
| 766 | | - |
| 767 | | - if (function_exists("finfo_open")) { |
| 768 | | - $local_magic = dirname(__FILE__) . "/share/magic"; |
| 769 | | - $finfo = @finfo_open(FILEINFO_MIME, $local_magic); |
| 770 | 766 | |
| 771 | | - if (!$finfo) |
| 772 | | - $finfo = @finfo_open(FILEINFO_MIME); |
| 773 | | - |
| 774 | | - if ($finfo) { |
| | 767 | + if ( function_exists( "finfo_open" ) ) { |
| | 768 | + $local_magic = dirname( __FILE__ ) . "/share/magic"; |
| | 769 | + $finfo = @finfo_open( FILEINFO_MIME, $local_magic ); |
| 775 | 770 | |
| 776 | | - if (is_file((string)$handle)) |
| 777 | | - $ct = @finfo_file($finfo, $handle); |
| 778 | | - else |
| 779 | | - $ct = @finfo_buffer($finfo, $handle); |
| | 771 | + if ( !$finfo ) |
| | 772 | + $finfo = @finfo_open( FILEINFO_MIME ); |
| 780 | 773 | |
| | 774 | + if ( $finfo ) { |
| | 775 | + |
| | 776 | + if ( is_file( (string)$handle ) ) |
| | 777 | + $ct = @finfo_file( $finfo, $handle ); |
| | 778 | + else |
| | 779 | + $ct = @finfo_buffer( $finfo, $handle ); |
| | 780 | + |
| 781 | 781 | /* PHP 5.3 fileinfo display extra information like |
| 782 | 782 | charset so we remove everything after the ; since |
| 783 | 783 | we are not into that stuff */ |
| 784 | | - if ($ct) { |
| 785 | | - $extra_content_type_info = strpos($ct, "; "); |
| 786 | | - if ($extra_content_type_info) |
| 787 | | - $ct = substr($ct, 0, $extra_content_type_info); |
| | 784 | + if ( $ct ) { |
| | 785 | + $extra_content_type_info = strpos( $ct, "; " ); |
| | 786 | + if ( $extra_content_type_info ) |
| | 787 | + $ct = substr( $ct, 0, $extra_content_type_info ); |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | | - if ($ct && $ct != 'application/octet-stream') |
| | 790 | + if ( $ct && $ct != 'application/octet-stream' ) |
| 791 | 791 | $this->content_type = $ct; |
| 792 | 792 | |
| 793 | | - @finfo_close($finfo); |
| | 793 | + @finfo_close( $finfo ); |
| 794 | 794 | } |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | | - if (!$this->content_type && (string)is_file($handle) && function_exists("mime_content_type")) { |
| 798 | | - $this->content_type = @mime_content_type($handle); |
| | 797 | + if ( !$this->content_type && (string)is_file( $handle ) && function_exists( "mime_content_type" ) ) { |
| | 798 | + $this->content_type = @mime_content_type( $handle ); |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | | - if (!$this->content_type) { |
| 802 | | - throw new BadContentTypeException("Required Content-Type not set"); |
| | 801 | + if ( !$this->content_type ) { |
| | 802 | + throw new BadContentTypeException( "Required Content-Type not set" ); |
| 803 | 803 | } |
| 804 | 804 | return True; |
| 805 | 805 | } |
| — | — | @@ -835,7 +835,7 @@ |
| 836 | 836 | * @return string Object's data |
| 837 | 837 | * @throws InvalidResponseException unexpected response |
| 838 | 838 | */ |
| 839 | | - function read($hdrs=array()) |
| | 839 | + function read( $hdrs = array() ) |
| 840 | 840 | { |
| 841 | 841 | return file_get_contents( $this->getFSPath() ); |
| 842 | 842 | } |
| — | — | @@ -882,7 +882,7 @@ |
| 883 | 883 | * @return string Object's data |
| 884 | 884 | * @throws InvalidResponseException unexpected response |
| 885 | 885 | */ |
| 886 | | - function stream(&$fp, $hdrs=array()) |
| | 886 | + function stream( &$fp, $hdrs = array() ) |
| 887 | 887 | { |
| 888 | 888 | $data = file_get_contents( $this->getFSPath() ); |
| 889 | 889 | fwrite( $fp, $data ); |
| — | — | @@ -919,46 +919,46 @@ |
| 920 | 920 | * @throws MisMatchedChecksumException $verify is set and checksums unequal |
| 921 | 921 | * @throws InvalidResponseException unexpected response |
| 922 | 922 | */ |
| 923 | | - function write($data=NULL, $bytes=0, $verify=True) |
| | 923 | + function write( $data = NULL, $bytes = 0, $verify = True ) |
| 924 | 924 | { |
| 925 | | - if (!$data && !is_string($data)) { |
| 926 | | - throw new SyntaxException("Missing data source."); |
| | 925 | + if ( !$data && !is_string( $data ) ) { |
| | 926 | + throw new SyntaxException( "Missing data source." ); |
| 927 | 927 | } |
| 928 | | - if ($bytes > MAX_OBJECT_SIZE) { |
| 929 | | - throw new SyntaxException("Bytes exceeds maximum object size."); |
| | 928 | + if ( $bytes > MAX_OBJECT_SIZE ) { |
| | 929 | + throw new SyntaxException( "Bytes exceeds maximum object size." ); |
| 930 | 930 | } |
| 931 | | - if ($verify) { |
| 932 | | - if (!$this->_etag_override) { |
| 933 | | - $this->etag = $this->compute_md5sum($data); |
| | 931 | + if ( $verify ) { |
| | 932 | + if ( !$this->_etag_override ) { |
| | 933 | + $this->etag = $this->compute_md5sum( $data ); |
| 934 | 934 | } |
| 935 | 935 | } else { |
| 936 | 936 | $this->etag = NULL; |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | $close_fh = False; |
| 940 | | - if (!is_resource($data)) { |
| | 940 | + if ( !is_resource( $data ) ) { |
| 941 | 941 | # A hack to treat string data as a file handle. php://memory feels |
| 942 | 942 | # like a better option, but it seems to break on Windows so use |
| 943 | 943 | # a temporary file instead. |
| 944 | 944 | # |
| 945 | | - $fp = fopen("php://temp", "wb+"); |
| 946 | | - #$fp = fopen("php://memory", "wb+"); |
| 947 | | - fwrite($fp, $data, strlen($data)); |
| 948 | | - rewind($fp); |
| | 945 | + $fp = fopen( "php://temp", "wb+" ); |
| | 946 | + # $fp = fopen("php://memory", "wb+"); |
| | 947 | + fwrite( $fp, $data, strlen( $data ) ); |
| | 948 | + rewind( $fp ); |
| 949 | 949 | $close_fh = True; |
| 950 | | - $this->content_length = (float) strlen($data); |
| 951 | | - if ($this->content_length > MAX_OBJECT_SIZE) { |
| 952 | | - throw new SyntaxException("Data exceeds maximum object size"); |
| | 950 | + $this->content_length = (float) strlen( $data ); |
| | 951 | + if ( $this->content_length > MAX_OBJECT_SIZE ) { |
| | 952 | + throw new SyntaxException( "Data exceeds maximum object size" ); |
| 953 | 953 | } |
| 954 | | - $ct_data = substr($data, 0, 64); |
| | 954 | + $ct_data = substr( $data, 0, 64 ); |
| 955 | 955 | } else { |
| 956 | 956 | $this->content_length = $bytes; |
| 957 | 957 | $fp = $data; |
| 958 | | - $ct_data = fread($data, 64); |
| 959 | | - rewind($data); |
| | 958 | + $ct_data = fread( $data, 64 ); |
| | 959 | + rewind( $data ); |
| 960 | 960 | } |
| 961 | 961 | |
| 962 | | - $this->_guess_content_type($ct_data); |
| | 962 | + $this->_guess_content_type( $ct_data ); |
| 963 | 963 | |
| 964 | 964 | $dir = dirname( $this->getFSPath() ); |
| 965 | 965 | if ( !file_exists( $dir ) ) { |
| — | — | @@ -966,7 +966,7 @@ |
| 967 | 967 | } |
| 968 | 968 | file_put_contents( $this->getFSPath(), $data, LOCK_EX ); |
| 969 | 969 | |
| 970 | | - if ($close_fh) { fclose($fp); } |
| | 970 | + if ( $close_fh ) { fclose( $fp ); } |
| 971 | 971 | return True; |
| 972 | 972 | } |
| 973 | 973 | |
| — | — | @@ -994,10 +994,10 @@ |
| 995 | 995 | * @throws MisMatchedChecksumException $verify is set and checksums unequal |
| 996 | 996 | * @throws InvalidResponseException unexpected response |
| 997 | 997 | */ |
| 998 | | - function copy($source) |
| | 998 | + function copy( $source ) |
| 999 | 999 | { |
| 1000 | | - if (!$source && !is_string($source)) { |
| 1001 | | - throw new SyntaxException("Missing data source."); |
| | 1000 | + if ( !$source && !is_string( $source ) ) { |
| | 1001 | + throw new SyntaxException( "Missing data source." ); |
| 1002 | 1002 | } |
| 1003 | 1003 | $sObj = new self( $this->container, $source ); |
| 1004 | 1004 | copy( $sObj->getFSPath(), $this->getFSPath() ); |
| — | — | @@ -1033,24 +1033,24 @@ |
| 1034 | 1034 | * @throws InvalidResponseException unexpected response |
| 1035 | 1035 | * @throws IOException error opening file |
| 1036 | 1036 | */ |
| 1037 | | - function load_from_filename($filename, $verify=True) |
| | 1037 | + function load_from_filename( $filename, $verify = True ) |
| 1038 | 1038 | { |
| 1039 | | - $fp = @fopen($filename, "r"); |
| 1040 | | - if (!$fp) { |
| 1041 | | - throw new IOException("Could not open file for reading: ".$filename); |
| | 1039 | + $fp = @fopen( $filename, "r" ); |
| | 1040 | + if ( !$fp ) { |
| | 1041 | + throw new IOException( "Could not open file for reading: " . $filename ); |
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | clearstatcache(); |
| 1045 | | - |
| 1046 | | - $size = (float) sprintf("%u", filesize($filename)); |
| 1047 | | - if ($size > MAX_OBJECT_SIZE) { |
| 1048 | | - throw new SyntaxException("File size exceeds maximum object size."); |
| | 1045 | + |
| | 1046 | + $size = (float) sprintf( "%u", filesize( $filename ) ); |
| | 1047 | + if ( $size > MAX_OBJECT_SIZE ) { |
| | 1048 | + throw new SyntaxException( "File size exceeds maximum object size." ); |
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | | - $this->_guess_content_type($filename); |
| 1052 | | - |
| 1053 | | - $this->write($fp, $size, $verify); |
| 1054 | | - fclose($fp); |
| | 1051 | + $this->_guess_content_type( $filename ); |
| | 1052 | + |
| | 1053 | + $this->write( $fp, $size, $verify ); |
| | 1054 | + fclose( $fp ); |
| 1055 | 1055 | return True; |
| 1056 | 1056 | } |
| 1057 | 1057 | |
| — | — | @@ -1078,14 +1078,14 @@ |
| 1079 | 1079 | * @throws IOException error opening file |
| 1080 | 1080 | * @throws InvalidResponseException unexpected response |
| 1081 | 1081 | */ |
| 1082 | | - function save_to_filename($filename) |
| | 1082 | + function save_to_filename( $filename ) |
| 1083 | 1083 | { |
| 1084 | | - $fp = @fopen($filename, "wb"); |
| 1085 | | - if (!$fp) { |
| 1086 | | - throw new IOException("Could not open file for writing: ".$filename); |
| | 1084 | + $fp = @fopen( $filename, "wb" ); |
| | 1085 | + if ( !$fp ) { |
| | 1086 | + throw new IOException( "Could not open file for writing: " . $filename ); |
| 1087 | 1087 | } |
| 1088 | | - $result = $this->stream($fp); |
| 1089 | | - fclose($fp); |
| | 1088 | + $result = $this->stream( $fp ); |
| | 1089 | + fclose( $fp ); |
| 1090 | 1090 | return $result; |
| 1091 | 1091 | } |
| 1092 | 1092 | |
| — | — | @@ -1098,7 +1098,7 @@ |
| 1099 | 1099 | * |
| 1100 | 1100 | * @param string $etag MD5 checksum hexidecimal string |
| 1101 | 1101 | */ |
| 1102 | | - function set_etag($etag) |
| | 1102 | + function set_etag( $etag ) |
| 1103 | 1103 | { |
| 1104 | 1104 | $this->etag = $etag; |
| 1105 | 1105 | $this->_etag_override = True; |
| — | — | @@ -1130,20 +1130,20 @@ |
| 1131 | 1131 | * @param filename|obj|string $data filename, open resource, or string |
| 1132 | 1132 | * @return string MD5 checksum hexidecimal string |
| 1133 | 1133 | */ |
| 1134 | | - function compute_md5sum(&$data) |
| | 1134 | + function compute_md5sum( &$data ) |
| 1135 | 1135 | { |
| 1136 | | - if (function_exists("hash_init") && is_resource($data)) { |
| 1137 | | - $ctx = hash_init('md5'); |
| 1138 | | - while (!feof($data)) { |
| 1139 | | - $buffer = fgets($data, 65536); |
| 1140 | | - hash_update($ctx, $buffer); |
| | 1136 | + if ( function_exists( "hash_init" ) && is_resource( $data ) ) { |
| | 1137 | + $ctx = hash_init( 'md5' ); |
| | 1138 | + while ( !feof( $data ) ) { |
| | 1139 | + $buffer = fgets( $data, 65536 ); |
| | 1140 | + hash_update( $ctx, $buffer ); |
| 1141 | 1141 | } |
| 1142 | | - $md5 = hash_final($ctx, false); |
| 1143 | | - rewind($data); |
| 1144 | | - } elseif ((string)is_file($data)) { |
| 1145 | | - $md5 = md5_file($data); |
| | 1142 | + $md5 = hash_final( $ctx, false ); |
| | 1143 | + rewind( $data ); |
| | 1144 | + } elseif ( (string)is_file( $data ) ) { |
| | 1145 | + $md5 = md5_file( $data ); |
| 1146 | 1146 | } else { |
| 1147 | | - $md5 = md5($data); |
| | 1147 | + $md5 = md5( $data ); |
| 1148 | 1148 | } |
| 1149 | 1149 | return $md5; |
| 1150 | 1150 | } |
| Index: trunk/extensions/SwiftMedia/smtest.py |
| — | — | @@ -5,7 +5,7 @@ |
| 6 | 6 | import twill |
| 7 | 7 | import twill.commands as t |
| 8 | 8 | import gd |
| 9 | | - |
| | 9 | + |
| 10 | 10 | temp_html = "/tmp/wikipedia.html" |
| 11 | 11 | rss_title = "Wikipedia watchlist" |
| 12 | 12 | rss_link = "http://en.wikipedia.org" |
| — | — | @@ -18,7 +18,7 @@ |
| 19 | 19 | t.go(host+"index.php/Special:UserLogin") |
| 20 | 20 | t.fv("1", "wpName", username) |
| 21 | 21 | t.fv("1", "wpPassword", password) |
| 22 | | - t.submit("wpLoginAttempt") |
| | 22 | + t.submit("wpLoginAttempt") |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | def upload_list(browser, pagename, uploads): |
| — | — | @@ -34,7 +34,7 @@ |
| 35 | 35 | t.formfile("1", "wpUploadFile", uploads[0]) |
| 36 | 36 | t.fv("1", "wpDestFile", pagename) |
| 37 | 37 | t.fv("1", "wpUploadDescription", "Uploading %s" % pagename) |
| 38 | | - t.submit("wpUpload") |
| | 38 | + t.submit("wpUpload") |
| 39 | 39 | |
| 40 | 40 | # Verify that we succeeded. |
| 41 | 41 | t.find("File:%s" % pagename) |
| — | — | @@ -44,7 +44,7 @@ |
| 45 | 45 | t.go(host+"index.php?title=Special:Upload&wpDestFile=%s&wpForReUpload=1" % pagename) |
| 46 | 46 | t.formfile("1", "wpUploadFile", fn) |
| 47 | 47 | t.fv("1", "wpUploadDescription", "Uploading %s as %s" % (fn, pagename)) |
| 48 | | - t.submit("wpUpload") |
| | 48 | + t.submit("wpUpload") |
| 49 | 49 | |
| 50 | 50 | # get the URLs for the thumbnails |
| 51 | 51 | urls = [] |
| — | — | @@ -65,7 +65,7 @@ |
| 66 | 66 | t.go(host+"index.php?title=File:%s&action=delete" % pagename) |
| 67 | 67 | # after we get the confirmation page, commit to the action. |
| 68 | 68 | t.fv("1", "wpReason", "Test Deleting...") |
| 69 | | - t.submit("mw-filedelete-submit") |
| | 69 | + t.submit("mw-filedelete-submit") |
| 70 | 70 | |
| 71 | 71 | # make sure that we can't visit their URLs. |
| 72 | 72 | for i, url in enumerate(urls): |
| Index: trunk/extensions/SwiftMedia/test_rewrite.py |
| — | — | @@ -4,7 +4,7 @@ |
| 5 | 5 | |
| 6 | 6 | import webob |
| 7 | 7 | |
| 8 | | -from wmf import rewrite |
| | 8 | +from wmf import rewrite |
| 9 | 9 | from wmf.client import ClientException |
| 10 | 10 | |
| 11 | 11 | class FakeApp(object): |
| — | — | @@ -96,13 +96,13 @@ |
| 97 | 97 | environ={'REQUEST_METHOD': 'GET'}) |
| 98 | 98 | resp = app(req.environ, start_response) |
| 99 | 99 | self.assertEquals(req.environ['PATH_INFO'], self.url448) |
| 100 | | - self.assertEquals(resp, |
| | 100 | + self.assertEquals(resp, |
| 101 | 101 | ['401 Unauthorized\n\nThis server could not verify that you are '\ |
| 102 | 102 | 'authorized to access the document you requested. Either you '\ |
| 103 | 103 | 'supplied the wrong credentials (e.g., bad password), or your '\ |
| 104 | 104 | 'browser does not understand how to supply the credentials '\ |
| 105 | 105 | 'required.\n\n Token may have timed out ']) |
| 106 | | - |
| | 106 | + |
| 107 | 107 | def test_06(self): |
| 108 | 108 | """#06 Give them a bad token so that the PUT fails.""" |
| 109 | 109 | app = rewrite.WMFRewrite(FakeApp("404 Bad", {}),self.a) |
| Index: trunk/extensions/SwiftMedia/wmf/swift.php |
| — | — | @@ -2,10 +2,10 @@ |
| 3 | 3 | /** |
| 4 | 4 | * Helper functions for Swift related image thumbnail purging. |
| 5 | 5 | * The functions here should only be called after MediaWiki setup. |
| 6 | | - * |
| | 6 | + * |
| 7 | 7 | * $wmfSwiftConfig must reside in PrivateSettings.php. It should also |
| 8 | 8 | * be extracted in CommonSettings.php to set any swift backend settings. |
| 9 | | - * |
| | 9 | + * |
| 10 | 10 | * This file belongs under wmf-config/ and should be included by CommonSettings.php. |
| 11 | 11 | */ |
| 12 | 12 | |
| — | — | @@ -16,7 +16,7 @@ |
| 17 | 17 | * Handler for the LocalFilePurgeThumbnails hook. |
| 18 | 18 | * To avoid excess inclusion of cloudfiles.php, a hook handler can be added |
| 19 | 19 | * to CommonSettings.php which includes this file and calls this function. |
| 20 | | - * |
| | 20 | + * |
| 21 | 21 | * @param $file File |
| 22 | 22 | * @param $archiveName string|false |
| 23 | 23 | * @return true |
| — | — | @@ -48,7 +48,7 @@ |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * Get the Swift thumbnail container for this wiki. |
| 52 | | - * |
| | 52 | + * |
| 53 | 53 | * @param $site string |
| 54 | 54 | * @param $lang string |
| 55 | 55 | * @return CF_Container|null |
| Index: trunk/extensions/SwiftMedia/SwiftMedia.body.php |
| — | — | @@ -91,7 +91,7 @@ |
| 92 | 92 | * @return string Path to a local copy of the file. |
| 93 | 93 | */ |
| 94 | 94 | public function getPath() { |
| 95 | | - if ( !array_key_exists('', $this->tempPaths ) ) { |
| | 95 | + if ( !array_key_exists( '', $this->tempPaths ) ) { |
| 96 | 96 | $this->tempPaths[''] = $this->repo->getLocalCopy( $this->repo->container, $this->getRel(), "getPath_" ); |
| 97 | 97 | } |
| 98 | 98 | return $this->tempPaths['']; |
| — | — | @@ -99,17 +99,17 @@ |
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * We're re-purposing getPath() to checkout a copy of the file, if we don't already have a copy. |
| 103 | | - * Get a local copy of a particular archived file specified by $suffix |
| | 103 | + * Get a local copy of a particular archived file specified by $suffix |
| 104 | 104 | * |
| 105 | 105 | * @param string suffix Specific archived copy. |
| 106 | 106 | * @return string Path to a local copy of the file. |
| 107 | 107 | */ |
| 108 | | - public function getArchivePath( $suffix = false) { |
| 109 | | - if (!$suffix) { |
| | 108 | + public function getArchivePath( $suffix = false ) { |
| | 109 | + if ( !$suffix ) { |
| 110 | 110 | throw new MWException( "Can't call getArchivePath without a suffix" ); |
| 111 | 111 | } |
| 112 | 112 | $rel = $this->getArchiveRel( $suffix ); |
| 113 | | - if ( !array_key_exists($rel, $this->tempPaths ) ) { |
| | 113 | + if ( !array_key_exists( $rel, $this->tempPaths ) ) { |
| 114 | 114 | $this->tempPaths[$rel] = $this->repo->getLocalCopy( $this->repo->container, $rel ); |
| 115 | 115 | } |
| 116 | 116 | return $this->tempPaths[$rel]; |
| — | — | @@ -117,24 +117,24 @@ |
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * We're re-purposing getPath() to checkout a copy of the file, if we don't already have a copy. |
| 121 | | - * Get a local copy of a particular thumb specified by $suffix |
| | 121 | + * Get a local copy of a particular thumb specified by $suffix |
| 122 | 122 | * |
| 123 | 123 | * @param string suffix Specific thumbnail. |
| 124 | 124 | * @return string Path to a local copy of the file. |
| 125 | 125 | */ |
| 126 | | - public function getThumbPath( $suffix = false) { |
| 127 | | - if (!$suffix) { |
| | 126 | + public function getThumbPath( $suffix = false ) { |
| | 127 | + if ( !$suffix ) { |
| 128 | 128 | throw new MWException( "Can't call getThumbPath without a suffix" ); |
| 129 | 129 | } |
| 130 | 130 | $rel = $this->getRel() . '/' . $suffix; |
| 131 | | - if ( !array_key_exists($rel, $this->tempPaths ) ) { |
| | 131 | + if ( !array_key_exists( $rel, $this->tempPaths ) ) { |
| 132 | 132 | $this->tempPaths[$rel] = $this->repo->getLocalCopy( $this->repo->getZoneContainer( 'thumb' ), $rel ); |
| 133 | 133 | } |
| 134 | 134 | return $this->tempPaths[$rel]; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | function __destruct() { |
| 138 | | - foreach ( $this->tempPaths as $path) { |
| | 138 | + foreach ( $this->tempPaths as $path ) { |
| 139 | 139 | // Clean up temporary data. |
| 140 | 140 | wfDebug( __METHOD__ . ": deleting $path\n" ); |
| 141 | 141 | unlink( $path ); |
| — | — | @@ -161,8 +161,8 @@ |
| 162 | 162 | $thumbPath = tempnam( $wgTmpDirectory, 'transform_out_' ); |
| 163 | 163 | unlink( $thumbPath ); |
| 164 | 164 | $thumbPath .= '.' . pathinfo( $thumbName, PATHINFO_EXTENSION ); |
| 165 | | - |
| 166 | 165 | |
| | 166 | + |
| 167 | 167 | if ( $this->repo && $this->repo->canTransformVia404() && !( $flags & self::RENDER_NOW ) ) { |
| 168 | 168 | return $this->handler->getTransform( $this, $thumbPath, $thumbUrl, $params ); |
| 169 | 169 | } |
| — | — | @@ -424,7 +424,7 @@ |
| 425 | 425 | foreach ( $triplets as $i => $triplet ) { |
| 426 | 426 | list( $srcPath, $dstZone, $dstRel ) = $triplet; |
| 427 | 427 | |
| 428 | | - wfDebug( __METHOD__ . ": Storing $srcPath into $dstZone::$dstRel\n"); |
| | 428 | + wfDebug( __METHOD__ . ": Storing $srcPath into $dstZone::$dstRel\n" ); |
| 429 | 429 | |
| 430 | 430 | // Point to the container. |
| 431 | 431 | $dstContainer = $this->getZoneContainer( $dstZone ); |
| — | — | @@ -442,7 +442,7 @@ |
| 443 | 443 | if ( !( $flags & self::OVERWRITE ) ) { |
| 444 | 444 | // does it exist? |
| 445 | 445 | try { |
| 446 | | - $objd = $dstc->get_object($dstRel); |
| | 446 | + $objd = $dstc->get_object( $dstRel ); |
| 447 | 447 | // and if it does, are we allowed to overwrite it? |
| 448 | 448 | if ( $flags & self::OVERWRITE_SAME ) { |
| 449 | 449 | $objs = $srcc->get_object( $srcRel ); |
| — | — | @@ -455,15 +455,15 @@ |
| 456 | 456 | $good = false; |
| 457 | 457 | } |
| 458 | 458 | $exists = true; |
| 459 | | - } catch (NoSuchObjectException $e) { |
| | 459 | + } catch ( NoSuchObjectException $e ) { |
| 460 | 460 | $exists = false; |
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | | - |
| | 463 | + |
| 464 | 464 | if ( $good ) { |
| 465 | 465 | try { |
| 466 | 466 | $this->swiftcopy( $srcc, $srcRel, $dstc, $dstRel ); |
| 467 | | - } catch (InvalidResponseException $e ) { |
| | 467 | + } catch ( InvalidResponseException $e ) { |
| 468 | 468 | $status->error( 'filecopyerror', $srcPath, "{$dstc->name}/$dstRel" ); |
| 469 | 469 | $good = false; |
| 470 | 470 | } |
| — | — | @@ -479,7 +479,7 @@ |
| 480 | 480 | $objd = $dstc->get_object( $dstRel ); |
| 481 | 481 | // and if it does, are we allowed to overwrite it? |
| 482 | 482 | if ( $flags & self::OVERWRITE_SAME ) { |
| 483 | | - if ( $objd->getETag() != md5_file($srcPath) ) { |
| | 483 | + if ( $objd->getETag() != md5_file( $srcPath ) ) { |
| 484 | 484 | $status->fatal( 'fileexistserror', $dstRel ); |
| 485 | 485 | $good = false; |
| 486 | 486 | } |
| — | — | @@ -488,15 +488,15 @@ |
| 489 | 489 | $good = false; |
| 490 | 490 | } |
| 491 | 491 | $exists = true; |
| 492 | | - } catch (NoSuchObjectException $e) { |
| | 492 | + } catch ( NoSuchObjectException $e ) { |
| 493 | 493 | $exists = false; |
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | 496 | if ( $good ) { |
| 497 | | - wfDebug( __METHOD__ . ": Writing $srcPath to {$dstc->name}/$dstRel\n"); |
| | 497 | + wfDebug( __METHOD__ . ": Writing $srcPath to {$dstc->name}/$dstRel\n" ); |
| 498 | 498 | try { |
| 499 | 499 | $this->write_swift_object( $srcPath, $dstc, $dstRel ); |
| 500 | | - } catch (InvalidResponseException $e ) { |
| | 500 | + } catch ( InvalidResponseException $e ) { |
| 501 | 501 | $status->error( 'filecopyerror', $srcPath, "{$dstc->name}/$dstRel" ); |
| 502 | 502 | $good = false; |
| 503 | 503 | } |
| — | — | @@ -547,7 +547,7 @@ |
| 548 | 548 | function appendFinish( $toAppendPath ) { |
| 549 | 549 | $conn = $this->connect(); |
| 550 | 550 | $container = $this->repo->get_container( $conn, $this->repo->container . '-temp' ); |
| 551 | | - $parts = $container->list_objects( 0, NULL, $toAppendPath); |
| | 551 | + $parts = $container->list_objects( 0, NULL, $toAppendPath ); |
| 552 | 552 | // list_objects() returns a sorted list. |
| 553 | 553 | |
| 554 | 554 | // FIXME probably want to put this into a different container. |
| — | — | @@ -667,12 +667,12 @@ |
| 668 | 668 | $srcObj = $srcContainer->get_object( $srcRel ); |
| 669 | 669 | } catch ( NoSuchObjectException $e ) { |
| 670 | 670 | throw new MWException( 'Source file does not exist: ' . $srcContainer->name . "/$srcRel: $e" ); |
| 671 | | - } |
| | 671 | + } |
| 672 | 672 | |
| 673 | 673 | wfDebug( __METHOD__ . ' copying to ' . $dstContainer->name . "/$dstRel from " . $srcContainer->name . "/$srcRel\n" ); |
| 674 | 674 | |
| 675 | 675 | try { |
| 676 | | - $dstContainer->copy_object_from($srcObj,$srcContainer,$dstRel); |
| | 676 | + $dstContainer->copy_object_from( $srcObj, $srcContainer, $dstRel ); |
| 677 | 677 | } catch ( SyntaxException $e ) { |
| 678 | 678 | throw new MWException( 'Source file does not exist: ' . $srcContainer->name . "/$srcRel: $e" ); |
| 679 | 679 | } catch ( MisMatchedChecksumException $e ) { |