Beispiel #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();
 }
 public function displayAddMember()
 {
     $user = $this->getUser();
     $wikiplaces = null;
     if ($this->name != null) {
         $wikiplace = $this->checkWikiPlace($this->name);
         if (is_null($wikiplace)) {
             return;
         }
         if ($user->isAllowed(WP_ADMIN_RIGHT) && !$wikiplace->isOwner($user->getId())) {
             $wikiplaces = array($wikiplace);
         }
     }
     $wikiplaceSelect = $this->populateWikiPlaceSelect(array('type' => 'select', 'label-message' => 'wp-wikiplace-field', 'section' => 'addmember-section', 'help-message' => 'wp-addmember-wikiplace-help', 'validation-callback' => array($this, 'validateAddMemberWikiplaceID'), 'options' => array()), $wikiplaces, $this->name);
     if (count($wikiplaceSelect['options']) == 0) {
         $this->action = self::ACTION_LIST_WIKIPLACES;
         $this->msgKey = 'wp-create-wp-first';
         $this->msgType = 'error';
         $this->display();
         return;
     }
     $usernameText = array('type' => 'text', 'label-message' => 'username', 'section' => 'addmember-section', 'help-message' => 'wp-addmember-username-help', 'validation-callback' => array($this, 'validateAddMemberUserName'), 'size' => 60, 'default' => '');
     $htmlForm = new HTMLFormS(array('WpId' => $wikiplaceSelect, 'UserName' => $usernameText));
     $htmlForm->addHeaderText(wfMessage('wp-addmember-header')->parse());
     $htmlForm->setMessagePrefix('wp');
     $htmlForm->setTitle($this->getTitleForCurrentRequest());
     $htmlForm->setSubmitCallback(array($this, 'processAddMember'));
     $htmlForm->setSubmitText(wfMessage('wp-add')->text());
     if ($htmlForm->show()) {
         $this->action = self::ACTION_LIST_MEMBERS;
         $this->msgKey = 'wp-addmember-success';
         $this->msgType = 'success';
         $this->display();
         return;
     }
 }
 protected function displayRenew()
 {
     // at this point, user is logged in
     $user_id = $this->getUser()->getId();
     $sub = WpSubscription::newActiveByUserId($user_id);
     if ($sub == null) {
         // "need an active subscription"
         $this->action = self::ACTION_LIST;
         $this->msgType = 'error';
         $this->msgKey = 'wp-no-active-sub';
         $this->display();
         return;
     }
     $renewal_plan_id = $sub->getRenewalPlanId();
     $formDescriptor = array('Plan' => array('type' => 'select', 'section' => 'sub-renew-section', 'label-message' => 'wp-planfield', 'help-message' => 'wp-planfield-help', 'validation-callback' => array($this, 'validateRenewPlanId'), 'options' => array(), 'default' => $renewal_plan_id), 'Check' => array('type' => 'check', 'section' => 'sub-renew-section', 'label-message' => 'wp-checkfield', 'validation-callback' => array($this, 'validateSubscribeCheck'), 'required' => 'true'));
     $nb_wikiplaces = WpWikiplace::countWikiplacesOwnedByUser($user_id);
     $nb_wikiplace_pages = WpPage::countPagesOwnedByUser($user_id);
     $diskspace = WpPage::countDiskspaceUsageByUser($user_id);
     $when = $sub->getEnd();
     $plans = WpPlan::factoryAvailableForRenewal($nb_wikiplaces, $nb_wikiplace_pages, $diskspace, $when);
     foreach ($plans as $plan) {
         $wpp_name = $plan->getName();
         $price = $plan->getPrice();
         $formDescriptor['Plan']['options'][wfMessage('wp-plan-desc-short', wfMessage('wpp-' . $wpp_name)->text(), $price['amount'])->text()] = $plan->getId();
     }
     // add "do not renew" at the end;
     $formDescriptor['Plan']['options'][wfMessage('wp-do-not-renew')->text()] = '0';
     $htmlForm = new HTMLFormS($formDescriptor);
     $htmlForm->setMessagePrefix('wp');
     $htmlForm->addHeaderText(wfMessage('wp-sub-renew-header')->parse());
     $htmlForm->setTitle($this->getTitleFor(self::TITLE_NAME, self::ACTION_RENEW));
     $htmlForm->setSubmitCallback(array($this, 'processRenew'));
     $htmlForm->setSubmitText(wfMessage('wp-plan-renew-go')->text());
     // validate and process the form is data sent
     if ($htmlForm->show()) {
         $this->action = self::ACTION_LIST;
         $this->msgKey = 'wp-renew-success';
         $this->msgType = 'success';
         $this->display();
     }
 }
 /**
  *
  * @return \HTMLFormS 
  */
 private function getInviteForm()
 {
     $user = $this->getUser();
     $signature = $user->getRealName() == '' ? $user->getName() : $user->getRealName();
     $formDesc = array('Category' => array('type' => 'select', 'label-message' => 'wp-inv-category-field', 'section' => 'create-section', 'help-message' => 'wp-inv-category-help', 'options' => array()), 'Email' => array('type' => 'text', 'label-message' => 'emailto', 'section' => 'mail-section', 'help-message' => 'wp-inv-email-help', 'validation-callback' => array($this, 'validateEmail')), 'Message' => array('type' => 'textarea', 'label-message' => 'emailmessage', 'section' => 'mail-section', 'help-message' => 'wp-inv-msg-help', 'default' => wfMessage('wp-inv-msg-default', $signature)->text(), 'validation-callback' => array($this, 'validateMessage'), 'rows' => 4), 'Language' => array('type' => 'select', 'label-message' => 'wp-inv-language-field', 'section' => 'mail-section', 'help-message' => 'wp-inv-language-help', 'options' => array()));
     global $wgLanguageSelectorLanguagesShorthand;
     $language = $this->getLanguage();
     foreach ($wgLanguageSelectorLanguagesShorthand as $ln) {
         $formDesc['Language']['options'][$language->getLanguageName($ln)] = $ln;
         if ($ln == $language->getCode()) {
             $formDesc['Language']['default'] = $ln;
         }
     }
     if ($this->userIsAdmin) {
         $formDesc['Code'] = array('type' => 'text', 'label-message' => 'wp-inv-code-field', 'help-message' => 'wp-inv-code-help', 'section' => 'admin-section', 'default' => WpInvitation::generateCode($this->getUser()), 'validation-callback' => array($this, 'validateCode'), 'filter-callback' => array($this, 'filterCode'));
         $formDesc['Counter'] = array('type' => 'text', 'label-message' => 'wp-inv-counter-field', 'section' => 'admin-section', 'help-message' => 'wp-inv-counter-help', 'default' => 1, 'validation-callback' => array($this, 'validateCounter'));
         foreach ($this->userInvitationsCategories as $category_id => $category) {
             $formDesc['Category']['options'][wfMessage('wpi-' . $category->getDescription())->text()] = $category_id;
             if ($this->category_id == $category_id) {
                 $formDesc['Category']['default'] = $category_id;
             }
         }
     } else {
         foreach ($this->userUsageLeftThisMonth as $category_id => $usageLeft) {
             $formDesc['Category']['options'][wfMessage('wp-inv-category-desc', wfMessage('wpi-' . $this->userInvitationsCategories[$category_id]->getDescription())->text(), $usageLeft, $this->userInvitationsCategories[$category_id]->getMonthlyLimit())->parse()] = $category_id;
             if ($this->category_id == $category_id) {
                 $formDesc['Category']['default'] = $category_id;
             }
         }
     }
     $htmlForm = new HTMLFormS($formDesc);
     $htmlForm->setMessagePrefix('wp-inv');
     $htmlForm->addHeaderText(wfMessage('wp-inv-create-header')->parse());
     $htmlForm->setTitle($this->getTitle(self::ACTION_CREATE));
     $htmlForm->setSubmitText(wfMessage('wp-create')->text());
     $htmlForm->setSubmitCallback(array($this, 'processInvite'));
     return $htmlForm;
 }