Esempio n. 1
0
 static function bigForm($title)
 {
     global $wgUser;
     $formDescriptor = array('amount' => array('section' => 'you', 'label' => 'montant', 'type' => 'float', 'default' => 99.98999999999999, 'disabled' => true, 'help' => 'montant-help'), 'email' => array('section' => 'you', 'type' => 'text', 'default' => 'bob@plop', 'label' => 'email', 'help' => 'email-help', 'disabled' => true), 'submit' => array('section' => 'you', 'type' => 'submit', 'default' => 'aller à l\'interface de paiement'), 'password' => array('type' => 'hidden', 'default' => '<a href="#">Change password</a>'), 'radio' => array('type' => 'radio', 'label' => 'who?', 'options' => array('Option 0' => 0, 'Option 1' => 1, 'Option 2' => 3), 'default' => 1, 'help' => 'test-help'));
     $htmlForm = new HTMLFormS($formDescriptor, 'sz-profil');
     $htmlForm->setSubmitText(wfMessage('sz-profil-save'));
     $htmlForm->setTitle($title);
     $htmlForm->addHeaderText('Ceci est un texte de tete.');
     $htmlForm->addFooterText('Ceci est un texte de pied.');
     $htmlForm->addHeaderText('Ceci est un texte de tetesection.', 'you');
     $htmlForm->addFooterText('Ceci est un texte de piedsection.', 'you');
     $htmlForm->show();
 }
 private function constructDefault($errorKey = null)
 {
     $user = $this->getUser();
     $output = $this->getOutput();
     $balance = 0;
     if ($user->isLoggedIn()) {
         $balance = TMRecord::getTrueBalanceFromDB($user->getId());
     }
     # Set Minimum payment value (regarding banking fees)
     $min = max(-$balance, 5);
     $defaultAmount = '';
     # Building the pending transaction table and sum
     if ($balance < 0) {
         $defaultAmount = $min;
         $table = new TransactionsTablePager();
         $table->setSelectFields(array('tmr_desc', 'tmr_date_created', 'tmr_amount', 'tmr_currency'));
         $table->setSelectConds(array('tmr_user_id' => $user->getId(), 'tmr_status' => 'PE', 'tmr_amount < 0', 'tmr_currency' => 'EUR'));
         $table->setFieldSortable(false);
         $tableHtml = $table->getBody();
     }
     # We check if the user has some pending transaction to pay
     # We are using the HTMLFormS Helper
     # That's the way to create a form
     $formDescriptor = array('amount' => array('label-message' => 'ep-cd-amountlabel', 'section' => 'section1', 'type' => 'float', 'required' => 'true', 'help-message' => array('ep-help-amount', $min), 'min' => $min, 'max' => 9000000, 'default' => $defaultAmount, 'filter-callback' => array($this, 'filterAmount')), 'mail' => array('label-message' => 'youremail', 'section' => 'section1', 'type' => 'email', 'required' => 'true', 'validation-callback' => array($this, 'validateEmail'), 'help-message' => 'ep-help-mail'));
     # If user has an email registered, don't let him change it
     if (!(($mail = $user->getEmail()) == '')) {
         $formDescriptor['mail']['default'] = $user->getEmail();
         #@FIXME: If form disabled
         $formDescriptor['mail']['disabled'] = true;
     }
     $htmlForm = new HTMLFormS($formDescriptor, 'ep-cd');
     $htmlForm->setSubmitText(wfMsg('next'));
     $htmlForm->setTitle($this->getTitle());
     $htmlForm->setSubmitCallback(array($this, 'initAttempt'));
     if ($balance < 0) {
         $htmlForm->addHeaderText(wfMessage('ep-default-formheader') . ' ' . wfMessage('ep-default-formheader-pending', $this->getLanguage()->formatNum(-$balance), 'cur-euro') . $tableHtml);
         $htmlForm->addFooterText(wfMessage('ep-default-formfooter-pending'));
     } else {
         $htmlForm->addHeaderText(wfMessage('ep-default-formheader'));
     }
     if (isset($errorKey)) {
         $output->addHTML($htmlForm->getErrors(wfMessage("ep-{$errorKey}")));
     }
     $htmlForm->show();
 }