r80525 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80524‎ | r80525 | r80526 >
Date:22:07, 18 January 2011
Author:btongminh
Status:deferred
Tags:license-work 
Comment:
Start on the interface backend
Modified paths:
  • /branches/license-work/phase3/includes/FilePropertiesEditForm.php (added) (history)
  • /branches/license-work/phase3/includes/upload/UploadBase.php (modified) (history)

Diff [purge]

Index: branches/license-work/phase3/includes/upload/UploadBase.php
@@ -503,7 +503,8 @@
504504 *
505505 * @return mixed Status indicating the whether the upload succeeded.
506506 */
507 - public function performUpload( $comment, $pageText, $watch, $user ) {
 507+ public function performUpload( $comment, $pageText, $watch, $user,
 508+ $properties = array() ) {
508509 $status = $this->getLocalFile()->upload(
509510 $this->mTempPath,
510511 $comment,
@@ -515,6 +516,10 @@
516517 );
517518
518519 if( $status->isGood() ) {
 520+ $propertiesObj = $this->getLocalFile()->properties();
 521+ $propertiesObj->set( $properties );
 522+ $propertiesObj->save( $this->getTitle()->getLatestRevID( Title::GAID_FOR_UPDATE ) );
 523+
519524 if ( $watch ) {
520525 $user->addWatch( $this->getLocalFile()->getTitle() );
521526 }
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
159 + native

Status & tagging log