Index: branches/license-work/phase3/includes/upload/UploadBase.php |
— | — | @@ -503,7 +503,8 @@ |
504 | 504 | * |
505 | 505 | * @return mixed Status indicating the whether the upload succeeded. |
506 | 506 | */ |
507 | | - public function performUpload( $comment, $pageText, $watch, $user ) { |
| 507 | + public function performUpload( $comment, $pageText, $watch, $user, |
| 508 | + $properties = array() ) { |
508 | 509 | $status = $this->getLocalFile()->upload( |
509 | 510 | $this->mTempPath, |
510 | 511 | $comment, |
— | — | @@ -515,6 +516,10 @@ |
516 | 517 | ); |
517 | 518 | |
518 | 519 | if( $status->isGood() ) { |
| 520 | + $propertiesObj = $this->getLocalFile()->properties(); |
| 521 | + $propertiesObj->set( $properties ); |
| 522 | + $propertiesObj->save( $this->getTitle()->getLatestRevID( Title::GAID_FOR_UPDATE ) ); |
| 523 | + |
519 | 524 | if ( $watch ) { |
520 | 525 | $user->addWatch( $this->getLocalFile()->getTitle() ); |
521 | 526 | } |
Index: branches/license-work/phase3/includes/FilePropertiesEditForm.php |
— | — | @@ -0,0 +1,57 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class FilePropertiesEditForm { |
| 5 | + public function __construct( $request = null, $file = null ) { |
| 6 | + $this->authors = array(); |
| 7 | + $this->licenses = array(); |
| 8 | + |
| 9 | + if ( $request ) { |
| 10 | + $authorsUsernames = $request->getArray( 'author_usernames' ); |
| 11 | + $authorsAttribution = $request->getArray( 'author_attribution' ); |
| 12 | + |
| 13 | + $this->makeAuthors( $authorsUsernames, $authorsAttribution ); |
| 14 | + |
| 15 | + $this->makeLicenses( $request->getArray( 'license' ) ); |
| 16 | + } else { |
| 17 | + |
| 18 | + } |
| 19 | + } |
| 20 | + |
| 21 | + public function getHtml() { |
| 22 | + |
| 23 | + } |
| 24 | + |
| 25 | + |
| 26 | + protected function makeAuthors( $authorsUsernames, $authorsAttribution ) { |
| 27 | + $usernames = array_values( $authorsUsernames ); |
| 28 | + $attribution = array_values( $authorsAttribution ); |
| 29 | + |
| 30 | + for ( $i = min( count( $usernames ), count( $attribution ) ); $i; $i-- ) { |
| 31 | + $username = trim( $usernames[$i] ); |
| 32 | + $attribution = trim( $usernames[$i] ); |
| 33 | + |
| 34 | + $user = User::newFromName( $username ); |
| 35 | + if ( $user && $user->getId() ) { |
| 36 | + $id = $user->getId(); |
| 37 | + } else { |
| 38 | + $id = null; |
| 39 | + } |
| 40 | + if ( !$id && !$attribution ) { |
| 41 | + continue; |
| 42 | + } |
| 43 | + if ( !$attribution ) { |
| 44 | + $attribution = null; |
| 45 | + } |
| 46 | + |
| 47 | + $this->authors[] = new FileAuthor( $id, $attribution ); |
| 48 | + } |
| 49 | + |
| 50 | + } |
| 51 | + |
| 52 | + protected function makeLicenses( $licenseNames ) { |
| 53 | + $this->licenses = array_map( 'FileLicense::newFromName', |
| 54 | + array_map( 'trim', $licenseNames ) ); |
| 55 | + FileLicense::loadArrayFrom( $this->licenses, 'name' ); |
| 56 | + } |
| 57 | + |
| 58 | +} |
\ No newline at end of file |
Property changes on: branches/license-work/phase3/includes/FilePropertiesEditForm.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 59 | + native |