SpecialTranslateSandbox.php
Go to the documentation of this file.00001 <?php
00015 class SpecialTranslateSandbox extends SpecialPage {
00016 function __construct() {
00017 global $wgTranslateUseSandbox;
00018 parent::__construct( 'TranslateSandbox', 'translate-sandboxmanage', $wgTranslateUseSandbox );
00019 }
00020
00021 public function execute( $params ) {
00022 $this->setHeaders();
00023 $this->checkPermissions();
00024 $out = $this->getOutput();
00025 $out->addModules( 'ext.translate.special.translatesandbox' );
00026 $this->showPage();
00027 }
00028
00032 protected function showPage() {
00033 $out = $this->getOutput();
00034 $out->addHtml( <<<HTML
00035 <div class="grid">
00036 <div class="row">
00037 <div class="nine columns pane filter">{$this->makeFilter()}</div>
00038 <div class="three columns pane search">{$this->makeSearchBox()}</div>
00039 </div>
00040 <div class="row">
00041 <div class="four columns pane requests">{$this->makeList()}</div>
00042 <div class="eight columns pane details"></div>
00043 </div>
00044 </div>
00045 HTML
00046 );
00047 }
00048
00049 protected function makeFilter() {
00050 return $this->msg( 'tsb-filter-pending' )->escaped();
00051 }
00052
00053 protected function makeSearchBox() {
00054 return <<<HTML
00055 <input class="request-filter-box right"
00056 placeholder="{$this->msg( 'tsb-search-requests' )->escaped()}" type="search">
00057 </input>
00058 HTML;
00059 }
00060
00061 protected function makeList() {
00062 $items = array();
00063
00064 $users = TranslateSandbox::getUsers();
00065 foreach ( $users as $user ) {
00066 $items[] = $this->makeRequestItem( $user );
00067 }
00068 $count = count( $items );
00069 $out = <<<HTML
00070 <div class="row request-header">
00071 <div class="four columns">
00072 <button class="language-selector">
00073 {$this->msg( "tsb-all-languages-button-label" )->escaped()}
00074 </button>
00075 </div>
00076 <div class="five columns request-count">
00077 <div>
00078 {$this->msg( "tsb-request-count" )->numparams( $count )->parse()}
00079 </div>
00080 </div>
00081 <div class="three columns center">
00082 <input class="request-selector-all" name="request" type="checkbox" />
00083 </div>
00084 </div>
00085 HTML;
00086 return $out. "\n\n" . implode( "\n", $items ) . "\n\n";
00087 }
00088
00089 protected function makeRequestItem( User $user ) {
00090 $request = array(
00091 'username' => $user->getName(),
00092 'email' => $user->getEmail(),
00093 'registrationdate' => $user->getRegistration(),
00094 'translations' => 0,
00095 'languagepreferences' => FormatJson::decode( $user->getOption( 'translate-sandbox' ) ),
00096 'userid' => $user->getId(),
00097 );
00098
00099 $requestdataEnc = htmlspecialchars( FormatJson::encode( $request ) );
00100
00101 $nameEnc = htmlspecialchars( $request['username'] );
00102 $emailEnc = htmlspecialchars( $request['email'] );
00103 $countEnc = htmlspecialchars( $request['translations'] );
00104 $timestamp = new MWTimestamp( $request['registrationdate'] );
00105 $agoEnc = htmlspecialchars( $timestamp->getHumanTimestamp() );
00106
00107 return <<<HTML
00108 <div class="row request" data-data="$requestdataEnc">
00109 <div class="two columns amount">
00110 <div class="proofread-marker"></div>
00111 <div class="translation-count">$countEnc</div>
00112 </div>
00113 <div class="seven columns details">
00114 <div class="row username">$nameEnc</div>
00115 <div class="row email">$emailEnc</div>
00116 </div>
00117 <div class="three columns approval center">
00118 <input class="row request-selector" name="request" type="checkbox" />
00119 <div class="row signup-age">$agoEnc</div>
00120 </div>
00121 </div>
00122 HTML;
00123 }
00124 }